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

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

	 use	INTP3.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
	
*-----------------------

L0E0000  ENT
         PHD
         TSC
         SEC
         SBC   #$00F9
         TCD
         ADC   #$00D8
         TCS
         PEA   $000A
         PEI   $FF
         JSL   L0D1030
         PLY
         PLY
         LDA   #L0316C4
         LDX   #^L0316C4
         STX   L020078
         STA   L020076
         LDA   #L0316D8
         LDX   #^L0316D8
         STX   L02007C
         STA   L02007A
         LDX   L020078
         LDA   L020076
         STA   $F4
         STX   $F6
         LDA   [$F4]
         CMP   #$FFFF
         BNE   L0E0042
         BRL   L0E0173
L0E0042  LDX   L020078
         LDA   L020076
         STA   $F4
         STX   $F6
         LDA   [$F4]
         CMP   L0200D5
         BNE   L0E005E
         LDA   L0200B8
         AND   #$00FF
         BNE   L0E005E
         BRL   L0E00B5
L0E005E  PEA   $0050
         LDX   L020078
         LDA   L020076
         STA   $F4
         STX   $F6
         LDY   #$0002
         LDA   [$F4],Y
         PHA
         LDX   L020078
         LDA   L020076
         STA   $F4
         STX   $F6
         LDA   [$F4]
         PHA
         JSL   L170184
         PLY
         PLY
         PLY
         LDA   L0200D5
         PHA
         LDA   #$0006
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L031782
         LDX   #^L031782
         JSL   L010410
         PLA
         PLX
         STA   $F4
         STX   $F6
         LDA   [$F4]
         AND   #$00FF
         CMP   #$0003
         BNE   L0E00B5
         JSL   L1705FF
L0E00B5  LDX   L020086
         LDA   L020084
         PHX
         PHA
         JSL   L070230
         PLY
         PLY
         LDA   L0200B4
         BNE   L0E00CB
         BRL   L0E0117
L0E00CB  LDA   L0200B9
         CMP   #$0006
         BNE   L0E00F2
         JSL   L160886
         LDA   #$0001
         STA   $EA
         BRA   L0E00E0
L0E00DE  INC   $EA
L0E00E0  LDA   $EA
         SEC
         SBC   #$000E
         BVS   L0E00EB
         EOR   #$8000
L0E00EB  BPL   L0E00DE
         STZ   L0200B9
         BRA   L0E0117
L0E00F2  LDA   L0200B9
         CMP   #$0008
         BNE   L0E0117
         JSL   L160886
         LDA   #$0001
         STA   $EA
         BRA   L0E0107
L0E0105  INC   $EA
L0E0107  LDA   $EA
         SEC
         SBC   #$000E
         BVS   L0E0112
         EOR   #$8000
L0E0112  BPL   L0E0105
         STZ   L0200B9
L0E0117  LDX   L0200BD
         LDA   L0200BB
         PHX
         PHA
         LDX   L020070
         LDA   L02006E
         PHX
         PHA
         PEA   $00B3
         PEA   $0050
         PEA   $0000
         JSL   L130695
         TAY
         TSC
         CLC
         ADC   #$000E
         TCS
         TYA
         LDX   L0200BD
         LDA   L0200BB
         PHX
         PHA
         LDX   L020070
         LDA   L02006E
         PHX
         PHA
         PEA   $00B2
         PEA   $0138
         PEA   $0001
         JSL   L130695
         TAY
         TSC
         CLC
         ADC   #$000E
         TCS
         TYA
         STZ   L0200B4
         LDX   L020078
         LDA   L020076
         STA   $F4
         STX   $F6
         LDA   #$FFFF
         STA   [$F4]
L0E0173  LDX   L0200A6
         LDA   L0200A4
         PHX
         PHA
         LDX   L020070
         LDA   L02006E
         PHX
         PHA
         JSL   L1607F3
         PLY
         PLY
         PLY
         PLY
         LDA   L0200B4
         BNE   L0E0197
         PEI   $FF
         JSL   L0C053B
         PLY
L0E0197  LDA   L02007E
         SEC
         SBC   #$0001
         STA   $EA
         BRL   L0E065E
L0E01A3  LDA   $EA
         LDX   #$0000
         TAY
         BPL   L0E01AC
         DEX
L0E01AC  STX   $F8
         ASL
         ROL   $F8
         LDX   $F8
         PHX
         PHA
         LDA   #L031700
         LDX   #^L031700
         JSL   L010410
         PLA
         PLX
         STA   $F4
         STX   $F6
         LDA   [$F4]
         PHA
         LDA   #$001A
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L03059A
         LDX   #^L03059A
         JSL   L010410
         PLA
         PLX
         STX   $E4
         STA   $E2
         LDA   $E2
         CLC
         ADC   #$000C
         LDX   $E4
         BCC   L0E01F1
         INX
