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

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

	 use	FNAPRO2.X.S
	 
*-----------------------

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

L090000  ENT
         PHD
         TSC
         SEC
         SBC   #$00ED
         TCD
         ADC   #$00CF
         TCS
         SEP   #$20
         STZ   $D1
         REP   #$20
         STZ   $DA
         LDX   #$0000
         LDA   #$0014
         STX   $D6
         STA   $D4
         STZ   $DC
         LDA   #$0000
         SEP   #$20
         STA   $D3
         REP   #$20
         LDA   $F7
         PHA
         LDA   #$00A0
         SEC
         JSL   L010FAB
         PLA
         LDX   #$0000
         TAY
         BPL   L09003B
         DEX
L09003B  PHX
         PHA
         LDX   L0200B4
         LDA   L0200B2
         JSL   L010E15
         PLA
         PLX
         STX   $E6
         STA   $E4
         LDA   $FD
         AND   #$0001
         TAY
         BEQ   L09005A
         LDA   #$FFFF
         BRA   L09005D
L09005A  LDA   #$0000
L09005D  STA   $DE
         PEA   $0028
         PEI   $DE
         PEA   $000A
         PEA   $0000
         PEA   $0001
         PEI   $E6
         PEI   $E4
         JSL   L050817
         TAY
         TSC
         CLC
         ADC   #$000E
         TCS
         TYA
         LDA   $FD
         AND   #$0002
         TAY
         BEQ   L09008A
         LDA   #$FFFF
         BRA   L09008D
L09008A  LDA   #$0000
L09008D  STA   $DE
         PEA   $0028
         PEI   $DE
         PEA   $000A
         PEA   $0000
         PEA   $0002
         PEI   $E6
         PEI   $E4
         JSL   L050817
         TAY
         TSC
         CLC
         ADC   #$000E
         TCS
         TYA
         LDA   $FD
         AND   #$0004
         TAY
         BEQ   L0900BA
         LDA   #$FFFF
         BRA   L0900BD
L0900BA  LDA   #$0000
L0900BD  STA   $DE
         PEA   $0028
         PEI   $DE
         PEA   $000A
         PEA   $0000
         PEA   $0003
         PEI   $E6
         PEI   $E4
         JSL   L050817
         TAY
         TSC
         CLC
         ADC   #$000E
         TCS
         TYA
         LDA   $FD
         AND   #$0008
         TAY
         BEQ   L0900EA
         LDA   #$FFFF
         BRA   L0900ED
L0900EA  LDA   #$0000
L0900ED  STA   $DE
         PEA   $0028
         PEI   $DE
         PEA   $000A
         PEA   $0000
         PEA   $0004
         PEI   $E6
         PEI   $E4
         JSL   L050817
         TAY
         TSC
         CLC
         ADC   #$000E
         TCS
         TYA
         LDX   $F5
         LDA   $F3
         STX   $E2
         STA   $E0
         PEA   $000C
         JSL   L100926
         PLY
         LDX   L0200B4
         LDA   L0200B2
         PHX
         PHA
         JSL   L0F0371
         PLY
         PLY
         LDA   $F7
         PHA
         LDA   #$00A0
         SEC
         JSL   L010FAB
         PLA
         LDX   #$0000
         TAY
         BPL   L09013E
         DEX
L09013E  PHX
         PHA
         LDX   L0200B4
         LDA   L0200B2
         JSL   L010E15
         PLA
         PLX
         STX   $E6
         STA   $E4
L090150  LDA   #$0001
         BNE   L090158
         BRL   L090358
L090158  LDA   [$E0]
         AND   #$00FF
         BNE   L090167
         LDX   $F5
         LDA   $F3
         STX   $E2
         STA   $E0
L090167  LDA   $DC
         EOR   #$0001
         STA   $DC
         LDA   L020097
         BEQ   L090195
         LDA   [$E0]
         AND   #$00FF
         CMP   #$0020
         BEQ   L090195
         LDA   $DC
         BEQ   L090195
         PEA   $00C8
         JSL   L0605D9
         PLY
         PEA   $0000
         PEA   $0001
         JSL   L0607F0
         PLY
         PLY
L090195  PEI   $F9
         _SetForeColor
         BCS   L0901A3
         LDA   #$0000
L0901A3  STAL  L020010
         PEI   $FD
         _SetBackColor
         BCS   L0901B5
         LDA   #$0000
L0901B5  STAL  L020010
         PEA   $0137
         PEA   $0008
         _MoveTo
         BCS   L0901CB
         LDA   #$0000
