SPC700_Engine_DKC2.asm
Yoshifanatic1_Donkey-Kong-Country-2-Disassembly/DKC2/SPC700/SPC700_Engine_DKC2.asm

;%SPCDataBlockStart(0560)
base $0560
DATA_0560:
	db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
	db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
	db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
	db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
	db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
	db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
	db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
	db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
	db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
	db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
	db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
	db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
	db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
	db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
	db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
	db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00

CODE_0660:
	MOV A, $055D
	ASL A
	MOV Y, A
	MOV A, $1312+y
	MOV $E5, A
	MOV A, $1313+y
	MOV $E6, A
	JMP CODE_0678

CODE_0672:
	MOV $E6, #$13
	MOV $E5, #$00
CODE_0678:
	CALL CODE_100B
	MOV A, #$00
	MOV $1C, A
	MOV $1D, A
	MOV $F1, A
CODE_0683:
	MOV A, $E9
	CMP A, $F4
	BEQ CODE_068C
	JMP CODE_0781

CODE_068C:
	MOV X, $F6
	MOV $055D, X
	MOV X, $F5
	MOV $F4, A
	INC A
	MOV $E9, A
	MOV A, X
	CMP A, #$80
	BPL CODE_06A0
	JMP CODE_0773

CODE_06A0:
	AND A, #$07
	ASL A
	MOV X, A
	JMP (DATA_06A7+x)

DATA_06A7:
	dw CODE_070A
	dw CODE_0702
	dw CODE_06FA
	dw CODE_06B7
	dw CODE_0739
	dw CODE_0712
	dw CODE_077B
	dw CODE_07DB

CODE_06B7:
	MOV X, #$7F
CODE_06B9:
	MOV A, #$71
CODE_06BB:
	MOV Y, A
	MOV $F2, Y
	CALL CODE_06EB
	DEC Y
	MOV $F2, Y
	CALL CODE_06EB
	MOV A, Y
	SETC
	SBC A, #$0F
	BPL CODE_06BB
	MOV $F2, #$0C
	CALL CODE_06EB
	MOV $F2, #$1C
	CALL CODE_06EB
	MOV $F2, #$2C
	CALL CODE_06EB
	MOV $F2, #$3C
	CALL CODE_06EB
	DEC X
	BNE CODE_06B9
	JMP CODE_0660

CODE_06EB:
	MOV A, $F3
	BEQ CODE_06F7
	BMI CODE_06F5
	DEC A
	DEC A
	BRA CODE_06F7

CODE_06F5:
	INC A
	INC A
CODE_06F7:
	MOV $F3, A
	RET

CODE_06FA:
	MOV A, $055D
	MOV $1D, A
	JMP CODE_0781

CODE_0702:
	MOV A, $055D
	MOV $E7, A
	JMP CODE_0781

CODE_070A:
	MOV A, $055D
	MOV $E8, A
	JMP CODE_0781

CODE_0712:
	MOV A, $04B6
	PUSH A
	PUSH X
	MOV X, #$05
	MOV A, $055D
	MOV $04B6, A
	MOV $F2, #$50
	MOV A, $F3
	CALL CODE_0C59
	MOV $F3, A
	INC $F2
	MOV A, $F3
	CALL CODE_0C59
	MOV $F3, A
	POP X
	POP A
	MOV $04B6, A
	BRA CODE_0781

CODE_0739:
	MOV A, $055D
	BMI CODE_074A
	CLRC
	MOV A, $055D
	MOV $EC, A
	MOV A, #$00
	MOV $ED, A
	BRA CODE_0756

CODE_074A:
	MOV $055D, A
	MOV A, $055D
	MOV $EC, A
	MOV A, #$FF
	MOV $ED, A
CODE_0756:
	MOVW YA, $EC
	ADDW YA, $EC
	ADDW YA, $EC
	ADDW YA, $EC
	ADDW YA, $EC
	ADDW YA, $EC
	ADDW YA, $EC
	ADDW YA, $EC
	MOVW $EC, YA
	MOV $F2, #$4D
	MOV A, $F3
	AND A, #$DF
	MOV $F3, A
	BRA CODE_0781

CODE_0773:
	MOV X, $055D
	CALL CODE_10F7
	BRA CODE_078E

CODE_077B:
	MOV $1C, #$01
	MOV $F1, #$00
CODE_0781:
	MOV A, $1C
	BNE CODE_0788
	JMP CODE_0683

CODE_0788:
	MOV $FA, $E4
	MOV $F1, #$01
CODE_078E:
	MOV A, $FD
	BEQ CODE_078E
	MOV $F1, #$01
	MOV $20, #$00
	CLRC
	ADC $1E, $1F
	ROR $20
	MOV $23, #$00
	CLRC
	ADC $21, $22
	ROR $23
	MOV X, #$00
CODE_07A9:
	MOV A, $20
	BNE CODE_07B2
	CALL CODE_09BC
	BRA CODE_07B7

CODE_07B2:
	CALL CODE_0813
	BNE CODE_07B2
CODE_07B7:
	MOV A, $01E0+x
	BEQ CODE_07D0
	PUSH X
	MOV A, X
	OR A, #$08
	MOV X, A
	MOV A, $23
	BNE CODE_07CA
	CALL CODE_09BC
	BRA CODE_07CF

