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

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

	 use	FNAPRO22.X.S
	 
*-----------------------

	use	4/Locator.Macs
	use	4/Mem.Macs
	use	4/Misc.Macs
	use	4/Util.Macs
	
*-----------------------

L0A0000  ENT
         PHD
         TSC
         SEC
         SBC   #$00F7
         TCD
         ADC   #$00EE
         TCS
         LDY   #$0002
         LDA   [$FD],Y
         PHA
         JSL   L090E0F
         PLY
         STA   $F0
         LDA   $F0
         CMP   #$8000
         BEQ   L0A003F
         PEA   $0000
         PEI   $F0
         JSL   L0804EF
         PLY
         PLY
         LDA   $F0
         LDY   #$0010
         STA   [$FD],Y
         LDA   #$003A
         STA   L020153
         LDA   #$0000
         LDY   #$0018
         STA   [$FD],Y
L0A003F  TSC
         CLC
         ADC   #$0008
         TCS
         PLD
         RTL

L0A0047  ENT
         PHD
         TSC
         SEC
         SBC   #$00F9
         TCD
         ADC   #$00F0
         TCS
         LDA   #$0008
         PHA
         LDA   $FF
         SEC
         JSL   L010E20
         PLY
         STA   $F2
         LDA   $F2
         SEC
         SBC   #$0090
         BEQ   L0A006F
         BVS   L0A006D
         EOR   #$8000
L0A006D  BMI   L0A0080
L0A006F  LDA   #$00F9
         SEC
         SBC   $F2
         STA   L020155
         LDA   #$00A2
         STA   L020157
         BRA   L0A00D9
L0A0080  LDA   $F2
         SEC
         SBC   #$0100
         BEQ   L0A008F
         BVS   L0A008D
         EOR   #$8000
L0A008D  BMI   L0A00AA
L0A008F  LDA   #$0069
         STA   L020155
         LDA   $F2
         SEC
         SBC   #$0090
         PHA
         LDA   #$00A2
         PLX
         STX   $F8
         SEC
         SBC   $F8
         STA   L020157
         BRA   L0A00D9
L0A00AA  LDA   $F2
         SEC
         SBC   #$0190
         BEQ   L0A00B9
         BVS   L0A00B7
         EOR   #$8000
L0A00B7  BMI   L0A00D4
L0A00B9  LDA   $F2
         SEC
         SBC   #$0100
         PHA
         LDA   #$0069
         PLX
         STX   $F8
         CLC
         ADC   $F8
         STA   L020155
         LDA   #$0032
         STA   L020157
         BRA   L0A00D9
L0A00D4  LDA   #$0000
         BRA   L0A00DC
L0A00D9  LDA   #$0001
L0A00DC  TAY
         TSC
         CLC
         ADC   #$0008
         TCS
         TYA
         PLD
         RTL

L0A00E6  PHD
         TSC
         SEC
         SBC   #$00F9
         TCD
         ADC   #$00F1
         TCS
         JSL   L100099
         AND   #$0080
         TAY
         BEQ   L0A0100
         LDA   #$001B
         BRA   L0A0158
L0A0100  LDA   L0200B6
         AND   #$00FF
         PHA
         JSL   L050AA9
         PLY
         SEP   #$20
         STA   $F3
         REP   #$20
         LDA   $F3
         AND   #$00FF
         CMP   #$001B
         BEQ   L0A0144
         LDA   $F3
         AND   #$00FF
         CMP   #$00C9
         BEQ   L0A0144
         LDA   $F3
         AND   #$00FF
         CMP   #$00CA
         BEQ   L0A0144
         LDA   $F3
         AND   #$00FF
         CMP   #$00CB
         BEQ   L0A0144
         LDA   $F3
         AND   #$00FF
         CMP   #$000D
         BNE   L0A0155
L0A0144  LDA   $F3
         AND   #$00FF
         SEC
         SBC   #$00C9
         CMP   $FF
         BEQ   L0A0155
         LDA   $F3
         BRA   L0A0158
L0A0155  LDA   #$0000
L0A0158  TAY
         TSC
         CLC
         ADC   #$0007
         TCS
         TYA
         PLD
         RTL

L0A0162  PHD
         TSC
         SEC
         SBC   #$00F1
         TCD
         ADC   #$00DF
         TCS
         LDA   L0200B6
         AND   #$00FF
         PHA
         JSL   L050AA9
         PLY
         SEP   #$20
         STA   $E1
         REP   #$20
         LDY   #$0008
         LDA   [$F7],Y
         PHA
         JSL   L0A0047
         PLY
         TAY
         BNE   L0A0190
         BRL   L0A0417
L0A0190  LDY   #$0014
         LDA   [$F7],Y
         BEQ   L0A01AE
         LDA   $FB
         CLC
         ADC   #$0001
         PHA
         PEA   $0001
         PEA   $0001
         JSL   L090BBC
         PLY
         PLY
         PLY
         BRL   L0A0417
L0A01AE  PEA   $0000
         PEA   $0000
         PEA   $0001
         JSL   L090BBC
         PLY
         PLY
         PLY
         STZ   $E6
         LDA   #L033753
         LDX   #^L033753
         STX   $EA
         STA   $E8
         PEA   $0020
         PEA   $0000
         LDX   L02013D
         LDA   L02013B
         PHX
         PHA
         LDA   L020157
         SEC
         SBC   #$0020
         PHA
         LDX   L0200B4
         LDA   L0200B2
         PHX
         PHA
         JSL   L1007BF
         TAY
         TSC
         CLC
         ADC   #$000E
         TCS
         TYA
         LDA   #$0001
         PHA
         LDA   L020155
         SEC
         JSL   L011179
         LDA   L020157
         SEC
         SBC   #$0020
         LDX   #$0000
         TAY
         BPL   L0A020E
         DEX