L0901CB  STAL  L020010
         PEA   $0004
         _SetTextMode
         BCS   L0901DE
         LDA   #$0000
L0901DE  STAL  L020010
         LDA   [$E0]
         AND   #$00FF
         PHA
         _DrawChar
         BCS   L0901F4
         LDA   #$0000
L0901F4  STAL  L020010
         PEI   $FB
         _SetForeColor
         BCS   L090206
         LDA   #$0000
L090206  STAL  L020010
         PEA   $0000
         _SetTextMode
         BCS   L090219
         LDA   #$0000
L090219  STAL  L020010
         PEA   $0136
         PEA   $0009
         _MoveTo
         BCS   L09022F
         LDA   #$0000
L09022F  STAL  L020010
         LDA   [$E0]
         AND   #$00FF
         PHA
         _DrawChar
         BCS   L090245
         LDA   #$0000
L090245  STAL  L020010
         STZ   $D8
         BRA   L090269
L09024D  JSL   L100969
         PEA   $0000
         PEA   $0013
         PEA   $000B
         PEI   $E6
         PEI   $E4
         JSL   L0507B3
         PLY
         PLY
         PLY
         PLY
         PLY
         INC   $D8
L090269  LDA   $D8
         SEC
         SBC   #$0004
         BVS   L090274
         EOR   #$8000
L090274  BPL   L09024D
         INC   $E0
         BNE   L09027C
         INC   $E2
L09027C  LDA   $FF
         BEQ   L09029E
         LDA   $DA
         SEC
         SBC   $FF
         BVS   L09028A
         EOR   #$8000
L09028A  BPL   L09029E
         PEA   $FFFF
         JSL   L100926
         PLY
         JSL   L0F03BA
         LDA   #$0000
         BRL   L090358
L09029E  LDX   $D6
         LDA   $D4
         STX   $E8
         ORA   $E8
         BNE   L0902DD
         JSL   L100099
         SEP   #$20
         STA   L0200B8
         REP   #$20
         AND   #$00FF
         BEQ   L0902C1
         LDA   L0200B8
         SEP   #$20
         STA   $D1
         REP   #$20
L0902C1  LDA   L0200B6
         AND   #$00FF
         BEQ   L0902DB
         LDA   L0200B6
         AND   #$00FF
         PHA
         JSL   L050AA9
         PLY
         SEP   #$20
         STA   $D1
         REP   #$20
L0902DB  BRA   L0902F3
L0902DD  LDA   $D4
         BNE   L0902E3
         DEC   $D6
L0902E3  DEC   $D4
         SEP   #$20
         STZ   L0200B8
         REP   #$20
         SEP   #$20
         STZ   L0200B6
         REP   #$20
L0902F3  LDA   $D1
         AND   #$00FF
         BNE   L0902FD
         BRL   L090355
L0902FD  PEA   $FFFF
         JSL   L100926
         PLY
         JSL   L0F03BA
         PEA   $000C
         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
         PEA   $000C
         PEA   $0000
         PEA   $00E1
         PEA   $2000
         PEA   $0000
         LDX   L020135
         LDA   L020133
         PHX
         PHA
         JSL   L1007BF
         TAY
         TSC
         CLC
         ADC   #$000E
         TCS
         TYA
         LDA   $D1
         BRA   L090358
L090355  BRL   L090150
L090358  TAY
         TSC
         CLC
         ADC   #$001D
         TCS
         TYA
         PLD
         RTL

*--- We do not have a disk 2

         PHD
         TSC
         SEC
         SBC   #$00FB
         TCD
         ADC   #$00EC
         TCS
         STZ   $F2
L09036F  PEA   $0003
         PEA   $0000
         PEA   $000D
         PEA   $000B
         PEA   $0000
         PEA   ^L033BA3
         PEA   L033BA3
         JSL   L090000
         TAY
         TSC
         CLC
         ADC   #$000E
         TCS
         TYA
         PEA   $0020
         PEA   ^L0305ED
         PEA   L0305ED
         JSL   L110068
         PLY
         PLY
         PLY
         STA   $F4
         SEC
         SBC   #$0000
         BVS   L0903AB
         EOR   #$8000
L0903AB  BPL   L0903B9
         PEI   $F4
         JSL   L110110
         PLY
         LDA   #$0001
         STA   $F2
L0903B9  LDA   $F2
         BEQ   L09036F
         STZ   $EE
         STZ   $F0
         BRA   L0903C9
L0903C3  INC   $EE
         BNE   L0903C9
         INC   $F0