L0E01F1  STX   $EE
         STA   $EC
         LDA   $E2
         CLC
         ADC   #$000A
         LDX   $E4
         BCC   L0E0200
         INX
L0E0200  STX   $F2
         STA   $F0
         LDA   [$F0]
         CMP   #$FFFF
         BNE   L0E020E
         BRL   L0E0656
L0E020E  LDA   [$F0]
         LDX   #$0000
         TAY
         BPL   L0E0217
         DEX
L0E0217  STX   $F8
         ASL
         ROL   $F8
         ASL
         ROL   $F8
         LDX   $F8
         PHX
         PHA
         LDA   #L030476
         LDX   #^L030476
         JSL   L010410
         PLA
         PLX
         STA   $F4
         STX   $F6
         LDY   #$0002
         LDA   [$F4],Y
         TAX
         LDA   [$F4]
         STX   $E8
         STA   $E6
         LDA   $EA
         LDX   #$0000
         TAY
         BPL   L0E0248
         DEX
L0E0248  STX   $F8
         ASL
         ROL   $F8
         LDX   $F8
         PHX
         PHA
         LDA   #L03170C
         LDX   #^L03170C
         JSL   L010410
         PLA
         PLX
         STA   $F4
         STX   $F6
         LDA   [$F4]
         BNE   L0E0268
         BRL   L0E0500
L0E0268  LDA   [$EC]
         LDX   #$0000
         TAY
         BPL   L0E0271
         DEX
L0E0271  PEA   $0000
         PEA   $0006
         CLC
         JSL   L0105E1
         LDX   $E8
         LDA   $E6
         JSL   L010410
         PLA
         PLX
         STA   $F4
         STX   $F6
         LDA   [$F4]
         STA   $DA
         LDA   [$F0]
         CMP   #$0000
         BEQ   L0E02DB
         LDA   [$F0]
         CMP   #$000E
         BEQ   L0E02DB
         LDA   [$F0]
         CMP   #$000F
         BEQ   L0E02DB
         LDA   $EA
         LDX   #$0000
         TAY
         BPL   L0E02AC
         DEX
L0E02AC  STX   $F8
         ASL
         ROL   $F8
         LDX   $F8
         PHX
         PHA
         LDA   #L031700
         LDX   #^L031700
         JSL   L010410
         PLA
         PLX
         STA   $F4
         STX   $F6
         LDA   [$F4]
         PHA
         PEI   $FF
         JSL   L0D0E3E
         PLY
         PLY
         STA   $DC
         CMP   #$FFFF
         BEQ   L0E02DB
         LDA   $DC
         STA   $DA
L0E02DB  LDA   $EA
         LDX   #$0000
         TAY
         BPL   L0E02E4
         DEX
L0E02E4  STX   $F8
         ASL
         ROL   $F8
         LDX   $F8
         PHX
         PHA
         LDA   #L03170C
         LDX   #^L03170C
         JSL   L010410
         PLA
         PLX
         STA   $F4
         STX   $F6
         LDA   [$F4]
         STA   $DC
         LDA   #$0006
         CLC
         ADC   $DC
         PHA
         PEI   $DA
         JSL   L1505CC
         PLY
         PLY
         SEC
         SBC   #$0004
         PHA
         LDA   $EA
         LDX   #$0000
         TAY
         BPL   L0E031E
         DEX
L0E031E  PHX
         PHA
         LDA   #L031718
         LDX   #^L031718
         JSL   L010410
         PLA
         PLX
         STA   $F4
         STX   $F6
         PLA
         SEP   #$20
         STA   [$F4]
         REP   #$20
         LDA   #$0006
         CLC
         ADC   $DC
         PHA
         PEI   $DA
         JSL   L15062E
         PLY
         PLY
         SEC
         SBC   #$0004
         PHA
         LDA   $EA
         LDX   #$0000
         TAY
         BPL   L0E0354
         DEX
L0E0354  PHX
         PHA
         LDA   #L03171E
         LDX   #^L03171E
         JSL   L010410
         PLA
         PLX
         STA   $F4
         STX   $F6
         PLA
         SEP   #$20
         STA   [$F4]
         REP   #$20
         LDA   $DC
         LDX   #$0000
         TAY
         BPL   L0E0376
         DEX
L0E0376  STX   $F8
         ASL
         ROL   $F8
         LDX   $F8
         PHX
         PHA
         LDA   #L0314FA
         LDX   #^L0314FA
         JSL   L010410
         PLA
         PLX
         STA   $F4
         STX   $F6
         LDA   [$F4]
         STA   $E0
         LDA   $DC
         LDX   #$0000
         TAY
         BPL   L0E039C
         DEX
