Engine.asm
Yoshifanatic1_Faceball-2000-Disassembly/FB2000/SPC700/Engine.asm

%SPCDataBlockStart(0700)
SPC700_Engine:
	CLRP
	MOV X, #$FF
	MOV SP, X
	MOV $F2, #$6C
	MOV $F3, X
	MOV $F1, #$B0
	MOV $FA, #$20
	MOV $F1, #$81
	CALL CODE_0DEF
	MOV $0B, #DATA_1800
	MOV $0C, #DATA_1800>>8
	MOV Y, #$03
CODE_071D:
	MOV A, $FFFF+y
	OR A, CODE_0728-$01+y
	MOV $FFFF+y, A
	DBNZ Y, CODE_071D
CODE_0728:
	INC $15
	MOV A, $1B
	BNE CODE_0733
	CALL CODE_1576
	BRA CODE_0736

CODE_0733:
	CALL CODE_0858
CODE_0736:
	MOV A, $F6
	BEQ CODE_073D
	CALL CODE_0B3D
CODE_073D:
	MOV A, $FD
	CLRC
	ADC A, $14
	MOV $14, A
	CMP A, #$05
	BCC CODE_0736
	SBC A, #$05
	MOV $14, A
	CMP A, #$14
	BCC CODE_0728
	MOV $14, #$00
	BRA CODE_0728

CODE_0755:
	MOV Y, #$00
	MOV $F4, #$AA
	MOV $F5, #$BB
CODE_075D:
	MOV X, $F4
	CMP X, #$CC
	BNE CODE_075D
CODE_0763:
	MOV $03, $F6
	MOV $04, $F7
	MOV A, X
	MOV X, $F5
	MOV $F4, A
	BNE CODE_0775
	MOV $F6, X
	JMP ($0003+x)

CODE_0775:
	MOV X, #$00
CODE_0777:
	CMP X, $F4
	BNE CODE_0777
CODE_077B:
	MOV A, $F5
	MOV ($03)+y, A
	MOV X, $F4
	MOV $F4, X
	INCW $03
CODE_0785:
	CMP X, $F4
	BEQ CODE_0785
	INC X
	CMP X, $F4
	BEQ CODE_077B
	MOV X, $F4
	BRA CODE_0763

CODE_0792:
	CALL CODE_0DEF
	MOV $F1, #$B0
	MOV X, #$00
CODE_079A:
	MOV A, CODE_0755+x
	MOV $0100+x, A
	INC X
	CMP X, #$3D
	BCC CODE_079A
	JMP $0100

DATA_07A8:
	db $FF,$D6,$A0,$80,$6B,$50,$40,$36,$28,$20,$1B,$14,$10,$0E,$0B,$08
	db $06,$05,$04,$03,$02,$01

DATA_07BE:
	db $1D,$1C,$1B,$1A,$19,$18,$17,$16,$15,$14,$13,$12,$11,$10,$0F,$0E
	db $0D,$0C,$0A,$09,$06,$00

DATA_07D4:
	db $08,$18,$28,$38,$48,$58,$68,$78

DATA_07DC:
	db $07,$17,$27,$37,$47,$57,$67,$77

DATA_07E4:
	db $04,$14,$24,$34,$44,$54,$64,$74

DATA_07EC:
	db $02,$12,$22,$32,$42,$52,$62,$72

DATA_07F4:
	db $00,$10,$20,$30,$40,$50,$60,$70

DATA_07FC:
	db $01,$02,$04,$08,$10,$20,$40,$80,$FE,$FD,$FB,$F7,$EF,$DF,$BF,$7F

DATA_080C:
	db $7D,$2C,$3C,$0D,$0F,$1F,$2F,$3F,$4F,$5F,$6F,$7F

DATA_0818:
	db $02,$02,$02,$02,$02,$03,$03,$03

DATA_0820:
	db $97,$AC,$C1,$D6,$EB,$00,$15,$2A

DATA_0828:
	db $03,$03,$03,$03,$03,$03,$03,$03

DATA_0830:
	db $3F,$54,$69,$7E,$93,$A8,$BD,$D2

DATA_0838:
	db $03,$03,$04,$04,$04,$04,$04,$04

DATA_0840:
	db $E7,$FC,$11,$26,$3B,$50,$65,$7A

DATA_0848:
	db $04,$04,$04,$04,$04,$04,$05,$05

DATA_0850:
	db $8F,$A5,$BB,$D1,$E7,$FD,$13,$29

CODE_0858:
	CALL CODE_1576
	CALL CODE_1302
	MOV $2F, #$00
	MOV $44, #$00
	MOV $F2, #$7C
	MOV A, $F3
	OR A, $41
	AND A, $47
	MOV $41, A
	MOV $F3, #$00
	AND A, $42
	OR A, $43
	MOV $43, A
	MOV X, #$07
	MOV $0D, #$7A
	MOV $0E, #$04
CODE_0880:
	MOV $0F, X
	MOV A, DATA_07FC+x
	MOV $31, A
	EOR A, #$FF
	MOV $32, A
	MOV A, $53+x
	AND A, #$02
	MOV $30, A
	BNE CODE_0899
	MOV A, $0277+x
	JMP CODE_089E

CODE_0899:
	CALL CODE_0ED3
	MOV X, $0F
CODE_089E:
	CMP A, $027F+x
	BNE CODE_08B3
	CALL CODE_106D
	CALL CODE_0B23
	MOV A, $48
	AND A, $45
	AND A, $31
	BNE CODE_08F4
	BEQ CODE_08F7
CODE_08B3:
	MOV $027F+x, A
	OR $2F, $31
	CALL CODE_106D
	MOV A, X
	ASL A
	MOV X, A
	MOV A, $49
	MOV $0287+x, A
	MOV A, $4A
	MOV $0288+x, A
	MOV X, $0F
	MOV A, $4B
	AND A, #$20
	BEQ CODE_08D6
	AND $42, $32
	BRA CODE_08D9

CODE_08D6:
	OR $42, $31
CODE_08D9:
	MOV A, $4B
	AND A, #$40
	BEQ CODE_08E4
	OR $48, $31
	BRA CODE_08E7

CODE_08E4:
	AND $48, $32
CODE_08E7:
	CALL CODE_0B23
	MOV A, $48
	OR A, $45
	AND A, $31
	BNE CODE_08F4
	BEQ CODE_08F7
CODE_08F4:
	OR $44, $31
CODE_08F7:
	DEC X
	BMI CODE_0904
	SETC
	SBC $0D, #$15
	SBC $0E, #$00
	JMP CODE_0880

CODE_0904:
	MOV A, $45
	AND A, $43
	OR A, $44
	MOV $46, A
	MOV $F2, #$5C
	MOV $F3, A
	MOV X, #$07
	MOV $0D, #$29
	MOV $0E, #$05
	MOV $34, #$00
CODE_091C:
	MOV $0F, X
	MOV A, $52
	BNE CODE_0935
	MOV A, $53+x
	AND A, #$08
	MOV $34, A
	BNE CODE_0930
	MOV A, $026F+x
	JMP CODE_0935

CODE_0930:
	CALL CODE_0ED3
	MOV X, $0F