L0903C9  SEC
         LDA   $EE
         SBC   #$9C40
         BNE   L0903D8
         LDA   $F0
         SBC   #$0000
         BRA   L0903DF
L0903D8  LDA   $F0
         SBC   #$0000
         REP   #$02
L0903DF  BVS   L0903E4
         EOR   #$8000
L0903E4  BPL   L0903C3
         TSC
         CLC
         ADC   #$000E
         TCS
         PLD
         RTL

L0903EE  ENT
         PHD
         TSC
         SEC
         SBC   #$00FB
         TCD
         ADC   #$00EA
         TCS
         STZ   $EE
         STZ   $EC
         STZ   $F2
         BRL   L090489
L090402  LDA   $F2
         LDX   #$0000
         TAY
         BPL   L09040B
         DEX
L09040B  PEA   $0000
         PEA   $001C
         CLC
         JSL   L010FF0
         LDA   #L032787
         LDX   #^L032787
         JSL   L010E15
         PLA
         PLX
         STA   $F6
         STX   $F8
         LDY   #$0012
         LDA   [$F6],Y
         BEQ   L090487
         INC   $EE
         STZ   $F4
         BRA   L09047A
L090433  LDA   $F4
         LDX   #$0000
         TAY
         BPL   L09043C
         DEX
L09043C  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   L090462
         INX
L090462  STA   $F6
         STX   $F8
         LDA   [$F6]
         PHA
         LDA   $F2
         CLC
         ADC   #$0001
         PLX
         STX   $F6
         CMP   $F6
         BNE   L090478
         INC   $EC
L090478  INC   $F4
L09047A  LDA   $F4
         SEC
         SBC   #$0003
         BVS   L090485
         EOR   #$8000
L090485  BPL   L090433
L090487  INC   $F2
L090489  LDA   $F2
         SEC
         SBC   #$0003
         BVS   L090494
         EOR   #$8000
L090494  BMI   L090499
         BRL   L090402
L090499  LDA   $EC
         BEQ   L0904A8
         LDA   $EE
         CMP   $EC
         BNE   L0904A8
         LDA   #$0001
         BRA   L0904B4
L0904A8  LDA   $EE
         BNE   L0904B1
         LDA   #$0002
         BRA   L0904B4
L0904B1  LDA   #$0000
L0904B4  TAY
         TSC
         CLC
         ADC   #$0010
         TCS
         TYA
         PLD
         RTL

L0904BE  PHD
         TSC
         SEC
         SBC   #$00FB
         TCD
         ADC   #$00EE
         TCS
         STZ   $F0
         LDA   #L03325D
         LDX   #^L03325D
         STX   $F4
         STA   $F2
         BRA   L09052E
L0904D7  LDA   $F0
         CLC
         ADC   #$0064
         STA   $F0
         LDA   #$0000
         LDY   #$000E
         STA   [$F2],Y
         LDA   #$000A
         PHA
         JSL   L080726
         SEC
         JSL   L010E20
         LDA   #$0010
         PLX
         STX   $FA
         CLC
         ADC   $FA
         LDY   #$000C
         STA   [$F2],Y
         LDA   $F0
         LDY   #$000A
         STA   [$F2],Y
         JSL   L080726
         AND   #$0003
         STA   [$F2]
         LDA   #$0000
         LDY   #$0004
         STA   [$F2],Y
         LDA   #$0000
         LDY   #$0008
         STA   [$F2],Y
         LDA   $F2
         CLC
         ADC   #$001A
         STA   $F2
         BCC   L09052E
         INC   $F4
L09052E  LDA   #L03359D
         LDX   #^L03359D
         PHX
         PHA
         LDX   $F4
         LDA   $F2
         JSL   L011077
         BEQ   L090547
         BVS   L090545
         EOR   #$8000
L090545  BMI   L0904D7
L090547  JSL   L080726
         AND   #$0001
         LDX   #$0000
         TAY
         BPL   L090555
         DEX
L090555  PEA   $0000
         PEA   $001A
         CLC
         JSL   L010FF0
         LDA   #L03325D
         LDX   #^L03325D
         JSL   L010E15
         PLA
         PLX
         STX   $F4
         STA   $F2
         BRA   L0905B5
L090572  LDA   #$0001
         LDY   #$000E
         STA   [$F2],Y
         LDA   L02010A
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   #L0305D1
         LDX   #^L0305D1
         JSL   L010E15
         PLA
         PLX
         STA   $F6
         STX   $F8
         LDA   [$F6]
         LDX   #$0000
         TAY
         BPL   L09059C
         DEX