L0A020E  STX   $F0
         ASL
         ROL   $F0
         LDX   $F0
         PHX
         PHA
         LDA   #L033ED8
         LDX   #^L033ED8
         JSL   L010E15
         PLA
         PLX
         STA   $EC
         STX   $EE
         LDA   [$EC]
         PLX
         STX   $F0
         CLC
         ADC   $F0
         SEC
         SBC   #$000C
         STA   $E2
         PEA   $003C
         PEA   $0020
         LDA   #$0001
         PHA
         LDA   L020155
         SEC
         JSL   L011179
         PLA
         LDX   #$0000
         TAY
         BPL   L0A024F
         DEX
L0A024F  PHX
         PHA
         LDX   L02013D
         LDA   L02013B
         JSL   L010E15
         PLA
         PLX
         SEC
         SBC   #$000C
         PHA
         TXA
         SBC   #$0000
         TAX
         PLA
         PHX
         PHA
         LDA   $E2
         LDX   #$0000
         TAY
         BPL   L0A0273
         DEX
L0A0273  PHX
         PHA
         LDX   L0200B4
         LDA   L0200B2
         JSL   L010E15
         JSL   L0F0B88
         TAY
         TSC
         CLC
         ADC   #$000C
         TCS
         TYA
L0A028B  STZ   $E4
         BRL   L0A039C
L0A0290  LDAL  L033DCF
         TAX
         LDAL  L033DCD
         PHX
         PHA
         LDX   L0200B4
         LDA   L0200B2
         PHX
         PHA
         LDA   L020157
         PHA
         LDA   L020155
         PHA
         LDA   $E6
         LDX   #$0000
         TAY
         BPL   L0A02B4
         DEX
L0A02B4  STX   $F0
         ASL
         ROL   $F0
         LDX   $F0
         PHX
         PHA
         LDX   $EA
         LDA   $E8
         JSL   L010E15
         PLA
         PLX
         STA   $EC
         STX   $EE
         LDA   [$EC]
         PHA
         JSL   L0F06F8
         TAY
         TSC
         CLC
         ADC   #$000E
         TCS
         TYA
         PEI   $FF
         PEI   $FD
         PEA   ^L030609
         PEA   L030609
         LDX   L0200B4
         LDA   L0200B2
         PHX
         PHA
         LDA   L020157
         SEC
         SBC   #$0008
         PHA
         LDA   L020155
         SEC
         SBC   #$0018
         PHA
         JSL   L0F0421
         TAY
         TSC
         CLC
         ADC   #$0010
         TCS
         TYA
         PEA   $003C
         PEA   $0020
         LDA   $E2
         LDX   #$0000
         TAY
         BPL   L0A0317
         DEX
L0A0317  PHX
         PHA
         LDX   #$00E1
         LDA   #$2000
         JSL   L010E15
         LDA   $E2
         LDX   #$0000
         TAY
         BPL   L0A032C
         DEX
L0A032C  PHX
         PHA
         LDX   L0200B4
         LDA   L0200B2
         JSL   L010E15
         JSL   L0F0B88
         TAY
         TSC
         CLC
         ADC   #$000C
         TCS
         TYA
         PEA   $003C
         PEA   $0020
         LDA   $E2
         LDX   #$0000
         TAY
         BPL   L0A0353
         DEX
L0A0353  PHX
         PHA
         LDX   L0200B4
         LDA   L0200B2
         JSL   L010E15
         LDA   #$0001
         PHA
         LDA   L020155
         SEC
         JSL   L011179
         PLA
         LDX   #$0000
         TAY
         BPL   L0A0373
         DEX
L0A0373  PHX
         PHA
         LDX   L02013D
         LDA   L02013B
         JSL   L010E15
         PLA
         PLX
         SEC
         SBC   #$000C
         PHA
         TXA
         SBC   #$0000
         TAX
         PLA
         PHX
         PHA
         JSL   L0F0B88
         TAY
         TSC
         CLC
         ADC   #$000C
         TCS
         TYA
         INC   $E4
L0A039C  LDA   $E4
         SEC
         SBC   #$0002
         BVS   L0A03A7
         EOR   #$8000
L0A03A7  BMI   L0A03AC
         BRL   L0A0290
L0A03AC  INC   $E6
         LDA   $E6
         LDX   #$0000
         TAY
         BPL   L0A03B7
         DEX
L0A03B7  STX   $F0
         ASL
         ROL   $F0
         LDX   $F0
         PHX
         PHA
         LDX   $EA
         LDA   $E8
         JSL   L010E15
         PLA
         PLX
         STA   $EC
         STX   $EE
         LDA   [$EC]
         AND   #$8000
         TAY
         BNE   L0A03EB
         PEI   $FB
         JSL   L0A00E6
         PLY
         SEP   #$20
         STA   $E1
         REP   #$20
         AND   #$00FF
         BNE   L0A03EB
         BRL   L0A028B
L0A03EB  PEA   $0020
         LDA   L020157
         SEC
         SBC   #$0020
         PHA
         PEA   $00E1
         PEA   $2000
         PEA   $0000
         LDX   L02013D
         LDA   L02013B
         PHX
         PHA
         JSL   L1007BF
         TAY
         TSC
         CLC
         ADC   #$000E
         TCS
         TYA
         JSL   L0B0DAB
L0A0417  LDA   $E1
         TAY
         TSC
         CLC
         ADC   #$0011
         TCS
         TYA
         PLD
         RTL

L0A0423  PHD
         TSC
         SEC
         SBC   #$00F1
         TCD
         ADC   #$00D7
         TCS
         LDA   L0200B6
         AND   #$00FF
         PHA
         JSL   L050AA9
         PLY
         SEP   #$20
         STA   $D9
         REP   #$20
         LDY   #$0008
         LDA   [$F7],Y
         PHA
         JSL   L0A0047
         PLY
         TAY
         BNE   L0A0451
         BRL   L0A06AE
