*
* Hostage
*
* (c) 1990, Infogrames / Mindscape
* (s) 2020, Antoine Vignau
*

*-----------------------
		
	 mx	%00
	 rel
	 lst	off

	 use	THEMAIN.X.S
	 
*-----------------------

	use	4/Event.Macs
	use	4/Locator.Macs
	use	4/Mem.Macs
	use	4/Misc.Macs
	use	4/QD.Macs
	use	4/Sound.Macs
	use	4/Util.Macs
	
*-----------------------

L0B0000  PHD
         TSC
         SEC
         SBC   #$00FB
         TCD
         ADC   #$00EE
         TCS
         PEA   ^L031B65
         PEA   L031B65
         JSL   L160334
         PLY
         PLY
         STX   L020064
         STA   L020062
         JSL   L160798
         PEA   $7D00
         PEA   $00E1
         PEA   $2000
         LDX   L020064
         LDA   L020062
         PHX
         PHA
         JSL   L160944
         PLY
         PLY
         PLY
         PLY
         PLY
         PEA   ^L031B75
         PEA   L031B75
         PEA   $00E1
         PEA   $2000
         PEA   $0064
         PEA   $007E
         JSL   L130403
         TAY
         TSC
         CLC
         ADC   #$000C
         TCS
         TYA
         PEA   ^L031B8B
         PEA   L031B8B
         PEA   $00E1
         PEA   $2000
         PEA   $0063
         PEA   $007D
         JSL   L130403
         TAY
         TSC
         CLC
         ADC   #$000C
         TCS
         TYA
         PEA   $0000
         LDX   L020064
         LDA   L020062
         PHX
         PHA
         JSL   L1605C8
         PLY
         PLY
         PLY
         PEA   $0028
         PEA   $0000
         PEA   ^L031BA1
         PEA   L031BA1
         JSL   L04064C
         PLY
         PLY
         PLY
         PLY
         PEA   $0022
         PEA   $0001
         PEA   ^L031BA8
         PEA   L031BA8
         JSL   L04064C
         PLY
         PLY
         PLY
         PLY
         PEA   $001D
         PEA   $0002
         PEA   ^L031BAF
         PEA   L031BAF
         JSL   L04064C
         PLY
         PLY
         PLY
         PLY
         PEA   $0028
         PEA   $0003
         PEA   ^L031BB8
         PEA   L031BB8
         JSL   L04064C
         PLY
         PLY
         PLY
         PLY
         PEA   $002D
         PEA   $0004
         PEA   ^L031BBF
         PEA   L031BBF
         JSL   L04064C
         PLY
         PLY
         PLY
         PLY
         PEA   $0028
         PEA   $0005
         PEA   ^L031BC4
         PEA   L031BC4
         JSL   L04064C
         PLY
         PLY
         PLY
         PLY
         PEA   $0028
         PEA   $0006
         PEA   ^L031BCB
         PEA   L031BCB
         JSL   L04064C
         PLY
         PLY
         PLY
         PLY
         PEA   $0020
         PEA   $0007
         PEA   ^L031BD2
         PEA   L031BD2
         JSL   L04064C
         PLY
         PLY
         PLY
         PLY
         PEA   $0000
         JSL   L110000
         PLY
         PEA   ^L031BD7
         PEA   L031BD7
         JSL   L160334
         PLY
         PLY
         STX   L020060
         STA   L02005E
         PEA   ^L031BEA
         PEA   L031BEA
         JSL   L07031E
         PLY
         PLY
         PHA
         TXA
         STAL  L03173E
         PLA
         STAL  L03173C
         PEA   ^L031BED
         PEA   L031BED
         JSL   L07031E
         PLY
         PLY
         PHA
         TXA
         STAL  L031746
         PLA
         STAL  L031744
         PEA   ^L031BF0
         PEA   L031BF0
         JSL   L07031E
         PLY
         PLY
         PHA
         TXA
         STAL  L03174A
         PLA
         STAL  L031748
         PEA   ^L031BF5
         PEA   L031BF5
         JSL   L07031E
         PLY
         PLY
         PHA
         TXA
         STAL  L031752
         PLA
         STAL  L031750
         PEA   ^L031BFB
         PEA   L031BFB
         JSL   L07031E
         PLY
         PLY
         STX   L0200BD
         STA   L0200BB
         PEA   ^L031C02
         PEA   L031C02
         JSL   L07031E
         PLY
         PLY
         PHA
         TXA
         STAL  L031742
         PLA
         STAL  L031740
         PEA   ^L031C09
         PEA   L031C09
         JSL   L07031E
         PLY
         PLY
         STX   L020054
         STA   L020052
         PEA   ^L031C10
         PEA   L031C10
         JSL   L07031E
         PLY
         PLY
         STX   L020058
         STA   L020056
         PEA   ^L031C16
         PEA   L031C16
         JSL   L07031E
         PLY
         PLY
         STX   L02005C
         STA   L02005A
         LDX   L020064
         LDA   L020062
         STX   L020086
         STA   L020084
         LDAL  L031742
         TAX
         LDAL  L031740
         STX   L020068
         STA   L020066
         JSL   L13115A
         TSC
         CLC
         ADC   #$000C
         TCS
         PLD
         RTL

L0B0225  PHD
         TSC
         SEC
         SBC   #$00FB
         TCD
         ADC   #$00F4
         TCS
         PEA   $0000
         PEA   $7D00
         JSL   L070000
         PLY
         PLY
         STX   L020070
         STA   L02006E
         TSC
         CLC
         ADC   #$0006
         TCS
         PLD
         RTL

L0B024A  PHD
         TSC
         SEC
         SBC   #$00F9
         TCD
         ADC   #$00F1
         TCS
         JSL   L150027
         SEP   #$20
         STA   $F3
         REP   #$20
         LDA   $FF
         BNE   L0B02A5
         LDA   $F3
         AND   #$00FF
         PHA
         LDA   L0200C0
         AND   #$00FF
         PLX
         STX   $F4
         CMP   $F4
         BNE   L0B028D
         LDA   L0200B6
         BEQ   L0B028D
         LDA   L0200B6
         SEC
         SBC   #$0001
         STA   L0200B6
         SEP   #$20
         STZ   $F3
         REP   #$20
         BRA   L0B02A3
L0B028D  LDA   $F3
         AND   #$00FF
         BEQ   L0B02A3
         LDA   #$0002
         STA   L0200B6
         LDA   $F3
         SEP   #$20
         STA   L0200C0
         REP   #$20
L0B02A3  BRA   L0B02FA
L0B02A5  LDA   $F3
         AND   #$00FF
         AND   #$0080
         TAY
         BNE   L0B02CF
         LDA   L0200B6
         BEQ   L0B02CF
         LDA   L0200B6
         SEC
         SBC   #$0001
         STA   L0200B6
         LDA   $F3
         AND   #$00FF
         ORA   #$0080
         SEP   #$20
         STA   $F3
         REP   #$20
         BRA   L0B02FA
