Engine.asm
Yoshifanatic1_Mega-Man-7-Disassembly/MM7/SPC700/Engine.asm

%SPCDataBlockStart(0DA0)
DATA_0DA0:
	db $68,$6C,$6C,$00,$00,$00,$F8,$01,$00,$00,$68,$6C,$6C,$D0,$D0,$30
	db $F8,$01,$D0

DATA_0DB3:
	db $00
%SPCDataBlockEnd(0DA0)

%SPCDataBlockStart(02C0)
CODE_02C0:
	CLRP
	MOV X, #$CF
	MOV SP, X
	MOV A, #$00
	MOV X, A
CODE_02C7:
	MOV (X+), A
	CMP X, #$E8
	BNE CODE_02C7
	SETP
	MOV X, A
CODE_02CE:
	MOV (X+), A
	CMP X, #$D0
	BNE CODE_02CE
	CLRP
	MOV X, A
CODE_02D5:
	MOV $0200+x, A
	INC X
	CMP X, #$C0
	BNE CODE_02D5
	CALL CODE_0451
	MOV A, #$40
	MOV $00FA, A
	MOV A, #$F1
	MOV $00F1, A
	MOV A, #$01
	MOV $B2, A
	MOV $00F6, A
	DEC A
	MOV $00F7, A
	DEC A
	MOV Y, A
	MOVW $DD, YA
CODE_02F9:
	CALL CODE_046A
	MOV A, $00FD
	CLRC
	ADC A, $B1
	MOV $B1, A
	BEQ CODE_02F9
	DEC $B1
	MOV Y, #$02
	MOV A, #$F9
	PUSH Y
	PUSH A
	CLRC
	ADC $B0, #$80
	BPL CODE_0317
	JMP CODE_03B7

CODE_0317:
	CMP $B6, $B7
	BEQ CODE_0331
	BBS7 $B7, CODE_032D
	MOV Y, #$6C
	MOV A, #$00
	CALL CODE_0D7E
	MOV Y, #$4D
	MOV A, #$FF
	CALL CODE_0D7E
CODE_032D:
	INC $B7
	BRA CODE_034C

CODE_0331:
	MOV Y, #$4D
	MOV A, $C3
	EOR A, #$FF
	AND A, $CA
	OR A, $C2
	CALL CODE_0D7E
	MOV Y, #$2C
	MOV A, $BB
	CALL CODE_0D7E
	MOV Y, #$3C
	MOV A, $BA
	CALL CODE_0D7E
CODE_034C:
	MOV Y, #$0C
	MOV A, $B9
	CALL CODE_0D7E
	MOV Y, #$1C
	MOV A, $B8
	CALL CODE_0D7E
	MOV X, #$07
	MOV Y, #$57
	MOV A, $C8
	OR A, $C0
	PUSH A
CODE_0363:
	PUSH Y
	BBC7 $C0, CODE_0376
	MOV A, $0238+y
	MOV $A0, A
	MOV A, $0240+y
	MOV $A1, A
	MOV A, $0248+y
	BRA CODE_0391

CODE_0376:
	BBC7 $CB, CODE_0381
	MOV A, $0250+x
	CALL CODE_097A
	BRA CODE_039F

CODE_0381:
	BBC7 $C8, CODE_039F
	MOV A, $0238+x
	MOV $A0, A
	MOV A, $0240+x
	MOV $A1, A
	MOV A, $0248+x
CODE_0391:
	MOV Y, #$07
	CALL CODE_0D73
	MOV Y, #$01
	MOV A, ($A0)+y
	MOV Y, #$05
	CALL CODE_0D73
CODE_039F:
	ASL $C0
	ASL $CB
	ASL $C8
	POP Y
	DEC Y
	DEC X
	BPL CODE_0363
	MOV Y, #$5C
	MOV A, #$00
	CALL CODE_0D7E
	POP A
	MOV Y, #$4C
	JMP CODE_0D7E

CODE_03B7:
	CLR7 $B0
	BBS6 $B0, CODE_0412
	MOV $B3, #$80
	MOV $C4, $C3
	MOVW YA, $CC
	ADDW YA, $CE
	MOVW $A8, YA
	MOV X, #$07
CODE_03CA:
	MOV A, $08+x
	OR A, $00+x
	BEQ CODE_03D3
	CALL CODE_0751
CODE_03D3:
	DEC X
	ASL $C4
	LSR $B3
	BNE CODE_03CA
	MOVW YA, $D5
	ADDW YA, $D7
	BCC CODE_03ED
	MOV Y, #$00
	BBC7 $D4, CODE_03E7
	MOV $D4, Y
CODE_03E7:
	MOV $D5, Y
	MOV $D6, Y
	DEC Y
	MOV A, Y
CODE_03ED:
	MOVW $D7, YA
	BBC0 $D9, CODE_0412
	BBC7 $D9, CODE_0401
	MOVW YA, $DB
	ADDW YA, $DD
	BCS CODE_040B
	CMP Y, $DA
	BCS CODE_040B
	BRA CODE_0410

CODE_0401:
	MOVW YA, $DD
	SUBW YA, $DB
	BCC CODE_040B
	CMP Y, $DA
	BCS CODE_0410