L0A0451  PEA   $0000
         PEA   $0000
         PEA   $0000
         JSL   L090BBC
         PLY
         PLY
         PLY
         STZ   $E2
         LDA   #L033771
         LDX   #^L033771
         STX   $EA
         STA   $E8
         LDA   L020155
         SEC
         SBC   #$00A0
         BEQ   L0A0482
         BVS   L0A047B
         EOR   #$8000
L0A047B  BPL   L0A0482
         LDA   #$0000
         BRA   L0A0485
L0A0482  LDA   #$0001
L0A0485  STA   $DC
         LDA   #L033783
         LDX   #^L033783
         STX   $E6
         STA   $E4
L0A0491  LDA   $DC
         BEQ   L0A0499
         LDA   [$E4]
         BRA   L0A049F
L0A0499  LDA   [$E4]
         EOR   #$FFFF
         INC
L0A049F  PHA
         LDA   L020155
         PLX
         STX   $F0
         CLC
         ADC   $F0
         STA   L020155
         LDY   #$0002
         LDA   [$E4],Y
         PHA
         LDA   L020157
         PLX
         STX   $F0
         CLC
         ADC   $F0
         STA   L020157
         LDY   #$0004
         LDA   [$E4],Y
         CMP   #$8000
         BEQ   L0A04DB
         LDX   $E6
         LDA   $E4
         CLC
         ADC   #$0004
         PHA
         TXA
         ADC   #$0000
         TAX
         PLA
         STX   $E6
         STA   $E4
L0A04DB  LDA   L020157
         SEC
         SBC   #$0028
         SEC
         SBC   #$0000
         BEQ   L0A04F8
         BVS   L0A04ED
         EOR   #$8000
L0A04ED  BPL   L0A04F8
         LDA   L020157
         SEC
         SBC   #$0028
         BRA   L0A04FB
L0A04F8  LDA   #$0000
L0A04FB  STA   $DA
         PEA   $0030
         PEA   $0000
         LDX   L02013D
         LDA   L02013B
         PHX
         PHA
         PEI   $DA
         LDX   L0200B4
         LDA   L0200B2
         PHX
         PHA
         JSL   L1007BF
         TAY
         TSC
         CLC
         ADC   #$000E
         TCS
         TYA
         STZ   $DE
         BRL   L0A064F
L0A0526  LDA   $E2
         LDX   #$0000
         TAY
         BPL   L0A052F
         DEX
L0A052F  STX   $F0
         ASL
         ROL   $F0
         LDX   $F0
         PHX
         PHA
         LDX   $EA
         LDA   $E8
         JSL   L010E15
         PLA
         PLX
         STA   $EC
         STX   $EE
         LDA   [$EC]
         CMP   #$8000
         BNE   L0A054F
         STZ   $E2
L0A054F  LDA   L020157
         BNE   L0A0557
         BRL   L0A05F5
L0A0557  LDA   $DC
         BEQ   L0A05A7
         LDAL  L033DCF
         TAX
         LDAL  L033DCD
         PHX
         PHA
         LDX   L0200B4
         LDA   L0200B2
         PHX
         PHA
         LDA   L020157
         PHA
         LDA   L020155
         PHA
         LDA   $E2
         LDX   #$0000
         TAY
         BPL   L0A057F
         DEX
L0A057F  STX   $F0
         ASL
         ROL   $F0
         LDX   $F0
         PHX
         PHA
         LDX   $EA
         LDA   $E8
         JSL   L010E15
         PLA
         PLX
         STA   $EC
         STX   $EE
         LDA   [$EC]
         PHA
         JSL   L0F06F8
         TAY
         TSC
         CLC
         ADC   #$000E
         TCS
         TYA
         BRA   L0A05F5
L0A05A7  LDAL  L033DCF
         TAX
         LDAL  L033DCD
         PHX
         PHA
         LDX   L0200B4
         LDA   L0200B2
         PHX
         PHA
         LDA   L020157
         PHA
         LDA   L020155
         PHA
         LDA   $E2
         LDX   #$0000
         TAY
         BPL   L0A05CB
         DEX
L0A05CB  STX   $F0
         ASL
         ROL   $F0
         LDX   $F0
         PHX
         PHA
         LDX   $EA
         LDA   $E8
         JSL   L010E15
         PLA
         PLX
         STA   $EC
         STX   $EE
         LDA   [$EC]
         CLC
         ADC   #$8000
         PHA
         JSL   L0F06F8
         TAY
         TSC
         CLC
         ADC   #$000E
         TCS
         TYA
L0A05F5  PEI   $FF
         PEI   $FD
         PEA   ^L030614
         PEA   L030614
         LDX   L0200B4
         LDA   L0200B2
         PHX
         PHA
         LDA   L020157
         SEC
         SBC   #$0008
         PHA
         LDA   L020155
         SEC
         SBC   #$0018
         PHA
         JSL   L0F0421
         TAY
         TSC
         CLC
         ADC   #$0010
         TCS
         TYA
         JSL   L0E0062
         PEA   $0030
         PEI   $DA
         LDX   L0200B4
         LDA   L0200B2
         PHX
         PHA
         PEA   $0000
         LDX   L02013D
         LDA   L02013B
         PHX
         PHA
         JSL   L1007BF
         TAY
         TSC
         CLC
         ADC   #$000E
         TCS
         TYA
         INC   $E2
         INC   $DE
L0A064F  LDA   $DE
         SEC
         SBC   #$0002
         BVS   L0A065A
         EOR   #$8000
L0A065A  BMI   L0A065F
         BRL   L0A0526
L0A065F  LDA   L020157
         SEC
         SBC   #$0000
         BVS   L0A066B
         EOR   #$8000