CODE_07CA:
	CALL CODE_0813
	BNE CODE_07CA
CODE_07CF:
	POP X
CODE_07D0:
	INC X
	CMP X, #$08
	BEQ CODE_07D8
	JMP CODE_07A9

CODE_07D8:
	JMP CODE_0683

CODE_07DB:
	MOV A, $055D
	BEQ CODE_07E3
	JMP $04F3

CODE_07E3:
	MOV $F2, #$5C
	MOV $F3, #$FF
	MOV $F1, #$00
	MOV $FB, #$C8
	MOV $F1, #$02
CODE_07F2:
	MOV A, $FE
	BEQ CODE_07F2
	MOV $F2, #$6C
	MOV $F3, #$A0
	MOV X, #$00
	MOV $F2, #$4D
	MOV $F3, X
	MOV $F2, #$2C
	MOV $F3, X
	MOV $F2, #$3C
	MOV $F3, X
	CALL CODE_100B
	JMP $04F3

CODE_0813:
	MOV A, $0110+x
	BNE CODE_081B
	MOV A, #$00
	RET

CODE_081B:
	DEC $34+x
	MOV A, $34+x
	CMP A, #$01
	BEQ CODE_0839
	CMP A, #$FF
	BNE CODE_082F
	MOV A, $24+x
	BEQ CODE_0850
	DEC $24+x
	BRA CODE_084A

CODE_082F:
	CMP A, #$00
	BNE CODE_084A
	MOV A, $24+x
	BEQ CODE_0850
	BRA CODE_084A

CODE_0839:
	MOV A, $24+x
	BNE CODE_084A
	MOV A, $01E0+x
	BNE CODE_084A
	MOV A, DATA_0F95+x
	MOV $F2, #$5C
	MOV $F3, A
CODE_084A:
	CALL CODE_09BC
	MOV A, #$00
	RET

CODE_0850:
	MOV A, $44+x
	MOV Y, $54+x
	MOVW $00, YA
	MOV Y, #$00
	MOV A, ($00)+y
	BMI CODE_0862
	PUSH X
	ASL A
	MOV X, A
	JMP (DATA_0FA5+x)

CODE_0862:
	CALL CODE_0867
	BRA CODE_084A

CODE_0867:
	CMP A, #$80
	BNE CODE_088B
	MOV A, $01E0+x
	BNE CODE_0888
	MOV A, DATA_0F95+x
	MOV $F2, #$5C
	MOV $F3, A
	MOV A, X
	AND A, #$07
	XCN A
	OR A, #$02
	MOV $F2, A
	MOV A, #$00
	MOV $F3, A
	INC $F2
	MOV $F3, A
CODE_0888:
	JMP CODE_0983

CODE_088B:
	CMP A, #$E0
	BMI CODE_0899
	CMP A, #$E1
	BEQ CODE_0897
	MOV A, $0C+x
	BRA CODE_0899

CODE_0897:
	MOV A, $14+x
CODE_0899:
	CLRC
	ADC A, #$24
	ADC A, $0140+x
	ASL A
	PUSH X
	MOV Y, $64+x
	BEQ CODE_08DF
	MOV X, A
	MOV $04, Y
	MOV A, Y
	BPL CODE_08AE
	EOR A, #$FF
	INC A
CODE_08AE:
	MOV Y, A
	PUSH Y
	MOV A, DATA_1199+x
	MUL YA
	MOV $02, Y
	MOV $03, #$00
	POP Y
	MOV A, DATA_1199+$01+x
	MUL YA
	ADDW YA, $02
	MOV $03, Y
	LSR $03
	ROR A
	LSR $03
	ROR A
	MOV $02, A
	MOV A, DATA_1199+$01+x
	MOV Y, A
	MOV A, DATA_1199+x
	MOV X, $04
	BMI CODE_08D9
	ADDW YA, $02
	BRA CODE_08DB

CODE_08D9:
	SUBW YA, $02
CODE_08DB:
	MOVW $02, YA
	BRA CODE_08EA

CODE_08DF:
	MOV X, A
	MOV A, DATA_1199+x
	MOV $02, A
	MOV A, DATA_1199+$01+x
	MOV $03, A
CODE_08EA:
	POP A
	MOV X, A
	AND A, #$07
	XCN A
	MOV $F2, A
	MOV A, $01E0+x
	BEQ CODE_08F9
	JMP CODE_0983

CODE_08F9:
	MOV A, $0254+x
	CALL CODE_0C59
	MOV $F3, A
	INC $F2
	MOV A, $0264+x
	CALL CODE_0C59
	MOV $F3, A
	INC $F2
	MOV A, $0150+x
	AND A, #$01
	BEQ CODE_092B
	MOV A, $0160+x
	MOV $01A0+x, A
	MOV A, $0170+x
	MOV $0100+x, A
	MOV A, $0180+x
	MOV $94+x, A
	MOV A, $0190+x
	MOV $01C0+x, A