CODE_040B:
	MOV $D9, #$00
	MOV Y, $DA
CODE_0410:
	MOVW $DD, YA
CODE_0412:
	SET7 $B0
	MOV $B3, #$80
	MOV $C4, #$00
	MOV X, #$57
CODE_041C:
	MOV A, $C3
	AND A, $B3
	BEQ CODE_042F
	MOV A, $0258+x
	MOV $A8, A
	MOV A, $0260+x
	MOV $A9, A
	CALL CODE_0751
CODE_042F:
	DEC X
	LSR $B3
	BNE CODE_041C
	MOV A, $C1
	OR A, $C9
	MOV $C1, #$00
	MOV $C9, #$00
	MOV Y, #$5C
	JMP CODE_0D7E

CODE_0443:
	MOV Y, #$07
	MOV A, #$9E
	CALL CODE_0D73
CODE_044A:
	MOV Y, #$05
	MOV A, #$00
	JMP CODE_0D73

CODE_0451:
	MOV Y, #$03
CODE_0453:
	MOV A, DATA_0464-$01+y
	MOV $00F2, A
	MOV A, DATA_0467-$01+y
	MOV $00F3, A
	DBNZ Y, CODE_0453
	JMP CODE_0AA8

DATA_0464:
	db $2D,$3D,$5D

DATA_0467:
	db $00,$00,$3A

CODE_046A:
	MOV A, $00F4
	CMP A, $00F4
	BNE CODE_046A
	MOV Y, A
	BEQ CODE_048C
	PUSH A
	INC $B2
	CALL CODE_048D
	MOV A, #$31
	MOV $00F1, A
	NOP
	NOP
	NOP
	MOV A, $B2
	MOV $00F6, A
	POP A
	MOV $00F7, A
CODE_048C:
	RET

CODE_048D:
	CMP A, #$F0
	BCC CODE_0494
	JMP CODE_0545

CODE_0494:
	CMP A, $1CA2
	BCC CODE_049F
	SETC
	SBC A, $1CA2
	BRA CODE_0494

CODE_049F:
	MOV $A2, #$A4
	MOV $A3, #$1C
	ASL A
	BCC CODE_04AA
	INC $A3
CODE_04AA:
	MOV Y, A
	MOV A, ($A2)+y
	MOV $A1, A
	INC Y
	MOV A, ($A2)+y
	MOV $A0, A
	OR A, $A1
	BEQ CODE_048C
	MOV Y, #$00
	MOV A, ($A0)+y
	BNE CODE_04C1
	JMP CODE_05AF

CODE_04C1:
	MOV $A4, A
	MOV $B3, #$80
	MOV X, #$57
CODE_04C8:
	MOV Y, #$00
	INCW $A0
	MOV A, ($A0)+y
	MOV $A3, A
	INCW $A0
	MOV A, ($A0)+y
	MOV $A2, A
	MOV A, ($A2)+y
	CMP A, #$17
	BEQ CODE_0519
	MOV A, $A4
	CMP A, $0250+x
	BCC CODE_0519
	OR $C3, $B3
	MOV A, $B3
	EOR A, #$FF
	MOV $A5, A
	AND $C2, $A5
	AND $C8, $A5
	CALL CODE_051F
	CALL CODE_0443
	OR $C1, $B3
	MOV A, $A4
	MOV $0250+x, A
	MOVW YA, $A2
	MOV $08+x, Y
	MOV $00+x, A
	MOV A, #$10
	MOV $0100+x, A
	MOV A, #$B8
	MOV $0248+x, A
	MOV A, $00F5
	CLRC
	ADC A, #$80
	MOV $0230+x, A
CODE_0519:
	DEC X
	LSR $B3
	BNE CODE_04C8
	RET

CODE_051F:
	MOV A, X
	CLRC
	ADC A, #$08
CODE_0523:
	MOV Y, A
	MOV A, #$00
	MOV $0200+y, A
	MOV A, Y
	CLRC
	ADC A, #$08
	CMP A, #$B8
	BCC CODE_0523
	SETP
	CALL CODE_0536
	CLRP
CODE_0536:
	PUSH X
CODE_0537:
	MOV A, #$00
	MOV (X), A
	MOV A, X
	CLRC
	ADC A, #$08
	MOV X, A
	CMP X, #$A0
	BCC CODE_0537
	POP X
	RET

CODE_0545:
	AND A, #$0F
	ASL A
	MOV X, A
	JMP (DATA_054C+x)

DATA_054C:
	dw CODE_056C
	dw CODE_056F
	dw CODE_0588
	dw CODE_0634
	dw CODE_0638
	dw CODE_066E
	dw CODE_0672
	dw CODE_06CD
	dw CODE_06E4
	dw CODE_06F5
	dw CODE_05A6
	dw CODE_05A9
	dw CODE_05F0
	dw CODE_0615
	dw CODE_06A8
	dw CODE_06AC

CODE_056C:
	CALL CODE_0588
CODE_056F:
	MOV $B3, #$80
	MOV X, #$57
CODE_0574:
	BBC7 $C3, CODE_057A
	CALL CODE_0A4A