L0A066B  BPL   L0A0682
         PEI   $FB
         JSL   L0A00E6
         PLY
         SEP   #$20
         STA   $D9
         REP   #$20
         AND   #$00FF
         BNE   L0A0682
         BRL   L0A0491
L0A0682  JSL   L0E0062
         PEA   $0030
         PEI   $DA
         LDX   L0200B4
         LDA   L0200B2
         PHX
         PHA
         PEA   $0000
         LDX   L02013D
         LDA   L02013B
         PHX
         PHA
         JSL   L1007BF
         TAY
         TSC
         CLC
         ADC   #$000E
         TCS
         TYA
         JSL   L0B0DAB
L0A06AE  LDA   $D9
         TAY
         TSC
         CLC
         ADC   #$0019
         TCS
         TYA
         PLD
         RTL

L0A06BA  PHD
         TSC
         SEC
         SBC   #$00FB
         TCD
         ADC   #$00F4
         TCS
         LDX   L020099+2
         LDA   L020099
         STA   $F6
         STX   $F8
         LDX   L020119+2
         LDA   L020119
         LDY   #$0002
         PHA
         TXA
         STA   [$F6],Y
         PLA
         STA   [$F6]
         TSC
         CLC
         ADC   #$0006
         TCS
         PLD
         RTL

L0A06E7  PHD
         TSC
         SEC
         SBC   #$00F9
         TCD
         ADC   #$00DE
         TCS
         STZ   $E0
         PEA   ^L07062C
         PEA   L07062C
         JSL   L0E01B6
         PLY
         PLY
         LDX   L020117
         LDA   L020115
         STX   $E5
         STA   $E3
         LDA   L0200FC
         BNE   L0A0712
         BRL   L0A0795
L0A0712  STZ   L0200FC
         PEA   $0000
         PEA   $0000
         PEA   $000D
         PEA   $000B
         PEA   $0000
         PEA   ^L03385F
         PEA   L03385F
         JSL   L090000
         TAY
         TSC
         CLC
         ADC   #$000E
         TCS
         TYA
         JSL   L0905D6
         LDA   #$0001
         STA   L02015D
         SEP   #$20
         STZ   $E2
         REP   #$20
L0A0746  PEA   $000D
         PEA   $000B
         PEA   $0002
         PEA   $0003
         PEA   $000C
         PEA   $000D
         PEA   $000D
         PEA   $000A
         JSL   L0C03ED
         TAY
         TSC
         CLC
         ADC   #$0010
         TCS
         TYA
         JSL   L0C0922
         SEP   #$20
         STA   $E2
         REP   #$20
         LDA   $E2
         AND   #$00FF
         BEQ   L0A0746
         STZ   $FF
         LDA   $FF
         CLC
         ADC   #$0001
         PHA
         PEA   $0001
         PEA   $0001
         JSL   L090BBC
         PLY
         PLY
         PLY
         STZ   $E3
         STZ   $E5
L0A0795  JSL   L0903EE
         STA   $EC
         LDA   $FF
         CLC
         ADC   #$00C9
         SEP   #$20
         STA   $E7
         REP   #$20
L0A07A7  LDA   $E7
         AND   #$00FF
         SEC
         SBC   #$00C9
         SEC
         SBC   #$0000
         BVS   L0A07B9
         EOR   #$8000
L0A07B9  BMI   L0A07BE
         BRL   L0A0854
L0A07BE  LDA   $E7
         AND   #$00FF
         SEC
         SBC   #$00C9
         SEC
         SBC   #$0002
         BEQ   L0A07D7
         BVS   L0A07D2
         EOR   #$8000
L0A07D2  BPL   L0A07D7
         BRL   L0A0854
L0A07D7  LDA   $E7
         AND   #$00FF
         SEC
         SBC   #$00C9
         LDX   #$0000
         TAY
         BPL   L0A07E7
         DEX
L0A07E7  PEA   $0000
         PEA   $001C
         CLC
         JSL   L010FF0
         LDA   #L032787
         LDX   #^L032787
         JSL   L010E15
         PLA
         PLX
         STX   $F2
         STA   $F0
         LDA   $E7
         AND   #$00FF
         SEC
         SBC   #$00C9
         LDX   #$0000
         TAY
         BPL   L0A0812
         DEX
L0A0812  STX   $F8
         ASL
         ROL   $F8
         ASL
         ROL   $F8
         LDX   $F8
         PHX
         PHA
         LDA   #L033C10
         LDX   #^L033C10
         JSL   L010E15
         PLA
         PLX
         STA   $F4
         STX   $F6
         LDY   #$0002
         LDA   [$F4],Y
         TAX
         LDA   [$F4]
         STX   $EA
         STA   $E8
         LDA   $E7
         AND   #$00FF
         SEC
         SBC   #$00C9
         STA   $FF
         PEI   $FF
         PEI   $F2
         PEI   $F0
         JSL   L0908C3
         PLY
         PLY
         PLY
         BRA   L0A08A9
L0A0854  LDA   $FF
         LDX   #$0000
         TAY
         BPL   L0A085D
         DEX
L0A085D  PEA   $0000
         PEA   $001C
         CLC
         JSL   L010FF0
         LDA   #L032787
         LDX   #^L032787
         JSL   L010E15
         PLA
         PLX
         STX   $F2
         STA   $F0
         LDA   $FF
         LDX   #$0000
         TAY
         BPL   L0A0881
         DEX
L0A0881  STX   $F8
         ASL
         ROL   $F8
         ASL
         ROL   $F8
         LDX   $F8
         PHX
         PHA
         LDA   #L033C10
         LDX   #^L033C10
         JSL   L010E15
         PLA
         PLX
         STA   $F4
         STX   $F6
         LDY   #$0002
         LDA   [$F4],Y
         TAX
         LDA   [$F4]
         STX   $EA
         STA   $E8
