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

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

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

L0F0000  PHD
         TSC
         SEC
         SBC   #$00F9
         TCD
         ADC   #$00F2
         TCS
         LDA   $FF
         CMP   #$0041
         BCC   L0F001E
         LDA   $FF
         SEC
         SBC   #$0041
         CLC
         ADC   #$000A
         BRA   L0F0024
L0F001E  LDA   $FF
         SEC
         SBC   #$0030
L0F0024  TAY
         TSC
         CLC
         ADC   #$0006
         TCS
         TYA
         PLD
         RTL

L0F002E  PHD
         TSC
         SEC
         SBC   #$00F7
         TCD
         ADC   #$00F0
         TCS
         LDX   $FF
         LDA   $FD
         TAY
         TSC
         CLC
         ADC   #$0006
         TCS
         TYA
         PLD
         RTL

L0F0047  ENT
         PHD
         TSC
         SEC
         SBC   #$00FB
         TCD
         ADC   #$00F4
         TCS
         PEA   $0000
         JSL   L0F0080
         PLY
         PEA   $0000
         PEA   $2710
         JSL   L10018A
         PLY
         PLY
         STX   L0200F6
         STA   L0200F4
         LDA   #L100887
         LDX   #^L100887
         STX   L0200FA
         STA   L0200F8
         TSC
         CLC
         ADC   #$0006
         TCS
         PLD
         RTL

L0F0080  PHD
         TSC
         SEC
         SBC   #$00F9
         TCD
         ADC   #$00EC
         TCS
         LDA   $FF
         STA   L0200C6
         LDA   $FF
         ASL
         ASL
         ASL
         ASL
         STA   L0200C8
         LDA   $FF
         ASL
         ASL
         ASL
         ASL
         ASL
         ASL
         ASL
         ASL
         STA   L0200CA
         LDA   #$000C
         PHA
         LDA   $FF
         CLC
         JSL   L011142
         PLA
         STA   L0200CC
         STZ   $F2
         BRL   L0F01D0
L0F00BA  LDA   $F2
         AND   #$000F
         CMP   $FF
         BNE   L0F00C8
         LDA   #$000F
         BRA   L0F00CB
L0F00C8  LDA   #$0000
L0F00CB  PHA
         LDA   $F2
         LDX   #$0000
         PHX
         PHA
         LDA   #L032E3F
         LDX   #^L032E3F
         JSL   L010E15
         PLA
         PLX
         STA   $F4
         STX   $F6
         PLA
         SEP   #$20
         STA   [$F4]
         REP   #$20
         LDA   $F2
         AND   #$000F
         CMP   $FF
         BNE   L0F00F8
         LDA   #$008F
         BRA   L0F00FB
L0F00F8  LDA   #$0088
L0F00FB  PHA
         LDA   $F2
         LDX   #$0000
         PHX
         PHA
         LDA   #L03303F
         LDX   #^L03303F
         JSL   L010E15
         PLA
         PLX
         STA   $F4
         STX   $F6
         PLA
         SEP   #$20
         STA   [$F4]
         REP   #$20
         LDA   $F2
         AND   #$00F0
         CMP   L0200C8
         BNE   L0F016E
         LDA   $F2
         LDX   #$0000
         PHX
         PHA
         LDA   #L032E3F
         LDX   #^L032E3F
         JSL   L010E15
         PLA
         PLX
         STA   $F4
         STX   $F6
         LDA   [$F4]
         AND   #$00FF
         ORA   #$00F0
         SEP   #$20
         STA   [$F4]
         REP   #$20
         LDA   $F2
         LDX   #$0000
         PHX
         PHA
         LDA   #L03303F
         LDX   #^L03303F
         JSL   L010E15
         PLA
         PLX
         STA   $F4
         STX   $F6
         LDA   [$F4]
         AND   #$00FF
         ORA   #$00F0
         SEP   #$20
         STA   [$F4]
         REP   #$20
L0F016E  SEP   #$20
         LDA   $F2
         LSR
         ROR
         ROR
         ROR
         TAY
         ROR
         REP   #$20
         AND   #$00F0
         STA   $F0
         TYA
         AND   #$000F
         ORA   $F0
         STA   $F0
         AND   #$0077
         STA   $EE
         LDA   $F0
         PHA
         LDA   $F2
         LDX   #$0000
         PHX
         PHA
         LDA   #L032F3F
         LDX   #^L032F3F
         JSL   L010E15
         PLA
         PLX
         STA   $F4
         STX   $F6
         PLA
         SEP   #$20
         STA   [$F4]
         REP   #$20
         LDA   $EE
         PHA
         LDA   $F2
         LDX   #$0000
         PHX
         PHA
         LDA   #L03313F
         LDX   #^L03313F
         JSL   L010E15
         PLA
         PLX
         STA   $F4
         STX   $F6
         PLA
         SEP   #$20
         STA   [$F4]
         REP   #$20
         INC   $F2