CODE_0935:
	MOV Y, A
	MOV A, $0267+x
	MOV $29, A
	MUL YA
	MOV X, #$64
	DIV YA, X
	MOV X, $0F
	MOV Y, $34
	BEQ CODE_0956
	MOV $27, A
	MOV Y, #$15
	MOV A, ($0D)+y
	BNE CODE_0951
	MOV A, $27
	BRA CODE_0956

CODE_0951:
	MOV A, $29
	SETC
	SBC A, $27
CODE_0956:
	MOV $27, A
	MOV A, DATA_07F4+x
	MOV Y, A
	MOV $F2, Y
	MOV $F3, $27
	MOV A, $29
	SETC
	SBC A, $27
	INC Y
	MOV $F2, Y
	MOV $F3, A
	SETC
	SBC $0D, #$16
	SBC $0E, #$00
	DEC X
	BMI CODE_0978
	JMP CODE_091C

CODE_0978:
	MOV X, #$07
	MOV $0D, #$D2
	MOV $0E, #$03
CODE_0980:
	MOV $0F, X
	MOV A, $53+x
	MOV Y, A
	AND A, #$40
	PUSH P
	MOV A, Y
	AND A, #$04
	PUSH P
	MOV A, X
	MOV Y, A
	ASL A
	MOV X, A
	MOV A, $0248+x
	MOV $2E, A
	MOV A, $0247+x
	MOV $2D, A
	POP P
	BEQ CODE_09AE
	PUSH X
	CALL CODE_0ED3
	POP X
	ADDW YA, $2D
	SETC
	SBC A, #$B0
	MOV $2D, A
	MOV A, Y
	SBC A, #$04
	MOV $2E, A
CODE_09AE:
	MOV A, $0288+x
	MOV Y, A
	MOV A, $0287+x
	ADDW YA, $2D
	POP P
	BNE CODE_09BD
	CALL CODE_1097
CODE_09BD:
	MOV X, $0F
	MOV $0257+x, A
	MOV A, Y
	MOV $025F+x, A
	SETC
	SBC $0D, #$15
	SBC $0E, #$00
	DEC X
	BPL CODE_0980
	MOV $F2, #$5C
	MOV $F3, #$00
	MOV X, #$07
	MOV $0D, #$2A
	MOV $0E, #$03
CODE_09DE:
	MOV $0F, X
	MOV A, DATA_07FC+x
	MOV $31, A
	EOR A, #$FF
	MOV $32, A
	MOV A, $53+x
	AND A, #$01
	BNE CODE_09F5
	MOV A, $022F+x
	JMP CODE_09FA

CODE_09F5:
	CALL CODE_0ED3
	MOV X, $0F
CODE_09FA:
	MOV $0237+x, A
	MOV Y, A
	MOV A, $2F
	AND A, $31
	BEQ CODE_0A0E
	MOV A, DATA_07E4+x
	MOV $F2, A
	MOV A, $027F+x
	MOV $F3, A
CODE_0A0E:
	MOV A, $40
	AND A, $31
	BEQ CODE_0A19
	AND $40, $32
	BRA CODE_0A50

CODE_0A19:
	MOV A, DATA_07D4+x
	MOV $F2, A
	MOV A, Y
	SETC
	SBC A, $F3
	BCS CODE_0A2D
	MOV $22, #$80
	EOR A, #$FF
	INC A
	JMP CODE_0A30

CODE_0A2D:
	MOV $22, #$C0
CODE_0A30:
	LSR A
	BNE CODE_0A3C
	CMP Y, #$00
	BNE CODE_0A3C
	MOV A, #$82
	JMP CODE_0A4A

CODE_0A3C:
	MOV Y, #$15
CODE_0A3E:
	CMP A, DATA_07A8+y
	BCC CODE_0A45
	DBNZ Y, CODE_0A3E
CODE_0A45:
	MOV A, DATA_07BE+y
	OR A, $22
CODE_0A4A:
	CMP A, $023F+x
	BEQ CODE_0A5B
	MOV Y, A
CODE_0A50:
	MOV A, DATA_07DC+x
	MOV $F2, A
	MOV $F3, Y
	MOV A, Y
	MOV $023F+x, A
CODE_0A5B:
	MOV A, DATA_07EC+x
	MOV $F2, A
	MOV Y, A
	MOV A, $0257+x
	MOV $F3, A
	INC Y
	MOV $F2, Y
	MOV A, $025F+x
	MOV $F3, A
	SETC
	SBC $0D, #$15
	SBC $0E, #$00
	DEC X
	BMI CODE_0A7B
	JMP CODE_09DE

CODE_0A7B:
	MOV $F2, #$4C
	MOV $F3, $46
	MOV A, $46
	EOR A, #$FF
	MOV $47, A
	AND $41, $47
	AND $43, $47
	MOV $45, #$00
	MOV X, #$07
	MOV Y, #$0E
CODE_0A94:
	MOV A, $0206+x
	BEQ CODE_0AC4
	MOV A, $53+x
	AND A, #$80
	BEQ CODE_0AA8
	MOV A, DATA_07FC+x
	AND A, $41
	BNE CODE_0ABF
	BRA CODE_0AC4

CODE_0AA8:
	MOV A, $0217+y
	SETC
	SBC A, #$01
	MOV $0217+y, A
	MOV $27, A
	MOV A, $0218+y
	SBC A, #$00
	MOV $0218+y, A
	OR A, $27
	BNE CODE_0AC4
CODE_0ABF:
	MOV A, #$00
	MOV $0206+x, A
CODE_0AC4:
	DEC Y
	DEC Y
	DEC X
	BPL CODE_0A94
	MOV Y, $0200
	BEQ CODE_0B22
	DEC $0201
	BNE CODE_0B22
	MOV $0201, Y
	MOV A, $16
	MOV X, $0202
	BMI CODE_0AEB
	CLRC
	ADC A, $0203
	BCS CODE_0AE7
	CMP A, #$7F
	BCC CODE_0AFA
CODE_0AE7:
	MOV A, #$7F
	BRA CODE_0AF5

CODE_0AEB:
	SETC
	SBC A, $0203
	BEQ CODE_0AF5
	BCS CODE_0AFA
	MOV A, #$00
CODE_0AF5:
	MOV Y, #$00
	MOV $0200, Y
CODE_0AFA:
	MOV $16, A
	MOV X, A
	MOV $F2, #$2C
	CMP A, $0204
	BCC CODE_0B08
	MOV A, $0204
CODE_0B08:
	MOV $F3, A
	MOV $F2, #$3C
	MOV A, X
	CMP A, $0205
	BCC CODE_0B16
	MOV A, $0204
CODE_0B16:
	MOV $F3, A
	MOV $F2, #$0C
	MOV $F3, X
	MOV $F2, #$1C
	MOV $F3, X
CODE_0B22:
	RET

CODE_0B23:
	MOV A, $4B
	BPL CODE_0B33
	AND A, #$1F
	MOV $F2, #$6C
	MOV $F3, A
	OR $4D, $31
	BRA CODE_0B36

CODE_0B33:
	AND $4D, $32
CODE_0B36:
	MOV $F2, #$3D
	MOV $F3, $4D
	RET