CODE_057A:
	DEC X
	ASL $C3
	LSR $B3
	BNE CODE_0574
	MOV $C0, #$00
	MOV $C2, #$00
	RET

CODE_0588:
	CALL CODE_0651
	MOV A, #$00
	MOV $CA, A
	MOV X, #$08
CODE_0591:
	MOV $0200+x, A
	INC X
	CMP X, #$58
	BNE CODE_0591
	SETP
	CALL CODE_059E
	CLRP
CODE_059E:
	MOV X, #$00
CODE_05A0:
	MOV (X+), A
	CMP X, #$50
	BNE CODE_05A0
	RET

CODE_05A6:
	CALL CODE_06F5
CODE_05A9:
	MOV $A1, #DATA_0DB3>>8
	MOV $A0, #DATA_0DB3
CODE_05AF:
	CALL CODE_0588
	MOV Y, #$00
	MOV A, Y
	MOVW $CE, YA
	MOV $D1, A
	MOVW $D2, YA
	DEC A
	MOV $D0, A
	CALL CODE_069D
	MOV X, #$07
CODE_05C3:
	MOV Y, #$00
	INCW $A0
	MOV A, ($A0)+y
	MOV $A3, A
	INCW $A0
	MOV A, ($A0)+y
	MOV $A2, A
	MOV A, ($A2)+y
	CMP A, #$17
	BEQ CODE_05EC
	MOVW YA, $A2
	MOV $08+x, Y
	MOV $00+x, A
	MOV A, #$10
	MOV $0100+x, A
	MOV A, #$B8
	MOV $0248+x, A
	MOV A, #$80
	MOV $0230+x, A
CODE_05EC:
	DEC X
	BPL CODE_05C3
	RET

CODE_05F0:
	MOV A, $00F5
	PUSH P
	BPL CODE_05F9
	EOR A, #$FF
	INC A
CODE_05F9:
	PUSH A
	MOV Y, #$69
	MUL YA
	MOV $A3, #$00
	MOV $A2, Y
	POP A
	MOV Y, #$03
	MUL YA
	ADDW YA, $A2
	POP P
	BPL CODE_0612
	MOVW $A2, YA
	MOV Y, #$00
	MOV A, Y
	SUBW YA, $A2
CODE_0612:
	MOVW $CE, YA
	RET

CODE_0615:
	MOV A, $00F5
	PUSH P
	BPL CODE_061E
	EOR A, #$FF
	INC A
CODE_061E:
	MOV X, A
	XCN A
	AND A, #$0F
	MOV Y, A
	MOV A, X
	XCN A
	AND A, #$F0
	POP P
	BPL CODE_0631
	MOVW $A2, YA
	MOV Y, #$00
	MOV A, Y
	SUBW YA, $A2
CODE_0631:
	MOVW $D2, YA
	RET

CODE_0634:
	SET6 $B0
	BRA CODE_0651

CODE_0638:
	CLR6 $B0
	MOV $C8, #$00
	MOV $B3, #$80
	MOV X, #$57
CODE_0642:
	MOV A, $C3
	AND A, $B3
	BNE CODE_064B
	CALL CODE_0A55
CODE_064B:
	DEC X
	LSR $B3
	BNE CODE_0642
	RET

CODE_0651:
	MOV X, #$07
	MOV $B3, #$80
CODE_0656:
	MOV A, $C3
	AND A, $B3
	BNE CODE_0662
	CALL CODE_0443
	OR $C9, $B3
CODE_0662:
	DEC X
	LSR $B3
	BNE CODE_0656
	MOV $C8, #$00
	MOV $CB, #$00
	RET

CODE_066E:
	MOV X, #$FF
	BRA CODE_0674

CODE_0672:
	MOV X, #$01
CODE_0674:
	CMP X, $D4
	BEQ CODE_0694
	MOV A, $00F6
	OR A, $00F7
	BEQ CODE_069D
	MOV A, $00F6
	MOV Y, $00F7
	ASL $D4
	BEQ CODE_0695
	CALL CODE_06A3
	MOV Y, #$FF
	MOV A, Y
	SUBW YA, $D7
	MOVW $D7, YA
CODE_0694:
	RET

CODE_0695:
	MOV $D7, #$00
	MOV $D8, #$00
	BRA CODE_06A3

CODE_069D:
	MOV A, #$00
	MOV Y, A
	MOV X, A
	MOVW $D7, YA
CODE_06A3:
	MOVW $D5, YA
	MOV $D4, X
	RET

CODE_06A8:
	MOV X, #$FF
	BRA CODE_06AE

CODE_06AC:
	MOV X, #$01
CODE_06AE:
	MOV A, $00F6
	OR A, $00F7
	BNE CODE_06BD
	MOV X, A
	DEC A
	MOV Y, A
	MOVW $DD, YA
	BRA CODE_06C2

CODE_06BD:
	MOV A, $00F5
	MOV $DA, A
CODE_06C2:
	MOV A, $00F6
	MOV Y, $00F7
	MOVW $DB, YA
	MOV $D9, X
	RET

CODE_06CD:
	CLR5 $B0
	MOV X, $B5