L0B02CF  LDA   $F3
         AND   #$00FF
         AND   #$0080
         TAY
         BNE   L0B02F4
         LDA   #$0002
         STA   L0200B6
         LDA   $F3
         SEP   #$20
         STA   L0200C0
         REP   #$20
         LDA   #$000B
         SEP   #$20
         STA   $F3
         REP   #$20
         BRA   L0B02FA
L0B02F4  LDA   #$0002
         STA   L0200B6
L0B02FA  LDA   $F3
         TAY
         TSC
         CLC
         ADC   #$0007
         TCS
         TYA
         PLD
         RTL

L0B0306  PHD
         TSC
         SEC
         SBC   #$00FB
         TCD
         ADC   #$00F4
         TCS
         LDAL  L030024
         TAX
         LDAL  L030022
         STX   L0200C7
         STA   L0200C5
         LDAL  L030028
         TAX
         LDAL  L030026
         STX   L0200C3
         STA   L0200C1
         TSC
         CLC
         ADC   #$0006
         TCS
         PLD
         RTL

L0B0337  PHD
         TSC
         SEC
         SBC   #$00FB
         TCD
         ADC   #$00F2
         TCS
         LDX   L0200C7
         LDA   L0200C5
         AND   #$000F
         PHA
         TXA
         AND   #$0000
         TAX
         PLA
         SEC
         SBC   #$0001
         PHA
         TXA
         SBC   #$0000
         TAX
         PLA
         PHX
         PHA
         LDX   #$0000
         LDA   #$0002
         JSL   L010591
         PLA
         PLX
         STAL  L03080A
         LDAL  L03080A
         SEC
         SBC   #$0003
         PHA
         LDA   #L0304DA
         LDX   #^L0304DA
         STA   $F6
         STX   $F8
         PLA
         LDY   #$0002
         STA   [$F6],Y
         TAY
         BNE   L0B0394
         LDA   #$FFFF
         STAL  L03080A
         BRA   L0B03A6
L0B0394  LDA   #L0304DA
         LDX   #^L0304DA
         STA   $F6
         STX   $F8
         LDA   #$0001
         LDY   #$0002
         STA   [$F6],Y
L0B03A6  LDX   #$0000
         LDA   #$0004
         PHX
         PHA
         LDX   L0200C7
         LDA   L0200C5
         AND   #$00F0
         PHA
         TXA
         AND   #$0000
         TAX
         PLA
         SEC
         JSL   L01078E
         PLA
         PLX
         SEC
         SBC   #$0001
         PHA
         TXA
         SBC   #$0000
         TAX
         PLA
         PHX
         PHA
         LDX   #$0000
         LDA   #$0002
         JSL   L010591
         PLA
         PLX
         STAL  L030810
         LDAL  L030810
         SEC
         SBC   #$0003
         PHA
         LDA   #L0304E2
         LDX   #^L0304E2
         STA   $F6
         STX   $F8
         PLA
         LDY   #$0002
         STA   [$F6],Y
         TAY
         BNE   L0B0407
         LDA   #$FFFF
         STAL  L030810
         BRA   L0B0419
L0B0407  LDA   #L0304E2
         LDX   #^L0304E2
         STA   $F6
         STX   $F8
         LDA   #$0001
         LDY   #$0002
         STA   [$F6],Y
L0B0419  LDX   #$0000
         LDA   #$0008
         PHX
         PHA
         LDX   L0200C7
         LDA   L0200C5
         AND   #$0F00
         PHA
         TXA
         AND   #$0000
         TAX
         PLA
         SEC
         JSL   L01078E
         PLA
         PLX
         SEC
         SBC   #$0001
         PHA
         TXA
         SBC   #$0000
         TAX
         PLA
         PHX
         PHA
         LDX   #$0000
         LDA   #$0002
         JSL   L010591
         PLA
         PLX
         STAL  L030816
         LDAL  L030816
         SEC
         SBC   #$0003
         PHA
         LDA   #L0304EA
         LDX   #^L0304EA
         STA   $F6
         STX   $F8
         PLA
         LDY   #$0002
         STA   [$F6],Y
         TAY
         BNE   L0B047A
         LDA   #$FFFF
         STAL  L030816
         BRA   L0B048C
L0B047A  LDA   #L0304EA
         LDX   #^L0304EA
         STA   $F6
         STX   $F8
         LDA   #$0001
         LDY   #$0002
         STA   [$F6],Y
L0B048C  STZ   $F4
         BRA   L0B04BA
L0B0490  LDA   $F4
         ASL
         ASL
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   #L0304DA
         LDX   #^L0304DA
         JSL   L010410
         PLA
         PLX
         STA   $F6
         STX   $F8
         LDY   #$0002
         LDA   [$F6],Y
         BEQ   L0B04B8
         LDA   $F4
         STA   L02004E
         BRA   L0B04C7
L0B04B8  INC   $F4
L0B04BA  LDA   $F4
         SEC
         SBC   #$0003
         BVS   L0B04C5
         EOR   #$8000
L0B04C5  BPL   L0B0490
L0B04C7  LDX   #$0000
         LDA   #$000C
         PHX
         PHA
         LDX   L0200C7
         LDA   L0200C5
         AND   #$F000
         PHA
         TXA
         AND   #$0000
         TAX
         PLA
         SEC
         JSL   L01078E
         PLA
         PLX
         STA   L020039
         LDX   #$0000
         LDA   #$0010
         PHX
         PHA
         LDX   L0200C7
         LDA   L0200C5
         AND   #$0000
         PHA
         TXA
         AND   #$000F
         TAX
         PLA
         SEC
         JSL   L01078E
         PLA
         PLX
         STA   L02003B
         STZ   L02009C
         STZ   L02009E
         JSL   L0F0FE2
         LDX   L0200C3
         LDA   L0200C1
         STX   L02009E
         STA   L02009C
         TSC
         CLC
         ADC   #$0008
         TCS
         PLD
         RTL

L0B0529  ENT
         PHD
         TSC
         SEC
         SBC   #$00FB
         TCD
         ADC   #$00D8
         TCS
         JSL   L0F0F81
         LDX   L02009E
         LDA   L02009C
         STX   $F4
         STA   $F2
         LDX   L0200A2
         LDA   L0200A0
         PHX
         PHA
         LDX   #$0000
         LDA   #$0032
         CLC
         JSL   L0105E1
         PLA
         PLX
         STX   L02009E
         STA   L02009C
         JSL   L010283
         JSL   L0F0FE2
         LDX   $F4
         LDA   $F2
         STX   L02009E
         STA   L02009C
L0B056F  JSL   L160000
         AND   #$8080
         TAY
         BEQ   L0B057B
         BRA   L0B056F
L0B057B  PEA   $0000
         JSL   L0C0000
         PLY
         TSC
         CLC
         ADC   #$0022
         TCS
         PLD
         RTL