L0A08A9  LDY   #$0012
         LDA   [$F0],Y
         BEQ   L0A08CB
         PEI   $EA
         PEI   $E8
         PEI   $FF
         PEI   $F2
         PEI   $F0
         JSL   L0A0162
         PLY
         PLY
         PLY
         PLY
         PLY
         SEP   #$20
         STA   $E7
         REP   #$20
         BRA   L0A08E4
L0A08CB  PEI   $EA
         PEI   $E8
         PEI   $FF
         PEI   $F2
         PEI   $F0
         JSL   L0A0423
         PLY
         PLY
         PLY
         PLY
         PLY
         SEP   #$20
         STA   $E7
         REP   #$20
L0A08E4  LDA   $E7
         AND   #$00FF
         SEC
         SBC   #$00C9
         CMP   $FF
         BEQ   L0A0918
         LDA   $E7
         AND   #$00FF
         CMP   #$00C9
         BNE   L0A08FE
         BRL   L0A07A7
L0A08FE  LDA   $E7
         AND   #$00FF
         CMP   #$00CA
         BNE   L0A090B
         BRL   L0A07A7
L0A090B  LDA   $E7
         AND   #$00FF
         CMP   #$00CB
         BNE   L0A0918
         BRL   L0A07A7
L0A0918  LDA   $E0
         BEQ   L0A091F
         BRL   L0A0A8F
L0A091F  LDA   $EC
         BNE   L0A0926
         BRL   L0A0A8F
L0A0926  SEP   #$20
         STZ   L0200B6
         REP   #$20
         SEP   #$20
         STZ   L0200B8
         REP   #$20
         PEA   $0003
         PEA   $0000
         PEA   $000D
         PEA   $000B
         PEA   $0000
         LDA   $EC
         SEC
         SBC   #$0001
         LDX   #$0000
         TAY
         BPL   L0A0950
         DEX
L0A0950  STX   $F8
         ASL
         ROL   $F8
         ASL
         ROL   $F8
         LDX   $F8
         PHX
         PHA
         LDA   #L033BE8
         LDX   #^L033BE8
         JSL   L010E15
         PLA
         PLX
         STA   $F4
         STX   $F6
         LDY   #$0002
         LDA   [$F4],Y
         TAX
         LDA   [$F4]
         PHX
         PHA
         JSL   L090000
         TAY
         TSC
         CLC
         ADC   #$000E
         TCS
         TYA
         SEP   #$20
         STA   $E7
         REP   #$20
         LDA   $EC
         CMP   #$0001
         BNE   L0A09AB
         LDA   $E7
         AND   #$00FF
         CMP   #$0052
         BEQ   L0A09A3
         LDA   $E7
         AND   #$00FF
         CMP   #$0072
         BNE   L0A09AB
L0A09A3  LDA   #$0001
         STA   $E0
         BRL   L0A0A8F
L0A09AB  LDA   $EC
         CMP   #$0002
         BEQ   L0A09C9
         LDA   $EC
         CMP   #$0001
         BEQ   L0A09BC
         BRL   L0A0A4D
L0A09BC  LDA   $E7
         AND   #$00FF
         CMP   #$0020
         BEQ   L0A09C9
         BRL   L0A0A4D
L0A09C9  STZ   $EC
         JSL   L0905D6
         LDA   #$0001
         STA   L02015D
         SEP   #$20
         STZ   $E2
         REP   #$20
L0A09DB  PEA   $000D
         PEA   $000B
         PEA   $0002
         PEA   $0003
         PEA   $000E
         PEA   $000D
         PEA   $000D
         PEA   $000A
         JSL   L0C03ED
         TAY
         TSC
         CLC
         ADC   #$0010
         TCS
         TYA
         JSL   L0C0922
         SEP   #$20
         STA   $E2
         REP   #$20
         LDA   $E2
         AND   #$00FF
         BEQ   L0A09DB
         STZ   $FF
         LDA   $FF
         CLC
         ADC   #$0001
         PHA
         PEA   $0001
         PEA   $0001
         JSL   L090BBC
         PLY
         PLY
         PLY
         PEA   $0005
         PEA   $0000
         PEA   $000D
         PEA   $000B
         PEA   $0000
         PEA   ^L03091F
         PEA   L03091F
         JSL   L090000
         TAY
         TSC
         CLC
         ADC   #$000E
         TCS
         TYA
         STZ   $E3
         STZ   $E5
         BRA   L0A0A8F
L0A0A4D  LDA   $E7
         AND   #$00FF
         CMP   #$000D
         BNE   L0A0A8F
         STZ   $EC
         LDA   #$0001
         STA   L020108
         LDA   L020121
         PHA
         LDA   #$003C
         CLC
         JSL   L010FAB
         PLA
         CLC
         ADC   L020123
         PHA
         LDA   #$003C
         CLC
         JSL   L010FAB
         PLA
         LDX   #$0000
         STX   L02011B
         STA   L020119
         PEA   ^L0A06BA
         PEA   L0A06BA
         JSL   L0E01B6
         PLY
         PLY
L0A0A8F  LDA   $E7
         AND   #$00FF
         CMP   #$001B
         BEQ   L0A0AA3
         JSL   L100099
         AND   #$0080
         TAY
         BEQ   L0A0AAA
L0A0AA3  LDY   #$0012
         LDA   [$F0],Y
         BNE   L0A0AB2
L0A0AAA  LDA   L020108
         BNE   L0A0AB2
         BRL   L0A07A7
L0A0AB2  LDA   L020108
         BNE   L0A0ADA
         PEI   $FF
         PEI   $F2
         PEI   $F0
         JSL   L090A46
         PLY
         PLY
         PLY
         LDX   $E5
         LDA   $E3
         STX   L02011B
         STA   L020119
         PEA   ^L07067E
         PEA   L07067E
         JSL   L0E01B6
         PLY
         PLY