L0F01D0  LDA   $F2
         CMP   #$0100
         BEQ   L0F01DA
         BRL   L0F00BA
L0F01DA  PHX
         PHA
         _GetPort
         BCS   L0F01E8
         LDA   #$0000
L0F01E8  STAL  L020010
         PLA
         PLX
         STX   L0200F2
         STA   L0200F0
         TSC
         CLC
         ADC   #$000C
         TCS
         PLD
         RTL

L0F01FC  XBA
         TAX
         LSR
         LSR
         LSR
         LSR
         AND   #$0F0F
         STA   L0200EA
         TXA
         ASL
         ASL
         ASL
         ASL
         AND   #$F0F0
         ORA   L0200EA
         RTL

L0F0214  STA   $00
         STX   $02
         XBA
         SEP   #$30
         TAX
         LDAL  L032E3F,X
         XBA
         LDX   $00
         LDAL  L032E3F,X
         REP   #$30
         TAX
         AND   $02
         STA   $02
         TXA
         EOR   #$FFFF
         AND   $00
         ORA   $02
         RTL

L0F0237  ENT
         PHD
         TSC
         SEC
         SBC   #$00F9
         TCD
         ADC   #$00E8
         TCS
         LDA   #$0000
         SEP   #$20
         STA   $F1
         REP   #$20
         LDA   #$0006
         STA   $F2
L0F0250  LDA   #$000A
         PHA
         LDA   $FF
         CLC
         JSL   L010E20
         LDA   #$0030
         PLX
         STX   $F8
         CLC
         ADC   $F8
         PHA
         LDA   $F2
         DEC   $F2
         LDX   #$0000
         PHX
         PHA
         LDX   #$0000
         TDC
         CLC
         ADC   #$00EA
         JSL   L010E15
         PLA
         PLX
         STA   $F4
         STX   $F6
         PLA
         SEP   #$20
         STA   [$F4]
         REP   #$20
         LDA   #$000A
         PHA
         LDA   $FF
         CLC
         JSL   L010E20
         PLY
         STA   $FF
         LDA   $FF
         BNE   L0F0250
         LDA   $F2
         CLC
         ADC   #$0001
         LDX   #$0000
         PHX
         PHA
         LDX   #$0000
         TDC
         CLC
         ADC   #$00EA
         JSL   L010E15
         _DrawCString
         BCS   L0F02BC
         LDA   #$0000
L0F02BC  STAL  L020010
         TSC
         CLC
         ADC   #$0010
         TCS
         PLD
         RTL

L0F02C8  PHD
         TSC
         SEC
         SBC   #$00F7
         TCD
         ADC   #$00E6
         TCS
         LDA   #$0000
         SEP   #$20
         STA   $EF
         REP   #$20
         LDA   #$0006
         STA   $F0
L0F02E1  LDX   #$0000
         LDA   #$000A
         PHX
         PHA
         LDX   $FF
         LDA   $FD
         CLC
         JSL   L010EAF
         LDX   #$0000
         LDA   #$0030
         JSL   L010E15
         PLA
         PLX
         PHA
         LDA   $F0
         DEC   $F0
         LDX   #$0000
         PHX
         PHA
         LDX   #$0000
         TDC
         CLC
         ADC   #$00E8
         JSL   L010E15
         PLA
         PLX
         STA   $F2
         STX   $F4
         PLA
         SEP   #$20
         STA   [$F2]
         REP   #$20
         LDX   #$0000
         LDA   #$000A
         PHX
         PHA
         LDX   $FF
         LDA   $FD
         CLC
         JSL   L010EAF
         PLY
         PLY
         STX   $FF
         STA   $FD
         LDX   $FF
         LDA   $FD
         STX   $F2
         ORA   $F2
         BNE   L0F02E1
         LDA   $F0
         CLC
         ADC   #$0001
         LDX   #$0000
         PHX
         PHA
         LDX   #$0000
         TDC
         CLC
         ADC   #$00E8
         JSL   L010E15
         _DrawCString
         BCS   L0F0365
         LDA   #$0000
L0F0365  STAL  L020010
         TSC
         CLC
         ADC   #$0010
         TCS
         PLD
         RTL