L0B058B  PHD
         TSC
         SEC
         SBC   #$00FB
         TCD
         ADC   #$00F4
         TCS
         PEA   $0001
         LDX   L020070
         LDA   L02006E
         PHX
         PHA
         LDX   L0200E8
         LDA   L0200E6
         PHX
         PHA
         JSL   L150060
         PLY
         PLY
         PLY
         PLY
         PLY
         LDX   L0200A6
         LDA   L0200A4
         PHX
         PHA
         LDX   L020070
         LDA   L02006E
         PHX
         PHA
         JSL   L1607F3
         PLY
         PLY
         PLY
         PLY
         JSL   L070062
         LDX   L0200A6
         LDA   L0200A4
         PHX
         PHA
         LDX   L020070
         LDA   L02006E
         PHX
         PHA
         JSL   L1607F3
         PLY
         PLY
         PLY
         PLY
         LDA   L0200DB
         AND   #$00FF
         BNE   L0B05F1
         BRL   L0B088D
L0B05F1  LDA   L02003B
         CMP   #$0004
         BEQ   L0B05FC
         BRL   L0B088D
L0B05FC  LDA   L020039
         CMP   #$0000
         BEQ   L0B0607
         BRL   L0B06D7
L0B0607  PEA   $0000
         PEA   $0082
         PEA   $0136
         PEA   $0046
         PEA   $000A
         JSL   L1503A9
         PLY
         PLY
         PLY
         PLY
         PLY
         PEA   $0004
         PEA   $0082
         PEA   $0136
         PEA   $0046
         PEA   $000A
         JSL   L15030E
         PLY
         PLY
         PLY
         PLY
         PLY
         PEA   ^L031C1F
         PEA   L031C1F
         LDX   L0200A6
         LDA   L0200A4
         PHX
         PHA
         PEA   $004C
         PEA   $000C
         JSL   L130403
         TAY
         TSC
         CLC
         ADC   #$000C
         TCS
         TYA
         PEA   ^L031C4B
         PEA   L031C4B
         LDX   L0200A6
         LDA   L0200A4
         PHX
         PHA
         PEA   $0055
         PEA   $000C
         JSL   L130403
         TAY
         TSC
         CLC
         ADC   #$000C
         TCS
         TYA
         PEA   ^L031C77
         PEA   L031C77
         LDX   L0200A6
         LDA   L0200A4
         PHX
         PHA
         PEA   $005E
         PEA   $000C
         JSL   L130403
         TAY
         TSC
         CLC
         ADC   #$000C
         TCS
         TYA
         PEA   ^L031CA3
         PEA   L031CA3
         LDX   L0200A6
         LDA   L0200A4
         PHX
         PHA
         PEA   $0067
         PEA   $000C
         JSL   L130403
         TAY
         TSC
         CLC
         ADC   #$000C
         TCS
         TYA
         PEA   ^L031CCF
         PEA   L031CCF
         LDX   L0200A6
         LDA   L0200A4
         PHX
         PHA
         PEA   $0070
         PEA   $000C
         JSL   L130403
         TAY
         TSC
         CLC
         ADC   #$000C
         TCS
         TYA
L0B06D7  LDA   L020039
         CMP   #$0001
         BEQ   L0B06E2
         BRL   L0B07B2
L0B06E2  PEA   $0000
         PEA   $0082
         PEA   $0136
         PEA   $0046
         PEA   $000A
         JSL   L1503A9
         PLY
         PLY
         PLY
         PLY
         PLY
         PEA   $0004
         PEA   $0082
         PEA   $0136
         PEA   $0046
         PEA   $000A
         JSL   L15030E
         PLY
         PLY
         PLY
         PLY
         PLY
         PEA   ^L031CFA
         PEA   L031CFA
         LDX   L0200A6
         LDA   L0200A4
         PHX
         PHA
         PEA   $004C
         PEA   $000C
         JSL   L130403
         TAY
         TSC
         CLC
         ADC   #$000C
         TCS
         TYA
         PEA   ^L031D24
         PEA   L031D24
         LDX   L0200A6
         LDA   L0200A4
         PHX
         PHA
         PEA   $0055
         PEA   $000C
         JSL   L130403
         TAY
         TSC
         CLC
         ADC   #$000C
         TCS
         TYA
         PEA   ^L031D4F
         PEA   L031D4F
         LDX   L0200A6
         LDA   L0200A4
         PHX
         PHA
         PEA   $005E
         PEA   $000C
         JSL   L130403
         TAY
         TSC
         CLC
         ADC   #$000C
         TCS
         TYA
         PEA   ^L031D7A
         PEA   L031D7A
         LDX   L0200A6
         LDA   L0200A4
         PHX
         PHA
         PEA   $0067
         PEA   $000C
         JSL   L130403
         TAY
         TSC
         CLC
         ADC   #$000C
         TCS
         TYA
         PEA   ^L031DA5
         PEA   L031DA5
         LDX   L0200A6
         LDA   L0200A4
         PHX
         PHA
         PEA   $0070
         PEA   $000C
         JSL   L130403
         TAY
         TSC
         CLC
         ADC   #$000C
         TCS
         TYA
L0B07B2  LDA   L020039
         CMP   #$0002
         BEQ   L0B07BD
         BRL   L0B084D
L0B07BD  PEA   $0000
         PEA   $0082
         PEA   $0136
         PEA   $0046
         PEA   $000A
         JSL   L1503A9
         PLY
         PLY
         PLY
         PLY
         PLY
         PEA   $0004
         PEA   $0082
         PEA   $0136
         PEA   $0046
         PEA   $000A
         JSL   L15030E
         PLY
         PLY
         PLY
         PLY
         PLY
         PEA   ^L031DD0
         PEA   L031DD0
         LDX   L0200A6
         LDA   L0200A4
         PHX
         PHA
         PEA   $0055
         PEA   $000C
         JSL   L130403
         TAY
         TSC
         CLC
         ADC   #$000C
         TCS
         TYA
         PEA   ^L031DFC
         PEA   L031DFC
         LDX   L0200A6
         LDA   L0200A4
         PHX
         PHA
         PEA   $005E
         PEA   $000C
         JSL   L130403
         TAY
         TSC
         CLC
         ADC   #$000C
         TCS
         TYA
         PEA   ^L031E28
         PEA   L031E28
         LDX   L0200A6
         LDA   L0200A4
         PHX
         PHA
         PEA   $0067
         PEA   $000C
         JSL   L130403
         TAY
         TSC
         CLC
         ADC   #$000C
         TCS
         TYA
L0B084D  JSL   L070062
L0B0851  JSL   L160000
         AND   #$8080
         TAY
         BEQ   L0B085D
         BRA   L0B0851
L0B085D  JSL   L160000
         AND   #$8080
         TAY
         BNE   L0B0869
         BRA   L0B085D
L0B0869  JSL   L160000
         AND   #$8080
         TAY
         BEQ   L0B0875
         BRA   L0B0869
L0B0875  LDX   L0200A6
         LDA   L0200A4
         PHX
         PHA
         LDX   L020070
         LDA   L02006E
         PHX
         PHA
         JSL   L1607F3
         PLY
         PLY
         PLY
         PLY