L0E039C  STX   $F8
         ASL
         ROL   $F8
         LDX   $F8
         PHX
         PHA
         LDA   #L0314F0
         LDX   #^L0314F0
         JSL   L010410
         PLA
         PLX
         STA   $F4
         STX   $F6
         LDA   [$F4]
         STA   $DE
         LDA   $DA
         CMP   #$000B
         BNE   L0E03F1
         LDA   $DC
         LDX   #$0000
         TAY
         BPL   L0E03C9
         DEX
L0E03C9  STX   $F8
         ASL
         ROL   $F8
         LDX   $F8
         PHX
         PHA
         LDA   #L031504
         LDX   #^L031504
         JSL   L010410
         PLA
         PLX
         STA   $F4
         STX   $F6
         LDA   [$F4]
         PHA
         LDA   $E0
         PLX
         STX   $F8
         CLC
         ADC   $F8
         STA   $E0
         BRA   L0E0427
L0E03F1  LDA   $DA
         CMP   #$800B
         BNE   L0E0427
         LDA   $DC
         LDX   #$0000
         TAY
         BPL   L0E0401
         DEX
L0E0401  STX   $F8
         ASL
         ROL   $F8
         LDX   $F8
         PHX
         PHA
         LDA   #L031504
         LDX   #^L031504
         JSL   L010410
         PLA
         PLX
         STA   $F4
         STX   $F6
         LDA   [$F4]
         PHA
         LDA   $E0
         PLX
         STX   $F8
         SEC
         SBC   $F8
         STA   $E0
L0E0427  LDA   $DA
         AND   #$8000
         TAY
         BEQ   L0E0464
         LDA   #$0002
         PHA
         LDA   $EA
         LDX   #$0000
         TAY
         BPL   L0E043C
         DEX
L0E043C  PHX
         PHA
         LDA   #L031718
         LDX   #^L031718
         JSL   L010410
         PLA
         PLX
         STA   $F4
         STX   $F6
         LDA   [$F4]
         AND   #$00FF
         SEC
         JSL   L01041B
         PLY
         PHA
         LDA   $E0
         PLX
         STX   $F8
         SEC
         SBC   $F8
         STA   $E0
L0E0464  LDA   #$0006
         CLC
         ADC   $DC
         LDX   #$0000
         TAY
         BPL   L0E0471
         DEX
L0E0471  STX   $F8
         ASL
         ROL   $F8
         ASL
         ROL   $F8
         LDX   $F8
         PHX
         PHA
         LDA   #L03173C
         LDX   #^L03173C
         JSL   L010410
         PLA
         PLX
         STA   $F4
         STX   $F6
         LDY   #$0002
         LDA   [$F4],Y
         TAX
         LDA   [$F4]
         PHX
         PHA
         LDX   L0200A6
         LDA   L0200A4
         PHX
         PHA
         PEI   $DE
         PEI   $E0
         PEI   $DA
         JSL   L130695
         TAY
         TSC
         CLC
         ADC   #$000E
         TCS
         TYA
         LDA   $EA
         LDX   #$0000
         TAY
         BPL   L0E04BA
         DEX
L0E04BA  STX   $F8
         ASL
         ROL   $F8
         LDX   $F8
         PHX
         PHA
         LDA   #L031724
         LDX   #^L031724
         JSL   L010410
         PLA
         PLX
         STA   $F4
         STX   $F6
         LDA   $E0
         STA   [$F4]
         LDA   $EA
         LDX   #$0000
         TAY
         BPL   L0E04E0
         DEX
L0E04E0  STX   $F8
         ASL
         ROL   $F8
         LDX   $F8
         PHX
         PHA
         LDA   #L031730
         LDX   #^L031730
         JSL   L010410
         PLA
         PLX
         STA   $F4
         STX   $F6
         LDA   $DE
         STA   [$F4]
         BRL   L0E0656
L0E0500  LDA   [$EC]
         LDX   #$0000
         TAY
         BPL   L0E0509
         DEX
L0E0509  PEA   $0000
         PEA   $0006
         CLC
         JSL   L0105E1
         LDX   $E8
         LDA   $E6
         JSL   L010410
         PLA
         PLX
         STA   $F4
         STX   $F6
         LDA   [$F4]
         STA   $DA
         LDAL  L03173E
         TAX
         LDAL  L03173C
         PHX
         PHA
         LDX   L0200A6
         LDA   L0200A4
         PHX
         PHA
         LDY   #$0010
         LDA   [$E2],Y
         PHA
         LDY   #$000E
         LDA   [$E2],Y
         PHA
         PEI   $DA
         JSL   L130695
         TAY
         TSC
         CLC
         ADC   #$000E
         TCS
         TYA
         LDA   $DA
         CMP   #$0009
         BEQ   L0E0568
         LDA   $DA
         CMP   #$0014
         BEQ   L0E0568
         LDA   $DA
         CMP   #$0015
         BNE   L0E0595