CODE_06D1:
	MOV A, DATA_0DA0+$01+x
	MOV Y, A
	MOV A, DATA_0DA0+$02+x
	MOVW $B8, YA
	MOV A, DATA_0DA0+$04+x
	MOV Y, A
	MOV A, DATA_0DA0+$05+x
	MOVW $BA, YA
	RET

CODE_06E4:
	SET5 $B0
	MOV X, $B5
CODE_06E8:
	MOV A, DATA_0DA0+x
	MOV Y, A
	MOVW $B8, YA
	MOV A, DATA_0DA0+$03+x
	MOV Y, A
	MOVW $BA, YA
	RET

CODE_06F5:
	CALL CODE_056C
	MOV A, #$AA
	MOV $00F4, A
	MOV A, #$BB
	MOV $00F5, A
CODE_0702:
	MOV A, $00F4
	CMP A, #$CC
	BNE CODE_0702
	BRA CODE_072C

CODE_070B:
	MOV Y, $00F4
	BNE CODE_070B
	CMP Y, $00F4
	BNE CODE_070B
CODE_0715:
	MOV A, $00F5
	MOV ($A0)+y, A
	MOV $00F4, Y
CODE_071D:
	CMP Y, $00F4
	BEQ CODE_071D
	INC Y
	BNE CODE_0727
	INC $A1
CODE_0727:
	CMP Y, $00F4
	BEQ CODE_0715
CODE_072C:
	MOV A, $00F6
	MOV Y, $00F7
	MOVW $A0, YA
	MOV Y, $00F4
	MOV A, $00F5
	BEQ CODE_0741
	MOV $00F4, Y
	BRA CODE_070B

CODE_0741:
	MOV $00F6, A
	INC A
	MOV $B2, A
	MOV A, $00FD
	MOV $B1, #$00
	MOV $00F4, Y
	RET

CODE_0751:
	MOV $B4, $B3
	EOR $B4, #$FF
	MOV A, $0210+x
	OR A, $0208+x
	BEQ CODE_079A
	CALL CODE_0B77
	MOV A, $28+x
	OR A, $20+x
	BEQ CODE_077F
	MOV Y, $28+x
	MOV A, $20+x
	SUBW YA, $A8
	BEQ CODE_0772
	BCS CODE_077B
CODE_0772:
	BBS7 $C4, CODE_0778
	CALL CODE_044A
CODE_0778:
	MOV Y, #$00
	MOV A, Y
CODE_077B:
	MOV $28+x, Y
	MOV $20+x, A
CODE_077F:
	MOV A, $0210+x
	MOV Y, A
	MOV A, $0208+x
	SUBW YA, $A8
	PUSH P
	MOV $0208+x, A
	MOV A, Y
	MOV $0210+x, A
	POP P
	BEQ CODE_079A
	BCC CODE_079A
	CMP Y, #$C1
	BCS CODE_079A
	RET

CODE_079A:
	MOV Y, #CODE_07A3>>8
	MOV A, #CODE_07A3
	PUSH Y
	PUSH A
	JMP CODE_08C2

CODE_07A3:
	PUSH A
	XCN A
	LSR A
	AND A, #$07
	DEC A
	MOV Y, A
	MOV A, $10+x
	AND A, #$30
	BNE CODE_07B5
	MOV A, DATA_08A4+y
	BRA CODE_07C7

CODE_07B5:
	AND A, #$10
	BNE CODE_07BE
	MOV A, DATA_089D+y
	BRA CODE_07C7

CODE_07BE:
	MOV A, $10+x
	AND A, #$EF
	MOV $10+x, A
	MOV A, DATA_08AB+y
CODE_07C7:
	CLRC
	ADC A, $0210+x
	MOV $0210+x, A
	POP A
	AND A, #$1F
	BNE CODE_07D4
	RET

CODE_07D4:
	PUSH A
	MOV A, $10+x
	AND A, #$0F
	MOV Y, A
	POP A
	CLRC
	ADC A, DATA_08B2+y
	BBS7 $B0, CODE_07E5
	CLRC
	ADC A, $D1
CODE_07E5:
	CLRC
	ADC A, $0218+x
	MOV $A1, A
	MOV $A0, #$00
	MOV Y, #$00
	MOV A, $0220+x
	BPL CODE_07F6
	DEC Y
CODE_07F6:
	ADDW YA, $A0
	CMP Y, #$61
	BCC CODE_07FE
	MOV Y, #$60
CODE_07FE:
	SETP
	MOVW $A2, YA
	MOV A, $00+x
	MOV $A4, A
	CLR0 $A4
	MOV A, $28+x
	BEQ CODE_0813
	MOV A, $40+x
	BEQ CODE_0813
	CMP A, $A3
	BNE CODE_0817
CODE_0813:
	MOV A, $A2
	BRA CODE_0825

CODE_0817:
	BCS CODE_081D
	SET1 $A4
	BRA CODE_081F

CODE_081D:
	CLR1 $A4
CODE_081F:
	INC $A4
	MOV Y, $40+x
	MOV A, $48+x