L0B088D  SEP   #$20
         STZ   L0200DB
         REP   #$20
         PEA   $0000
         PEA   $0078
         PEA   $013F
         PEA   $0046
         PEA   $0000
         JSL   L1503A9
         PLY
         PLY
         PLY
         PLY
         PLY
         PEA   $0004
         PEA   $0078
         PEA   $013F
         PEA   $0046
         PEA   $0000
         JSL   L15030E
         PLY
         PLY
         PLY
         PLY
         PLY
         PEA   ^L031E54
         PEA   L031E54
         LDX   L0200A6
         LDA   L0200A4
         PHX
         PHA
         PEA   $004B
         PEA   $000B
         JSL   L130403
         TAY
         TSC
         CLC
         ADC   #$000C
         TCS
         TYA
         PEA   ^L031E7A
         PEA   L031E7A
         LDX   L0200A6
         LDA   L0200A4
         PHX
         PHA
         PEA   $0055
         PEA   $0033
         JSL   L130403
         TAY
         TSC
         CLC
         ADC   #$000C
         TCS
         TYA
         PEA   ^L031E9F
         PEA   L031E9F
         LDX   L0200A6
         LDA   L0200A4
         PHX
         PHA
         PEA   $004A
         PEA   $000A
         JSL   L130403
         TAY
         TSC
         CLC
         ADC   #$000C
         TCS
         TYA
         PEA   ^L031EC2
         PEA   L031EC2
         LDX   L0200A6
         LDA   L0200A4
         PHX
         PHA
         PEA   $0054
         PEA   $0032
         JSL   L130403
         TAY
         TSC
         CLC
         ADC   #$000C
         TCS
         TYA
         PEA   ^L031EE4
         PEA   L031EE4
         LDX   L0200A6
         LDA   L0200A4
         PHX
         PHA
         PEA   $0061
         PEA   $000B
         JSL   L130403
         TAY
         TSC
         CLC
         ADC   #$000C
         TCS
         TYA
         PEA   ^L031F0A
         PEA   L031F0A
         LDX   L0200A6
         LDA   L0200A4
         PHX
         PHA
         PEA   $006B
         PEA   $0033
         JSL   L130403
         TAY
         TSC
         CLC
         ADC   #$000C
         TCS
         TYA
         PEA   ^L031F2E
         PEA   L031F2E
         LDX   L0200A6
         LDA   L0200A4
         PHX
         PHA
         PEA   $0060
         PEA   $000A
         JSL   L130403
         TAY
         TSC
         CLC
         ADC   #$000C
         TCS
         TYA
         PEA   ^L031F51
         PEA   L031F51
         LDX   L0200A6
         LDA   L0200A4
         PHX
         PHA
         PEA   $006A
         PEA   $0032
         JSL   L130403
         TAY
         TSC
         CLC
         ADC   #$000C
         TCS
         TYA
         JSL   L070062
         TSC
         CLC
         ADC   #$0006
         TCS
         PLD
         RTL

L0B09D0  ENT
         PHD
         TSC
         SEC
         SBC   #$00FB
         TCD
         ADC   #$00DB
         TCS
         SEP   #$20
         STZ   $EC
         REP   #$20
         LDA   #$0001
         SEP   #$20
         STA   $EB
         REP   #$20
         SEP   #$20
         STZ   $EA
         REP   #$20
         SEP   #$20
         STZ   $E9
         REP   #$20
         STZ   $DF
         JSL   L0701B6
         JSL   L1600AA
         JSL   L040611
         PEI   $E1
         PEA   ^L031F72
         PEA   L031F72
         JSL   L170000
         PLY
         PLY
         PLY
         JSL   L0B0225
         JSL   L0B0000
         JSL   L150491
         PEA   $FFFF
         PEA   $00E1
         PEA   $2000
         LDX   L020070
         LDA   L02006E
         PHX
         PHA
         JSL   L150000
         PLY
         PLY
         PLY
         PLY
         PLY
         JSL   L150491
         JSL   L070062
         PEA   $FFFF
         PEA   $00E1
         PEA   $2000
         LDX   L0200A6
         LDA   L0200A4
         PHX
         PHA
         JSL   L150000
         PLY
         PLY
         PLY
         PLY
         PLY
         LDA   #$0001
         STA   $E1
         PEA   $013F
         PEA   $0000
         JSL   L1507C2
         PLY
         PLY
         LDA   #$0003
         STA   $F0
         BRA   L0B0AC7
L0B0A73  LDA   $F0
         PHA
         LDA   #$0006
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L0316A0
         LDX   #^L0316A0
         JSL   L010410
         PLA
         PLX
         STA   $F6
         STX   $F8
         LDA   #$00F0
         LDY   #$0002
         STA   [$F6],Y
         LDA   $F0
         PHA
         LDA   #$0006
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L0316A0
         LDX   #^L0316A0
         JSL   L010410
         PLA
         PLX
         STA   $F6
         STX   $F8
         LDA   #$0082
         LDY   #$0004
         STA   [$F6],Y
         INC   $F0
L0B0AC7  LDA   $F0
         SEC
         SBC   #$0006
         BVS   L0B0AD2
         EOR   #$8000
L0B0AD2  BPL   L0B0A73
         STZ   $F0
         BRL   L0B0B8B
L0B0AD9  LDA   $F0
         PHA
         LDA   #$0006
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L031782
         LDX   #^L031782
         JSL   L010410
         PLA
         PLX
         STA   $F6
         STX   $F8
         LDA   #$0000
         LDY   #$0001
         STA   [$F6],Y
         LDA   $F0
         PHA
         LDA   #$0006
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L031782
         LDX   #^L031782
         JSL   L010410
         PLA
         PLX
         STA   $F6
         STX   $F8
         LDA   #$0000
         SEP   #$20
         LDY   #$0005
         STA   [$F6],Y
         REP   #$20
         LDA   $F0
         PHA
         LDA   #$0006
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L031782
         LDX   #^L031782
         JSL   L010410
         PLA
         PLX
         STA   $F6
         STX   $F8
         LDA   #$0000
         SEP   #$20
         LDY   #$0004
         STA   [$F6],Y
         REP   #$20
         LDA   $F0
         PHA
         LDA   #$0006
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L031782
         LDX   #^L031782
         JSL   L010410
         PLA
         PLX
         STA   $F6
         STX   $F8
         LDA   #$0000
         SEP   #$20
         LDY   #$0003
         STA   [$F6],Y
         REP   #$20
         INC   $F0
L0B0B8B  LDA   $F0
         SEC
         SBC   #$0082
         BVS   L0B0B96
         EOR   #$8000
L0B0B96  BMI   L0B0B9B
         BRL   L0B0AD9
L0B0B9B  LDA   #$0000
         SEP   #$20
         STA   $E9
         REP   #$20
         SEP   #$20
         STA   $EA
         REP   #$20
         SEP   #$20
         STA   $EC
         REP   #$20
         LDA   #$0001
         SEP   #$20
         STA   $EB
         REP   #$20
         LDA   #$0001
         SEP   #$20
         STA   L0200B8
         REP   #$20
         SEP   #$20
         STZ   $E9
         REP   #$20
         LDA   #$0001
         SEP   #$20
         STA   $EB
         REP   #$20
         STZ   $E1
         STZ   L020048
         LDA   #$0003
         STA   $F0
         BRA   L0B0C21