CODE_0B3D:
	MOV $17, A
	MOV $19, $F4
	MOV $1A, $F5
	MOV A, $F7
	MOV $F1, #$B1
	AND A, #$FE
	MOV $18, A
	MOV $F6, $17
	MOV X, A
	CMP X, #$1D
	BCS CODE_0B69
	MOV A, $19
	MOV Y, $1A
	JMP (DATA_1794+x)

CODE_0B5D:
	MOV $1B, #$FF
	CALL CODE_0E39
	MOV $F2, #$6C
	MOV $F3, #$00
CODE_0B69:
	RET

CODE_0B6A:
	MOVW $3A, YA
	MOV $39, #$FF
	RET

CODE_0B70:
	MOV $52, A
	RET

CODE_0B73:
	MOV A, #$00
	MOV $0200, A
	RET

CODE_0B79:
	MOV X, #$01
	BRA CODE_0B7F

CODE_0B7D:
	MOV X, #$FF
CODE_0B7F:
	MOV $0200, A
	MOV $0201, A
	MOV $0203, Y
	MOV $0202, X
	RET

CODE_0B8C:
	MOV $5C, #$00
	CMP A, #$00
	BNE CODE_0B96
	MOV $054F, A
CODE_0B96:
	RET

CODE_0B97:
	MOV $0216, A
	MOV X, #$07
CODE_0B9C:
	CMP Y, #$80
	BEQ CODE_0BB7
	MOV A, #$01
	BCS CODE_0BB2
	CMP Y, #$00
	BNE CODE_0BB0
	MOV A, $0216
	CMP A, $020E+x
	BNE CODE_0BD2
CODE_0BB0:
	MOV A, #$80
CODE_0BB2:
	CMP A, $0206+x
	BNE CODE_0BD2
CODE_0BB7:
	MOV A, DATA_07DC+x
	MOV $F2, A
	MOV A, #$00
	MOV $F3, A
	MOV $022F+x, A
	MOV $0206+x, A
	MOV $0277+x, A
	MOV $53+x, A
	MOV A, DATA_07FC+x
	OR A, $45
	MOV $45, A
CODE_0BD2:
	DEC X
	BPL CODE_0B9C
	RET

CODE_0BD6:
	MOV Y, #$0E
	MOV $0216, A
	CALL CODE_0DB3
	MOVW $09, YA
	MOV Y, #$00
	MOV A, ($09)+y
	MOV $3C, A
	INCW $09
CODE_0BE8:
	MOV Y, #$07
	MOV A, ($09)+y
	MOV $3D, A
	MOV Y, #$06
	MOV A, ($09)+y
	MOV $3E, A
	MOV $3F, #$80
	MOV X, #$07
	CALL CODE_0C44
	BMI CODE_0C34
	MOV A, #$80
	MOV $0206+x, A
	MOV A, $0216
	MOV $020E+x, A
	MOV Y, #$02
	MOV A, ($09)+y
	MOV $35, A
	INC Y
	MOV A, ($09)+y
	MOV $36, A
	MOV Y, #$04
	MOV A, ($09)+y
	MOV $37, A
	INC Y
	MOV A, ($09)+y
	MOV $38, A
	MOV A, $39
	BEQ CODE_0C27
	MOVW YA, $3A
	MOVW $37, YA
CODE_0C27:
	MOV Y, #$01
	MOV A, ($09)+y
	PUSH A
	MOV Y, #$00
	MOV A, ($09)+y
	POP Y
	CALL CODE_0C6E
CODE_0C34:
	CLRC
	ADC $09, #$08
	BCC CODE_0C3C
	INC $0A
CODE_0C3C:
	DEC $3C
	BNE CODE_0BE8
	MOV $39, #$00
	RET

CODE_0C44:
	MOV Y, #$07
CODE_0C46:
	MOV A, $3F
	AND A, $3D
	BEQ CODE_0C58
	MOV A, $0206+x
	BEQ CODE_0C66
	MOV A, $3E
	CMP A, $0227+x
	BCS CODE_0C68
CODE_0C58:
	LSR $3F
	BNE CODE_0C61
	MOV $3F, #$80
	MOV X, #$08
CODE_0C61:
	DEC X
	DEC Y
	BPL CODE_0C46
	RET

CODE_0C66:
	MOV A, $3E
CODE_0C68:
	MOV $0227+x, A
	MOV A, #$00
	RET

CODE_0C6E:
	MOV $33, X
	PUSH A
	MOV A, Y
	MOV $0267+x, A
	MOV A, X
	ASL A
	MOV X, A
	MOV A, $37
	MOV $0247+x, A
	MOV A, $38
	MOV $0248+x, A
	MOV A, $35
	MOV $0217+x, A
	MOV A, $36
	MOV $0218+x, A
	POP A
	MOV Y, #$02
	CALL CODE_0DB3
	MOVW $07, YA
	MOV X, $33
	MOV A, DATA_07FC+x
	MOV $4E, A
	EOR A, #$FF
	MOV $4F, A
	MOV Y, #$00
	MOV A, ($07)+y
	MOV $53+x, A
	MOV $34, A
	AND A, #$20
	BEQ CODE_0CB0
	OR $50, $4E
	BRA CODE_0CB3

CODE_0CB0:
	AND $50, $4F
CODE_0CB3:
	MOV $F2, #$2D
	MOV $F3, $50
	MOV A, $34
	AND A, #$10
	BEQ CODE_0CEE
	MOV Y, #$05
	MOV A, ($07)+y
	MOV Y, #$0C
	CALL CODE_0DB3
	MOV Y, #$00
CODE_0CCA:
	MOV A, DATA_080C+y
	MOV $F2, A
	MOV A, ($10)+y
	CMP Y, #$01
	BEQ CODE_0CD9
	CMP Y, #$02
	BNE CODE_0CE2
CODE_0CD9:
	MOV $0203+y, A
	CMP A, $16
	BCC CODE_0CE2
	MOV A, $16
CODE_0CE2:
	MOV $F3, A
	INC Y
	CMP Y, #$0C
	BCC CODE_0CCA
	OR $51, $4E
	BRA CODE_0CF1

CODE_0CEE:
	AND $51, $4F
CODE_0CF1:
	MOV $F2, #$4D
	MOV $F3, $51
	MOV A, $34
	AND A, #$01
	PUSH P
	MOV Y, #$01
	MOV A, ($07)+y
	POP P
	BNE CODE_0D0B
	MOV X, $33
	MOV $022F+x, A
	JMP CODE_0D21

CODE_0D0B:
	MOV Y, #$04
	CALL CODE_0DB3
	MOV X, $33
	MOV A, DATA_0820+x
	MOV $0D, A
	MOV A, DATA_0818+x
	MOV $0E, A
	MOVW YA, $35
	CALL CODE_0E5C
CODE_0D21:
	MOV A, $34
	AND A, #$04
	BEQ CODE_0D41
	MOV Y, #$03
	MOV A, ($07)+y
	MOV Y, #$06
	CALL CODE_0DB3
	MOV X, $33
	MOV A, DATA_0830+x
	MOV $0D, A
	MOV A, DATA_0828+x
	MOV $0E, A
	MOVW YA, $35
	CALL CODE_0E5C