L09059C  PEA   $0000
         PEA   $001A
         CLC
         JSL   L010FF0
         LDX   $F4
         LDA   $F2
         JSL   L010E15
         PLA
         PLX
         STX   $F4
         STA   $F2
L0905B5  LDA   #L03359D
         LDX   #^L03359D
         PHX
         PHA
         LDX   $F4
         LDA   $F2
         JSL   L011077
         BEQ   L0905CE
         BVS   L0905CC
         EOR   #$8000
L0905CC  BMI   L090572
L0905CE  TSC
         CLC
         ADC   #$000C
         TCS
         PLD
         RTL

L0905D6  ENT
         PHD
         TSC
         SEC
         SBC   #$00FB
         TCD
         ADC   #$00F2
         TCS
         STZ   $F4
         BRL   L090696
L0905E6  LDA   $F4
         LDX   #$0000
         TAY
         BPL   L0905EF
         DEX
L0905EF  PEA   $0000
         PEA   $001C
         CLC
         JSL   L010FF0
         LDA   #L032733
         LDX   #^L032733
         JSL   L010E15
         PLA
         PLX
         STA   $F6
         STX   $F8
         LDA   $F6
         LDX   $F8
         PHX
         PHA
         LDA   $F4
         LDX   #$0000
         TAY
         BPL   L090619
         DEX
L090619  PEA   $0000
         PEA   $001C
         CLC
         JSL   L010FF0
         LDA   #L032787
         LDX   #^L032787
         JSL   L010E15
         PLA
         PLX
         STA   $F6
         STX   $F8
         PEI   $F8
         PEI   $F6
         PEA   $001C
         JSL   L0110A2
         PLA
         PLA
         PLA
         PLA
         PLX
         LDA   L02010A
         LDX   #$0000
         TAY
         BPL   L09064E
         DEX
L09064E  STX   $FA
         ASL
         ROL   $FA
         LDX   $FA
         PHX
         PHA
         LDA   #L0337E7
         LDX   #^L0337E7
         JSL   L010E15
         PLA
         PLX
         STA   $F6
         STX   $F8
         LDA   [$F6]
         PHA
         LDA   $F4
         LDX   #$0000
         TAY
         BPL   L090673
         DEX
L090673  PEA   $0000
         PEA   $001C
         CLC
         JSL   L010FF0
         LDA   #L032787
         LDX   #^L032787
         JSL   L010E15
         PLA
         PLX
         STA   $F6
         STX   $F8
         PLA
         LDY   #$001A
         STA   [$F6],Y
         INC   $F4
L090696  LDA   $F4
         SEC
         SBC   #$0003
         BVS   L0906A1
         EOR   #$8000
L0906A1  BMI   L0906A6
         BRL   L0905E6
L0906A6  JSL   L0904BE
         JSL   L0906B6
         TSC
         CLC
         ADC   #$0008
         TCS
         PLD
         RTL

L0906B6  PHD
         TSC
         SEC
         SBC   #$00FB
         TCD
         ADC   #$00E8
         TCS
         JSL   L080726
         AND   #$0007
         STA   $F4
         STZ   $F2
         BRL   L0908AB
L0906CF  LDA   $F2
         LDX   #$0000
         TAY
         BPL   L0906D8
         DEX
L0906D8  PEA   $0000
         PEA   $000E
         CLC
         JSL   L010FF0
         LDA   #L032823
         LDX   #^L032823
         JSL   L010E15
         PLA
         PLX
         STX   $EC
         STA   $EA
         LDA   $F2
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   $F4
         PHA
         LDA   #$0006
         CLC
         JSL   L010FAB
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L030AAF
         LDX   #^L030AAF
         JSL   L010E15
         PLA
         PLX
         JSL   L010E15
         PLA
         PLX
         STA   $F6
         STX   $F8
         LDA   [$F6]
         LDX   #$0000
         TAY
         BPL   L09072B
         DEX
L09072B  PEA   $0000
         PEA   $000A
         CLC
         JSL   L010FF0
         LDA   #L030ADF
         LDX   #^L030ADF
         JSL   L010E15
         PLA
         PLX
         STA   $F6
         STX   $F8
         LDY   #$0006
         LDA   [$F6],Y
         PHA
         LDA   $F2
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   $F4
         PHA
         LDA   #$0006
         CLC
         JSL   L010FAB
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L030AAF
         LDX   #^L030AAF
         JSL   L010E15
         PLA
         PLX
         JSL   L010E15
         PLA
         PLX
         STA   $F6
         STX   $F8
         LDA   [$F6]
         LDX   #$0000
         TAY
         BPL   L090784
         DEX