L0B0BDE  LDA   $F0
         ASL
         ASL
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   #L0304DA
         LDX   #^L0304DA
         JSL   L010410
         PLA
         PLX
         STA   $F6
         STX   $F8
         LDA   #$0001
         LDY   #$0002
         STA   [$F6],Y
         LDA   $F0
         ASL
         ASL
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   #L0304DA
         LDX   #^L0304DA
         JSL   L010410
         PLA
         PLX
         STA   $F6
         STX   $F8
         LDA   #$0002
         STA   [$F6]
         INC   $F0
L0B0C21  LDA   $F0
         SEC
         SBC   #$0006
         BVS   L0B0C2C
         EOR   #$8000
L0B0C2C  BPL   L0B0BDE
         JSL   L110132
         JSL   L0B0306
         JSL   L0B0337
         LDA   #$0001
         SEP   #$20
         STA   L020045
         REP   #$20
         LDA   #$0006
         STA   $F0
         BRA   L0B0C54
L0B0C4B  PEI   $F0
         JSL   L080969
         PLY
         INC   $F0
L0B0C54  LDA   $F0
         SEC
         SBC   #$0018
         BVS   L0B0C5F
         EOR   #$8000
L0B0C5F  BPL   L0B0C4B
         LDA   L02003B
         CMP   #$0004
         BNE   L0B0C75
         PEA   $0001
         PEA   $0059
         JSL   L0F0628
         PLY
         PLY
L0B0C75  LDA   L02004E
         STA   $F2
         LDA   #$0064
         STA   $E7
         JSL   L01027B
L0B0C83  LDA   $E7
         SEC
         SBC   #$0001
         STA   $E7
         LDA   $E7
         BNE   L0B0CBB
         LDA   #$0064
         STA   $E7
         JSL   L0703A5
         AND   #$003F
         PHA
         LDA   #$00A0
         PLX
         STX   $FA
         CLC
         ADC   $FA
         PHA
         JSL   L0405F2
         PLY
         PEA   $0001
         PEA   ^L03162E
         PEA   L03162E
         JSL   L040732
         PLY
         PLY
         PLY
L0B0CBB  JSL   L160143
         STA   $DD
         LDA   $DD
         BNE   L0B0CC8
         BRL   L0B0E8D
L0B0CC8  LDA   L0200B4
         BEQ   L0B0CD0
         BRL   L0B0E8D
L0B0CD0  LDA   $EB
         AND   #$00FF
         BEQ   L0B0CDA
         BRL   L0B0E8D
L0B0CDA  LDA   $EC
         AND   #$00FF
         BEQ   L0B0CE4
         BRL   L0B0E8D
L0B0CE4  LDA   $F5
         AND   #$00FF
         AND   #$0080
         TAY
         BEQ   L0B0CF2
         BRL   L0B0E8D
L0B0CF2  PEI   $DD
         JSL   L1508E5
         PLY
         STA   $DD
         BRL   L0B0E58
L0B0CFE  LDA   $DD
         SEC
         SBC   #$00C9
         SEP   #$20
         STA   $F4
         REP   #$20
         LDA   $F4
         AND   #$00FF
         ASL
         ASL
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   #L0304DA
         LDX   #^L0304DA
         JSL   L010410
         PLA
         PLX
         STA   $F6
         STX   $F8
         LDY   #$0002
         LDA   [$F6],Y
         BEQ   L0B0D3B
         LDA   $F4
         AND   #$00FF
         STA   $F2
         SEP   #$20
         STZ   $EC
         REP   #$20
L0B0D3B  BRL   L0B0E8D
L0B0D3E  LDA   #$0003
         SEP   #$20
         STA   $E9
         REP   #$20
         LDA   $DD
         SEC
         SBC   #$00C9
         SEP   #$20
         STA   $F4
         REP   #$20
         LDA   $F4
         AND   #$00FF
         ASL
         ASL
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   #L0304DA
         LDX   #^L0304DA
         JSL   L010410
         PLA
         PLX
         STA   $F6
         STX   $F8
         LDY   #$0002
         LDA   [$F6],Y
         BEQ   L0B0DC6
         LDA   $F4
         AND   #$00FF
         CMP   $F2
         BEQ   L0B0DC6
         LDA   $F4
         AND   #$00FF
         ASL
         ASL
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   #L0304DA
         LDX   #^L0304DA
         JSL   L010410
         PLA
         PLX
         STA   $F6
         STX   $F8
         LDA   [$F6]
         SEC
         SBC   #$0003
         BVS   L0B0DA8
         EOR   #$8000
L0B0DA8  BPL   L0B0DC6
         LDA   $F4
         AND   #$00FF
         STA   $F2
         PEA   $0004
         PEI   $F2
         JSL   L110377
         PLY
         PLY
         PEI   $F2
         JSL   L0D093C
         PLY
         BRL   L0B0E48
L0B0DC6  LDA   $F4
         AND   #$00FF
         ASL
         ASL
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   #L0304DA
         LDX   #^L0304DA
         JSL   L010410
         PLA
         PLX
         STA   $F6
         STX   $F8
         LDA   [$F6]
         SEC
         SBC   #$0003
         BVS   L0B0DEE
         EOR   #$8000
L0B0DEE  BMI   L0B0E48
         LDA   $F4
         AND   #$00FF
         ASL
         ASL
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   #L0304DA
         LDX   #^L0304DA
         JSL   L010410
         PLA
         PLX
         STA   $F6
         STX   $F8
         LDY   #$0002
         LDA   [$F6],Y
         BEQ   L0B0E48
         LDA   $F4
         AND   #$00FF
         STA   $F2
         LDA   $F4
         AND   #$00FF
         ASL
         ASL
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   #L0304DA
         LDX   #^L0304DA
         JSL   L010410
         PLA
         PLX
         STA   $F6
         STX   $F8
         LDA   [$F6]
         CMP   #$0002
         BNE   L0B0E48
         LDA   #$0001
         SEP   #$20
         STA   $EB
         REP   #$20
L0B0E48  BRL   L0B0E8D
L0B0E4B  LDA   #$0001
         SEP   #$20
         STA   $EB
         REP   #$20
         BRA   L0B0E8D
         BRA   L0B0E8D
L0B0E58  CMP   #$001B
         BEQ   L0B0E4B
         CMP   #$00C9
         BNE   L0B0E65
         BRL   L0B0CFE
L0B0E65  CMP   #$00CA
         BNE   L0B0E6D
         BRL   L0B0CFE
L0B0E6D  CMP   #$00CB
         BNE   L0B0E75
         BRL   L0B0CFE
L0B0E75  CMP   #$00CC
         BNE   L0B0E7D
         BRL   L0B0D3E