CODE_092B:
	MOV A, $0150+x
	AND A, #$02
	BEQ CODE_094D
	MOV A, $0234+x
	BPL CODE_093D
	EOR A, #$FF
	INC A
	MOV $0234+x, A
CODE_093D:
	MOV A, $0200+x
	LSR A
	MOV $A4+x, A
	MOV A, $0210+x
	MOV $B4+x, A
	MOV A, $0220+x
	MOV $C4+x, A
CODE_094D:
	MOV A, $02
	MOV $84+x, A
	MOV $F3, A
	INC $F2
	MOV A, $03
	MOV $74+x, A
	MOV $F3, A
	INC $F2
	MOV A, $0244+x
	MOV $F3, A
	INC $F2
	MOV A, $0274+x
	MOV $F3, A
	INC $F2
	MOV A, $0284+x
	MOV $F3, A
	INC $F2
	MOV $F3, #$7F
	MOV $F2, #$5C
	MOV $F3, #$00
	MOV $F2, #$4C
	MOV A, DATA_0F95+x
	MOV $F3, A
CODE_0983:
	MOV A, $0120+x
	BEQ CODE_0997
	MOV $00, #$01
	MOV A, $0120+x
	MOV $34+x, A
	MOV A, $0130+x
	MOV $24+x, A
	BRA CODE_09AE

CODE_0997:
	MOV Y, #$01
	MOV A, ($00)+y
	MOV $34+x, A
	MOV A, $01D0+x
	BEQ CODE_09AB
	MOV A, $34+x
	MOV $24+x, A
	INC Y
	MOV A, ($00)+y
	MOV $34+x, A
CODE_09AB:
	INC Y
	MOV $00, Y
CODE_09AE:
	MOV $01, #$00
	MOV A, $44+x
	MOV Y, $54+x
	ADDW YA, $00
	MOV $54+x, Y
	MOV $44+x, A
	RET

CODE_09BC:
	MOV A, $0150+x
	AND A, #$01
	BNE CODE_09C6
	JMP CODE_0A39

CODE_09C6:
	MOV A, $01A0+x
	BEQ CODE_09DA
	CMP A, #$FF
	BEQ CODE_0A39
	DEC A
	MOV $01A0+x, A
	BNE CODE_0A39
	MOV A, #$01
	MOV $0100+x, A
CODE_09DA:
	MOV A, $0100+x
	DEC A
	MOV $0100+x, A
	BNE CODE_0A39
	MOV A, $0170+x
	MOV $0100+x, A
	MOV A, $01C0+x
	BEQ CODE_0A10
	DEC A
	MOV $01C0+x, A
	MOV A, $01B0+x
	EOR A, #$FF
	INC A
	MOV $00, A
	BPL CODE_0A00
	MOV A, #$FF
	BRA CODE_0A02

CODE_0A00:
	MOV A, #$00
CODE_0A02:
	MOV $01, A
	MOV A, $84+x
	MOV Y, $74+x
	ADDW YA, $00
	MOV $74+x, Y
	MOV $84+x, A
	BRA CODE_0A1B

CODE_0A10:
	MOV A, $01B0+x
	MOV $00, A
	BPL CODE_0A00
	MOV A, #$FF
	BRA CODE_0A02

CODE_0A1B:
	MOV A, $01E0+x
	BNE CODE_0A30
	MOV A, X
	AND A, #$07
	XCN A
	OR A, #$02
	MOV $F2, A
	MOV A, $84+x
	MOV $F3, A
	INC $F2
	MOV $F3, Y
CODE_0A30:
	DEC $94+x
	BNE CODE_0A39
	MOV A, #$FF
	MOV $01A0+x, A
CODE_0A39:
	MOV A, $0150+x
	AND A, #$02
	BEQ CODE_0AB4
	MOV A, $C4+x
	BEQ CODE_0A48
	DEC $C4+x
	BRA CODE_0AB4

CODE_0A48:
	DEC $B4+x
	BNE CODE_0AB4
	MOV A, $0210+x
	MOV $B4+x, A
	MOV A, $0234+x
	MOV $00, A
	BPL CODE_0A5C
	MOV A, #$FF
	BRA CODE_0A5E

CODE_0A5C:
	MOV A, #$00
CODE_0A5E:
	MOV $01, A
	MOV A, $84+x
	MOV Y, $74+x
	CMP X, #$0D
	BNE CODE_0A87
	PUSH A
	MOV A, $EC
	CMP A, $EE
	BNE CODE_0A78
	MOV A, $ED
	CMP A, $EF
	BNE CODE_0A78
	POP A
	BRA CODE_0A87

CODE_0A78:
	POP A
	SUBW YA, $EE
	ADDW YA, $EC
	PUSH A
	MOV A, $EC
	MOV $EE, A
	MOV A, $ED
	MOV $EF, A
	POP A
CODE_0A87:
	ADDW YA, $00
	MOV $74+x, Y
	MOV $84+x, A
	MOV A, $01E0+x
	BNE CODE_0AA2
	MOV A, X
	AND A, #$07
	XCN A
	OR A, #$02
	MOV $F2, A
	MOV A, $84+x
	MOV $F3, A
	INC $F2
	MOV $F3, Y