L090784  PEA   $0000
         PEA   $000A
         CLC
         JSL   L010FF0
         LDA   #L030BA7
         LDX   #^L030BA7
         JSL   L010E15
         PLA
         PLX
         STA   $F6
         STX   $F8
         LDY   #$0006
         LDA   [$F6],Y
         PLX
         STX   $FA
         CLC
         ADC   $FA
         STA   $EE
         LDA   #$0002
         PHA
         LDA   $EE
         SEC
         JSL   L010E20
         PLY
         PHA
         JSL   L0A0047
         PLY
         LDA   L020155
         CMP   #$0069
         BNE   L0907E1
         LDA   L020155
         SEC
         SBC   #$0010
         STA   L020155
         LDA   L020157
         SEC
         SBC   #$0008
         STA   L020157
         LDA   #$0002
         STA   $F0
         BRA   L09081D
L0907E1  LDA   L020157
         CMP   #$00A2
         BNE   L090804
         LDA   L020157
         CLC
         ADC   #$0008
         STA   L020157
         LDA   L020155
         CLC
         ADC   #$0008
         STA   L020155
         LDA   #$0004
         STA   $F0
         BRA   L09081D
L090804  LDA   L020157
         SEC
         SBC   #$0007
         STA   L020157
         LDA   L020155
         CLC
         ADC   #$0008
         STA   L020155
         LDA   #$0003
         STA   $F0
L09081D  LDA   L020155
         STA   [$EA]
         LDA   L020157
         LDY   #$0002
         STA   [$EA],Y
         LDA   $F0
         LDY   #$0004
         STA   [$EA],Y
         LDA   $F2
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   $F4
         PHA
         LDA   #$0006
         CLC
         JSL   L010FAB
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L030AAF
         LDX   #^L030AAF
         JSL   L010E15
         PLA
         PLX
         JSL   L010E15
         PLA
         PLX
         STA   $F6
         STX   $F8
         LDA   [$F6]
         LDY   #$0006
         STA   [$EA],Y
         LDA   $EA
         CLC
         ADC   #$0008
         LDX   $EC
         BCC   L090872
         INX
L090872  STA   $F6
         STX   $F8
         LDA   #$0000
         STA   [$F6]
         LDA   $EA
         CLC
         ADC   #$0008
         LDX   $EC
         BCC   L090886
         INX
L090886  STA   $F6
         STX   $F8
         LDA   #$0000
         LDY   #$0002
         STA   [$F6],Y
         LDA   $EA
         CLC
         ADC   #$0008
         LDX   $EC
         BCC   L09089D
         INX
L09089D  STA   $F6
         STX   $F8
         LDA   #$0000
         LDY   #$0004
         STA   [$F6],Y
         INC   $F2
L0908AB  LDA   $F2
         SEC
         SBC   #$0003
         BVS   L0908B6
         EOR   #$8000
L0908B6  BMI   L0908BB
         BRL   L0906CF
L0908BB  TSC
         CLC
         ADC   #$0012
         TCS
         PLD
         RTL

L0908C3  ENT
         PHD
         TSC
         SEC
         SBC   #$00F5
         TCD
         ADC   #$00E2
         TCS
         STZ   $E4
         STZ   $EE
         BRL   L090A2E
L0908D5  LDA   $EE
         LDX   #$0000
         TAY
         BPL   L0908DE
         DEX
L0908DE  PEA   $0000
         PEA   $000E
         CLC
         JSL   L010FF0
         LDA   #L032823
         LDX   #^L032823
         JSL   L010E15
         PLA
         PLX
         STX   $E8
         STA   $E6
         LDY   #$0006
         LDA   [$E6],Y
         PHA
         LDY   #$0016
         LDA   [$FB],Y
         PLX
         STX   $F0
         CMP   $F0
         BEQ   L09090E
         BRL   L090A2C
L09090E  LDA   #$0003
         STA   $EE
         STZ   $EC
         BRA   L09098B
L090917  LDA   $E6
         CLC
         ADC   #$0008
         LDX   $E8
         BCC   L090922
         INX
L090922  STA   $F0
         STX   $F2
         LDA   [$F0]
         PHA
         LDA   $FF
         CLC
         ADC   #$0001
         PLX
         STX   $F0
         CMP   $F0
         BNE   L09094A
         LDA   #$0001
         LDY   #$0014
         STA   [$FB],Y
         LDA   #$0003
         STA   $EC
         LDA   #$0001
         STA   $E4
         BRA   L090989