CODE_0825:
	PUSH A
	MOV A, $A4
	MOV $00+x, A
	MOV A, $A3
	MOV $40+x, A
	MOV A, $A2
	MOV $48+x, A
	POP A
	MOV $30+x, Y
	MOV $38+x, A
	CLRP
	MOV A, $10+x
	BMI CODE_0866
	MOV A, $0100+x
	MOV Y, A
	AND A, #$10
	BEQ CODE_084F
	MOV A, Y
	AND A, #$3F
	MOV $0100+x, A
	MOV A, #$00
	MOV $0120+x, A
CODE_084F:
	BBC7 $B0, CODE_085A
	OR $C0, $B3
	OR $C1, $B3
	BRA CODE_0863

CODE_085A:
	BBS7 $C4, CODE_086F
	OR $C8, $B3
	OR $C9, $B3
CODE_0863:
	CALL CODE_0443
CODE_0866:
	BBS7 $C4, CODE_086F
	CALL CODE_0CA6
	CALL CODE_0BC9
CODE_086F:
	MOV A, $10+x
	MOV Y, A
	AND A, #$7F
	MOV $A0, A
	MOV A, Y
	AND A, #$40
	ASL A
	OR A, $A0
	MOV $10+x, A
	BPL CODE_0885
	MOV Y, #$00
	MOV A, Y
	BRA CODE_0898

CODE_0885:
	MOV Y, $18+x
	MOV A, $0208+x
	MUL YA
	MOV $A0, Y
	MOV $A1, #$00
	MOV Y, $18+x
	MOV A, $0210+x
	MUL YA
	ADDW YA, $A0
CODE_0898:
	MOV $28+x, Y
	MOV $20+x, A
	RET

DATA_089D:
	db $02,$04,$08,$10,$20,$40,$80

DATA_08A4:
	db $03,$06,$0C,$18,$30,$60,$C0

DATA_08AB:
	db $00,$09,$12,$24,$48,$90,$00

DATA_08B2:
	db $00,$0C,$18,$24,$30,$3C,$48,$54,$18,$24,$30,$3C,$48,$54,$60,$6C

CODE_08C2:
	CALL CODE_08DF
	CMP A, #$20
	BCS CODE_08EF
	MOV $A7, A
	MOV Y, #CODE_08C2>>8
	PUSH Y
	MOV Y, #CODE_08C2
	PUSH Y
	ASL A
	MOV Y, A
	MOV A, DATA_08F0+$01+y
	PUSH A
	MOV A, DATA_08F0+y
	PUSH A
	CMP Y, #$08
	BCC CODE_08EF
CODE_08DF:
	MOV Y, $08+x
	MOV A, $00+x
	MOVW $A0, YA
	MOV Y, #$00
	MOV A, ($A0)+y
	INC $00+x
	BNE CODE_08EF
	INC $08+x
CODE_08EF:
	RET

DATA_08F0:
	dw CODE_0930
	dw CODE_0934
	dw CODE_0938
	dw CODE_093E
	dw CODE_0A1F
	dw CODE_0945
	dw CODE_0958
	dw CODE_095B
	dw CODE_0970
	dw CODE_09AA
	dw CODE_09B5
	dw CODE_09BB
	dw CODE_09BF
	dw CODE_09C3
	dw CODE_09C7
	dw CODE_09CB
	dw CODE_09CF
	dw CODE_09D3
	dw CODE_09C7
	dw CODE_09CB
	dw CODE_09CF
	dw CODE_09D3
	dw CODE_0A09
	dw CODE_0A2A
	dw CODE_0A65
	dw CODE_0A6C
	dw CODE_0A76
	dw CODE_0A9C
	dw CODE_0B57
	dw CODE_0B71
	dw CODE_08EF
	dw CODE_08EF

CODE_0930:
	MOV A, #$20
	BRA CODE_0940

CODE_0934:
	MOV A, #$40
	BRA CODE_0940

CODE_0938:
	MOV A, #$10
	OR A, $10+x
	BRA CODE_0942

CODE_093E:
	MOV A, #$08
CODE_0940:
	EOR A, $10+x
CODE_0942:
	MOV $10+x, A
	RET

CODE_0945:
	PUSH A
	CALL CODE_08DF
	POP Y
	BBC7 $B0, CODE_0955
	MOV $0258+x, A
	MOV A, Y
	MOV $0260+x, A
	RET

CODE_0955:
	MOVW $CC, YA
	RET

CODE_0958:
	MOV $18+x, A
	RET

CODE_095B:
	MOV Y, A
	CALL CODE_0C4A
	BBS7 $B0, CODE_096C
	PUSH A
	MOV Y, $1CA3
	CALL CODE_0C4A
	POP Y
	MUL YA
	MOV A, Y
CODE_096C:
	MOV $0228+x, A
	RET

CODE_0970:
	BBS7 $B0, CODE_097B
	INC A
	MOV $0250+x, A
	BBS7 $C4, CODE_09A9
CODE_097A:
	DEC A
CODE_097B:
	MOV Y, #$06
	MUL YA
	MOVW $A0, YA
	CLRC
	ADC $A0, #$F8
	ADC $A1, #$3A
	MOVW YA, $A0
	MOV $0238+x, A
	MOV A, Y
	MOV $0240+x, A
	PUSH X
	MOV A, X
	XCN A
	AND A, #$70
	OR A, #$04
	MOV X, A
	MOV Y, #$00