CODE_0AA2:
	DEC $A4+x
	BNE CODE_0AB4
	MOV A, $0200+x
	MOV $A4+x, A
	MOV A, $0234+x
	EOR A, #$FF
	INC A
	MOV $0234+x, A
CODE_0AB4:
	MOV A, $0150+x
	AND A, #$0C
	BNE CODE_0ABE
	JMP CODE_0B17

CODE_0ABE:
	MOV A, $02A4+x
	BEQ CODE_0ACD
	MOV A, $02A4+x
	DEC A
	MOV $02A4+x, A
	JMP CODE_0B17

CODE_0ACD:
	MOV A, $02B4+x
	DEC A
	MOV $02B4+x, A
	BEQ CODE_0AD9
	JMP CODE_0B17

CODE_0AD9:
	MOV A, $02C4+x
	MOV $02B4+x, A
	MOV A, $01E0+x
	BNE CODE_0AF8
	MOV A, X
	AND A, #$07
	XCN A
	OR A, #$00
	MOV $F2, A
	MOV A, $0254+x
	MOV $F3, A
	MOV A, $0264+x
	INC $F2
	MOV $F3, A
CODE_0AF8:
	MOV A, $02E4+x
	DEC A
	MOV $02E4+x, A
	BNE CODE_0B17
	MOV A, $0150+x
	AND A, #$08
	BNE CODE_0B17
	MOV A, $02F4+x
	MOV $02E4+x, A
	MOV A, $02D4+x
	EOR A, #$FF
	INC A
	MOV $02D4+x, A
CODE_0B17:
	RET

CODE_0B18:
	POP X
	MOV A, #$00
	MOV $0110+x, A
	MOV A, $01E0+x
	BNE CODE_0B2B
	MOV $F2, #$5C
	MOV A, DATA_0F95+x
	MOV $F3, A
CODE_0B2B:
	MOV A, X
	CMP A, #$08
	BCC CODE_0B61
	PUSH X
	SETC
	SBC A, #$08
	MOV X, A
	MOV A, #$00
	MOV $01E0+x, A
	MOV $F2, #$3D
	MOV A, DATA_0F95+x
	EOR A, #$FF
	AND A, $F3
	MOV $F3, A
	MOV $F2, #$4D
	MOV A, $0294+x
	BEQ CODE_0B57
	MOV A, DATA_0F95+x
	OR A, $F3
	MOV $F3, A
	BRA CODE_0B60

CODE_0B57:
	MOV A, DATA_0F95+x
	EOR A, #$FF
	AND A, $F3
	MOV $F3, A
CODE_0B60:
	POP X
CODE_0B61:
	MOV A, #$00
	RET

CODE_0B64:
	POP Y
	POP A
	POP X
	PUSH A
	PUSH Y
CODE_0B69:
	MOV Y, #$01
	MOV $34+x, Y
	MOV A, #$00
	MOV $24+x, A
	RET

CODE_0B72:
	CALL CODE_0B64
	CALL CODE_0B8B
CODE_0B78:
	MOV $00, #$02
CODE_0B7B:
	MOV $01, #$00
	MOV A, $44+x
	MOV Y, $54+x
	ADDW YA, $00
	MOV $54+x, Y
	MOV $44+x, A
	MOV A, #$01
	RET

CODE_0B8B:
	PUSH X
	MOV A, ($00)+y
	MOV X, A
	MOV A, DATA_0560+x
	POP X
	MOV $0244+x, A
	RET

CODE_0B97:
	CALL CODE_0B64
	CALL CODE_0B8B
	INC Y
	MOV A, ($00)+y
	MOV $0140+x, A
	INC Y
	MOV A, ($00)+y
	MOV $64+x, A
	INC Y
	CALL CODE_0BC2
	INC Y
	CALL CODE_0E4E
	MOV $00, #$08
	JMP CODE_0B7B

CODE_0BB6:
	CALL CODE_0B64
	CALL CODE_0BC2
CODE_0BBC:
	MOV $00, #$03
	JMP CODE_0B7B

CODE_0BC2:
	MOV A, $1D
	BNE CODE_0BD2
	MOV A, ($00)+y
	MOV $0254+x, A
	INC Y
CODE_0BCC:
	MOV A, ($00)+y
	MOV $0264+x, A
	RET

CODE_0BD2:
	MOV A, ($00)+y
	BPL CODE_0BD9
	EOR A, #$FF
	INC A
CODE_0BD9:
	LSR A
	MOV $03, A
	INC Y
	CLRC
	MOV A, ($00)+y
	BPL CODE_0BE5
	EOR A, #$FF
	INC A
CODE_0BE5:
	LSR A
	CLRC
	ADC A, $03
	MOV $0254+x, A
	MOV $0264+x, A
	RET

CODE_0BF0:
	CALL CODE_0B64
	MOV $0254+x, A
	CALL CODE_0BCC
	MOV A, $0264+x
	MOV $0254+x, A
	JMP CODE_0B78

CODE_0C02:
	CALL CODE_0B64
	MOV A, $04B8
	MOV $0254+x, A
	MOV A, $04B9
	MOV $0264+x, A
	MOV A, $1D
	BNE CODE_0C2E
	JMP CODE_0ED6