L0F0371  ENT
         PHD
         TSC
         SEC
         SBC   #$00F7
         TCD
         ADC   #$00F0
         TCS
         LDX   L0200F2
         LDA   L0200F0
         STA   $F2
         STX   $F4
         LDY   #$0004
         LDA   [$F2],Y
         TAX
         LDY   #$0002
         LDA   [$F2],Y
         STX   L0200EE
         STA   L0200EC
         LDX   L0200F2
         LDA   L0200F0
         STA   $F2
         STX   $F4
         LDX   $FF
         LDA   $FD
         LDY   #$0004
         PHA
         TXA
         STA   [$F2],Y
         PLA
         LDY   #$0002
         STA   [$F2],Y
         TSC
         CLC
         ADC   #$0006
         TCS
         PLD
         RTL

L0F03BA  ENT
         PHD
         TSC
         SEC
         SBC   #$00FB
         TCD
         ADC   #$00F4
         TCS
         LDX   L0200F2
         LDA   L0200F0
         STA   $F6
         STX   $F8
         LDX   L0200EE
         LDA   L0200EC
         LDY   #$0004
         PHA
         TXA
         STA   [$F6],Y
         PLA
         LDY   #$0002
         STA   [$F6],Y
         TSC
         CLC
         ADC   #$0006
         TCS
         PLD
         RTL

         PHD
         TSC
         SEC
         SBC   #$00F7
         TCD
         ADC   #$00F0
         TCS
         PEI   $FD
         _SetForeColor
         BCS   L0F0403
         LDA   #$0000
L0F0403  STAL  L020010
         PEI   $FF
         _SetBackColor
         BCS   L0F0415
         LDA   #$0000
L0F0415  STAL  L020010
         TSC
         CLC
         ADC   #$0006
         TCS
         PLD
         RTL

L0F0421  ENT
         PHD
         TSC
         SEC
         SBC   #$00EF
         TCD
         ADC   #$00DA
         TCS
         DEC   $F7
         PEI   $FB
         PEI   $F9
         JSL   L0F0371
         PLY
         PLY
         PEI   $F5
         LDA   $F7
         CLC
         ADC   #$0008
         PHA
         _MoveTo
         BCS   L0F044D
         LDA   #$0000
L0F044D  STAL  L020010
         LDX   #$0000
         TDC
         CLC
         ADC   #$00FD
         STX   $E8
         STA   $E6
         LDX   $E8
         LDA   $E6
         CLC
         ADC   #$0004
         PHA
         TXA
         ADC   #$0000
         TAX
         PLA
         STX   $E8
         STA   $E6
L0F0470  LDA   [$FD]
         AND   #$00FF
         BNE   L0F047A
         BRL   L0F0694
L0F047A  LDA   [$FD]
         AND   #$00FF
         BEQ   L0F04B1
         LDA   [$FD]
         AND   #$00FF
         CMP   #$0025
         BEQ   L0F04B1
         LDX   $FF
         LDA   $FD
         INC   $FD
         BNE   L0F0495
         INC   $FF
L0F0495  STA   $EA
         STX   $EC
         LDA   [$EA]
         AND   #$00FF
         PHA
         _DrawChar
         BCS   L0F04AB
         LDA   #$0000
L0F04AB  STAL  L020010
         BRA   L0F047A
L0F04B1  LDA   [$FD]
         AND   #$00FF
         CMP   #$0025
         BEQ   L0F04BE
         BRL   L0F0691
L0F04BE  INC   $FD
         BNE   L0F04C4
         INC   $FF
L0F04C4  LDX   $FF
         LDA   $FD
         INC   $FD
         BNE   L0F04CE
         INC   $FF
L0F04CE  STA   $EA
         STX   $EC
         LDA   [$EA]
         AND   #$00FF
         STA   $E4
         STZ   $E2
         LDA   $E4
         BRL   L0F0627
L0F04E0  PEA   $0025
         _DrawChar
         BCS   L0F04EF
         LDA   #$0000
L0F04EF  STAL  L020010
         BRL   L0F067C
L0F04F6  PEA   $0004
         _SetTextMode
         BCS   L0F0505
         LDA   #$0000
L0F0505  STAL  L020010
         BRL   L0F067C
L0F050C  PEA   $0000
         _SetTextMode
         BCS   L0F051B
         LDA   #$0000
L0F051B  STAL  L020010
         BRL   L0F067C
L0F0522  LDA   [$E6]
         PHA
         _SetForeColor
         BCS   L0F0531
         LDA   #$0000