CODE_0D41:
	MOV A, $34
	AND A, #$08
	PUSH P
	MOV Y, #$04
	MOV A, ($07)+y
	POP P
	BNE CODE_0D55
	MOV X, $33
	MOV $026F+x, A
	JMP CODE_0D82

CODE_0D55:
	MOV Y, #$08
	CALL CODE_0DB3
	MOV X, $33
	MOV A, DATA_0850+x
	MOV $0D, A
	MOV A, DATA_0848+x
	MOV $0E, A
	MOVW YA, $35
	CALL CODE_0E5C
	MOV Y, #$07
	MOV A, ($0D)+y
	BEQ CODE_0D7C
	MOV Y, #$15
	MOV A, ($0D)+y
	BNE CODE_0D7C
	MOV A, #$FF
	JMP CODE_0D7E

CODE_0D7C:
	MOV A, #$00
CODE_0D7E:
	MOV Y, #$15
	MOV ($0D)+y, A
CODE_0D82:
	MOV A, $34
	AND A, #$02
	PUSH P
	MOV Y, #$02
	MOV A, ($07)+y
	POP P
	BNE CODE_0D96
	MOV X, $33
	MOV $0277+x, A
	JMP CODE_0DAC

CODE_0D96:
	MOV Y, #$0A
	CALL CODE_0DB3
	MOV X, $33
	MOV A, DATA_0840+x
	MOV $0D, A
	MOV A, DATA_0838+x
	MOV $0E, A
	MOVW YA, $35
	CALL CODE_0E5C
CODE_0DAC:
	OR $45, $4E
	OR $40, $4E
	RET

CODE_0DB3:
	MOV $06, #$00
	ASL A
	ROL $06
	CLRC
	ADC A, $17E0+y
	MOV $05, A
	MOV A, $06
	ADC A, $17E0+$01+y
	MOV $06, A
	MOV Y, #$01
	MOV A, ($05)+y
	MOV $11, A
	DEC Y
	MOV A, ($05)+y
	MOV $10, A
	MOV Y, $11
	RET

DATA_0DD4:
	db $6C,$FF,$3D,$00,$4D,$00,$7D,$00,$6D,$FF,$5D,$18,$5C,$00,$2D,$00
	db $7C,$00,$2C,$00,$3C,$00,$0C,$7F,$1C,$7F,$FF

CODE_0DEF:
	MOV Y, #$00
CODE_0DF1:
	MOV A, DATA_0DD4+y
	CMP A, #$FF
	BEQ CODE_0E03
	MOV $F2, A
	INC Y
	MOV A, DATA_0DD4+y
	MOV $F3, A
	INC Y
	BNE CODE_0DF1
CODE_0E03:
	MOV X, #$70
CODE_0E05:
	MOV A, #$00
	MOV $04+x, A
	MOV $07+x, A
	MOV $03+x, A
	MOV $02+x, A
	MOV A, #$00
	MOV $05+x, A
	MOV A, X
	SETC
	SBC A, #$10
	MOV X, A
	BPL CODE_0E05
	MOV A, #$02
	MOV X, #$07
	CALL CODE_0E43
	MOV Y, A
CODE_0E22:
	MOV $0000+y, A
	INC Y
	CMP Y, #$F0
	BCC CODE_0E22
	DEC A
	MOV $41, A
	MOV $43, A
	MOV $48, A
	MOV $42, A
	MOV $47, A
	MOV $16, #$7F
	RET

CODE_0E39:
	MOV A, $17E0+$01
	MOV $F2, #$6D
	MOV $F3, A
	MOV X, #$00
CODE_0E43:
	MOV CODE_0E4B+$02, A
	MOV A, #$00
	MOV CODE_0E4B+$01, A
CODE_0E4B:
	MOV $0200, A
	INC CODE_0E4B+$01
	BNE CODE_0E4B
	INC CODE_0E4B+$02
	CMP X, CODE_0E4B+$02
	BNE CODE_0E4B
	RET

CODE_0E5C:
	MOVW $27, YA
	MOV Y, #$07
CODE_0E60:
	MOV A, ($10)+y
	MOV ($0D)+y, A
	DEC Y
	BPL CODE_0E60
	MOV A, $10
	CLRC
	ADC A, #$08
	MOV Y, #$08
	MOV ($0D)+y, A
	MOV A, $11
	ADC A, #$00
	INC Y
	MOV ($0D)+y, A
	MOV Y, #$03
	MOV A, ($0D)+y
	MOV X, A
	MOV Y, #$02
	MOV A, ($0D)+y
	MOV Y, A
	MOV A, X
	MUL YA
	MOVW $2B, YA
	MOVW YA, $27
	SUBW YA, $2B
	BCS CODE_0E8E
	MOV A, #$00
	MOV Y, A
CODE_0E8E:
	MOV $2C, Y
	MOV Y, #$0D
	MOV ($0D)+y, A
	INC Y
	MOV A, $2C
	MOV ($0D)+y, A
	MOV Y, #$03
	MOV A, ($0D)+y
	INC A
	MOV Y, #$0F
	MOV ($0D)+y, A
	CMP A, #$03
	BCS CODE_0EAC
	MOV Y, #$04
	MOV A, #$00
	MOV ($0D)+y, A
CODE_0EAC:
	MOV Y, #$08
	MOV A, ($0D)+y
	MOV Y, #$0A
	MOV ($0D)+y, A
	MOV Y, #$09
	MOV A, ($0D)+y
	MOV Y, #$0B
	MOV ($0D)+y, A
	MOV A, #$01
	MOV Y, #$14
	MOV ($0D)+y, A
	DEC A
	MOV Y, #$0C
	MOV ($0D)+y, A
	MOV Y, #$12
	MOV ($0D)+y, A
	INC Y
	MOV ($0D)+y, A
	MOV $20, A
	JMP CODE_0F81

CODE_0ED3:
	MOV Y, #$14
	MOV A, ($0D)+y
	BEQ CODE_0F12
	MOV Y, #$04
	MOV A, ($0D)+y
	MOV $20, A
	MOV Y, #$0F
	MOV A, ($0D)+y
	MOV $21, A
	BEQ CODE_0EEA
	DEC A
	BNE CODE_0EF0
CODE_0EEA:
	MOV Y, #$03
	MOV A, ($0D)+y
	MOV Y, #$0F
CODE_0EF0:
	MOV ($0D)+y, A
	CMP $21, #$02
	BCC CODE_0EFA
	JMP CODE_0F81

CODE_0EFA:
	MOV Y, #$0C
	MOV A, ($0D)+y
	INC A
	MOV Y, #$05
	CMP A, ($0D)+y
	BCC CODE_0F1C
	DEC A
	MOV Y, #$01
	CMP A, ($0D)+y
	BEQ CODE_0F76
	MOV A, #$00
	MOV Y, #$14
	MOV ($0D)+y, A
CODE_0F12:
	MOV Y, #$11
	MOV A, ($0D)+y
	PUSH A
	DEC Y
	MOV A, ($0D)+y
	POP Y
	RET