CODE_099A:
	MOV A, ($A0)+y
	MOV $00F2, X
	MOV $00F3, A
	INC X
	INC Y
	CMP Y, #$04
	BNE CODE_099A
	POP X
CODE_09A9:
	RET

CODE_09AA:
	MOV $A0, A
	MOV A, $10+x
	AND A, #$F8
	OR A, $A0
	MOV $10+x, A
	RET

CODE_09B5:
	BBS7 $B0, CODE_09BA
	MOV $D1, A
CODE_09BA:
	RET

CODE_09BB:
	MOV $0218+x, A
	RET

CODE_09BF:
	MOV $0220+x, A
	RET

CODE_09C3:
	MOV $0128+x, A
	RET

CODE_09C7:
	MOV Y, #$30
	BRA CODE_09D5

CODE_09CB:
	MOV Y, #$38
	BRA CODE_09D5

CODE_09CF:
	MOV Y, #$40
	BRA CODE_09D5

CODE_09D3:
	MOV Y, #$48
CODE_09D5:
	MOV $A2, A
	MOV $A0, Y
	MOV A, X
	CLRC
	ADC A, $A0
	MOV Y, A
	MOV $A1, #$00
	MOV $A0, #$00
	CMP $A7, #$12
	BCS CODE_09FA
	MOV A, ($A0)+y
	BEQ CODE_09F4
	DEC A
	MOV ($A0)+y, A
	BEQ CODE_0A13
	BRA CODE_0A06

CODE_09F4:
	MOV A, $A2
	MOV ($A0)+y, A
	BRA CODE_0A06

CODE_09FA:
	MOV A, ($A0)+y
	DEC A
	BNE CODE_0A13
	MOV ($A0)+y, A
	MOV A, $A2
	CALL CODE_0A1F
CODE_0A06:
	CALL CODE_08DF
CODE_0A09:
	PUSH A
	CALL CODE_08DF
	MOV $00+x, A
	POP A
	MOV $08+x, A
	RET

CODE_0A13:
	MOV A, #$02
	CLRC
	ADC A, $00+x
	MOV $00+x, A
	BCC CODE_0A1E
	INC $08+x
CODE_0A1E:
	RET

CODE_0A1F:
	MOV $A0, A
	MOV A, $10+x
	AND A, #$97
	OR A, $A0
	MOV $10+x, A
	RET

CODE_0A2A:
	POP A
	POP A
	POP A
	POP A
	BBS7 $B0, CODE_0A44
	MOV A, #$00
	MOV $08+x, A
	MOV $00+x, A
	MOV $0250+x, A
	BBS7 $C4, CODE_0A43
	CALL CODE_0443
	OR $C9, $B3
CODE_0A43:
	RET

CODE_0A44:
	AND $C3, $B4
	AND $C2, $B4
CODE_0A4A:
	MOV A, #$00
	MOV $0250+x, A
	CALL CODE_0443
	OR $C1, $B3
CODE_0A55:
	PUSH X
	MOV A, X
	SETC
	SBC A, #$50
	MOV X, A
	MOV A, $0250+x
	BEQ CODE_0A63
	OR $CB, $B3
CODE_0A63:
	POP X
	RET

CODE_0A65:
	CLRC
	ADC A, #$80
	MOV $0230+x, A
	RET

CODE_0A6C:
	BBS7 $B0, CODE_0A75
	MOV Y, A
	CALL CODE_0C4A
	MOV $D0, A
CODE_0A75:
	RET

CODE_0A76:
	PUSH A
	CALL CODE_08DF
	POP Y
	CMP Y, #$03
	BNE CODE_0A8D
	XCN A
	MOV $A0, A
	MOV A, $0100+x
	AND A, #$EF
	OR A, $A0
	MOV $0100+x, A
	RET

CODE_0A8D:
	PUSH A
	MOV A, #$08
	MUL YA
	MOV $A0, X
	CLRC
	ADC A, $A0
	MOV Y, A
	POP A
	MOV $0108+y, A
	RET

CODE_0A9C:
	CALL CODE_08DF
	MOV Y, #$0A
	MUL YA
	CMP A, $B5
	BEQ CODE_0AF6
	MOV $B5, A
CODE_0AA8:
	PUSH X
	MOV X, A
	BBS5 $B0, CODE_0AB2
	CALL CODE_06D1
	BRA CODE_0AB5

CODE_0AB2:
	CALL CODE_06E8
CODE_0AB5:
	CALL CODE_0AF7
	MOV Y, #$6D
	MOV A, DATA_0DA0+$06+x
	CALL CODE_0D7E
	MOV A, #$7D
	MOV $00F2, A
	MOV A, $00F3
	AND A, #$0F
	INC A
	EOR A, #$FF
	BBC7 $B7, CODE_0AD9
	CLRC
	ADC A, $B7
	CMP A, #$E0
	BCS CODE_0AD9
	MOV A, #$E0
CODE_0AD9:
	MOV $B7, A
	MOV A, DATA_0DA0+$07+x
	MOV $00F3, A
	MOV Y, A
	MOV A, DATA_0B10+y
	MOV $B6, A
	MOV Y, #$0D
	MOV A, DATA_0DA0+$08+x
	CALL CODE_0D7E
	MOV A, DATA_0DA0+$09+x
	CALL CODE_0B20
	POP X