L0F0531  STAL  L020010
         LDA   #$0002
         STA   $E2
         BRL   L0F067C
L0F053D  LDA   [$E6]
         PHA
         _SetBackColor
         BCS   L0F054C
         LDA   #$0000
L0F054C  STAL  L020010
         LDA   #$0002
         STA   $E2
         BRL   L0F067C
L0F0558  LDX   $FF
         LDA   $FD
         INC   $FD
         BNE   L0F0562
         INC   $FF
L0F0562  STA   $EA
         STX   $EC
         LDA   [$EA]
         AND   #$00FF
         PHA
         JSL   L0F0000
         PLY
         STA   $E0
         PEI   $E0
         _SetForeColor
         BCS   L0F0581
         LDA   #$0000
L0F0581  STAL  L020010
         BRL   L0F067C
L0F0588  LDX   $FF
         LDA   $FD
         INC   $FD
         BNE   L0F0592
         INC   $FF
L0F0592  STA   $EA
         STX   $EC
         LDA   [$EA]
         AND   #$00FF
         PHA
         JSL   L0F0000
         PLY
         STA   $E0
         PEI   $E0
         _SetBackColor
         BCS   L0F05B1
         LDA   #$0000
L0F05B1  STAL  L020010
         BRL   L0F067C
L0F05B8  LDY   #$0002
         LDA   [$E6],Y
         TAX
         LDA   [$E6]
         PHX
         PHA
         _DrawCString
         BCS   L0F05CE
         LDA   #$0000
L0F05CE  STAL  L020010
         LDA   #$0004
         STA   $E2
         BRL   L0F067C
L0F05DA  LDA   [$E6]
         PHA
         JSL   L0F0237
         PLY
         LDA   #$0002
         STA   $E2
         BRL   L0F067C
L0F05EA  LDY   #$0002
         LDA   [$E6],Y
         TAX
         LDA   [$E6]
         PHX
         PHA
         JSL   L0F02C8
         PLY
         PLY
         LDA   #$0004
         STA   $E2
         BRL   L0F067C
L0F0602  LDA   $F7
         CLC
         ADC   #$0008
         STA   $F7
         PEI   $F5
         LDA   $F7
         CLC
         ADC   #$0008
         PHA
         _MoveTo
         BCS   L0F061F
         LDA   #$0000
L0F061F  STAL  L020010
         BRA   L0F067C
         BRA   L0F067C
L0F0627  CMP   #$0025
         BNE   L0F062F
         BRL   L0F04E0
L0F062F  CMP   #$0043
         BNE   L0F0637
         BRL   L0F0558
L0F0637  CMP   #$0046
         BNE   L0F063F
         BRL   L0F0588
L0F063F  CMP   #$0049
         BNE   L0F0647
         BRL   L0F04F6
L0F0647  CMP   #$004E
         BNE   L0F064F
         BRL   L0F050C
L0F064F  CMP   #$0063
         BNE   L0F0657
         BRL   L0F0522
L0F0657  CMP   #$0064
         BNE   L0F065F
         BRL   L0F05DA
L0F065F  CMP   #$0066
         BNE   L0F0667
         BRL   L0F053D
L0F0667  CMP   #$006C
         BNE   L0F066F
         BRL   L0F05EA
L0F066F  CMP   #$006E
         BEQ   L0F0602
         CMP   #$0073
         BNE   L0F067C
         BRL   L0F05B8
L0F067C  LDA   $E2
         LDX   #$0000
         PHX
         PHA
         LDX   $E8
         LDA   $E6
         JSL   L010E15
         PLA
         PLX
         STX   $E8
         STA   $E6
L0F0691  BRL   L0F0470
L0F0694  PEA   $0000
         _SetTextMode
         BCS   L0F06A3
         LDA   #$0000
L0F06A3  STAL  L020010
         JSL   L0F03BA
         TSC
         CLC
         ADC   #$0014
         TCS
         PLD
         RTL

L0F06B3  ENT
         PHD
         TSC
         SEC
         SBC   #$00ED
         TCD
         ADC   #$00E6
         TCS
         LDA   #L0F002E
         LDX   #^L0F002E
         STX   L0200FA
         STA   L0200F8
         PEI   $FF
         PEI   $FD
         PEI   $FB
         PEI   $F9
         PEI   $F7
         PEI   $F5
         PEI   $F3
         JSL   L0F06F8
         TAY
         TSC
         CLC
         ADC   #$000E
         TCS
         TYA
         LDA   #L100887
         LDX   #^L100887
         STX   L0200FA
         STA   L0200F8
         TSC
         CLC
         ADC   #$0006
         TCS
         PLD
         RTL