L0E0568  LDAL  L03173E
         TAX
         LDAL  L03173C
         PHX
         PHA
         LDX   L020070
         LDA   L02006E
         PHX
         PHA
         LDY   #$0010
         LDA   [$E2],Y
         PHA
         LDY   #$000E
         LDA   [$E2],Y
         PHA
         PEI   $DA
         JSL   L130695
         TAY
         TSC
         CLC
         ADC   #$000E
         TCS
         TYA
L0E0595  LDA   $DA
         AND   #$7FFF
         STA   $DA
         PEA   $0000
         PEI   $DA
         JSL   L1505CC
         PLY
         PLY
         SEC
         SBC   #$0006
         PHA
         LDA   $EA
         LDX   #$0000
         TAY
         BPL   L0E05B5
         DEX
L0E05B5  PHX
         PHA
         LDA   #L031718
         LDX   #^L031718
         JSL   L010410
         PLA
         PLX
         STA   $F4
         STX   $F6
         PLA
         SEP   #$20
         STA   [$F4]
         REP   #$20
         PEA   $0000
         PEI   $DA
         JSL   L15062E
         PLY
         PLY
         SEC
         SBC   #$0006
         PHA
         LDA   $EA
         LDX   #$0000
         TAY
         BPL   L0E05E7
         DEX
L0E05E7  PHX
         PHA
         LDA   #L03171E
         LDX   #^L03171E
         JSL   L010410
         PLA
         PLX
         STA   $F4
         STX   $F6
         PLA
         SEP   #$20
         STA   [$F4]
         REP   #$20
         LDY   #$000E
         LDA   [$E2],Y
         PHA
         LDA   $EA
         LDX   #$0000
         TAY
         BPL   L0E060F
         DEX
L0E060F  STX   $F8
         ASL
         ROL   $F8
         LDX   $F8
         PHX
         PHA
         LDA   #L031724
         LDX   #^L031724
         JSL   L010410
         PLA
         PLX
         STA   $F4
         STX   $F6
         PLA
         STA   [$F4]
         LDY   #$0010
         LDA   [$E2],Y
         PHA
         LDA   $EA
         LDX   #$0000
         TAY
         BPL   L0E063A
         DEX
L0E063A  STX   $F8
         ASL
         ROL   $F8
         LDX   $F8
         PHX
         PHA
         LDA   #L031730
         LDX   #^L031730
         JSL   L010410
         PLA
         PLX
         STA   $F4
         STX   $F6
         PLA
         STA   [$F4]
L0E0656  LDA   $EA
         SEC
         SBC   #$0001
         STA   $EA
L0E065E  LDA   $EA
         SEC
         SBC   #$0000
         BVS   L0E0669
         EOR   #$8000
L0E0669  BPL   L0E066E
         BRL   L0E01A3
L0E066E  LDX   L02007C
         LDA   L02007A
         STA   $F4
         STX   $F6
         LDA   [$F4]
         CMP   #$FFFF
         BNE   L0E0682
         BRL   L0E0A4B
L0E0682  LDX   L02007C
         LDA   L02007A
         STA   $F4
         STX   $F6
         LDY   #$0006
         LDA   [$F4],Y
         LDX   #$0000
         TAY
         BPL   L0E0698
         DEX
L0E0698  STX   $F8
         ASL
         ROL   $F8
         ASL
         ROL   $F8
         LDX   $F8
         PHX
         PHA
         LDA   #L03173C
         LDX   #^L03173C
         JSL   L010410
         PLA
         PLX
         STA   $F4
         STX   $F6
         LDY   #$0002
         LDA   [$F4],Y
         TAX
         LDA   [$F4]
         PHX
         PHA
         LDX   L0200A6
         LDA   L0200A4
         PHX
         PHA
         LDX   L02007C
         LDA   L02007A
         STA   $F4
         STX   $F6
         LDY   #$0004
         LDA   [$F4],Y
         PHA
         LDX   L02007C
         LDA   L02007A
         STA   $F4
         STX   $F6
         LDY   #$0002
         LDA   [$F4],Y
         PHA
         LDX   L02007C
         LDA   L02007A
         STA   $F4
         STX   $F6
         LDA   [$F4]
         PHA
         JSL   L130695
         TAY
         TSC
         CLC
         ADC   #$000E
         TCS
         TYA
         LDX   L02007C
         LDA   L02007A
         STA   $F4
         STX   $F6
         LDA   [$F4]
         SEC
         SBC   #$0006
         BNE   L0E0714
         BRL   L0E083C