CODE_0AF6:
	RET

CODE_0AF7:
	MOV Y, #$03
CODE_0AF9:
	MOV A, DATA_0B0D-$01+y
	MOV $00F2, A
	MOV A, #$00
	MOV $00F3, A
	DBNZ Y, CODE_0AF9
	MOV Y, #$6C
	MOV A, #$20
	JMP CODE_0D7E

DATA_0B0D:
	db $2C,$3C,$4D

DATA_0B10:
	db $00,$0C,$16,$22,$2C,$34,$42,$4C,$50,$58,$6C,$74,$80,$88,$98,$A0

CODE_0B20:
	PUSH X
	MOV Y, #$08
	MUL YA
	MOV X, A
	MOV Y, #$0F
CODE_0B27:
	MOV A, DATA_0B37+x
	CALL CODE_0D7E
	INC X
	MOV A, Y
	CLRC
	ADC A, #$10
	MOV Y, A
	BPL CODE_0B27
	POP X
	RET

DATA_0B37:
	db $7F,$00,$00,$00,$00,$00,$00,$00,$58,$BF,$DB,$F0,$FE,$07,$0C,$0C
	db $0C,$21,$2B,$2B,$13,$FE,$F3,$F9,$34,$33,$00,$D9,$E5,$01,$FC,$EB

CODE_0B57:
	AND A, #$01
	LSR A
	BCC CODE_0B5E
	MOV A, $B3
CODE_0B5E:
	BBS7 $B0, CODE_0B69
	AND $CA, $B4
	OR A, $CA
	MOV $CA, A
	RET

CODE_0B69:
	AND $C2, $B4
	OR A, $C2
	MOV $C2, A
	RET

CODE_0B71:
	OR A, #$A0
	MOV $0248+x, A
	RET

CODE_0B77:
	SETP
	MOV A, $18+x
	CLRC
	ADC A, $20+x
	MOV $20+x, A
	BCC CODE_0B88
	MOV A, $00+x
	CLRC
	ADC A, #$40
	MOV $00+x, A
CODE_0B88:
	MOV A, $00+x
	MOV $A4, A
	BBC0 $A4, CODE_0BC1
	MOV $A1, #$00
	MOV A, $28+x
	ASL A
	MOV $A0, A
	MOV A, $40+x
	MOV $A3, A
	MOV A, $48+x
	MOV $A2, A
	MOV Y, $30+x
	MOV A, $38+x
	BBS1 $A4, CODE_0BB0
	SUBW YA, $A0
	BCC CODE_0BB6
	CMPW YA, $A2
	BCC CODE_0BB6
	BRA CODE_0BBD

CODE_0BB0:
	ADDW YA, $A0
	CMPW YA, $A2
	BCC CODE_0BBD
CODE_0BB6:
	MOV A, $A4
	DEC A
	MOV $00+x, A
	MOVW YA, $A2
CODE_0BBD:
	MOV $30+x, Y
	MOV $38+x, A
CODE_0BC1:
	CLRP
	BBC7 $C4, CODE_0BC6
	RET

CODE_0BC6:
	CALL CODE_0C92
CODE_0BC9:
	SETP
	MOV Y, $10+x
	MOV A, $00+x
	ASL A
	ASL A
	MOV A, $20+x
	BCS CODE_0BD6
	EOR A, #$FF
CODE_0BD6:
	MUL YA
	MOVW $A0, YA
	MOV Y, #$7E
	MOV A, #$81
	SUBW YA, $A0
	CALL CODE_0C4C
	MOV Y, A
	CLRP
	BBS7 $B0, CODE_0C05
	MOV A, $D0
	MUL YA
	BBC0 $D4, CODE_0BFD
	PUSH Y
	MOVW YA, $D7
	BBS7 $D4, CODE_0BF8
	MOV Y, #$FF
	MOV A, Y
	SUBW YA, $D7
CODE_0BF8:
	CALL CODE_0C44
	POP Y
	MUL YA
CODE_0BFD:
	PUSH Y
	MOVW YA, $DD
	CALL CODE_0C44
	POP Y
	MUL YA
CODE_0C05:
	MOV A, $0228+x
	MUL YA
	MOV $A2, Y
	MOV A, $0230+x
	BBC5 $B0, CODE_0C13
	MOV A, #$80
CODE_0C13:
	MOV Y, #$14
	MUL YA
	MOVW $A0, YA
	MOV $A3, #$01
CODE_0C1B:
	MOV Y, $A1
	MOV A, DATA_0C7C+$01+y
	SETC
	SBC A, DATA_0C7C+y
	MOV Y, $A0
	MUL YA
	MOV A, Y
	MOV Y, $A1
	CLRC
	ADC A, DATA_0C7C+y
	MOV Y, $A2
	MUL YA
	MOV A, Y
	MOV Y, $A3
	CALL CODE_0D73
	MOV Y, #$14
	MOV A, #$00
	SUBW YA, $A0
	MOVW $A0, YA
	DEC $A3
	BPL CODE_0C1B
	RET

CODE_0C44:
	MOV $A4, Y
	MOV Y, #$04
	BRA CODE_0C50