CODE_0C18:
	CALL CODE_0B64
	MOV A, $04BA
	MOV $0254+x, A
	MOV A, $04BB
	MOV $0264+x, A
	MOV A, $1D
	BNE CODE_0C2E
	JMP CODE_0ED6

CODE_0C2E:
	MOV A, $0254+x
	BPL CODE_0C36
	EOR A, #$FF
	INC A
CODE_0C36:
	LSR A
	MOV $00, A
	MOV A, $0264+x
	BPL CODE_0C41
	EOR A, #$FF
	INC A
CODE_0C41:
	LSR A
	CLRC
	ADC A, $00
	MOV $0254+x, A
	MOV $0264+x, A
	JMP CODE_0ED6

CODE_0C4E:
	CALL CODE_0B64
	MOV A, ($00)+y
	MOV $04B6, A
	JMP CODE_0B78

CODE_0C59:
	PUSH X
	MOV Y, $04B6
	CMP X, #$08
	BCS CODE_0C6F
	CMP A, #$00
	BMI CODE_0C71
	MUL YA
	MOV X, #$64
	DIV YA, X
	CMP A, #$7F
	BMI CODE_0C6F
	MOV A, #$7F
CODE_0C6F:
	POP X
	RET

CODE_0C71:
	EOR A, #$FF
	INC A
	MUL YA
	MOV X, #$64
	DIV YA, X
	CMP A, #$7F
	BMI CODE_0C7E
	MOV A, #$7F
CODE_0C7E:
	EOR A, #$FF
	INC A
	POP X
	RET

CODE_0C83:
	CALL CODE_0B64
	MOV A, ($00)+y
	MOV $04B8, A
	INC Y
	MOV A, ($00)+y
	MOV $04B9, A
	INC Y
	MOV A, ($00)+y
	MOV $04BA, A
	INC Y
	MOV A, ($00)+y
	MOV $04BB, A
	JMP CODE_0F76

CODE_0CA0:
	CALL CODE_0B64
	MOV A, ($00)+y
	CALL CODE_10F0
	MOV $F2, #$7D
	CLRC
	LSR A
	MOV $F3, A
	MOV $F2, #$6D
	ROL A
	ROL A
	ROL A
	MOV $00, A
	MOV A, #$FF
	SETC
	SBC A, $00
	MOV $F3, A
	MOV $04B7, A
	MOV Y, A
	MOV A, #$00
	MOVW $00, YA
CODE_0CC6:
	MOV Y, A
CODE_0CC7:
	MOV ($00)+y, A
	INC Y
	BNE CODE_0CC7
	INC $01
	MOV Y, $01
	CMP Y, #$00
	BNE CODE_0CC6
	JMP CODE_0B78

CODE_0CD7:
	CALL CODE_0B64
	MOV A, ($00)+y
	MOV $44+x, A
	INC Y
	MOV A, ($00)+y
	MOV $54+x, A
	MOV A, #$01
	RET

CODE_0CE6:
	CALL CODE_0B64
	MOV A, ($00)+y
	MOV $04, A
	INC Y
	CALL CODE_0D1C
CODE_0CF1:
	MOV $0334+y, A
CODE_0CF4:
	INC $D4+x
	MOVW YA, $02
	MOV $44+x, A
	MOV $54+x, Y
	MOV A, #$01
	RET

CODE_0CFF:
	CALL CODE_0B64
	MOV $04, #$01
	CALL CODE_0D1C
	BEQ CODE_0D0E
	DEC A
	JMP CODE_0CF1

CODE_0D0E:
	DEC A
	MOV $0334+y, A
	MOV A, $03B4+y
	DEC A
	MOV $03B4+y, A
	JMP CODE_0CF4

CODE_0D1C:
	MOV A, ($00)+y
	MOV $02, A
	INC Y
	MOV A, ($00)+y
	MOV $03, A
	MOV Y, $D4+x
	MOV A, $04
	MOV $0434+y, A
	MOV A, $54+x
	MOV $03B4+y, A
	MOV A, $44+x
	RET

CODE_0D34:
	CALL CODE_0B64
	DEC $D4+x
	MOV Y, $D4+x
	MOV A, $03B4+y
	MOV $54+x, A
	MOV A, $0334+y
	MOV $44+x, A
	MOV A, $0434+y
	DEC A
	MOV $0434+y, A
	BEQ CODE_0D6A
	MOV A, $44+x
	MOV Y, $54+x
	MOVW $00, YA
	MOV Y, #$02
	MOV A, ($00)+y
	MOV $02, A
	INC Y
	MOV A, ($00)+y
	MOV $03, A
	INC $D4+x
	MOVW YA, $02
	MOV $44+x, A
	MOV $54+x, Y
	MOV A, #$01
	RET

CODE_0D6A:
	MOV $00, #$04
	JMP CODE_0B7B

CODE_0D70:
	CALL CODE_0B64
	MOV A, ($00)+y
	MOV $0120+x, A
	MOV A, $01D0+x
	BEQ CODE_0D89
	MOV A, $0120+x
	MOV $0130+x, A
	INC Y
	MOV A, ($00)+y
	MOV $0120+x, A