CODE_0F1C:
	MOV Y, #$0C
	MOV ($0D)+y, A
	MOV Y, #$06
	MOV A, ($0D)+y
	MOV Y, #$0A
	CLRC
	ADC A, ($0D)+y
	MOV ($0D)+y, A
	BCC CODE_0F34
	INC Y
	MOV A, ($0D)+y
	ADC A, #$00
	MOV ($0D)+y, A
CODE_0F34:
	MOV Y, #$0E
	MOV A, ($0D)+y
	MOV X, A
	DEC Y
	MOV A, ($0D)+y
	BNE CODE_0F42
	CMP X, #$00
	BEQ CODE_0F81
CODE_0F42:
	MOV Y, #$03
	SETC
	SBC A, ($0D)+y
	MOV Y, #$0D
	MOV ($0D)+y, A
	MOV $2B, A
	MOV A, X
	SBC A, #$00
	BCS CODE_0F58
	MOV A, #$00
	MOV ($0D)+y, A
	MOV $2B, A
CODE_0F58:
	INC Y
	MOV ($0D)+y, A
	OR A, $2B
	BNE CODE_0F6A
	MOV Y, #$01
	MOV A, ($0D)+y
	CMP A, #$FF
	BEQ CODE_0F6A
	JMP CODE_0F7A

CODE_0F6A:
	MOV Y, #$0C
	MOV A, ($0D)+y
	MOV Y, #$01
	CMP A, ($0D)+y
	BCC CODE_0F81
	BEQ CODE_0F81
CODE_0F76:
	MOV Y, #$00
	MOV A, ($0D)+y
CODE_0F7A:
	MOV Y, #$0C
	MOV ($0D)+y, A
	CALL CODE_1024
CODE_0F81:
	MOV X, $20
	BEQ CODE_0F99
	CMP $21, #$03
	BCC CODE_0F99
	MOV Y, #$13
	MOV X, #$03
CODE_0F8E:
	MOV A, ($0D)+y
	MOV $1C+x, A
	DEC Y
	DEC X
	BPL CODE_0F8E
	JMP CODE_1001

CODE_0F99:
	CALL CODE_1013
	MOV Y, #$06
	MOV A, ($0D)+y
	MOV X, A
	MOV Y, #$00
	MOV A, ($12)+y
	CMP X, #$01
	BEQ CODE_0FAF
	MOV X, A
	INC Y
	MOV A, ($12)+y
	MOV Y, A
	MOV A, X
CODE_0FAF:
	MOV X, $20
	BEQ CODE_1005
	CMP $21, #$02
	BEQ CODE_1005
	MOVW $27, YA
	MOV Y, #$11
	MOV A, ($0D)+y
	MOV $1D, A
	DEC Y
	MOV A, ($0D)+y
	MOV $1C, A
	MOV Y, $1D
	SETC
	SUBW YA, $27
	MOVW $1E, YA
	MOV A, #$00
	ROL A
	MOV $27, A
	BNE CODE_0FDB
	EOR $1E, #$FF
	EOR $1F, #$FF
	INCW $1E
CODE_0FDB:
	MOV Y, #$03
	MOV A, ($0D)+y
	MOV X, A
	MOVW YA, $1E
	CALL CODE_103F
	MOV $1E, A
	MOV $1F, X
	CMP $27, #$01
	BNE CODE_0FF6
	EOR $1E, #$FF
	EOR $1F, #$FF
	INCW $1E
CODE_0FF6:
	MOV Y, #$12
	MOV A, $1E
	MOV ($0D)+y, A
	INC Y
	MOV A, $1F
	MOV ($0D)+y, A
CODE_1001:
	MOVW YA, $1C
	ADDW YA, $1E
CODE_1005:
	MOVW $1C, YA
	MOV Y, #$10
	MOV ($0D)+y, A
	MOV A, $1D
	INC Y
	MOV ($0D)+y, A
	MOVW YA, $1C
	RET

CODE_1013:
	MOV Y, #$0A
	JMP CODE_101A

CODE_1018:
	MOV Y, #$08
CODE_101A:
	MOV A, ($0D)+y
	MOV $12, A
	INC Y
	MOV A, ($0D)+y
	MOV $13, A
	RET

CODE_1024:
	PUSH A
	CALL CODE_1018
	MOV Y, #$06
	MOV A, ($0D)+y
	MOV Y, A
	POP A
	MUL YA
	ADDW YA, $12
	MOVW $12, YA
	MOV Y, #$0A
	MOV A, $12
	MOV ($0D)+y, A
	INC Y
	MOV A, $13
	MOV ($0D)+y, A
	RET

CODE_103F:
	CMP X, #$00
	BNE CODE_1048
	MOV A, #$FF
	MOV Y, A
	MOV X, A
	RET

CODE_1048:
	MOV $24, Y
	CMP X, $24
	BEQ CODE_1050
	BCS CODE_1069
CODE_1050:
	MOV $23, A
	MOV A, Y
	MOV Y, #$00
	DIV YA, X
	MOV $25, A
	MOV Y, A
	MOV A, X
	MUL YA
	MOV $26, A
	MOV A, $24
	SETC
	SBC A, $26
	MOV Y, A
	MOV A, $23
	DIV YA, X
	MOV X, $25
	RET

CODE_1069:
	DIV YA, X
	MOV X, #$00
	RET

CODE_106D:
	MOV A, $027F+x
	MOV Y, #$04
	MUL YA
	ADDW YA, $0B
	MOVW $03, YA
	MOV Y, #$01
	MOV A, ($03)+y
	MOV $2A, A
	DEC Y
	MOV A, ($03)+y
	SETC
	SBC A, #$03
	MOV $29, A
	SBC $2A, #$00
	MOV A, ($29)+y
	MOV $49, A
	INC Y
	MOV A, ($29)+y
	MOV $4A, A
	INC Y
	MOV A, ($29)+y
	MOV $4B, A
	RET

CODE_1097:
	CMP Y, #$04
	BCC CODE_10A1
	BNE CODE_10A7
	CMP A, #$B0
	BCS CODE_10A7
CODE_10A1:
	MOV $4C, #$FF
	JMP CODE_10BD

CODE_10A7:
	CMP Y, #$80
	BCC CODE_10BA
CODE_10AA:
	MOV $4C, #$00
	CLRC
	ADC A, #$20
	MOV X, A
	MOV A, Y
	ADC A, #$DF
	MOV Y, A
	MOV A, X
	JMP CODE_10BD

CODE_10BA:
	MOV $4C, #$04
CODE_10BD:
	MOV X, #$F0
	DIV YA, X
	CMP $4C, #$FF
	BNE CODE_10C7
	MOV $4C, A
CODE_10C7:
	MOV A, DATA_10E2+y
	MOV $27, A
	MOV A, DATA_11D2+y
	MOV $28, A
	MOV A, #$04
	SETC
	SBC A, $4C
	BEQ CODE_10DF
	MOV Y, A
CODE_10D9:
	LSR $28
	ROR $27
	DBNZ Y, CODE_10D9
CODE_10DF:
	MOVW YA, $27
	RET