L0F06F8  ENT
         PHD
         TSC
         SEC
         SBC   #$00ED
         TCD
         ADC   #$00D0
         TCS
         LDA   $F3
         AND   #$8000
         STA   $E2
         LDA   $F3
         AND   #$4000
         TAY
         BEQ   L0F0717
         LDA   #$0000
         BRA   L0F071A
L0F0717  LDA   #$0001
L0F071A  STA   $E0
         LDA   $F3
         AND   #$3FFF
         STA   $F3
         LDA   $F3
         LDX   #$0000
         STX   $EC
         ASL
         ROL   $EC
         ASL
         ROL   $EC
         LDX   $EC
         PHX
         PHA
         LDX   $FF
         LDA   $FD
         JSL   L010E15
         PLA
         PLX
         STA   $E8
         STX   $EA
         LDY   #$0002
         LDA   [$E8],Y
         TAX
         LDA   [$E8]
         STX   $D6
         STA   $D4
         LDX   $FF
         LDA   $FD
         CLC
         ADC   $D4
         PHA
         TXA
         ADC   $D6
         TAX
         PLA
         STX   $DE
         STA   $DC
         LDX   $DE
         LDA   $DC
         INC   $DC
         BNE   L0F0769
         INC   $DE
L0F0769  STA   $E8
         STX   $EA
         LDA   [$E8]
         AND   #$00FF
         ASL
         ASL
         ASL
         ASL
         STA   $E4
         LDA   $E4
         LSR
         PHA
         LDA   #$0001
         PHA
         LDA   $F5
         SEC
         JSL   L011179
         PLA
         PLX
         STX   $EC
         CLC
         ADC   $EC
         CMP   #$00A0
         BEQ   L0F07AF
         BCC   L0F07AF
         LDA   #$0001
         PHA
         LDA   $F5
         SEC
         JSL   L011179
         LDA   #$00A0
         PLX
         STX   $EC
         SEC
         SBC   $EC
         SEC
         SBC   #$0002
         BRA   L0F07B6
L0F07AF  LDA   $E4
         LSR
         SEC
         SBC   #$0002
L0F07B6  STA   $D2
         LDA   $D2
         SEC
         SBC   #$0000
         BEQ   L0F07C7
         BVS   L0F07C5
         EOR   #$8000
L0F07C5  BMI   L0F07CA
L0F07C7  BRL   L0F0949
L0F07CA  LDX   $DE
         LDA   $DC
         INC   $DC
         BNE   L0F07D4
         INC   $DE
L0F07D4  STA   $E8
         STX   $EA
         LDA   [$E8]
         AND   #$00FF
         STA   $E6
         LDA   $E4
         PHA
         LDA   $E6
         CLC
         JSL   L010FAB
         PLA
         LSR
         CLC
         ADC   #$0001
         PHA
         LDX   L0200F6
         LDA   L0200F4
         PHX
         PHA
         PEI   $DE
         PEI   $DC
         LDX   L0200FA
         LDA   L0200F8
         STA   $E8
         STX   $EA
         LDA   $E8
         LDX   $EA
         JSL   L011296
         PLY
         PLY
         PLY
         PLY
         PLY
         STX   $DE
         STA   $DC
         LDA   $F7
         SEC
         SBC   $E6
         BVS   L0F0821
         EOR   #$8000
L0F0821  BMI   L0F0880
         LDA   $F7
         SEC
         SBC   #$0000
         BEQ   L0F0832
         BVS   L0F0830
         EOR   #$8000
L0F0830  BMI   L0F0835
L0F0832  BRL   L0F0949
L0F0835  LDA   #$0001
         PHA
         LDA   $F5
         SEC
         JSL   L011179
         PLA
         LDX   #$0000
         TAY
         BPL   L0F0848
         DEX
L0F0848  PHX
         PHA
         LDX   $FB
         LDA   $F9
         JSL   L010E15
         PLA
         PLX
         STX   $DA
         STA   $D8
         LDA   $E4
         PHA
         LDA   $E6
         SEC
         SBC   $F7
         CLC
         JSL   L010FAB
         PLA
         LSR
         LDX   #$0000
         PHX
         PHA
         LDX   $DE
         LDA   $DC
         JSL   L010E15
         PLA
         PLX
         STX   $DE
         STA   $DC
         LDA   $F7
         STA   $E6
         BRA   L0F08D5