L0B0E7D  CMP   #$00CD
         BNE   L0B0E85
         BRL   L0B0D3E
L0B0E85  CMP   #$00CE
         BNE   L0B0E8D
         BRL   L0B0D3E
L0B0E8D  JSL   L010276
         TAY
         BEQ   L0B0E98
         JSL   L0B0529
L0B0E98  LDA   $EC
         AND   #$00FF
         BNE   L0B0EA2
         BRL   L0B0F3D
L0B0EA2  SEP   #$20
         STZ   $EC
         REP   #$20
         PEA   $0000
         LDX   L020070
         LDA   L02006E
         PHX
         PHA
         LDX   L020064
         LDA   L020062
         PHX
         PHA
         JSL   L150060
         PLY
         PLY
         PLY
         PLY
         PLY
         PEI   $F2
         JSL   L0D093C
         PLY
         LDA   $EA
         AND   #$00FF
         BEQ   L0B0EF5
         PEI   $F2
         JSL   L060500
         PLY
         PEI   $F2
         JSL   L0C0300
         PLY
         PEI   $F2
         JSL   L0D09CE
         PLY
         LDA   #$0001
         STA   L0200B4
         SEP   #$20
         STZ   $EA
         REP   #$20
         BRA   L0B0F3D
L0B0EF5  LDA   $E9
         AND   #$00FF
         CMP   #$0001
         BNE   L0B0F1A
         LDA   $EB
         AND   #$00FF
         BNE   L0B0F1A
         PEI   $F2
         JSL   L0D093C
         PLY
         PEA   $000C
         PEI   $F2
         JSL   L110377
         PLY
         PLY
         BRA   L0B0F3D
L0B0F1A  LDA   $E9
         AND   #$00FF
         CMP   #$0000
         BNE   L0B0F3D
         LDA   $EB
         AND   #$00FF
         BNE   L0B0F3D
         PEI   $F2
         JSL   L0D093C
         PLY
         PEA   $0008
         PEI   $F2
         JSL   L110377
         PLY
         PLY
L0B0F3D  PEI   $F2
         JSL   L0A0D67
         PLY
         SEP   #$20
         STA   $F4
         REP   #$20
         LDA   $F4
         AND   #$00FF
         CMP   #$000C
         BEQ   L0B0F7F
         LDA   L02004E
         STA   $F2
         PEA   $0080
         PEA   $00E0
         PEA   $0032
         PEA   $0058
         JSL   L11019F
         PLY
         PLY
         PLY
         PLY
         LDA   #$0003
         SEP   #$20
         STA   $E9
         REP   #$20
         LDA   #$0001
         SEP   #$20
         STA   $EB
         REP   #$20
L0B0F7F  LDA   $EB
         AND   #$00FF
         BNE   L0B0F89
         BRL   L0B1045
L0B0F89  LDA   L020045
         AND   #$00FF
         BNE   L0B0F94
         BRL   L0B1045
L0B0F94  LDA   $E9
         AND   #$00FF
         BRL   L0B0FE1
L0B0F9C  PEA   $000D
         PEI   $F2
         JSL   L110377
         PLY
         PLY
         BRL   L0B0FEE
L0B0FAA  PEA   $0005
         PEI   $F2
         JSL   L110377
         PLY
         PLY
         BRL   L0B0FEE
L0B0FB8  PEA   $0009
         PEI   $F2
         JSL   L110377
         PLY
         PLY
         BRL   L0B0FEE
L0B0FC6  PEA   $0001
         PEI   $F2
         JSL   L110377
         PLY
         PLY
         BRL   L0B0FEE
L0B0FD4  BRL   L0B0FEE
L0B0FD7  DA    L0B0FAA
         DA    L0B0FB8
         DA    L0B0F9C
         DA    L0B0FC6
         DA    L0B0FD4
L0B0FE1  CMP   #$0004
         BCC   L0B0FE9
         LDA   #$0004
L0B0FE9  ASL
         TAX
         JMP   (L0B0FD7,X)

L0B0FEE  SEP   #$20
         STZ   $EB
         REP   #$20
         PEI   $F2
         JSL   L1413F1
         PLY
         STA   $F2
         LDA   #$0002
         SEP   #$20
         STA   $E9
         REP   #$20
         LDA   $F2
         ASL
         ASL
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   #L0304DA
         LDX   #^L0304DA
         JSL   L010410
         PLA
         PLX
         STA   $F6
         STX   $F8
         LDA   [$F6]
         SEC
         SBC   #$0003
         BVS   L0B102B
         EOR   #$8000
L0B102B  BPL   L0B1045
         PEI   $F2
         JSL   L0D093C
         PLY
         LDA   #$0001
         STA   L0200B4
         PEA   $0010
         PEI   $F2
         JSL   L110377
         PLY
         PLY
L0B1045  LDA   L020045
         AND   #$00FF
         BNE   L0B1050
         BRL   L0B1645
L0B1050  LDA   $F2
         ASL
         ASL
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   #L0304DA
         LDX   #^L0304DA
         JSL   L010410
         PLA
         PLX
         STA   $F6
         STX   $F8
         LDA   [$F6]
         SEC
         SBC   #$0003
         BVS   L0B1075
         EOR   #$8000
L0B1075  BMI   L0B107A
         BRL   L0B1182
L0B107A  LDA   $F2
         ASL
         ASL
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   #L0304DA
         LDX   #^L0304DA
         JSL   L010410
         PLA
         PLX
         STA   $F6
         STX   $F8
         LDY   #$0002
         LDA   [$F6],Y
         BNE   L0B109E
         BRL   L0B1182
L0B109E  LDA   $F2
         PHA
         LDA   #$001A
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L03059A
         LDX   #^L03059A
         JSL   L010410
         PLA
         PLX
         STA   $F6
         STX   $F8
         LDY   #$000A
         LDA   [$F6],Y
         CMP   #$000E
         BNE   L0B10CC
         BRL   L0B1182
L0B10CC  LDA   L020050
         BNE   L0B110C
         JSL   L160143
         SEP   #$20
         STA   $ED
         REP   #$20
         LDA   $F2
         PHA
         LDA   #$0006
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L0316A0
         LDX   #^L0316A0
         JSL   L010410
         PLA
         PLX
         STA   $F6
         STX   $F8
         LDA   [$F6]
         PHA
         JSL   L0B024A
         PLY
         SEP   #$20
         STA   $F5
         REP   #$20
         BRA   L0B111C
L0B110C  STZ   L020050
         SEP   #$20
         STZ   L0200A8
         REP   #$20
         SEP   #$20
         STZ   $F5
         REP   #$20
L0B111C  LDA   $ED
         AND   #$00FF
         BRL   L0B1140
L0B1124  LDA   #$0009
         SEP   #$20
         STA   $F5
         REP   #$20
         BRL   L0B114D
L0B1130  LDA   #$000B
         SEP   #$20
         STA   $F5
         REP   #$20
         BRL   L0B114D
L0B113C  BRA   L0B114D
         BRA   L0B114D