CODE_0D89:
	INC Y
	MOV $00, Y
	JMP CODE_0B7B

CODE_0D8F:
	POP X
	MOV A, #$00
	MOV $0120+x, A
	MOV $0130+x, A
	JMP CODE_0DDF

CODE_0D9B:
	POP X
	MOV Y, #$04
	MOV A, ($00)+y
	BRA CODE_0DAA

CODE_0DA2:
	POP X
	MOV Y, #$04
	MOV A, ($00)+y
	EOR A, #$FF
	INC A
CODE_0DAA:
	MOV $01B0+x, A
	MOV A, $0150+x
	OR A, #$01
	MOV $0150+x, A
	CALL CODE_0B69
	MOV A, ($00)+y
	MOV $0160+x, A
	INC Y
	MOV A, ($00)+y
	MOV $0170+x, A
	INC Y
	MOV A, ($00)+y
	MOV $0180+x, A
	INC Y
	INC Y
	MOV A, ($00)+y
	MOV $0190+x, A
	MOV $00, #$06
	JMP CODE_0B7B

CODE_0DD6:
	POP X
	MOV A, $0150+x
	AND A, #$FE
	MOV $0150+x, A
CODE_0DDF:
	MOV A, #$01
	MOV $00, A
	MOV $34+x, A
	DEC A
	MOV $24+x, A
	JMP CODE_0B7B

CODE_0DEB:
	POP X
	MOV Y, #$01
	MOV A, ($00)+y
	MOV $1F, A
CODE_0DF2:
	CALL CODE_0B69
	JMP CODE_0B78

CODE_0DF8:
	POP X
	MOV Y, #$01
	MOV A, ($00)+y
	CLRC
	ADC A, $1F
	MOV $1F, A
	JMP CODE_0DF2

CODE_0E05:
	POP X
	MOV A, $0150+x
	AND A, #$FD
	MOV $0150+x, A
	JMP CODE_0DDF

CODE_0E11:
	POP X
	MOV A, #$00
	CALL CODE_0E25
	JMP CODE_0D6A

CODE_0E1A:
	POP X
	MOV Y, #$04
	MOV A, ($00)+y
	CALL CODE_0E25
	JMP CODE_0F76

CODE_0E25:
	MOV $0220+x, A
	MOV A, $0150+x
	OR A, #$02
	MOV $0150+x, A
	CALL CODE_0B69
	MOV A, ($00)+y
	MOV $0200+x, A
	INC Y
	MOV A, ($00)+y
	MOV $0210+x, A
	INC Y
	MOV A, ($00)+y
	MOV $0234+x, A
	RET

CODE_0E45:
	CALL CODE_0B64
	CALL CODE_0E4E
	JMP CODE_0BBC

CODE_0E4E:
	MOV A, ($00)+y
	MOV $0274+x, A
	INC Y
	MOV A, ($00)+y
	MOV $0284+x, A
	RET

CODE_0E5A:
	POP X
	MOV Y, #$01
	MOV A, ($00)+y
	MOV $0C+x, A
	JMP CODE_0E6B

CODE_0E64:
	POP X
	MOV Y, #$01
	MOV A, ($00)+y
	MOV $14+x, A
CODE_0E6B:
	CALL CODE_0B69
	JMP CODE_0B78

CODE_0E71:
	CALL CODE_0B64
	MOV A, ($00)+y
	MOV $64+x, A
	JMP CODE_0B78

CODE_0E7B:
	CALL CODE_0B64
	MOV $24+x, A
	MOV A, ($00)+y
	MOV $0140+x, A
	JMP CODE_0B78

CODE_0E88:
	CALL CODE_0B64
	MOV A, ($00)+y
	CLRC
	ADC A, $0140+x
	MOV $0140+x, A
	JMP CODE_0B78

CODE_0E97:
	POP X
	MOV $F2, #$0D
	MOV Y, #$01
	MOV A, ($00)+y
	MOV $F3, A
	INC Y
	MOV $F2, #$2C
	MOV A, ($00)+y
	MOV $0232, A
	MOV $F3, A
	MOV $F2, #$3C
	INC Y
	MOV A, ($00)+y
	MOV $0233, A
	MOV $F3, A
	MOV A, #$00
	MOV $04B5, A
	MOV $F2, #$6C
	MOV $F3, A
	JMP CODE_0D6A

CODE_0EC4:
	CALL CODE_0B64
	MOV $F2, #$4D
	MOV A, DATA_0F95+x
	OR A, $F3
	MOV $F3, A
	MOV A, #$01
	MOV $0294+x, A
CODE_0ED6:
	MOV $00, #$01
	JMP CODE_0B7B

CODE_0EDC:
	POP X
	MOV $F2, #$4D
	MOV A, DATA_0F95+x
	EOR A, #$FF
	AND A, $F3
	MOV $F3, A
	MOV A, #$00
	MOV $0294+x, A
	MOV $24+x, A
	INC A
	MOV $34+x, A
	JMP CODE_0ED6

CODE_0EF6:
	CALL CODE_0B64
	MOV $F2, #$0F