L0F0880  LDA   $F7
         SEC
         SBC   $E6
         LDX   #$0000
         TAY
         BPL   L0F088C
         DEX
L0F088C  STX   $EC
         ASL
         ROL   $EC
         LDX   $EC
         PHX
         PHA
         LDA   #L033ED8
         LDX   #^L033ED8
         JSL   L010E15
         PLA
         PLX
         STA   $E8
         STX   $EA
         LDA   [$E8]
         LDX   #$0000
         PHX
         PHA
         LDA   #$0001
         PHA
         LDA   $F5
         SEC
         JSL   L011179
         PLA
         LDX   #$0000
         TAY
         BPL   L0F08BF
         DEX
L0F08BF  PHX
         PHA
         LDX   $FB
         LDA   $F9
         JSL   L010E15
         PLA
         PLX
         JSL   L010E15
         PLA
         PLX
         STX   $DA
         STA   $D8
L0F08D5  LDA   $E0
         BEQ   L0F0913
         LDA   $E2
         BEQ   L0F08F7
         PEI   $E4
         PEI   $E6
         PEI   $DA
         PEI   $D8
         PEI   $DE
         PEI   $DC
         JSL   L0F0CB7
         TAY
         TSC
         CLC
         ADC   #$000C
         TCS
         TYA
         BRA   L0F0911
L0F08F7  PEI   $D2
         PEI   $E4
         PEI   $E6
         PEI   $DA
         PEI   $D8
         PEI   $DE
         PEI   $DC
         JSL   L0F0C10
         TAY
         TSC
         CLC
         ADC   #$000E
         TCS
         TYA
L0F0911  BRA   L0F0949
L0F0913  LDA   $E2
         BEQ   L0F0931
         PEI   $E4
         PEI   $E6
         PEI   $DA
         PEI   $D8
         PEI   $DE
         PEI   $DC
         JSL   L0F0C63
         TAY
         TSC
         CLC
         ADC   #$000C
         TCS
         TYA
         BRA   L0F0949
L0F0931  PEI   $E4
         PEI   $E6
         PEI   $DA
         PEI   $D8
         PEI   $DE
         PEI   $DC
         JSL   L0F0B2C
         TAY
         TSC
         CLC
         ADC   #$000C
         TCS
         TYA
L0F0949  TSC
         CLC
         ADC   #$001C
         TCS
         PLD
         RTL

L0F0951  ENT
         PHD
         TSC
         SEC
         SBC   #$00ED
         TCD
         ADC   #$00B6
         TCS
         LDX   L0200B4
         LDA   L0200B2
         STX   $FB
         STA   $F9
         LDA   $F3
         TAX
         AND   #$8000
         STA   $D0
         TXA
         AND   #$3FFF
         STA   $F3
         ASL
         ASL
         CLC
         TAY
         LDA   [$FD],Y
         ADC   $FD
         STA   $CA
         INY
         INY
         LDA   [$FD],Y
         ADC   $FF
         STA   $CC
         LDY   #$0003
         SEP   #$20
         LDA   [$CA],Y
         PHA
         PHA
         DEY
         LDA   [$CA],Y
         PHA
         PHA
         DEY
         LDA   [$CA],Y
         PHA
         PHA
         LDA   [$CA]
         PHA
         PHA
         REP   #$20
         PLA
         AND   #$00FF
         STA   $E4
         SEC
         SBC   #$0002
         STA   $B8
         PLA
         AND   #$00FF
         STA   $E6
         PLA
         AND   #$00FF
         STA   $D4
         LDY   $D0
         BEQ   L0F09C3
         LDA   #$0020
         SEC
         SBC   $E4
         SBC   $D4
L0F09C3  CLC
         LSR   $F5
         CLC
         ADC   $F5
         STA   $F5
         PLA
         AND   #$00FF
         STA   $D6
         SEC
         LDA   $F7
         SBC   $D6
         STA   $F7
         SEC
         LDA   $F7
         SBC   $E6
         ASL
         TAY
         LDA   #L033ED8
         STA   $FD
         LDA   #^L033ED8
         STA   $FF
         LDA   [$FD],Y
         CLC
         ADC   $F5
         PHA
         ADCL  L0200B2
         STA   $C2
         LDAL  L0200B4
         ADC   #$0000
         STA   $C4
         PLA
         ADC   $F9
         STA   $C6
         LDA   $FB
         ADC   #$0000
         STA   $C8
         PHB
         LDA   #$0101
         PHA
         PLB
         PLB
         LDA   L0200CE
         STA   L0200D6
         LDA   L0200D0
         STA   L0200D8
         LDA   L0200D4
         STA   L0200DC
         LDA   L0200D2
         STA   L0200DA
         LDA   $F5
         STA   L0200CE
         LDA   $F7
         STA   L0200D0
         LDA   $B8
         CLC
         ADC   #$0002
         STA   L0200D2
         LDA   $E6
         STA   L0200D4
         LDA   $E6
         BNE   L0F0A48
         BRL   L0F0B1A