L0B1140  CMP   #$000D
         BEQ   L0B1130
         CMP   #$0071
         BEQ   L0B1124
         JMP   L0B113C

L0B114D  LDA   L0200B4
         BNE   L0B116B
         LDA   $F5
         AND   #$00FF
         AND   #$0081
         TAY
         BEQ   L0B116B
         LDA   $F5
         AND   #$00FF
         PHA
         PEI   $F2
         JSL   L0D0ABA
         PLY
         PLY
L0B116B  PEI   $F2
         JSL   L0E0000
         PLY
         LDA   #$0003
         SEP   #$20
         STA   $E9
         REP   #$20
         JSL   L070062
         BRL   L0B1645
L0B1182  LDA   $F2
         SEC
         SBC   #$0003
         BVS   L0B118D
         EOR   #$8000
L0B118D  BMI   L0B1192
         BRL   L0B14A5
L0B1192  LDA   $F2
         ASL
         ASL
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   #L0304DA
         LDX   #^L0304DA
         JSL   L010410
         PLA
         PLX
         STA   $F6
         STX   $F8
         LDA   [$F6]
         CMP   #$0001
         BEQ   L0B11B6
         BRL   L0B14A5
L0B11B6  LDA   $F2
         SEP   #$20
         STA   $F4
         REP   #$20
         LDA   $E9
         AND   #$00FF
         BRL   L0B120B
L0B11C6  PEA   $000E
         PEI   $F2
         JSL   L110377
         PLY
         PLY
         BRL   L0B1218
L0B11D4  PEA   $0006
         PEI   $F2
         JSL   L110377
         PLY
         PLY
         BRL   L0B1218
L0B11E2  PEA   $000A
         PEI   $F2
         JSL   L110377
         PLY
         PLY
         BRL   L0B1218
L0B11F0  PEA   $0002
         PEI   $F2
         JSL   L110377
         PLY
         PLY
         BRL   L0B1218
L0B11FE  BRL   L0B1218
L0B1201  DA    L0B11D4
         DA    L0B11E2
         DA    L0B11C6
         DA    L0B11F0
         DA    L0B11FE
         MX    %00
L0B120B  CMP   #$0004
         BCC   L0B1213
         LDA   #$0004
L0B1213  ASL
         TAX
         JMP   (L0B1201,X)

L0B1218  PEI   $F2
         JSL   L12227F
         PLY
         SEP   #$20
         STA   $F4
         REP   #$20
         LDA   $F4
         AND   #$00FF
         CMP   #$000C
         BEQ   L0B1281
         LDA   $F4
         AND   #$00FF
         ASL
         ASL
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   #L0304DA
         LDX   #^L0304DA
         JSL   L010410
         PLA
         PLX
         STA   $F6
         STX   $F8
         LDY   #$0002
         LDA   [$F6],Y
         BEQ   L0B1281
         LDA   $F4
         AND   #$00FF
         PHA
         LDA   #$001A
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L03059A
         LDX   #^L03059A
         JSL   L010410
         PLA
         PLX
         STA   $F6
         STX   $F8
         LDY   #$000A
         LDA   [$F6],Y
         CMP   #$000E
         BNE   L0B1299
L0B1281  LDA   #$0001
         SEP   #$20
         STA   $EB
         REP   #$20
         LDA   $F4
         AND   #$00FF
         CMP   #$000C
         BEQ   L0B1299
         LDA   L02004E
         STA   $F2
L0B1299  LDA   #$0001
         SEP   #$20
         STA   $E9
         REP   #$20
         LDA   $EB
         AND   #$00FF
         BEQ   L0B12AC
         BRL   L0B14A2
L0B12AC  LDA   $F4
         AND   #$00FF
         STA   $F2
         LDA   $F2
         PHA
         LDA   #$001A
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L03059A
         LDX   #^L03059A
         JSL   L010410
         PLA
         PLX
         STA   $F6
         STX   $F8
         LDY   #$0004
         LDA   [$F6],Y
         BNE   L0B12DE
         BRL   L0B1446
L0B12DE  LDA   $F2
         ASL
         ASL
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   #L0304DA
         LDX   #^L0304DA
         JSL   L010410
         PLA
         PLX
         STA   $F6
         STX   $F8
         LDA   [$F6]
         CMP   #$0001
         BEQ   L0B1302
         BRL   L0B1446
L0B1302  LDA   $F2
         PHA
         LDA   #$001A
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L03059A
         LDX   #^L03059A
         JSL   L010410
         PLA
         PLX
         STA   $F6
         STX   $F8
         LDY   #$0004
         LDA   [$F6],Y
         STA   $F0
         LDA   $F0
         PHA
         LDA   #$0016
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L03082E
         LDX   #^L03082E
         JSL   L010410
         PLA
         PLX
         STA   $F6
         STX   $F8
         LDY   #$0002
         LDA   [$F6],Y
         PHA
         LDA   $F2
         PHA
         LDA   #$001A
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L03059A
         LDX   #^L03059A
         JSL   L010410
         PLA
         PLX
         STA   $F6
         STX   $F8
         PLA
         STA   [$F6]
         LDA   $F0
         PHA
         LDA   #$0016
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L03082E
         LDX   #^L03082E
         JSL   L010410
         PLA
         PLX
         STA   $F6
         STX   $F8
         LDY   #$0004
         LDA   [$F6],Y
         PHA
         LDA   $F2
         PHA
         LDA   #$001A
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L03059A
         LDX   #^L03059A
         JSL   L010410
         PLA
         PLX
         STA   $F6
         STX   $F8
         PLA
         LDY   #$0002
         STA   [$F6],Y
         LDA   $F0
         PHA
         LDA   #$0016
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L03082E
         LDX   #^L03082E
         JSL   L010410
         PLA
         PLX
         STA   $F6
         STX   $F8
         LDA   [$F6]
         PHA
         LDA   $F2
         ASL
         ASL
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   #L0304DA
         LDX   #^L0304DA
         JSL   L010410
         PLA
         PLX
         STA   $F6
         STX   $F8
         PLA
         STA   [$F6]
         LDA   $F2
         SEC
         SBC   #$0003
         LDX   #$0000
         TAY
         BPL   L0B1411
         DEX
L0B1411  STX   $FA
         ASL
         ROL   $FA
         LDX   $FA
         PHX
         PHA
         LDA   #L03177C
         LDX   #^L03177C
         JSL   L010410
         PLA
         PLX
         STA   $F6
         STX   $F8
         LDA   #$0000
         STA   [$F6]
         LDA   #$0001
         SEP   #$20
         STA   $EC
         REP   #$20
         LDA   #$0001
         SEP   #$20
         STA   $EA
         REP   #$20
         STZ   L0200B6
         BRA   L0B14A2
L0B1446  LDA   $F2
         ASL
         ASL
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   #L0304DA
         LDX   #^L0304DA
         JSL   L010410
         PLA
         PLX
         STA   $F6
         STX   $F8
         LDA   [$F6]
         SEC
         SBC   #$0003
         BVS   L0B146B
         EOR   #$8000