DATA_10E2:
	db $00,$18,$2F,$47,$5F,$77,$8F,$A7,$BF,$D8,$F0,$08,$21,$39,$52,$6B
	db $83,$9C,$B5,$CE,$E7,$00,$19,$33,$4C,$65,$7F,$98,$B2,$CC,$E5,$FF
	db $19,$33,$4D,$67,$82,$9C,$B6,$D1,$EB,$06,$20,$3B,$56,$71,$8C,$A7
	db $C2,$DD,$F9,$14,$2F,$4B,$67,$82,$9E,$BA,$D6,$F2,$0E,$2A,$46,$63
	db $7F,$9C,$B8,$D5,$F2,$0F,$2B,$48,$66,$83,$A0,$BD,$DB,$F8,$16,$34
	db $51,$6F,$8D,$AB,$C9,$E7,$06,$24,$43,$61,$80,$9E,$BD,$DC,$FB,$1A
	db $39,$59,$78,$97,$B7,$D7,$F6,$16,$36,$56,$76,$96,$B7,$D7,$F7,$18
	db $39,$59,$7A,$9B,$BC,$DD,$FF,$20,$41,$63,$84,$A6,$C8,$EA,$0C,$2E
	db $50,$72,$95,$B7,$DA,$FC,$1F,$42,$65,$88,$AB,$CF,$F2,$16,$39,$5D
	db $81,$A5,$C9,$ED,$11,$35,$5A,$7E,$A3,$C8,$ED,$12,$37,$5C,$81,$A6
	db $CC,$F2,$17,$3D,$63,$89,$AF,$D6,$FC,$22,$49,$70,$97,$BE,$E5,$0C
	db $33,$5A,$82,$AA,$D1,$F9,$21,$49,$71,$9A,$C2,$EB,$13,$3C,$65,$8E
	db $B7,$E0,$0A,$33,$5D,$87,$B0,$DA,$04,$2F,$59,$84,$AE,$D9,$04,$2F
	db $5A,$85,$B0,$DC,$07,$33,$5F,$8B,$B7,$E3,$0F,$3C,$68,$95,$C2,$EF
	db $1C,$49,$77,$A4,$D2,$00,$2E,$5C,$8A,$B8,$E7,$15,$44,$73,$A2,$D1

DATA_11D2:
	db $20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$21,$21,$21,$21,$21
	db $21,$21,$21,$21,$21,$22,$22,$22,$22,$22,$22,$22,$22,$22,$22,$22
	db $23,$23,$23,$23,$23,$23,$23,$23,$23,$24,$24,$24,$24,$24,$24,$24
	db $24,$24,$24,$25,$25,$25,$25,$25,$25,$25,$25,$25,$26,$26,$26,$26
	db $26,$26,$26,$26,$26,$27,$27,$27,$27,$27,$27,$27,$27,$27,$28,$28
	db $28,$28,$28,$28,$28,$28,$29,$29,$29,$29,$29,$29,$29,$29,$29,$2A
	db $2A,$2A,$2A,$2A,$2A,$2A,$2A,$2B,$2B,$2B,$2B,$2B,$2B,$2B,$2B,$2C
	db $2C,$2C,$2C,$2C,$2C,$2C,$2C,$2D,$2D,$2D,$2D,$2D,$2D,$2D,$2E,$2E
	db $2E,$2E,$2E,$2E,$2E,$2E,$2F,$2F,$2F,$2F,$2F,$2F,$2F,$30,$30,$30
	db $30,$30,$30,$30,$31,$31,$31,$31,$31,$31,$31,$32,$32,$32,$32,$32
	db $32,$32,$33,$33,$33,$33,$33,$33,$33,$34,$34,$34,$34,$34,$34,$35
	db $35,$35,$35,$35,$35,$35,$36,$36,$36,$36,$36,$36,$37,$37,$37,$37
	db $37,$37,$38,$38,$38,$38,$38,$38,$39,$39,$39,$39,$39,$39,$3A,$3A
	db $3A,$3A,$3A,$3A,$3B,$3B,$3B,$3B,$3B,$3B,$3C,$3C,$3C,$3C,$3C,$3C
	db $3D,$3D,$3D,$3D,$3D,$3E,$3E,$3E,$3E,$3E,$3E,$3F,$3F,$3F,$3F,$3F

DATA_12C2:
	db $30,$20,$AC,$10,$24,$38,$4C,$60,$74,$88,$9C,$B0,$C4,$D8,$EC,$00
	db $14,$28,$3C,$50,$64,$78,$8C,$A0,$B4,$C8,$DC,$F0,$54,$E0,$D0,$C0

DATA_12E2:
	db $FD,$FE,$FE,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$00
	db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$01,$01,$02,$03

CODE_1302:
	MOV A, $5C
	BNE CODE_1315
	MOV A, $054F
	BEQ CODE_132D
	MOV A, #$00
	MOV $054F, A
	CALL CODE_16FA
	BRA CODE_1302

CODE_1315:
	MOV A, $5B
	DEC A
	MOV $5D, A
	ASL A
	MOV $5E, A
CODE_131D:
	MOV X, $5D
	MOV A, $61+x
	MOV X, A
	JMP (DATA_1788+x)

CODE_1325:
	DEC $5E
	DEC $5E
	DEC $5D
	BPL CODE_131D
CODE_132D:
	RET

CODE_132E:
	MOV X, $5D
	DEC $9B+x
	BNE CODE_1325
	MOV A, $0560+x
	MOV $9B+x, A
	DEC $A3+x
	BNE CODE_1325
	MOV A, $61+x
	CMP A, #$02
	BNE CODE_134A
	MOV A, #$06
	MOV $61+x, A
	JMP CODE_135B

CODE_134A:
	MOV A, #$08
	MOV $61+x, A
	JMP CODE_1549

CODE_1351:
	CALL CODE_14B0
	MOV $CE+x, A
	CALL CODE_14B0
	MOV $CF+x, A
CODE_135B:
	CALL CODE_14B0
	MOV Y, A
	AND A, #$20
	MOV $5F, A
	MOV A, Y
	AND A, #$40
	MOV $60, A
	MOV X, $5D
	MOV $0588+x, A
	CMP Y, #$80
	BCC CODE_13AE
	CMP Y, #$F0
	BCC CODE_137D
	MOV A, Y
	AND A, #$0F
	ASL A
	MOV X, A
	JMP (DATA_152C+x)

CODE_137D:
	MOV A, $0590+x
	BEQ CODE_13CE
	MOV A, Y
	AND A, #$08
	PUSH P
	MOV A, Y
	AND A, #$07
	INC A
	ASL A
	MOV X, $5E
	POP P
	BEQ CODE_139D
	CLRC
	ADC A, $DE+x
	MOV $DE+x, A
	MOV A, $DF+x
	ADC A, #$00
	MOV $DF+x, A
	BRA CODE_13CE

CODE_139D:
	MOV $27, A
	MOV A, $DE+x
	SETC
	SBC A, $27
	MOV $DE+x, A
	MOV A, $DF+x
	SBC A, #$00
	MOV $DF+x, A
	BRA CODE_13CE