L09094A  LDA   $EC
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   $E6
         CLC
         ADC   #$0008
         LDX   $E8
         BCC   L09095D
         INX
L09095D  JSL   L010E15
         PLA
         PLX
         STA   $F0
         STX   $F2
         LDA   [$F0]
         PHA
         LDA   $FF
         CLC
         ADC   #$0001
         PLX
         STX   $F0
         CMP   $F0
         BNE   L090989
         LDA   #$0000
         LDY   #$0014
         STA   [$FB],Y
         LDA   #$0003
         STA   $EC
         LDA   #$0001
         STA   $E4
L090989  INC   $EC
L09098B  LDA   $EC
         SEC
         SBC   #$0003
         BVS   L090996
         EOR   #$8000
L090996  BMI   L09099B
         BRL   L090917
L09099B  LDA   $E4
         BEQ   L0909A2
         BRL   L090A2C
L0909A2  STZ   $EC
         BRA   L090A1C
L0909A6  LDA   $EC
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   $E6
         CLC
         ADC   #$0008
         LDX   $E8
         BCC   L0909B9
         INX
L0909B9  JSL   L010E15
         PLA
         PLX
         STA   $F0
         STX   $F2
         LDA   [$F0]
         BNE   L090A1A
         LDA   $FF
         CLC
         ADC   #$0001
         PHA
         LDA   $EC
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   $E6
         CLC
         ADC   #$0008
         LDX   $E8
         BCC   L0909E1
         INX
L0909E1  JSL   L010E15
         PLA
         PLX
         STA   $F0
         STX   $F2
         PLA
         STA   [$F0]
         LDA   $E6
         CLC
         ADC   #$0008
         LDX   $E8
         BCC   L0909F9
         INX
L0909F9  STA   $F0
         STX   $F2
         LDA   [$F0]
         PHA
         LDA   $FF
         CLC
         ADC   #$0001
         PLX
         STX   $F0
         CMP   $F0
         BNE   L090A15
         LDA   #$0001
         LDY   #$0014
         STA   [$FB],Y
L090A15  LDA   #$0003
         STA   $EC
L090A1A  INC   $EC
L090A1C  LDA   $EC
         SEC
         SBC   #$0003
         BVS   L090A27
         EOR   #$8000
L090A27  BMI   L090A2C
         BRL   L0909A6
L090A2C  INC   $EE
L090A2E  LDA   $EE
         SEC
         SBC   #$0003
         BVS   L090A39
         EOR   #$8000
L090A39  BMI   L090A3E
         BRL   L0908D5
L090A3E  TSC
         CLC
         ADC   #$0012
         TCS
         PLD
         RTL

L090A46  ENT
         PHD
         TSC
         SEC
         SBC   #$00F5
         TCD
         ADC   #$00E6
         TCS
         STZ   $EE
         BRL   L090B9C
L090A56  LDA   $EE
         LDX   #$0000
         TAY
         BPL   L090A5F
         DEX
L090A5F  PEA   $0000
         PEA   $000E
         CLC
         JSL   L010FF0
         LDA   #L032823
         LDX   #^L032823
         JSL   L010E15
         PLA
         PLX
         STX   $EA
         STA   $E8
         STZ   $EC
         BRL   L090B8A
L090A7F  LDA   $EC
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   $E8
         CLC
         ADC   #$0008
         LDX   $EA
         BCC   L090A92
         INX
L090A92  JSL   L010E15
         PLA
         PLX
         STA   $F0
         STX   $F2
         LDA   [$F0]
         PHA
         LDA   $FF
         CLC
         ADC   #$0001
         PLX
         STX   $F0
         CMP   $F0
         BEQ   L090AAF
         BRL   L090B88
L090AAF  LDA   $EC
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   $E8
         CLC
         ADC   #$0008
         LDX   $EA
         BCC   L090AC2
         INX
L090AC2  JSL   L010E15
         PLA
         PLX
         STA   $F0
         STX   $F2
         LDA   #$0000
         STA   [$F0]
         LDA   $EC
         CMP   #$0000
         BNE   L090B40
         LDA   $E8
         CLC
         ADC   #$0008
         LDX   $EA
         BCC   L090AE3
         INX
L090AE3  STA   $F0
         STX   $F2
         LDY   #$0002
         LDA   [$F0],Y
         PHA
         LDA   $E8
         CLC
         ADC   #$0008
         LDX   $EA
         BCC   L090AF8
         INX