CODE_0EFC:
	MOV A, ($00)+y
	MOV $F3, A
	INC Y
	CLRC
	ADC $F2, #$10
	CMP $F2, #$8F
	BNE CODE_0EFC
	MOV $00, #$09
	JMP CODE_0B7B

CODE_0F10:
	CALL CODE_0B64
	MOV A, ($00)+y
	MOV $04B4, A
	OR A, $04B5
	MOV $F2, #$6C
	MOV $F3, A
	JMP CODE_0B78

CODE_0F23:
	POP X
	MOV $F2, #$3D
	MOV A, DATA_0F95+x
	OR A, $F3
	MOV $F3, A
CODE_0F2E:
	CALL CODE_0B69
	JMP CODE_0ED6

CODE_0F34:
	POP X
	MOV $F2, #$3D
	MOV A, DATA_0F95+x
	EOR A, #$FF
	AND A, $F3
	MOV $F3, A
	JMP CODE_0F2E

CODE_0F44:
	POP X
	MOV Y, #$04
	MOV A, ($00)+y
	EOR A, #$FF
	INC A
	BRA CODE_0F53

CODE_0F4E:
	POP X
	MOV Y, #$04
	MOV A, ($00)+y
CODE_0F53:
	MOV $01B0+x, A
	MOV A, $0150+x
	OR A, #$01
	MOV $0150+x, A
	CALL CODE_0B69
	MOV A, ($00)+y
	MOV $0160+x, A
	INC Y
	MOV A, ($00)+y
	MOV $0170+x, A
	INC Y
	MOV A, ($00)+y
	MOV $0190+x, A
	ASL A
	MOV $0180+x, A
CODE_0F76:
	MOV $00, #$05
	JMP CODE_0B7B

CODE_0F7C:
	CALL CODE_0B64
	INC A
	MOV $01D0+x, A
	JMP CODE_0ED6

CODE_0F86:
	CALL CODE_0B64
	MOV $01D0+x, A
	JMP CODE_0ED6

CODE_0F8F:
	MOV $00, #$07
	JMP CODE_0B7B

DATA_0F95:
	db $01,$02,$04,$08,$10,$20,$40,$80,$01,$02,$04,$08,$10,$20,$40,$80

DATA_0FA5:
	dw CODE_0B18
	dw CODE_0B72
	dw CODE_0BB6
	dw CODE_0CD7
	dw CODE_0CE6
	dw CODE_0D34
	dw CODE_0D70
	dw CODE_0D8F
	dw CODE_0D9B
	dw CODE_0DA2
	dw CODE_0DD6
	dw CODE_0DEB
	dw CODE_0DF8
	dw CODE_0E11
	dw CODE_0E05
	dw CODE_0E1A
	dw CODE_0E45
	dw $0000
	dw CODE_0E71
	dw CODE_0E7B
	dw CODE_0E88
	dw CODE_0E97
	dw CODE_0EC4
	dw CODE_0EDC
	dw CODE_0EF6
	dw CODE_0F10
	dw CODE_0F23
	dw CODE_0F34
	dw CODE_0E5A
	dw CODE_0E64
	dw CODE_0C83
	dw CODE_0CA0
	dw CODE_0C02
	dw CODE_0CFF
	dw CODE_0B97
	dw CODE_0BF0
	dw CODE_0C4E
	dw $0000
	dw CODE_0F44
	dw CODE_0F4E
	dw $0000
	dw $0000
	dw $0000
	dw CODE_0F7C
	dw CODE_0F86
	dw $0000
	dw $0000
	dw $0000
	dw CODE_0EDC
	dw CODE_0C18
	dw CODE_0EDC

CODE_100B:
	MOV A, #$00
	MOV $EC, A
	MOV $ED, A
	MOV $EE, A
	MOV $EF, A
	MOV $F2, #$6C
	MOV $F3, #$E0
	MOV $F2, #$2C
	MOV $0232, A
	MOV $F3, A
	MOV $F2, #$3C
	MOV $0233, A
	MOV $F3, A
	MOV $F2, #$0D
	MOV $F3, A
	MOV $F2, #$4C
	MOV $F3, A
	MOV $F2, #$5C
	MOV $F3, #$FF
	MOV $F2, #$2D
	MOV $F3, A
	MOV $F2, #$3D
	MOV $F3, A
	MOV $F2, #$4D
	MOV $F3, A
	MOV A, #$3C
	MOV $0230, A
	MOV $0231, A
	MOV $F2, #$0C
	MOV $F3, A
	MOV $F2, #$1C
	MOV $F3, A
	MOV A, #$64
	MOV $04B6, A
	MOV $F2, #$5D
	MOV $F3, #$31
	MOV Y, #$08
	MOV $F2, #$00
CODE_106C:
	MOV A, #$7F
	MOV $F3, A
	INC $F2
	MOV $F3, A
	CLRC
	ADC $F2, #$04
	MOV A, #$00
	MOV $F3, A
	INC $F2
	MOV $F3, A
	INC $F2
	MOV $F3, #$FF
	CLRC
	ADC $F2, #$09
	DEC Y
	BNE CODE_106C
	MOV $E7, #$FF
	MOV $E8, #$FF
	MOV A, #$64
	MOV $E4, A
	MOV A, #$20
	MOV $04B5, A
	MOV $00, #$08
	MOV X, #$00
	MOV Y, #$00
	MOV $0A, Y
	MOV $04B4, Y
	MOV $01, Y