L0E0714  BVS   L0E0719
         EOR   #$8000
L0E0719  BMI   L0E071E
         BRL   L0E083C
L0E071E  PEA   $0000
         JSL   L1504CE
         PLY
         LDX   L020070
         LDA   L02006E
         PHX
         PHA
         LDA   $FF
         PHA
         LDA   #$0006
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L0316A0
         LDX   #^L0316A0
         JSL   L010410
         PLA
         PLX
         STA   $F4
         STX   $F6
         LDY   #$0004
         LDA   [$F4],Y
         PHA
         LDA   $FF
         PHA
         LDA   #$0006
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L0316A0
         LDX   #^L0316A0
         JSL   L010410
         PLA
         PLX
         STA   $F4
         STX   $F6
         LDY   #$0002
         LDA   [$F4],Y
         PHA
         JSL   L1504ED
         PLY
         PLY
         PLY
         PLY
         PEA   $0007
         JSL   L1504CE
         PLY
         LDX   L020070
         LDA   L02006E
         PHX
         PHA
         LDA   $FF
         PHA
         LDA   #$0006
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L0316A0
         LDX   #^L0316A0
         JSL   L010410
         PLA
         PLX
         STA   $F4
         STX   $F6
         LDY   #$0004
         LDA   [$F4],Y
         PHA
         LDA   $FF
         PHA
         LDA   #$0006
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L0316A0
         LDX   #^L0316A0
         JSL   L010410
         PLA
         PLX
         STA   $F4
         STX   $F6
         LDY   #$0002
         LDA   [$F4],Y
         CLC
         ADC   #$0001
         PHA
         JSL   L1504ED
         PLY
         PLY
         PLY
         PLY
         LDA   L0200D5
         SEC
         SBC   #$0080
         BVS   L0E07FA
         EOR   #$8000
L0E07FA  BMI   L0E0827
         LDA   L0200D5
         PHA
         LDA   #$0006
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L031782
         LDX   #^L031782
         JSL   L010410
         PLA
         PLX
         STA   $F4
         STX   $F6
         LDA   #$0004
         SEP   #$20
         STA   [$F4]
         REP   #$20
L0E0827  LDX   L02007C
         LDA   L02007A
         STA   $F4
         STX   $F6
         LDA   [$F4]
         SEC
         SBC   #$0004
         STA   [$F4]
         BRL   L0E0A31
L0E083C  LDA   $FF
         ASL
         ASL
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   #L0304DA
         LDX   #^L0304DA
         JSL   L010410
         PLA
         PLX
         STA   $F4
         STX   $F6
         LDA   [$F4]
         CMP   #$0003
         BEQ   L0E0860
         BRL   L0E0A31
L0E0860  JSL   L0703A5
         AND   #$0007
         TAY
         BEQ   L0E086D
         BRL   L0E08EA
L0E086D  LDX   L02007C
         LDA   L02007A
         STA   $F4
         STX   $F6
         LDY   #$0006
         LDA   [$F4],Y
         LDX   #$0000
         TAY
         BPL   L0E0883
         DEX
L0E0883  STX   $F8
         ASL
         ROL   $F8
         ASL
         ROL   $F8
         LDX   $F8
         PHX
         PHA
         LDA   #L03173C
         LDX   #^L03173C
         JSL   L010410
         PLA
         PLX
         STA   $F4
         STX   $F6
         LDY   #$0002
         LDA   [$F4],Y
         TAX
         LDA   [$F4]
         PHX
         PHA
         LDX   L020070
         LDA   L02006E
         PHX
         PHA
         LDX   L02007C
         LDA   L02007A
         STA   $F4
         STX   $F6
         LDY   #$0004
         LDA   [$F4],Y
         PHA
         LDX   L02007C
         LDA   L02007A
         STA   $F4
         STX   $F6
         LDY   #$0002
         LDA   [$F4],Y
         PHA
         LDX   L02007C
         LDA   L02007A
         STA   $F4
         STX   $F6
         LDA   [$F4]
         PHA
         JSL   L130695
         TAY
         TSC
         CLC
         ADC   #$000E
         TCS
         TYA