L0A0ADA  LDA   $FF
         TAY
         TSC
         CLC
         ADC   #$001A
         TCS
         TYA
         PLD
         RTL

L0A0AE6  PHD
         TSC
         SEC
         SBC   #$00FB
         TCD
         ADC   #$00EC
         TCS
         STZ   $F2
         STZ   $F4
         STZ   $F0
         BRL   L0A0BC7
L0A0AFA  STZ   $EE
         BRL   L0A0BB5
L0A0AFF  LDA   $EE
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   $F0
         LDX   #$0000
         TAY
         BPL   L0A0B10
         DEX
L0A0B10  PEA   $0000
         PEA   $000E
         CLC
         JSL   L010FF0
         LDA   #L032823
         LDX   #^L032823
         JSL   L010E15
         PLA
         PLX
         STA   $F6
         STX   $F8
         LDX   $F8
         LDA   #$0008
         CLC
         ADC   $F6
         BCC   L0A0B36
         INX
L0A0B36  JSL   L010E15
         PLA
         PLX
         STA   $F6
         STX   $F8
         LDA   [$F6]
         BEQ   L0A0BB3
         LDA   $EE
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   $F0
         LDX   #$0000
         TAY
         BPL   L0A0B55
         DEX
L0A0B55  PEA   $0000
         PEA   $000E
         CLC
         JSL   L010FF0
         LDA   #L032823
         LDX   #^L032823
         JSL   L010E15
         PLA
         PLX
         STA   $F6
         STX   $F8
         LDX   $F8
         LDA   #$0008
         CLC
         ADC   $F6
         BCC   L0A0B7B
         INX
L0A0B7B  JSL   L010E15
         PLA
         PLX
         STA   $F6
         STX   $F8
         LDA   [$F6]
         SEC
         SBC   #$0001
         PHA
         LDA   #$0004
         SEC
         JSL   L010FAB
         LDA   $F0
         CLC
         ADC   #$0001
         SEC
         JSL   L011142
         PLA
         LDX   #$0000
         PHX
         PHA
         LDX   $F4
         LDA   $F2
         JSL   L010EA5
         PLA
         PLX
         STX   $F4
         STA   $F2
L0A0BB3  INC   $EE
L0A0BB5  LDA   $EE
         SEC
         SBC   #$0003
         BVS   L0A0BC0
         EOR   #$8000
L0A0BC0  BMI   L0A0BC5
         BRL   L0A0AFF
L0A0BC5  INC   $F0
L0A0BC7  LDA   $F0
         SEC
         SBC   #$0003
         BVS   L0A0BD2
         EOR   #$8000
L0A0BD2  BMI   L0A0BD7
         BRL   L0A0AFA
L0A0BD7  LDX   $F4
         LDA   $F2
         AND   #$0FFF
         PHA
         TXA
         AND   #$0000
         TAX
         PLA
         STX   $F4
         STA   $F2
         LDX   #$0000
         LDA   #$000C
         PHX
         PHA
         LDA   L02010A
         LDX   #$0000
         CLC
         JSL   L011152
         PLA
         PLX
         AND   #$F000
         PHA
         TXA
         AND   #$0000
         TAX
         PLA
         PHX
         PHA
         LDX   $F4
         LDA   $F2
         JSL   L010EA5
         PLA
         PLX
         STX   $F4
         STA   $F2
         LDX   #$0000
         LDA   #$0010
         PHX
         PHA
         LDA   L0200A1
         LDX   #$0000
         CLC
         JSL   L011152
         PLA
         PLX
         AND   #$0000
         PHA
         TXA
         AND   #$000F
         TAX
         PLA
         PHX
         PHA
         LDX   $F4
         LDA   $F2
         JSL   L010EA5
         PLA
         PLX
         STX   $F4
         STA   $F2
         LDX   $F4
         LDA   $F2
         PHA
         TXA
         STAL  L030024
         PLA
         STAL  L030022
         LDX   L02009F
         LDA   L02009D
         PHA
         TXA
         STAL  L030028
         PLA
         STAL  L030026
         TSC
         CLC
         ADC   #$000E
         TCS
         PLD
         RTL

L0A0C6F  ENT
         PHD
         TSC
         SEC
         SBC   #$00FB
         TCD
         ADC   #$00F4
         TCS
         JSL   L0A0AE6
         TSC
         CLC
         ADC   #$0006
         TCS
         PLD
         RTL

L0A0C86  ENT
         PHD
         TSC
         SEC
         SBC   #$00F9
         TCD
         ADC   #$00F2
         TCS
         PEA   $00C8
         PEA   $0000
         LDX   L0200B4
         LDA   L0200B2
         PHX
         PHA
         PEA   $0000
         LDX   L020135
         LDA   L020133
         PHX
         PHA
         JSL   L1007BF
         TAY
         TSC
         CLC
         ADC   #$000E
         TCS
         TYA
         JSL   L070593
         LDA   L020108
         BNE   L0A0CC6
         STZ   L0200FE
         JSL   L070763
L0A0CC6  LDAL  L033DE7
         TAX
         LDAL  L033DE5
         PHX
         PHA
         LDX   L0200B4
         LDA   L0200B2
         PHX
         PHA
         PEA   $0030
         PEA   $0104
         PEA   $0009
         JSL   L0F06F8
         TAY
         TSC
         CLC
         ADC   #$000E
         TCS
         TYA
         LDA   $FF
         LDX   #$0000
         TAY
         BPL   L0A0CF7
         DEX