CODE_10A9:
	MOV A, #$01
	MOV $34+x, A
	MOV $0110+x, A
	MOV A, ($E5)+y
	MOV $44+x, A
	INC Y
	MOV A, ($E5)+y
	MOV $54+x, A
	MOV A, $01
	MOV $D4+x, A
	MOV A, #$00
	MOV $01D0+x, A
	MOV $24+x, A
	MOV $0120+x, A
	MOV $0130+x, A
	MOV $0150+x, A
	MOV $0140+x, A
	MOV $64+x, A
	MOV $01E0+x, A
	MOV $0294+x, A
	INC X
	INC Y
	CLRC
	ADC $01, #$08
	DBNZ $00, CODE_10A9
	MOV A, ($E5)+y
	MOV $1F, A
	INC Y
	MOV A, ($E5)+y
	MOV $22, A
	MOV A, #$00
	MOV $1E, A
	MOV $21, A
CODE_10F0:
	MOV $F2, #$6C
	MOV $F3, #$20
	RET

CODE_10F7:
	PUSH A
	CMP A, #$60
	BPL CODE_1104
	SETC
	SBC A, $2410
	BPL CODE_110D
	BRA CODE_1111

CODE_1104:
	SETC
	SBC A, #$60
	SETC
	SBC A, $2E94
	BMI CODE_1111
CODE_110D:
	POP A
	MOV A, #$00
	PUSH A
CODE_1111:
	POP A
	ASL A
	PUSH A
	MOV A, #$01
	MOV $01E0+x, A
	MOV $F2, #$3D
	MOV A, DATA_0F95+x
	EOR A, #$FF
	AND A, $F3
	MOV $F3, A
	MOV A, X
	CLRC
	ADC A, #$08
	MOV X, A
	ASL A
	ASL A
	ASL A
	MOV $D4+x, A
	MOV A, #$01
	MOV $0110+x, A
	DEC A
	MOV $0120+x, A
	MOV $0130+x, A
	MOV $24+x, A
	MOV $01D0+x, A
	MOV $01E0+x, A
	MOV $0150+x, A
	MOV $0140+x, A
	MOV $0294+x, A
	MOV $64+x, A
	MOV A, #$7F
	MOV $0254+x, A
	MOV $0264+x, A
	MOV $0314+x, A
	MOV $0324+x, A
	MOV A, #$8E
	MOV $0274+x, A
	MOV A, #$E0
	MOV $0284+x, A
	POP A
	CMP A, #$C0
	BCS CODE_1179
	MOV Y, A
	MOV A, $2412+y
	MOV $44+x, A
	INC Y
	MOV A, $2412+y
	MOV $54+x, A
	BRA CODE_1188

CODE_1179:
	SETC
	SBC A, #$C0
	MOV Y, A
	MOV A, $2E96+y
	MOV $44+x, A
	INC Y
	MOV A, $2E96+y
	MOV $54+x, A
CODE_1188:
	MOV A, #$02
	MOV $34+x, A
	MOV $F2, #$4D
	MOV A, DATA_0F95+x
	EOR A, #$FF
	AND A, $F3
	MOV $F3, A
	RET

DATA_1199:
	db $00,$00,$40,$00,$44,$00,$48,$00,$4C,$00,$51,$00,$55,$00,$5B,$00
	db $60,$00,$66,$00,$6C,$00,$72,$00,$79,$00,$80,$00,$88,$00,$90,$00
	db $98,$00,$A1,$00,$AB,$00,$B5,$00,$C0,$00,$CB,$00,$D7,$00,$E4,$00
	db $F2,$00,$00,$01,$0F,$01,$1F,$01,$30,$01,$43,$01,$56,$01,$6A,$01
	db $80,$01,$96,$01,$AF,$01,$C8,$01,$E3,$01,$00,$02,$1E,$02,$3F,$02
	db $61,$02,$85,$02,$AB,$02,$D4,$02,$FF,$02,$2D,$03,$5D,$03,$90,$03
	db $C7,$03,$00,$04,$3D,$04,$7D,$04,$C2,$04,$0A,$05,$57,$05,$A8,$05
	db $FE,$05,$5A,$06,$BA,$06,$21,$07,$8D,$07,$00,$08,$7A,$08,$FB,$08
	db $84,$09,$14,$0A,$AE,$0A,$50,$0B,$FD,$0B,$B3,$0C,$74,$0D,$41,$0E
	db $1A,$0F,$00,$10,$F4,$10,$F6,$11,$07,$13,$29,$14,$5C,$15,$A1,$16
	db $F9,$17,$66,$19,$E9,$1A,$82,$1C,$34,$1E,$00,$20,$E7,$21,$EB,$23
	db $0E,$26,$51,$28,$B7,$2A,$41,$2D,$F2,$2F,$CC,$32,$D1,$35,$04,$39
	db $68,$3C,$FF,$3F,$FF

base off
;%SPCDataBlockEnd(0560)