CODE_13AE:
	MOV A, $0590+x
	BEQ CODE_13CE
	MOV A, Y
	AND A, #$1F
	MOV Y, A
	MOV X, $5E
	MOV A, $CE+x
	CLRC
	ADC A, DATA_12C2+y
	MOV $CE+x, A
	MOV A, $CF+x
	ADC A, DATA_12E2+y
	MOV $CF+x, A
	MOV A, #$00
	MOV $DE+x, A
	MOV $DF+x, A
CODE_13CE:
	CALL CODE_14B0
	CMP A, #$00
	BNE CODE_13E7
	MOV X, $5D
	MOV A, $61+x
	CMP A, #$08
	BNE CODE_13E4
	MOV A, #$0A
	MOV $61+x, A
	JMP CODE_1587

CODE_13E4:
	JMP CODE_131D

CODE_13E7:
	MOV X, $5D
	MOV $A3+x, A
	MOV Y, A
	MOV A, $0560+x
	MOV $9B+x, A
	MUL YA
	MOVW $35, YA
	CALL CODE_1508
	MOV A, $0598+x
	BMI CODE_1414
	MOV X, A
	MOV A, $0206+x
	BEQ CODE_140C
	MOV A, #$40
	CMP A, $0227+x
	BCS CODE_140E
	JMP CODE_1325

CODE_140C:
	MOV A, #$40
CODE_140E:
	MOV $0227+x, A
	JMP CODE_1435

CODE_1414:
	MOV A, $05A0+x
	MOV $3D, A
	MOV A, $05A8+x
	BMI CODE_1422
	MOV Y, $5F
	BEQ CODE_1427
CODE_1422:
	DEC A
	BPL CODE_1427
	MOV A, #$07
CODE_1427:
	MOV X, A
	MOV A, DATA_07FC+x
	MOV $3F, A
	MOV $3E, #$40
	CALL CODE_0C44
	BMI CODE_14AD
CODE_1435:
	MOV A, #$01
	MOV $0206+x, A
	MOV $AB, X
	MOV A, X
	MOV X, $5D
	MOV $05A8+x, A
	MOV A, $0590+x
	BNE CODE_1453
	MOV X, $5E
	MOV A, $CE+x
	MOV $37, A
	MOV A, $CF+x
	MOV $38, A
	BRA CODE_1478

CODE_1453:
	MOV X, $5E
	MOV A, $CE+x
	CLRC
	ADC A, $BE+x
	MOV Y, A
	MOV A, $CF+x
	ADC A, $BF+x
	MOV $38, A
	MOV A, Y
	CLRC
	ADC A, $AE+x
	MOV Y, A
	MOV A, $38
	ADC A, $AF+x
	MOV $38, A
	MOV A, Y
	CLRC
	ADC A, $DE+x
	MOV $37, A
	MOV A, $38
	ADC A, $DF+x
	MOV $38, A
CODE_1478:
	MOV Y, $5F
	BNE CODE_148B
	ASL $AB
	MOV X, $AB
	MOV $0248+x, A
	MOV A, $37
	MOV $0247+x, A
	JMP CODE_1325

CODE_148B:
	MOV X, $5D
	MOV A, $0568+x
	CLRC
	ADC A, $0570+x
	BPL CODE_1498
	MOV A, #$7F
CODE_1498:
	MOV $AC, A
	MOV A, $60
	BEQ CODE_14A0
	MOV A, #$08
CODE_14A0:
	OR A, $5D
	MOV X, A
	MOV A, $0578+x
	MOV X, $AB
	MOV Y, $AC
	CALL CODE_0C6E
CODE_14AD:
	JMP CODE_1325

CODE_14B0:
	MOV X, $5E
	MOV A, ($8B+x)
	INC $8B+x
	BNE CODE_14BA
	INC $8C+x
CODE_14BA:
	RET

CODE_14BB:
	MOV X, $5D
	MOV A, #$0A
	MOV $61+x, A
	JMP CODE_1587

CODE_14C4:
	CALL CODE_14B0
	MOV $AD, A
	MOV X, $5D
	MOV A, $0570+x
	CALL CODE_1518
	MOV $0570+x, A
	JMP CODE_135B

CODE_14D7:
	CALL CODE_14B0
	MOV X, $5D
	MOV $0570+x, A
	JMP CODE_135B

CODE_14E2:
	MOV X, $5D
	MOV A, $05A8+x
	BMI CODE_14F6
	MOV Y, A
	MOV A, $0206+y
	CMP A, #$80
	BEQ CODE_14F6
	MOV A, #$00
	MOV $0267+y, A
CODE_14F6:
	CALL CODE_14B0
	MOV X, $5D
	MOV $A3+x, A
	MOV A, $0560+x
	MOV $9B+x, A
	CALL CODE_1508
	JMP CODE_1325

CODE_1508:
	MOV A, $61+x
	CMP A, #$06
	BNE CODE_1513
	MOV A, #$02
	JMP CODE_1515

CODE_1513:
	MOV A, #$04
CODE_1515:
	MOV $61+x, A
	RET

CODE_1518:
	CMP $AD, #$80
	BCC CODE_1525
	CLRC
	ADC A, $AD
	BPL CODE_152B
	MOV A, #$00
	RET

CODE_1525:
	ADC A, $AD
	BPL CODE_152B
	MOV A, #$7F
CODE_152B:
	RET

DATA_152C:
	dw CODE_14BB
	dw CODE_14C4
	dw CODE_14D7
	dw CODE_14E2
	dw CODE_14F6

CODE_1536:
	CALL CODE_14B0
	MOV X, $5D
	MOV $05B0+x, A
	MOV A, #$00
	MOV $DE+x, A
	MOV $DF+x, A
	MOV X, $5D
	MOV $0588+x, A
CODE_1549:
	MOV X, $5D
	MOV A, $0590+x
	BEQ CODE_1569
	MOV A, $05B0+x
	MOV Y, #$12
	CALL CODE_0DB3
	CALL CODE_1576
	AND A, #$0E
	MOV Y, A
	MOV X, $5E
	MOV A, ($10)+y
	MOV $CE+x, A
	INC Y
	MOV A, ($10)+y
	MOV $CF+x, A
CODE_1569:
	MOV $5F, #$20
	MOV X, $5D
	MOV A, $0588+x
	MOV $60, A
	JMP CODE_13CE

CODE_1576:
	MOV A, $00
	ASL A
	EOR A, $00
	ASL A
	ASL A
	ASL A
	ROL $02
	ROL $01
	ROL $00
	MOV A, $02
	RET

CODE_1587:
	CALL CODE_158E
	MOV X, A
	JMP (DATA_165F+x)

CODE_158E:
	MOV X, $5E
CODE_1590:
	MOV A, ($7B+x)
	INC $7B+x
	BNE CODE_1598
	INC $7C+x
CODE_1598:
	RET

CODE_1599:
	MOV X, $5D
	MOV A, #$0C
	MOV $61+x, A
	JMP CODE_1677

CODE_15A2:
	MOV Y, #$00
	MOV X, $5E
CODE_15A6:
	CALL CODE_1590
	CMP Y, #$10
	BCS CODE_15B1
	MOV $053F+y, A
	INC Y