L0A0CF7  STX   $F8
         ASL
         ROL   $F8
         ASL
         ROL   $F8
         LDX   $F8
         PHX
         PHA
         LDA   #L033C10
         LDX   #^L033C10
         JSL   L010E15
         PLA
         PLX
         STA   $F4
         STX   $F6
         LDY   #$0002
         LDA   [$F4],Y
         TAX
         LDA   [$F4]
         PHX
         PHA
         PEA   ^L03061F
         PEA   L03061F
         LDX   L0200B4
         LDA   L0200B2
         PHX
         PHA
         PEA   $0021
         PEA   $010A
         JSL   L0F0421
         TAY
         TSC
         CLC
         ADC   #$0010
         TCS
         TYA
         LDA   $FF
         LDX   #$0000
         TAY
         BPL   L0A0D46
         DEX
L0A0D46  STX   $F8
         ASL
         ROL   $F8
         ASL
         ROL   $F8
         LDX   $F8
         PHX
         PHA
         LDA   #L033C10
         LDX   #^L033C10
         JSL   L010E15
         PLA
         PLX
         STA   $F4
         STX   $F6
         LDY   #$0002
         LDA   [$F4],Y
         TAX
         LDA   [$F4]
         PHX
         PHA
         PEA   ^L030627
         PEA   L030627
         LDX   L0200B4
         LDA   L0200B2
         PHX
         PHA
         PEA   $0022
         PEA   $0109
         JSL   L0F0421
         TAY
         TSC
         CLC
         ADC   #$0010
         TCS
         TYA
         PEA   $0010
         PEA   $0000
         PEA   $00E1
         PEA   $2000
         PEA   $0000
         LDX   L020135
         LDA   L020133
         PHX
         PHA
         JSL   L1007BF
         TAY
         TSC
         CLC
         ADC   #$000E
         TCS
         TYA
         PEA   $00B8
         PEA   $0010
         PEA   $00E1
         PEA   $2000
         PEA   $0010
         LDX   L0200B4
         LDA   L0200B2
         PHX
         PHA
         JSL   L1007BF
         TAY
         TSC
         CLC
         ADC   #$000E
         TCS
         TYA
         TSC
         CLC
         ADC   #$0006
         TCS
         PLD
         RTL

L0A0DDA  ENT
         PHD
         TSC
         SEC
         SBC   #$00F5
         TCD
         ADC   #$00EB
         TCS
         JSL   L100099
         AND   #$0080
         TAY
         BNE   L0A0DFD
         LDA   L0200B6
         AND   #$00FF
         CMP   #$001B
         BEQ   L0A0DFD
         BRL   L0A0EA2
L0A0DFD  SEP   #$20
         STZ   L0200B6
         REP   #$20
         SEP   #$20
         STZ   L0200B8
         REP   #$20
         PEI   $FF
         PEI   $FD
         PEI   $FB
         JSL   L0908C3
         PLY
         PLY
         PLY
         PEA   $0000
         PEA   $0000
         PEA   $0000
         JSL   L090BBC
         PLY
         PLY
         PLY
         LDA   L02015B
         BNE   L0A0E30
         BRL   L0A0E76
L0A0E30  PEA   $0005
         PEA   $0000
         PEA   $000D
         PEA   $000B
         PEA   $0000
         PEA   ^L03091F
         PEA   L03091F
         JSL   L090000
         TAY
         TSC
         CLC
         ADC   #$000E
         TCS
         TYA
         STZ   L020119
         STZ   L02011B
         PEA   ^L07067E
         PEA   L07067E
         JSL   L0E01B6
         PLY
         PLY
         PEA   $0000
         PEA   $0000
         PEA   $0000
         JSL   L090BBC
         PLY
         PLY
         PLY
         STZ   L02015B
L0A0E76  PEI   $FF
         JSL   L0A06E7
         PLY
         STA   $FF
L0A0E7F  JSL   L100099
         AND   #$0080
         TAY
         BNE   L0A0E94
         LDA   L0200B6
         AND   #$00FF
         CMP   #$001B
         BNE   L0A0E96
L0A0E94  BRA   L0A0E7F
L0A0E96  LDA   L020108
         BNE   L0A0EA2
         PEI   $FF
         JSL   L0A0C86
         PLY
L0A0EA2  LDA   $FF
         TAY
         TSC
         CLC
         ADC   #$0009
         TCS
         TYA
         PLD
         RTL

L0A0EAE  ENT
         PHD
         TSC
         SEC
         SBC   #$00F3
         TCD
         ADC   #$00DE
         TCS
         STZ   L02013F
         LDA   L02014D
         BEQ   L0A0EC4
         BRL   L0A0FA3
L0A0EC4  LDY   #$0008
         LDA   [$FB],Y
         PHA
         LDA   L020149
         ASL
         ASL
         ASL
         PHA
         LDA   #$0020
         PLX
         STX   $F2
         CLC
         ADC   $F2
         PLX
         STX   $EE
         SEC
         SBC   $EE
         BEQ   L0A0EF1
         BVS   L0A0EE7
         EOR   #$8000
L0A0EE7  BPL   L0A0EF1
         LDA   #$FFF4
         STA   L02014D
         BRA   L0A0F1A
L0A0EF1  LDY   #$0008
         LDA   [$FB],Y
         PHA
         LDA   L020149
         ASL
         ASL
         ASL
         PHA
         LDA   #$00C0
         PLX
         STX   $F2
         CLC
         ADC   $F2
         PLX
         STX   $EE
         SEC
         SBC   $EE
         BVS   L0A0F12
         EOR   #$8000
L0A0F12  BMI   L0A0F1A
         LDA   #$000C
         STA   L02014D
L0A0F1A  LDA   L02014D
         BNE   L0A0F22
         BRL   L0A0FA3
L0A0F22  LDA   #$FFFF
         STA   L02013F
         LDA   L020149
         CLC
         ADC   L02014D
         STA   L020149
         LDA   L020149
         SEC
         SBC   #$0000
         BVS   L0A0F3E
         EOR   #$8000