L0E08EA  PEA   $0000
         JSL   L1504CE
         PLY
         LDX   L020070
         LDA   L02006E
         PHX
         PHA
         LDA   $FF
         PHA
         LDA   #$0006
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L0316A0
         LDX   #^L0316A0
         JSL   L010410
         PLA
         PLX
         STA   $F4
         STX   $F6
         LDY   #$0004
         LDA   [$F4],Y
         PHA
         LDA   $FF
         PHA
         LDA   #$0006
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L0316A0
         LDX   #^L0316A0
         JSL   L010410
         PLA
         PLX
         STA   $F4
         STX   $F6
         LDY   #$0002
         LDA   [$F4],Y
         PHA
         JSL   L1504ED
         PLY
         PLY
         PLY
         PLY
         PEA   $0007
         JSL   L1504CE
         PLY
         LDX   L020070
         LDA   L02006E
         PHX
         PHA
         LDA   $FF
         PHA
         LDA   #$0006
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L0316A0
         LDX   #^L0316A0
         JSL   L010410
         PLA
         PLX
         STA   $F4
         STX   $F6
         LDY   #$0004
         LDA   [$F4],Y
         PHA
         LDA   $FF
         PHA
         LDA   #$0006
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L0316A0
         LDX   #^L0316A0
         JSL   L010410
         PLA
         PLX
         STA   $F4
         STX   $F6
         LDY   #$0002
         LDA   [$F4],Y
         CLC
         ADC   #$0001
         PHA
         JSL   L1504ED
         PLY
         PLY
         PLY
         PLY
         LDA   L0200D5
         SEC
         SBC   #$0080
         BVS   L0E09C6
         EOR   #$8000
L0E09C6  BMI   L0E0A22
         LDA   L0200D5
         PHA
         LDA   #$0006
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L031782
         LDX   #^L031782
         JSL   L010410
         PLA
         PLX
         STA   $F4
         STX   $F6
         LDA   #$0003
         SEP   #$20
         STA   [$F4]
         REP   #$20
         LDA   L0200D5
         PHA
         LDA   #$0006
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L031782
         LDX   #^L031782
         JSL   L010410
         PLA
         PLX
         STA   $F4
         STX   $F6
         LDY   #$0001
         LDA   [$F4],Y
         PHA
         INC
         LDY   #$0001
         STA   [$F4],Y
         PLA
L0E0A22  LDX   L02007C
         LDA   L02007A
         STA   $F4
         STX   $F6
         LDA   #$FFFF
         STA   [$F4]
L0E0A31  LDX   L02007C
         LDA   L02007A
         CLC
         ADC   #$0008
         PHA
         TXA
         ADC   #$0000
         TAX
         PLA
         STX   L02007C
         STA   L02007A
         BRL   L0E066E
L0E0A4B  LDA   $FF
         ASL
         ASL
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   #L0304DA
         LDX   #^L0304DA
         JSL   L010410
         PLA
         PLX
         STA   $F4
         STX   $F6
         LDA   [$F4]
         CMP   #$0003
         BEQ   L0E0A6F
         BRL   L0E0BD5
L0E0A6F  LDA   L0200B4
         BEQ   L0E0A77
         BRL   L0E0BD5
L0E0A77  LDA   $FF
         PHA
         LDA   #$0006
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L0316A0
         LDX   #^L0316A0
         JSL   L010410
         PLA
         PLX
         STA   $F4
         STX   $F6
         LDA   [$F4]
         BNE   L0E0A9F
         BRL   L0E0BAA
L0E0A9F  LDAL  L031746
         TAX
         LDAL  L031744
         PHX
         PHA
         LDX   L0200A6
         LDA   L0200A4
         PHX
         PHA
         PEA   $00B2
         PEA   $0082
         PEA   $0004
         JSL   L130695
         TAY
         TSC
         CLC
         ADC   #$000E
         TCS
         TYA
         LDA   $FF
         PHA
         LDA   #$0006
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L0316A0
         LDX   #^L0316A0
         JSL   L010410
         PLA
         PLX
         STA   $F4
         STX   $F6
         LDY   #$0002
         LDA   [$F4],Y
         SEC
         SBC   #$00F5
         BVS   L0E0AF6
         EOR   #$8000
L0E0AF6  BMI   L0E0B23
         LDAL  L03174A
         TAX
         LDAL  L031748
         PHX
         PHA
         LDX   L0200A6
         LDA   L0200A4
         PHX
         PHA
         PEA   $00A3
         PEA   $00A2
         PEA   $0000
         JSL   L130695
         TAY
         TSC
         CLC
         ADC   #$000E
         TCS
         TYA
         BRL   L0E0BA8
L0E0B23  LDA   $FF
         PHA
         LDA   #$0006
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L0316A0
         LDX   #^L0316A0
         JSL   L010410
         PLA
         PLX
         STA   $F4
         STX   $F6
         LDY   #$0002
         LDA   [$F4],Y
         SEC
         SBC   #$015E
         BEQ   L0E0B80
         BVS   L0E0B54
         EOR   #$8000