CODE_0C4A:
	MOV A, #$FF
CODE_0C4C:
	MOV $A4, Y
	MOV Y, #$03
CODE_0C50:
	LSR $A4
	ROR A
	DBNZ Y, CODE_0C50
	MOV $A5, A
	MOV Y, $A4
	MOV A, DATA_0C6B+$01+y
	SETC
	SBC A, DATA_0C6B+y
	MOV Y, $A5
	MUL YA
	MOV A, Y
	MOV Y, $A4
	CLRC
	ADC A, DATA_0C6B+y
	RET

DATA_0C6B:
	db $00,$0C,$19,$26,$33,$40,$4C,$59,$66,$73,$80,$8C,$99,$B3,$CC,$E6
	db $FF

DATA_0C7C:
	db $00,$01,$03,$07,$0D,$15,$1E,$29,$34,$42,$51,$5E,$67,$6E,$73,$77
	db $7A,$7C,$7D,$7E,$7F,$7F

CODE_0C92:
	MOV A, $0100+x
	AND A, #$01
	OR A, $0108+x
	BNE CODE_0CA6
	BBS7 $B0, CODE_0CA5
	MOV A, $D2
	OR A, $D3
	BNE CODE_0CA6
CODE_0CA5:
	RET

CODE_0CA6:
	SETP
	MOV A, $08+x
	BNE CODE_0CB1
	MOV Y, $30+x
	MOV A, $38+x
	BRA CODE_0CE0

CODE_0CB1:
	ASL A
	MOV Y, #$0C
	MUL YA
	MOVW $A0, YA
	MOV A, $00+x
	PUSH P
	ASL A
	ASL A
	MOV A, $20+x
	BCC CODE_0CC2
	EOR A, #$FF
CODE_0CC2:
	PUSH A
	MOV Y, $A0
	MUL YA
	MOV $A0, Y
	POP A
	MOV Y, $A1
	MUL YA
	MOV $A1, #$00
	ADDW YA, $A0
	MOVW $A0, YA
	MOV Y, $30+x
	MOV A, $38+x
	POP P
	BMI CODE_0CDE
	ADDW YA, $A0
	BRA CODE_0CE0

CODE_0CDE:
	SUBW YA, $A0
CODE_0CE0:
	CLRP
	BBS7 $B0, CODE_0CE6
	ADDW YA, $D2
CODE_0CE6:
	DEC Y
	MOVW $A0, YA
	MOV A, Y
	MOV Y, #$00
	SETC
	SBC A, #$34
	BCS CODE_0CFA
	MOV A, $A1
	SETC
	SBC A, #$13
	BCS CODE_0CFE
	DEC Y
	ASL A
CODE_0CFA:
	ADDW YA, $A0
	MOVW $A0, YA
CODE_0CFE:
	PUSH X
	MOV A, $A1
	ASL A
	MOV Y, #$00
	MOV X, #$18
	DIV YA, X
	MOV X, A
	MOV A, DATA_0D85+$01+y
	MOV $A3, A
	MOV A, DATA_0D85+y
	MOV $A2, A
	MOV A, DATA_0D85+$03+y
	PUSH A
	MOV A, DATA_0D85+$02+y
	POP Y
	SUBW YA, $A2
	MOV Y, $A0
	MUL YA
	MOV A, Y
	MOV Y, #$00
	ADDW YA, $A2
	MOV $A1, Y
	ASL A
	ROL $A1
CODE_0D29:
	CMP X, #$08
	BEQ CODE_0D33
	LSR $A1
	ROR A
	INC X
	BRA CODE_0D29

CODE_0D33:
	MOV $A0, A
	POP X
	MOV A, $0238+x
	MOV $A4, A
	MOV A, $0240+x
	MOV $A5, A
	MOV Y, #$05
	MOV A, ($A4)+y
	MOV Y, $A1
	MUL YA
	MOVW $A2, YA
	MOV Y, #$05
	MOV A, ($A4)+y
	MOV Y, $A0
	MUL YA
	PUSH Y
	MOV Y, #$04
	MOV A, ($A4)+y
	MOV Y, $A0
	MUL YA
	ADDW YA, $A2
	MOVW $A2, YA
	MOV Y, #$04
	MOV A, ($A4)+y
	MOV Y, $A1
	MUL YA
	MOV Y, A
	POP A
	ADDW YA, $A2
	AND A, #$F0
	PUSH Y
	MOV Y, #$02
	CALL CODE_0D73
	POP A
	INC Y
	BRA CODE_0D7E

CODE_0D73:
	PUSH A
	MOV $A6, Y
	MOV A, X
	XCN A
	AND A, #$70
	OR A, $A6
	MOV Y, A
	POP A
CODE_0D7E:
	MOV $00F2, Y
	MOV $00F3, A
	RET

DATA_0D85:
	db $5F,$08,$DE,$08,$65,$09,$F4,$09,$8C,$0A,$2C,$0B,$D6,$0B,$8B,$0C
	db $4A,$0D,$14,$0E,$EA,$0E,$CD,$0F,$BE,$10
%SPCDataBlockEnd(02C0)

%EndSPCUploadAndJumpToEngine($02C0)