L0A0F3E  BMI   L0A0F49
         LDA   #$0001
         STA   L020141
         STZ   L020149
L0A0F49  LDA   L020149
         SEC
         SBC   #$016C
         BEQ   L0A0F65
         BVS   L0A0F57
         EOR   #$8000
L0A0F57  BPL   L0A0F65
         LDA   #$0001
         STA   L020141
         LDA   #$016C
         STA   L020149
L0A0F65  LDA   L02014D
         BEQ   L0A0FA0
         LDA   L02014D
         CLC
         ADC   #$000C
         LDX   #$0000
         TAY
         BPL   L0A0F78
         DEX
L0A0F78  STX   $F2
         ASL
         ROL   $F2
         LDX   $F2
         PHX
         PHA
         LDA   #L033C65
         LDX   #^L033C65
         JSL   L010E15
         PLA
         PLX
         STA   $EE
         STX   $F0
         LDA   [$EE]
         PHA
         LDA   L02014D
         PLX
         STX   $F2
         CLC
         ADC   $F2
         STA   L02014D
L0A0FA0  STZ   L02014D
L0A0FA3  LDA   L020149
         PHA
         LDA   #$0008
         SEC
         JSL   L010FAB
         LDY   #$0008
         LDA   [$FB],Y
         PLX
         STX   $F2
         SEC
         SBC   $F2
         LDY   #$000C
         STA   [$FB],Y
         LDY   #$000A
         LDA   [$FB],Y
         LDY   #$000E
         STA   [$FB],Y
         LDY   #$000C
         LDA   [$FB],Y
         STA   $E8
         LDY   #$000E
         LDA   [$FB],Y
         STA   $E6
         LDX   #$0000
         LDA   #$0001
         PHX
         PHA
         LDA   #$0001
         PHA
         LDA   L020149
         SEC
         JSL   L011179
         PLA
         LDX   #$0000
         TAY
         BPL   L0A0FF3
         DEX
L0A0FF3  SEC
         JSL   L011152
         LDX   #$0000
         LDA   #$0001
         PHX
         PHA
         LDA   L02014B
         PHA
         LDA   #$00C8
         SEC
         JSL   L010FAB
         PLA
         LDX   #$0000
         TAY
         BPL   L0A1014
         DEX
L0A1014  SEC
         JSL   L011152
         LDX   L020129
         LDA   L020127
         JSL   L010E15
         PLA
         PLX
         JSL   L010E15
         PLA
         PLX
         STX   L020131
         STA   L02012F
         LDA   L020149
         AND   #$FFFE
         PHA
         LDA   #$0008
         PHA
         LDA   $E8
         SEC
         SBC   #$0010
         SEC
         JSL   L010E20
         PLY
         PLX
         STX   $F2
         CLC
         ADC   $F2
         STA   $EC
         LDA   #$0010
         PHA
         LDA   $E6
         SEC
         SBC   #$0040
         SEC
         JSL   L010E20
         PLY
         CLC
         ADC   L02014B
         SEC
         SBC   #$0005
         STA   $EA
         LDA   $E6
         AND   #$000F
         TAY
         BEQ   L0A1074
         INC   $EA
L0A1074  LDA   $F9
         LDX   #$0000
         TAY
         BPL   L0A107D
         DEX
L0A107D  PEA   $0000
         PEA   $000C
         CLC
         JSL   L010FF0
         LDA   #L033DED
         LDX   #^L033DED
         JSL   L010E15
         PLA
         PLX
         STX   $E2
         STA   $E0
         LDX   #$0000
         LDA   #$0001
         PHX
         PHA
         LDA   #$0001
         PHA
         LDA   $EC
         SEC
         JSL   L011179
         PLA
         LDX   #$0000
         TAY
         BPL   L0A10B3
         DEX
L0A10B3  SEC
         JSL   L011152
         LDX   #$0000
         LDA   #$0001
         PHX
         PHA
         LDA   $EA
         PHA
         LDA   #$00C8
         SEC
         JSL   L010FAB
         PLA
         LDX   #$0000
         TAY
         BPL   L0A10D3
         DEX
L0A10D3  SEC
         JSL   L011152
         LDX   L020129
         LDA   L020127
         JSL   L010E15
         PLA
         PLX
         JSL   L010E15
         PLA
         PLX
         LDY   #$0002
         PHA
         TXA
         STA   [$E0],Y
         PLA
         STA   [$E0]
         LDA   $E8
         AND   #$FFF0
         LSR
         LDX   #$0000
         PHX
         PHA
         LDA   $EA
         CLC
         ADC   #$0004
         ASL
         ASL
         ASL
         ASL
         PHA
         LDA   #$00A0
         SEC
         JSL   L010FAB
         PLA
         LDX   #$0000
         TAY
         BPL   L0A111A
         DEX
L0A111A  PHX
         PHA
         LDX   L0200B4
         LDA   L0200B2
         JSL   L010E15
         PLA
         PLX
         JSL   L010E15
         PLA
         PLX
         LDY   #$0006
         PHA
         TXA
         STA   [$E0],Y
         PLA
         LDY   #$0004
         STA   [$E0],Y
         LDX   L0200B4
         LDA   L0200B2
         LDY   #$000A
         PHA
         TXA
         STA   [$E0],Y
         PLA
         LDY   #$0008
         STA   [$E0],Y
         LDA   L02013F
         BEQ   L0A117B
         LDA   $FF
         BEQ   L0A117B
         LDX   L020131
         LDA   L02012F
         PHX
         PHA
         LDA   #$0001
         PHA
         LDA   L020149
         SEC
         JSL   L011179
         JSL   L010DA8
         PLY
         PLY
         PLY
         STZ   L020104
         STZ   L02001F
         STZ   L020102
L0A117B  TSC
         CLC
         ADC   #$0014
         TCS
         PLD
         RTL