L0E0B54  BPL   L0E0B80
         LDAL  L03174A
         TAX
         LDAL  L031748
         PHX
         PHA
         LDX   L0200A6
         LDA   L0200A4
         PHX
         PHA
         PEA   $00A3
         PEA   $00A2
         PEA   $0002
         JSL   L130695
         TAY
         TSC
         CLC
         ADC   #$000E
         TCS
         TYA
         BRA   L0E0BA8
L0E0B80  LDAL  L03174A
         TAX
         LDAL  L031748
         PHX
         PHA
         LDX   L0200A6
         LDA   L0200A4
         PHX
         PHA
         PEA   $00A3
         PEA   $00A2
         PEA   $0001
         JSL   L130695
         TAY
         TSC
         CLC
         ADC   #$000E
         TCS
         TYA
L0E0BA8  BRA   L0E0BD2
L0E0BAA  LDAL  L031746
         TAX
         LDAL  L031744
         PHX
         PHA
         LDX   L0200A6
         LDA   L0200A4
         PHX
         PHA
         PEA   $00B2
         PEA   $0082
         PEA   $0002
         JSL   L130695
         TAY
         TSC
         CLC
         ADC   #$000E
         TCS
         TYA
L0E0BD2  BRL   L0E0D9D
L0E0BD5  LDA   L0200B4
         BNE   L0E0BDD
         BRL   L0E0D9D
L0E0BDD  LDA   $FF
         PHA
         LDA   #$001A
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L03059A
         LDX   #^L03059A
         JSL   L010410
         PLA
         PLX
         STA   $F4
         STX   $F6
         LDY   #$000A
         LDA   [$F4],Y
         SEC
         SBC   #$0004
         BNE   L0E0C0C
         BRL   L0E0D9D
L0E0C0C  BVS   L0E0C11
         EOR   #$8000
L0E0C11  BMI   L0E0C16
         BRL   L0E0D9D
L0E0C16  LDA   $FF
         PHA
         LDA   #$001A
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L03059A
         LDX   #^L03059A
         JSL   L010410
         PLA
         PLX
         STX   $E4
         STA   $E2
         LDA   $E2
         CLC
         ADC   #$000C
         LDX   $E4
         BCC   L0E0C42
         INX
L0E0C42  STX   $EE
         STA   $EC
         LDA   $E2
         CLC
         ADC   #$000A
         LDX   $E4
         BCC   L0E0C51
         INX
L0E0C51  STX   $F2
         STA   $F0
         LDA   [$F0]
         LDX   #$0000
         TAY
         BPL   L0E0C5E
         DEX
L0E0C5E  STX   $F8
         ASL
         ROL   $F8
         ASL
         ROL   $F8
         LDX   $F8
         PHX
         PHA
         LDA   #L0314C0
         LDX   #^L0314C0
         JSL   L010410
         PLA
         PLX
         STA   $F4
         STX   $F6
         LDY   #$0002
         LDA   [$F4],Y
         TAX
         LDA   [$F4]
         STX   $E8
         STA   $E6
         LDAL  L031746
         TAX
         LDAL  L031744
         PHX
         PHA
         LDX   L0200A6
         LDA   L0200A4
         PHX
         PHA
         LDY   #$0010
         LDA   [$E2],Y
         PHA
         LDY   #$000E
         LDA   [$E2],Y
         PHA
         LDA   [$EC]
         LDX   #$0000
         TAY
         BPL   L0E0CAE
         DEX
L0E0CAE  PEA   $0000
         PEA   $0006
         CLC
         JSL   L0105E1
         LDX   $E8
         LDA   $E6
         JSL   L010410
         PLA
         PLX
         STA   $F4
         STX   $F6
         LDA   [$F4]
         PHA
         JSL   L130695
         TAY
         TSC
         CLC
         ADC   #$000E
         TCS
         TYA
         LDA   [$EC]
         LDX   #$0000
         TAY
         BPL   L0E0CDF
         DEX
L0E0CDF  PEA   $0000
         PEA   $0006
         CLC
         JSL   L0105E1
         LDX   $E8
         LDA   $E6
         JSL   L010410
         PLA
         PLX
         STA   $F4
         STX   $F6
         LDY   #$0002
         LDA   [$F4],Y
         PHA
         LDY   #$000E
         LDA   [$E2],Y
         PLX
         STX   $F8
         CLC
         ADC   $F8
         LDY   #$000E
         STA   [$E2],Y
         LDA   [$EC]
         LDX   #$0000
         TAY
         BPL   L0E0D17
         DEX