CODE_15B1:
	CALL CODE_1590
	CMP A, #$14
	BEQ CODE_15A6
	CMP A, #$16
	BNE CODE_1599
	MOV A, Y
	MOV X, A
	CALL CODE_1576
	MOV Y, #$00
	DIV YA, X
	MOV A, $053F+y
	MOV Y, #$10
	CALL CODE_1652
	BRA CODE_15D3

CODE_15CE:
	MOV Y, #$10
	CALL CODE_164D
CODE_15D3:
	MOV A, #$06
	MOV $61+x, A
	JMP CODE_1351

CODE_15DA:
	MOV Y, #$14
	CALL CODE_164D
	MOV A, #$08
	MOV $61+x, A
	JMP CODE_1536

CODE_15E6:
	CALL CODE_158E
	MOV Y, $5E
	MOV $00BE+y, A
	CALL CODE_1590
	MOV $00BF+y, A
	JMP CODE_1587

CODE_15F7:
	CALL CODE_158E
	MOV X, $5D
	MOV $0578+x, A
	JMP CODE_1587

CODE_1602:
	CALL CODE_158E
	MOV X, $5D
	MOV $0580+x, A
	JMP CODE_1587

CODE_160D:
	CALL CODE_158E
	MOV $AD, A
	MOV X, $5D
	MOV A, $0568+x
	CALL CODE_1518
	MOV $0568+x, A
	JMP CODE_1587

CODE_1620:
	CALL CODE_158E
	MOV X, $5D
	MOV $0568+x, A
	JMP CODE_1587

CODE_162B:
	MOV A, #$FF
	MOV X, $5D
	MOV $0590+x, A
	JMP CODE_1587

CODE_1635:
	CALL CODE_158E
	MOV Y, $5E
	MOV $00CE+y, A
	CALL CODE_1590
	MOV $00CF+y, A
	MOV A, #$00
	MOV X, $5D
	MOV $0590+x, A
	JMP CODE_1587

CODE_164D:
	PUSH Y
	CALL CODE_158E
	POP Y
CODE_1652:
	CALL CODE_0DB3
	MOV X, $5E
	MOV $8B+x, A
	MOV A, Y
	MOV $8C+x, A
	MOV X, $5D
	RET

DATA_165F:
	dw CODE_1599
	dw CODE_15CE
	dw CODE_15DA
	dw CODE_15E6
	dw CODE_15F7
	dw CODE_1602
	dw CODE_162B
	dw CODE_1635
	dw CODE_160D
	dw CODE_1620
	dw CODE_15A2
	dw CODE_1599

CODE_1677:
	CALL CODE_167E
	MOV X, A
	JMP (DATA_16EE+x)

CODE_167E:
	MOV X, $5E
CODE_1680:
	MOV A, ($6B+x)
	INC $6B+x
	BNE CODE_1688
	INC $6C+x
CODE_1688:
	RET

CODE_1689:
	MOV X, $5D
	MOV A, #$00
	MOV $61+x, A
	DEC $5C
	JMP CODE_1325

CODE_1694:
	MOV X, $5E
	MOV A, $0550+x
	MOV $6B+x, A
	MOV A, $0551+x
	MOV $6C+x, A
	JMP CODE_1677

CODE_16A3:
	CALL CODE_167E
	MOV X, $5D
	MOV $0560+x, A
	JMP CODE_1677

CODE_16AE:
	CALL CODE_167E
	MOV Y, $5E
	MOV $00AE+y, A
	CALL CODE_1680
	MOV $00AF+y, A
	JMP CODE_1677

CODE_16BF:
	CALL CODE_167E
	MOV Y, #$16
	CALL CODE_0DB3
	MOV X, $5E
	MOV $7B+x, A
	MOV A, Y
	MOV $7C+x, A
	MOV X, $5D
	MOV A, #$0A
	MOV $61+x, A
	JMP CODE_1587

CODE_16D7:
	CALL CODE_167E
	MOV X, $5D
	MOV $0598+x, A
	CMP A, #$FF
	BNE CODE_16EB
	CALL CODE_167E
	MOV X, $5D
	MOV $05A0+x, A
CODE_16EB:
	JMP CODE_1677

DATA_16EE:
	dw CODE_1689
	dw CODE_1694
	dw CODE_16A3
	dw CODE_16AE
	dw CODE_16BF
	dw CODE_16D7

CODE_16FA:
	MOV Y, #$93
CODE_16FC:
	MOV X, $5A+y
	MOV A, $05B7+y
	MOV $005A+y, A
	MOV A, X
	MOV $05B7+y, A
	DBNZ Y, CODE_16FC
	MOV Y, #$69
CODE_170C:
	MOV A, $054E+y
	MOV X, A
	MOV A, $064A+y
	MOV $054E+y, A
	MOV A, X
	MOV $064A+y, A
	DBNZ Y, CODE_170C
	RET

CODE_171D:
	CALL CODE_1726
	MOV A, #$01
	MOV $054F, A
	RET

CODE_1726:
	PUSH A
	CALL CODE_16FA
	POP A
CODE_172B:
	MOV Y, #$1A
	CALL CODE_0DB3
	MOVW $69, YA
	MOV Y, #$00
	MOV A, ($69)+y
	MOV $5B, A
	MOV $5C, A
	BEQ CODE_1787
	MOV $5D, #$00
	MOV $5E, #$00
CODE_1742:
	INC Y
	MOV A, ($69)+y
	PUSH Y
	MOV Y, #$18
	CALL CODE_0DB3
	MOV X, $5E
	MOV $0550+x, A
	MOV $6B+x, A
	MOV A, Y
	POP Y
	MOV $0551+x, A
	MOV $6C+x, A
	MOV A, #$00
	MOV $AE+x, A
	MOV $AF+x, A
	MOV $BE+x, A
	MOV $BF+x, A
	MOV X, $5D
	MOV A, #$0C
	MOV $61+x, A
	MOV A, #$FF
	MOV $0590+x, A
	MOV $05A8+x, A
	MOV A, #$00
	MOV $0568+x, A
	MOV $0570+x, A
	MOV $0588+x, A
	INC $5E
	INC $5E
	INC X
	MOV $5D, X
	CMP X, $5B
	BCC CODE_1742
CODE_1787:
	RET

DATA_1788:
	dw CODE_1325
	dw CODE_132E
	dw CODE_132E
	dw CODE_135B
	dw CODE_1549
	dw CODE_1587

DATA_1794:
	dw CODE_1677
	dw CODE_0B5D
	dw CODE_0BD6
	dw CODE_172B
	dw CODE_1726
	dw CODE_171D
	dw CODE_16FA
	dw CODE_0792
	dw CODE_0B7D
	dw CODE_0B79
	dw CODE_0B73
	dw CODE_0B70
	dw CODE_0B6A
	dw CODE_0B8C
	dw CODE_0B97
%SPCDataBlockEnd(0700)

%SPCDataBlockStart(17D4)
DATA_17D4:
	db $00,$00,$40,$80,$00,$00,$00,$00,$00,$00,$00,$00
%SPCDataBlockEnd(17D4)

base $1800					; Note: Sample bank?
DATA_1800:

%EndSPCUploadAndJumpToEngine($0700)