L090AF8  STA   $F0
         STX   $F2
         PLA
         STA   [$F0]
         LDA   $E8
         CLC
         ADC   #$0008
         LDX   $EA
         BCC   L090B0A
         INX
L090B0A  STA   $F0
         STX   $F2
         LDY   #$0004
         LDA   [$F0],Y
         PHA
         LDA   $E8
         CLC
         ADC   #$0008
         LDX   $EA
         BCC   L090B1F
         INX
L090B1F  STA   $F0
         STX   $F2
         PLA
         LDY   #$0002
         STA   [$F0],Y
         LDA   $E8
         CLC
         ADC   #$0008
         LDX   $EA
         BCC   L090B34
         INX
L090B34  STA   $F0
         STX   $F2
         LDA   #$0000
         LDY   #$0004
         STA   [$F0],Y
L090B40  LDA   $EC
         CMP   #$0001
         BNE   L090B88
         LDA   $E8
         CLC
         ADC   #$0008
         LDX   $EA
         BCC   L090B52
         INX
L090B52  STA   $F0
         STX   $F2
         LDY   #$0004
         LDA   [$F0],Y
         PHA
         LDA   $E8
         CLC
         ADC   #$0008
         LDX   $EA
         BCC   L090B67
         INX
L090B67  STA   $F0
         STX   $F2
         PLA
         LDY   #$0002
         STA   [$F0],Y
         LDA   $E8
         CLC
         ADC   #$0008
         LDX   $EA
         BCC   L090B7C
         INX
L090B7C  STA   $F0
         STX   $F2
         LDA   #$0000
         LDY   #$0004
         STA   [$F0],Y
L090B88  INC   $EC
L090B8A  LDA   $EC
         SEC
         SBC   #$0003
         BVS   L090B95
         EOR   #$8000
L090B95  BMI   L090B9A
         BRL   L090A7F
L090B9A  INC   $EE
L090B9C  LDA   $EE
         SEC
         SBC   #$0003
         BVS   L090BA7
         EOR   #$8000
L090BA7  BMI   L090BAC
         BRL   L090A56
L090BAC  LDA   #$0000
         LDY   #$0014
         STA   [$FB],Y
         TSC
         CLC
         ADC   #$000E
         TCS
         PLD
         RTL

L090BBC  ENT
         PHD
         TSC
         SEC
         SBC   #$00F5
         TCD
         ADC   #$00EA
         TCS
         PEA   $00C8
         PEA   $0000
         LDX   L0200B4
         LDA   L0200B2
         PHX
         PHA
         PEA   $0000
         PEA   $00E1
         PEA   $2000
         JSL   L1007BF
         TAY
         TSC
         CLC
         ADC   #$000E
         TCS
         TYA
         PEA   $0010
         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
         LDX   L020139
         LDA   L020137
         PHX
         PHA
         LDX   L0200B4
         LDA   L0200B2
         PHX
         PHA
         PEA   $00B2
         PEA   $002B
         PEA   $0000
         JSL   L0F06B3
         TAY
         TSC
         CLC
         ADC   #$000E
         TCS
         TYA
         JSL   L090CD3
         LDA   $FB
         BNE   L090C43
         BRL   L090CC7
L090C43  LDAL  L033DE7
         TAX
         LDAL  L033DE5
         PHX
         PHA
         LDX   L0200B4
         LDA   L0200B2
         PHX
         PHA
         PEA   $007A
         PEA   $00BA
         PEI   $FD
         JSL   L0F06F8
         TAY
         TSC
         CLC
         ADC   #$000E
         TCS
         TYA
         LDA   $FF
         BEQ   L090CC7
         LDA   $FF
         SEC
         SBC   #$0001
         LDX   #$0000
         TAY
         BPL   L090C7B
         DEX
L090C7B  STX   $F4
         ASL
         ROL   $F4
         ASL
         ROL   $F4
         LDX   $F4
         PHX
         PHA
         LDA   #L033C10
         LDX   #^L033C10
         JSL   L010E15
         PLA
         PLX
         STA   $F0
         STX   $F2
         LDY   #$0002
         LDA   [$F0],Y
         TAX
         LDA   [$F0]
         STX   $EE
         STA   $EC
         PEI   $EE
         PEI   $EC
         PEA   ^L0305F9
         PEA   L0305F9
         LDX   L0200B4
         LDA   L0200B2
         PHX
         PHA
         PEA   $006A
         PEA   $00C4
         JSL   L0F0421
         TAY
         TSC
         CLC
         ADC   #$0010
         TCS
         TYA