L0E0D17  PEA   $0000
         PEA   $0006
         CLC
         JSL   L0105E1
         LDX   $E8
         LDA   $E6
         JSL   L010410
         PLA
         PLX
         STA   $F4
         STX   $F6
         LDY   #$0004
         LDA   [$F4],Y
         PHA
         LDY   #$0010
         LDA   [$E2],Y
         PLX
         STX   $F8
         CLC
         ADC   $F8
         LDY   #$0010
         STA   [$E2],Y
         LDA   [$EC]
         CLC
         ADC   #$0001
         STA   [$EC]
         LDA   [$EC]
         LDX   #$0000
         TAY
         BPL   L0E0D57
         DEX
L0E0D57  PEA   $0000
         PEA   $0006
         CLC
         JSL   L0105E1
         LDX   $E8
         LDA   $E6
         JSL   L010410
         PLA
         PLX
         STA   $F4
         STX   $F6
         LDA   [$F4]
         CMP   #$FFFF
         BNE   L0E0D9D
         LDA   [$F0]
         STA   L0200B9
         LDA   #$000B
         STA   [$F0]
         LDA   #$0000
         STA   [$EC]
         PEI   $FF
         JSL   L0D09CE
         PLY
         LDA   #$00BE
         LDY   #$000E
         STA   [$E2],Y
         LDA   #$0092
         LDY   #$0010
         STA   [$E2],Y
L0E0D9D  LDA   $FF
         LDX   #$0000
         TAY
         BPL   L0E0DA6
         DEX
L0E0DA6  STX   $F8
         ASL
         ROL   $F8
         ASL
         ROL   $F8
         LDX   $F8
         PHX
         PHA
         LDA   #L03165E
         LDX   #^L03165E
         JSL   L010410
         PLA
         PLX
         STA   $F4
         STX   $F6
         LDY   #$0002
         LDA   [$F4],Y
         TAX
         LDA   [$F4]
         PHX
         PHA
         PEA   ^L031FD3
         PEA   L031FD3
         LDX   L0200A6
         LDA   L0200A4
         PHX
         PHA
         PEA   $000C
         PEA   $0060
         JSL   L130403
         TAY
         TSC
         CLC
         ADC   #$0010
         TCS
         TYA
         LDA   $FF
         LDX   #$0000
         TAY
         BPL   L0E0DF5
         DEX
L0E0DF5  STX   $F8
         ASL
         ROL   $F8
         ASL
         ROL   $F8
         LDX   $F8
         PHX
         PHA
         LDA   #L03165E
         LDX   #^L03165E
         JSL   L010410
         PLA
         PLX
         STA   $F4
         STX   $F6
         LDY   #$0002
         LDA   [$F4],Y
         TAX
         LDA   [$F4]
         PHX
         PHA
         PEA   ^L031FDB
         PEA   L031FDB
         LDX   L0200A6
         LDA   L0200A4
         PHX
         PHA
         PEA   $000D
         PEA   $0060
         JSL   L130403
         TAY
         TSC
         CLC
         ADC   #$0010
         TCS
         TYA
         PEI   $FF
         JSL   L0C0000
         PLY
         PEI   $FF
         JSL   L0C0129
         PLY
         LDA   L0200D1
         EOR   #$0001
         STA   L0200D1
         LDA   #$0001
         BNE   L0E0E5A
         BRL   L0E0EC8
L0E0E5A  SEP   #$20
         STZ   L0200BF
         REP   #$20
         LDA   L02003F
         BEQ   L0E0E84
         PEA   $008C
         JSL   L0405F2
         PLY
         PEA   $0000
         PEA   ^L031622
         PEA   L031622
         JSL   L040732
         PLY
         PLY
         PLY
         STZ   L02003F
         BRL   L0E0EC6
L0E0E84  LDA   L02003D
         BEQ   L0E0EA6
         PEA   $00B4
         JSL   L0405F2
         PLY
         PEA   $0000
         PEA   ^L03161A
         PEA   L03161A
         JSL   L040732
         PLY
         PLY
         PLY
         STZ   L02003D
         BRA   L0E0EC6
L0E0EA6  LDA   L020041
         BEQ   L0E0EC6
         PEA   $0050
         JSL   L0405F2
         PLY
         PEA   $0000
         PEA   ^L031626
         PEA   L031626
         JSL   L040732
         PLY
         PLY
         PLY
         STZ   L020041
L0E0EC6  BRA   L0E0ED1
L0E0EC8  STZ   L020041
         STZ   L02003F
         STZ   L02003D
L0E0ED1  PEA   $0003
         JSL   L0F102A
         PLY
         TSC
         CLC
         ADC   #$0020
         TCS
         PLD
         RTL