L0F0A48  LDY   #$0004
         STY   $E0
         LDA   $D0
         BNE   L0F0A53
         BRA   L0F0AB9
L0F0A53  LDA   $B8
         STA   $E2
L0F0A57  LDY   $E0
         LDA   [$CA],Y
         BEQ   L0F0A9B
         SEP   #$30
         TAX
         LDAL  L03313F,X
         STA   $CF
         TAX
         LDAL  L03303F,X
         XBA
         TAX
         LDAL  L03313F,X
         STA   $CE
         TAX
         LDAL  L03303F,X
         REP   #$30
         LDY   $E2
         AND   ($C6),Y
         ORA   $CE
         STA   ($C6),Y
         INC   $E0
         INC   $E0
         DEC   $E2
         DEC   $E2
         BPL   L0F0A57
         CLC
         LDA   $C6
         ADC   #$00A0
         STA   $C6
         DEC   $E6
         BNE   L0F0A53
         BRL   L0F0B1A
L0F0A9B  LDY   $E2
         LDA   ($C6),Y
         STA   ($C6),Y
         INC   $E0
         INC   $E0
         DEC   $E2
         DEC   $E2
         BPL   L0F0A57
         CLC
         LDA   $C6
         ADC   #$00A0
         STA   $C6
         DEC   $E6
         BNE   L0F0A53
         BRA   L0F0B1A
L0F0AB9  INC   $B8
         INC   $B8
L0F0ABD  LDA   #$0000
L0F0AC0  STA   $E2
         LDY   $E0
         LDA   [$CA],Y
         STA   $CE
         BEQ   L0F0AFC
         SEP   #$30
         TAX
         LDAL  L03303F,X
         XBA
         TAX
         LDAL  L03303F,X
         XBA
         REP   #$30
         LDY   $E2
         AND   ($C6),Y
         ORA   $CE
         STA   ($C6),Y
         INC   $E0
         INC   $E0
         LDA   $E2
         INC
         INC
         CMP   $B8
         BCC   L0F0AC0
         CLC
         LDA   $C6
         ADC   #$00A0
         STA   $C6
         DEC   $E6
         BNE   L0F0ABD
         BRA   L0F0B1A
L0F0AFC  LDY   $E2
         LDA   ($C6),Y
         STA   ($C6),Y
         INC   $E0
         INC   $E0
         LDA   $E2
         INC
         INC
         CMP   $B8
         BCC   L0F0AC0
         CLC
         LDA   $C6
         ADC   #$00A0
         STA   $C6
         DEC   $E6
         BNE   L0F0ABD
L0F0B1A  LDA   $C6
         SEC
         SBC   #$00A0
         STA   L0200DE
         PLB
         TSC
         CLC
         ADC   #$0036
         TCS
         PLD
         RTL

L0F0B2C  PHD
         TSC
         SEC
         SBC   #$00EF
         TCD
         ADC   #$00E4
         TCS
         LDA   $FF
         LSR
         DEC
         STA   $FF
         LDA   #$00A0
         SEC
         SBC   $FF
         DEC
         STA   $E6
         PHB
         PHK
         PLB
         PER   L0F0B60+1
         PLA
         STA   $E8
         SEP   #$20
         LDA   $F7
         XBA
         LDA   $FB
         REP   #$20
         STA   ($E8)
         LDX   $F5
         LDY   $F9
L0F0B5E  LDA   $FF
L0F0B60  MVN   $000000,$000000
         TYA
         CLC
         ADC   $E6
         TAY
         DEC   $FD
         BNE   L0F0B5E
         PLB
         TSC
         CLC
         ADC   #$000A
         TCS
         PLD
         RTL

         PHD
         TSC
         SEC
         SBC   #$00EF
         TCD
         ADC   #$00E4
         TCS
         TSC
         CLC
         ADC   #$000A
         TCS
         PLD
         RTL