L090CC7  JSL   L0E0062
         TSC
         CLC
         ADC   #$000A
         TCS
         PLD
         RTL

L090CD3  PHD
         TSC
         SEC
         SBC   #$00FB
         TCD
         ADC   #$00E8
         TCS
         STZ   $F4
         BRL   L090DF7
L090CE3  LDA   $F4
         LDX   #$0000
         TAY
         BPL   L090CEC
         DEX
L090CEC  PEA   $0000
         PEA   $000E
         CLC
         JSL   L010FF0
         LDA   #L032823
         LDX   #^L032823
         JSL   L010E15
         PLA
         PLX
         STX   $EC
         STA   $EA
         LDA   $EA
         CLC
         ADC   #$0008
         LDX   $EC
         BCC   L090D12
         INX
L090D12  STA   $F6
         STX   $F8
         LDA   [$F6]
         BNE   L090D48
         LDAL  L033DE7
         TAX
         LDAL  L033DE5
         PHX
         PHA
         LDX   L0200B4
         LDA   L0200B2
         PHX
         PHA
         LDY   #$0002
         LDA   [$EA],Y
         PHA
         LDA   [$EA]
         PHA
         PEA   $0007
         JSL   L0F06F8
         TAY
         TSC
         CLC
         ADC   #$000E
         TCS
         TYA
         BRL   L090DF5
L090D48  LDAL  L033DE7
         TAX
         LDAL  L033DE5
         PHX
         PHA
         LDX   L0200B4
         LDA   L0200B2
         PHX
         PHA
         LDY   #$0002
         LDA   [$EA],Y
         PHA
         LDA   [$EA]
         PHA
         LDY   #$0004
         LDA   [$EA],Y
         PHA
         JSL   L0F06F8
         TAY
         TSC
         CLC
         ADC   #$000E
         TCS
         TYA
         LDA   $EA
         CLC
         ADC   #$0008
         LDX   $EC
         BCC   L090D81
         INX
L090D81  STA   $F6
         STX   $F8
         LDA   [$F6]
         SEC
         SBC   #$0001
         LDX   #$0000
         TAY
         BPL   L090D92
         DEX
L090D92  STX   $FA
         ASL
         ROL   $FA
         ASL
         ROL   $FA
         LDX   $FA
         PHX
         PHA
         LDA   #L033C10
         LDX   #^L033C10
         JSL   L010E15
         PLA
         PLX
         STA   $F6
         STX   $F8
         LDY   #$0002
         LDA   [$F6],Y
         TAX
         LDA   [$F6]
         STX   $F0
         STA   $EE
         PEI   $F0
         PEI   $EE
         PEA   ^L030601
         PEA   L030601
         LDX   L0200B4
         LDA   L0200B2
         PHX
         PHA
         LDA   $F2
         ASL
         ASL
         ASL
         PHA
         LDY   #$0002
         LDA   [$EA],Y
         SEC
         SBC   #$0008
         PLX
         STX   $FA
         CLC
         ADC   $FA
         PHA
         LDA   [$EA]
         SEC
         SBC   #$0018
         PHA
         JSL   L0F0421
         TAY
         TSC
         CLC
         ADC   #$0010
         TCS
         TYA
L090DF5  INC   $F4
L090DF7  LDA   $F4
         SEC
         SBC   #$0003
         BVS   L090E02
         EOR   #$8000
L090E02  BMI   L090E07
         BRL   L090CE3
L090E07  TSC
         CLC
         ADC   #$0012
         TCS
         PLD
         RTL

L090E0F  ENT
         PHD
         TSC
         SEC
         SBC   #$00F9
         TCD
         ADC   #$00EE
         TCS
         LDA   #L0327FF
         LDX   #^L0327FF
         STX   $F2
         STA   $F0
L090E24  LDA   [$F0]
         AND   #$8000
         TAY
         BNE   L090E4E
         LDA   [$F0]
         CMP   $FF
         BNE   L090E39
         LDY   #$0002
         LDA   [$F0],Y
         BRA   L090E51
L090E39  LDX   $F2
         LDA   $F0
         CLC
         ADC   #$0004
         PHA
         TXA
         ADC   #$0000
         TAX
         PLA
         STX   $F2
         STA   $F0
         BRA   L090E24
L090E4E  LDA   #$8000
L090E51  TAY
         TSC
         CLC
         ADC   #$000A
         TCS
         TYA
         PLD
         RTL