L0B146B  BPL   L0B1478
         LDA   #$0001
         SEP   #$20
         STA   $EC
         REP   #$20
         BRA   L0B14A2
L0B1478  LDA   $F2
         ASL
         ASL
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   #L0304DA
         LDX   #^L0304DA
         JSL   L010410
         PLA
         PLX
         STA   $F6
         STX   $F8
         LDA   [$F6]
         CMP   #$0002
         BNE   L0B14A2
         LDA   #$0001
         SEP   #$20
         STA   $EB
         REP   #$20
L0B14A2  BRL   L0B1645
L0B14A5  LDA   $F2
         SEC
         SBC   #$0003
         BVS   L0B14B0
         EOR   #$8000
L0B14B0  BPL   L0B14B5
         BRL   L0B1602
L0B14B5  LDA   $E9
         AND   #$00FF
         BRL   L0B1502
L0B14BD  PEA   $0007
         PEI   $F2
         JSL   L110377
         PLY
         PLY
         BRL   L0B150F
L0B14CB  PEA   $000F
         PEI   $F2
         JSL   L110377
         PLY
         PLY
         BRL   L0B150F
L0B14D9  PEA   $000B
         PEI   $F2
         JSL   L110377
         PLY
         PLY
         BRL   L0B150F
L0B14E7  PEA   $0003
         PEI   $F2
         JSL   L110377
         PLY
         PLY
         BRL   L0B150F
L0B14F5  BRL   L0B150F
L0B14F8  DA    L0B14BD
         DA    L0B14D9
         DA    L0B14CB
         DA    L0B14E7
         DA    L0B14F5
L0B1502  CMP   #$0004
         BCC   L0B150A
         LDA   #$0004
L0B150A  ASL
         TAX
         JMP   (L0B14F8,X)

L0B150F  PEI   $F2
         JSL   L1221E5
         PLY
         SEP   #$20
         STA   $F4
         REP   #$20
         LDA   $F4
         AND   #$00FF
         CMP   #$000C
         BEQ   L0B1578
         LDA   $F4
         AND   #$00FF
         ASL
         ASL
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   #L0304DA
         LDX   #^L0304DA
         JSL   L010410
         PLA
         PLX
         STA   $F6
         STX   $F8
         LDY   #$0002
         LDA   [$F6],Y
         BEQ   L0B1578
         LDA   $F4
         AND   #$00FF
         PHA
         LDA   #$001A
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L03059A
         LDX   #^L03059A
         JSL   L010410
         PLA
         PLX
         STA   $F6
         STX   $F8
         LDY   #$000A
         LDA   [$F6],Y
         CMP   #$000E
         BNE   L0B1590
L0B1578  LDA   #$0001
         SEP   #$20
         STA   $EB
         REP   #$20
         LDA   $F4
         AND   #$00FF
         CMP   #$000C
         BEQ   L0B1590
         LDA   L02004E
         STA   $F2
L0B1590  SEP   #$20
         STZ   $E9
         REP   #$20
         LDA   $EB
         AND   #$00FF
         BNE   L0B1600
         LDA   $F4
         AND   #$00FF
         STA   $F2
         LDA   $F2
         ASL
         ASL
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   #L0304DA
         LDX   #^L0304DA
         JSL   L010410
         PLA
         PLX
         STA   $F6
         STX   $F8
         LDA   [$F6]
         SEC
         SBC   #$0003
         BVS   L0B15C9
         EOR   #$8000
L0B15C9  BPL   L0B15D6
         LDA   #$0001
         SEP   #$20
         STA   $EC
         REP   #$20
         BRA   L0B1600
L0B15D6  LDA   $F2
         ASL
         ASL
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   #L0304DA
         LDX   #^L0304DA
         JSL   L010410
         PLA
         PLX
         STA   $F6
         STX   $F8
         LDA   [$F6]
         CMP   #$0002
         BNE   L0B1600
         LDA   #$0001
         SEP   #$20
         STA   $EB
         REP   #$20
L0B1600  BRA   L0B1645
L0B1602  LDA   L02004E
         STA   $F2
         PEA   $00B4
         JSL   L0405F2
         PLY
         PEA   $0000
         PEA   ^L031622
         PEA   L031622
         JSL   L040732
         PLY
         PLY
         PLY
         PEA   $0080
         PEA   $00E0
         PEA   $0032
         PEA   $0058
         JSL   L11019F
         PLY
         PLY
         PLY
         PLY
         LDA   #$0003
         SEP   #$20
         STA   $E9
         REP   #$20
         LDA   #$0001
         SEP   #$20
         STA   $EB
         REP   #$20
L0B1645  LDA   L020045
         AND   #$00FF
         BEQ   L0B1650
         BRL   L0B0C83
L0B1650  JSL   L10026A
         LDA   #$0003
         STA   $F0
         BRA   L0B1664
L0B165B  PEI   $F0
         JSL   L0800E0
         PLY
         INC   $F0
L0B1664  LDA   $F0
         SEC
         SBC   #$0006
         BVS   L0B166F
         EOR   #$8000
L0B166F  BPL   L0B165B
L0B1671  LDA   L0200A8
         AND   #$00FF
         CMP   #$000D
         BEQ   L0B1687
         LDA   L0200A8
         AND   #$00FF
         CMP   #$0020
         BNE   L0B1689
L0B1687  BRA   L0B1671
L0B1689  JSL   L0B058B
L0B168D  LDA   L0200A8
         SEP   #$20
         STA   $ED
         REP   #$20
         LDA   $ED
         AND   #$00FF
         CMP   #$000D
         BEQ   L0B16AA
         LDA   $ED
         AND   #$00FF
         CMP   #$0020
         BNE   L0B168D
L0B16AA  PEA   $0001
         LDX   L0200A6
         LDA   L0200A4
         PHX
         PHA
         LDX   L0200E8
         LDA   L0200E6
         PHX
         PHA
         JSL   L150060
         PLY
         PLY
         PLY
         PLY
         PLY
         JSL   L070062
         LDA   #$FFFF
         STA   $DF
         LDA   $ED
         AND   #$00FF
         CMP   #$000D
         BNE   L0B16E1
         LDA   #$0001
         STA   L020018
         BRA   L0B16E7
L0B16E1  LDA   #$0002
         STA   L020018
L0B16E7  LDA   $DF
         BEQ   L0B1671
L0B16EB  LDA   L020027
         AND   #$00FF
         BNE   L0B16FD
         LDA   L020029
         AND   #$00FF
         BEQ   L0B16FD
         BRA   L0B16EB
L0B16FD  JSL   L04042E
         JSL   L040635
         JSL   L160886
         PEA   $2710
         JSL   L140D0A
         PLY
         PEA   $0001
         LDX   L0200A6
         LDA   L0200A4
         PHX
         PHA
         LDX   L0200E8
         LDA   L0200E6
         PHX
         PHA
         JSL   L150060
         PLY
         PLY
         PLY
         PLY
         PLY
         JSL   L070062
         TSC
         CLC
         ADC   #$001F
         TCS
         PLD
         RTL