L0F0B88  ENT
         PHD
         TSC
         SEC
         SBC   #$00EF
         TCD
         ADC   #$00E4
         TCS
         LDA   $FF
         LSR
         DEC
         STA   $FF
         LDA   #$00A0
         SEC
         SBC   $FF
         DEC
         STA   $E6
         PHB
         PHK
         PLB
         PER   L0F0BBC+1
         PLA
         STA   $E8
         SEP   #$20
         LDA   $F7
         XBA
         LDA   $FB
         REP   #$20
         STA   ($E8)
         LDX   $F5
         LDY   $F9
L0F0BBA  LDA   $FF
L0F0BBC  MVN   $000000,$000000
         TYA
         CLC
         ADC   $E6
         TAY
         TXA
         CLC
         ADC   $E6
         TAX
         DEC   $FD
         BNE   L0F0BBA
         PLB
         TSC
         CLC
         ADC   #$000A
         TCS
         PLD
         RTL

L0F0BD6  ENT
         PHD
         TSC
         SEC
         SBC   #$00F5
         TCD
         ADC   #$00EA
         TCS
         LDA   $FF
         LSR
         DEC
         STA   $FF
         LDA   #$00A0
         SEC
         SBC   $FF
         DEC
         STA   $EE
         PHB
         CLC
         LDA   $FB
         ADC   #$2000
         TAX
         TAY
L0F0BF9  LDA   $FF
         MVN   $010000,$E10000
         TYA
         ADC   $EE
         TAY
         TAX
         DEC   $FD
         BNE   L0F0BF9
         PLB
         TSC
         CLC
         ADC   #$000A
         TCS
         PLD
         RTL

L0F0C10  PHD
         TSC
         SEC
         SBC   #$00ED
         TCD
         ADC   #$00E4
         TCS
         LDA   $FD
         LSR
         LSR
         DEC
         ASL
         CLC
         ADC   #$0002
         STA   $FD
L0F0C27  LDY   $FF
L0F0C29  LDA   [$F3],Y
         BEQ   L0F0C45
         STA   $E6
         SEP   #$30
         XBA
         TAX
         LDAL  L032E3F,X
         XBA
         TAX
         LDAL  L032E3F,X
         REP   #$30
         AND   [$F7],Y
         ORA   $E6
         STA   [$F7],Y
L0F0C45  DEY
         DEY
         BPL   L0F0C29
         CLC
         LDA   $F7
         ADC   #$00A0
         STA   $F7
         LDA   $F3
         ADC   $FD
         STA   $F3
         DEC   $FB
         BNE   L0F0C27
         TSC
         CLC
         ADC   #$0008
         TCS
         PLD
         RTL

L0F0C63  PHD
         TSC
         SEC
         SBC   #$00EF
         TCD
         ADC   #$00E8
         TCS
         LDA   $FF
         LSR
         LSR
         DEC
         ASL
         STA   $FF
         LDX   $FD
L0F0C78  PHX
         LDY   $FF
L0F0C7B  LDA   [$F5],Y
         STY   L0200E8
         JSL   L0F01FC
         TAX
         LDA   $FF
         SEC
         SBC   L0200E8
         TAY
         TXA
         STA   [$F9],Y
         LDY   L0200E8
         DEY
         DEY
         BPL   L0F0C7B
         CLC
         LDA   $F9
         ADC   #$00A0
         BCC   L0F0CA0
         INC   $FB
L0F0CA0  STA   $F9
         LDA   $F5
         ADC   $FF
         ADC   #$0002
         STA   $F5
         PLX
         DEX
         BNE   L0F0C78
         TSC
         CLC
         ADC   #$0006
         TCS
         PLD
         RTL

L0F0CB7  PHD
         TSC
         SEC
         SBC   #$00EF
         TCD
         ADC   #$00E8
         TCS
         LDA   $FF
         LSR
         LSR
         DEC
         ASL
         STA   $FF
         LDX   $FD
L0F0CCC  PHX
         LDY   $FF
L0F0CCF  LDA   [$F5],Y
         STY   L0200E8
         JSL   L0F01FC
         PHA
         LDA   $FF
         SEC
         SBC   L0200E8
         TAY
         LDA   [$F9],Y
         TAX
         PLA
         PHY
         JSL   L0F0214
         PLY
         STA   [$F9],Y
         LDY   L0200E8
         DEY
         DEY
         BPL   L0F0CCF
         CLC
         LDA   $F9
         ADC   #$00A0
         STA   $F9
         LDA   $F5
         ADC   $FF
         ADC   #$0002
         STA   $F5
         PLX
         DEX
         BNE   L0F0CCC
         TSC
         CLC
         ADC   #$0006
         TCS
         PLD
         RTL

