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

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

	 use	HELI.X.S
	 
*-----------------------

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

L0D0000  PHD
         TSC
         SEC
         SBC   #$00F1
         TCD
         ADC   #$00E4
         TCS
         LDA   $F9
         CMP   $FD
         BEQ   L0D001F
         BCC   L0D001F
         LDA   $FD
         STA   $EA
         LDA   $F9
         STA   $FD
         LDA   $EA
         STA   $F9
L0D001F  LDA   $F7
         LSR
         PHA
         LDA   $F9
         LDX   #$0000
         STX   $F0
         ASL
         ROL   $F0
         LDX   $F0
         PHX
         PHA
         LDA   #L033ED8
         LDX   #^L033ED8
         JSL   L010E15
         PLA
         PLX
         STA   $EC
         STX   $EE
         LDA   [$EC]
         PLX
         STX   $F0
         CLC
         ADC   $F0
         STA   $EA
         LDA   $FD
         SEC
         SBC   $F9
         STA   $E6
         LDX   #$FFF0
         LDA   $F7
         AND   #$0001
         BNE   L0D0067
         ASL   $FF
         ASL   $FF
         ASL   $FF
         ASL   $FF
         LDX   #$FF0F
L0D0067  STX   $E8
         LDX   $EA
         LDY   $E6
         BEQ   L0D0084
         CLC
L0D0070  LDAL  $012000,X
         AND   $E8
         ORA   $FF
         STAL  $012000,X
         TXA
         ADC   #$00A0
         TAX
         DEY
         BNE   L0D0070
L0D0084  TSC
         CLC
         ADC   #$000C
         TCS
         PLD
         RTL

L0D008C  PHD
         TSC
         SEC
         SBC   #$00FB
         TCD
         ADC   #$00F0
         TCS
         JSL   L010320
         TAY
         BEQ   L0D00AC
L0D009E  LDA   L0200B6
         AND   #$00FF
         BEQ   L0D00A8
         BRA   L0D009E
L0D00A8  JSL   L01032D
L0D00AC  TSC
         CLC
         ADC   #$000A
         TCS
         PLD
         RTL

L0D00B4  PHD
         TSC
         SEC
         SBC   #$00FB
         TCD
         ADC   #$00F4
         TCS
         LDA   L0200B6
         AND   #$00FF
         CMP   #$001B
         BNE   L0D00D4
         LDA   #$0001
         SEP   #$20
         STA   L0200A3
         REP   #$20
L0D00D4  TSC
         CLC
         ADC   #$0006
         TCS
         PLD
         RTL

         PHD
         TSC
         SEC
         SBC   #$00F5
         TCD
         ADC   #$00EE
         TCS
         LDA   [$FB]
         SEC
         SBC   #$0000
         BVS   L0D00F2
         EOR   #$8000
L0D00F2  BPL   L0D0109
         LDA   [$FB]
         SEC
         SBC   $FF
         BEQ   L0D0102
         BVS   L0D0100
         EOR   #$8000
L0D0100  BMI   L0D0109
L0D0102  LDA   #$0000
         BRA   L0D0121
         BRA   L0D0121
L0D0109  LDA   [$FB]
         SEC
         SBC   $FF
         BVS   L0D0113
         EOR   #$8000
L0D0113  BPL   L0D0119
         LDA   $FF
         BRA   L0D011C
L0D0119  LDA   #$0000
L0D011C  STA   [$FB]
         LDA   #$0001
L0D0121  TAY
         TSC
         CLC
         ADC   #$0006
         TCS
         TYA
         PLD
         RTL

L0D012B  PHD
         TSC
         SEC
         SBC   #$00E7
         TCD
         ADC   #$00DC
         TCS
         PEI   $FD
         PEI   $FF
         LDA   $FB
         LDX   #$0000
         TAY
         BPL   L0D0143
         DEX
L0D0143  STX   $E6
         ASL
         ROL   $E6
         LDX   $E6
         PHX
         PHA
         LDA   #L033ED8
         LDX   #^L033ED8
         JSL   L010E15
         PLA
         PLX
         STA   $E2
         STX   $E4
         LDA   [$E2]
         LDX   #$0000
         PHX
         PHA
         LDA   #$0001
         PHA
         LDA   $F9
         SEC
         JSL   L011179
         PLA
         LDX   #$0000
         TAY
         BPL   L0D0176
         DEX
L0D0176  PHX
         PHA
         LDX   $F7
         LDA   $F5
         JSL   L010E15
         PLA
         PLX
         JSL   L010E15
         LDA   $F3
         LDX   #$0000
         TAY
         BPL   L0D018F
         DEX
L0D018F  STX   $E6
         ASL
         ROL   $E6
         LDX   $E6
         PHX
         PHA
         LDA   #L033ED8
         LDX   #^L033ED8
         JSL   L010E15
         PLA
         PLX
         STA   $E2
         STX   $E4
         LDA   [$E2]
         LDX   #$0000
         PHX
         PHA
         LDA   #$0001
         PHA
         LDA   $F1
         SEC
         JSL   L011179
         PLA
         LDX   #$0000
         TAY
         BPL   L0D01C2
         DEX
L0D01C2  PHX
         PHA
         LDX   $EF
         LDA   $ED
         JSL   L010E15
         PLA
         PLX
         JSL   L010E15
         JSL   L0F0B88
         TAY
         TSC
         CLC
         ADC   #$000C
         TCS
         TYA
         TSC
         CLC
         ADC   #$000A
         TCS
         PLD
         RTL

L0D01E6  PHD
         TSC
         SEC
         SBC   #$00FB
         TCD
         ADC   #$00F4
         TCS
         JSL   L100969
         PEA   $00B0
         LDA   L0200B0
         PHA
         LDAL  L033F18
         CLC
         ADC   #$0010
         PHA
         JSL   L0F0BD6
         PLY
         PLY
         PLY
         TSC
         CLC
         ADC   #$0006
         TCS
         PLD
         RTL

L0D0214  PHD
         TSC
         SEC
         SBC   #$00FB
         TCD
         ADC   #$00F0
         TCS
         SEP   #$20
         STZ   L0200A3
         REP   #$20
         PEA   $0080
         PEA   $0020
         JSL   L05042F
         PLY
         PLY
         JSL   L100429
         PEA   ^L032919
         PEA   L032919
         JSL   L01044B
         PLY
         PLY
         STX   L0200A6
         STA   L0200A4
         PEA   $001D
         PEA   $0008
         PEA   ^L032921
         PEA   L032921
         JSL   L060633
         PLY
         PLY
         PLY
         PLY
         PEA   ^L032928
         PEA   L032928
         JSL   L1002E2
         PLY
         PLY
         STX   $F4
         STA   $F2
         PEI   $F4
         PEI   $F2
         PEA   ^L03295B
         PEA   L03295B
         PEA   $0000
         PEA   $0020
         _BlockMove
         BCS   L0D0288
         LDA   #$0000
L0D0288  STAL  L020010
         PEA   $7D00
         PEA   $00E1
         PEA   $2000
         PEI   $F4
         PEI   $F2
         JSL   L1008F3
         PLY
         PLY
         PLY
         PLY
         PLY
         PEI   $F4
         PEI   $F2
         JSL   L100210
         PLY
         PLY
         PEA   ^L03293B
         PEA   L03293B
         JSL   L1002E2
         PLY
         PLY
         STX   $F4
         STA   $F2
         PEA   $7D00
         LDX   L020135
         LDA   L020133
         PHX
         PHA
         PEI   $F4
         PEI   $F2
         JSL   L1008F3
         PLY
         PLY
         PLY
         PLY
         PLY
         PEI   $F4
         PEI   $F2
         JSL   L100210
         PLY
         PLY
         LDX   L0200B4
         LDA   L0200B2
         PHX
         PHA
         PEA   $00E1
         PEA   $2000
         JSL   L100798
         PLY
         PLY
         PLY
         PLY
         TSC
         CLC
         ADC   #$000A
         TCS
         PLD
         RTL

L0D02FC  PHD
         TSC
         SEC
         SBC   #$00FB
         TCD
         ADC   #$00F2
         TCS
         LDAL  L032977
         STA   $F4
         LDAL  L032975
         STAL  L032977
         LDAL  L03295F
         STAL  L032975
         LDA   $F4
         STAL  L03295F
         PEA   ^L03295B
         PEA   L03295B
         JSL   L0E0279
         PLY
         PLY
         TSC
         CLC
         ADC   #$0008
         TCS
         PLD
         RTL

L0D0337  PHD
         TSC
         SEC
         SBC   #$00FB
         TCD
         ADC   #$00F2
         TCS
         JSL   L0D008C
         JSL   L0D00B4
         PEA   $0060
         PEA   $00B0
         PEA   $0020
         PEA   $0020
         LDX   L0200B4
         LDA   L0200B2
         PHX
         PHA
         LDA   L0200AA
         PHA
         LDA   L0200A8
         PHA
         LDX   L020135
         LDA   L020133
         PHX
         PHA
         JSL   L0D012B
         TAY
         TSC
         CLC
         ADC   #$0014
         TCS
         TYA
         LDX   L0200A6
         LDA   L0200A4
         PHX
         PHA
         LDX   L0200B4
         LDA   L0200B2
         PHX
         PHA
         LDA   L0200AE
         PHA
         LDA   L0200AC
         PHA
         PEA   $0000
         JSL   L0F06F8
         TAY
         TSC
         CLC
         ADC   #$000E
         TCS
         TYA
         JSL   L0D02FC
         JSL   L0D01E6
         TSC
         CLC
         ADC   #$0008
         TCS
         PLD
         RTL

L0D03B1  PHD
         TSC
         SEC
         SBC   #$00FB
         TCD
         ADC   #$00EE
         TCS
         LDA   #$FFF0
         STA   $F0
         BRL   L0D0456
L0D03C4  PEA   $0060
         PEA   $00B0
         PEA   $0020
         PEA   $0020
         LDX   L0200B4
         LDA   L0200B2
         PHX
         PHA
         LDA   L0200AA
         PHA
         LDA   L0200A8
         PHA
         LDX   L020135
         LDA   L020133
         PHX
         PHA
         JSL   L0D012B
         TAY
         TSC
         CLC
         ADC   #$0014
         TCS
         TYA
         LDX   L0200A6
         LDA   L0200A4
         PHX
         PHA
         LDX   L0200B4
         LDA   L0200B2
         PHX
         PHA
         LDA   L0200AE
         PHA
         LDA   L0200AC
         PHA
         PEA   $0000
         JSL   L0F06F8
         TAY
         TSC
         CLC
         ADC   #$000E
         TCS
         TYA
         PEA   $0000
         LDA   L0200AE
         CLC
         ADC   $F0
         PHA
         LDA   L0200AC
         CLC
         ADC   #$002E
         PHA
         LDA   L0200AE
         SEC
         SBC   #$0010
         PHA
         LDA   L0200AC
         CLC
         ADC   #$002E
         PHA
         JSL   L0D0000
         PLY
         PLY
         PLY
         PLY
         PLY
         JSL   L0D02FC
         JSL   L0D01E6
         LDA   $F0
         CLC
         ADC   #$0004
         STA   $F0
L0D0456  LDA   $F0
         SEC
         SBC   #$002A
         BVS   L0D0461
         EOR   #$8000
L0D0461  BMI   L0D046E
         LDA   L0200A3
         AND   #$00FF
         BNE   L0D046E
         BRL   L0D03C4
L0D046E  LDA   L0200AE
         CLC
         ADC   #$002A
         PHA
         PEA   $0020
         JSL   L05042F
         PLY
         PLY
         STZ   $F4
         BRL   L0D05DF
L0D0484  STZ   $F2
         BRA   L0D04C1
L0D0488  PEA   $0000
         LDA   L0200AE
         CLC
         ADC   #$002C
         PHA
         LDA   L0200AC
         CLC
         ADC   #$002E
         SEC
         SBC   $F2
         PHA
         LDA   L0200AE
         SEC
         SBC   #$0010
         PHA
         LDA   L0200AC
         CLC
         ADC   #$002E
         PHA
         JSL   L0D0000
         PLY
         PLY
         PLY
         PLY
         PLY
         JSL   L0D02FC
         JSL   L0D01E6
         INC   $F2
L0D04C1  LDA   $F2
         SEC
         SBC   #$0003
         BVS   L0D04CC
         EOR   #$8000
L0D04CC  BPL   L0D0488
         LDA   #$0008
         STA   $F2
         BRL   L0D05CD
L0D04D6  JSL   L0D008C
         JSL   L0D00B4
         PEA   $0060
         PEA   $00B0
         PEA   $0020
         PEA   $0020
         LDX   L0200B4
         LDA   L0200B2
         PHX
         PHA
         LDA   L0200AA
         PHA
         LDA   L0200A8
         PHA
         LDX   L020135
         LDA   L020133
         PHX
         PHA
         JSL   L0D012B
         TAY
         TSC
         CLC
         ADC   #$0014
         TCS
         TYA
         LDX   L0200A6
         LDA   L0200A4
         PHX
         PHA
         LDX   L0200B4
         LDA   L0200B2
         PHX
         PHA
         LDA   L0200AE
         PHA
         LDA   L0200AC
         PHA
         PEA   $0000
         JSL   L0F06F8
         TAY
         TSC
         CLC
         ADC   #$000E
         TCS
         TYA
         PEA   $0000
         LDA   L0200AE
         CLC
         ADC   $F2
         SEC
         SBC   #$0020
         PHA
         LDA   L0200AC
         CLC
         ADC   #$002E
         PHA
         LDA   L0200AE
         SEC
         SBC   #$0010
         PHA
         LDA   L0200AC
         CLC
         ADC   #$002E
         PHA
         JSL   L0D0000
         PLY
         PLY
         PLY
         PLY
         PLY
         LDX   L0200A6
         LDA   L0200A4
         PHX
         PHA
         LDX   L0200B4
         LDA   L0200B2
         PHX
         PHA
         LDA   L0200AE
         CLC
         ADC   $F2
         PHA
         LDA   L0200AC
         PHA
         PEA   $0001
         JSL   L0F06F8
         TAY
         TSC
         CLC
         ADC   #$000E
         TCS
         TYA
         PEA   $0000
         LDA   L0200AE
         CLC
         ADC   #$0028
         PHA
         LDA   L0200AC
         CLC
         ADC   #$002B
         PHA
         LDA   L0200AE
         CLC
         ADC   $F2
         SEC
         SBC   #$001A
         PHA
         LDA   L0200AC
         CLC
         ADC   #$002B
         PHA
         JSL   L0D0000
         PLY
         PLY
         PLY
         PLY
         PLY
         JSL   L0D02FC
         JSL   L0D01E6
         LDA   $F2
         CLC
         ADC   #$0003
         STA   $F2
L0D05CD  LDA   $F2
         SEC
         SBC   #$0048
         BVS   L0D05D8
         EOR   #$8000
L0D05D8  BMI   L0D05DD
         BRL   L0D04D6
L0D05DD  INC   $F4
L0D05DF  LDA   $F4
         SEC
         SBC   #$0003
         BVS   L0D05EA
         EOR   #$8000
L0D05EA  BMI   L0D05F7
         LDA   L0200A3
         AND   #$00FF
         BNE   L0D05F7
         BRL   L0D0484
L0D05F7  LDA   #$002A
         STA   $F0
         BRL   L0D0691
L0D05FF  PEA   $0060
         PEA   $00B0
         PEA   $0020
         PEA   $0020
         LDX   L0200B4
         LDA   L0200B2
         PHX
         PHA
         LDA   L0200AA
         PHA
         LDA   L0200A8
         PHA
         LDX   L020135
         LDA   L020133
         PHX
         PHA
         JSL   L0D012B
         TAY
         TSC
         CLC
         ADC   #$0014
         TCS
         TYA
         LDX   L0200A6
         LDA   L0200A4
         PHX
         PHA
         LDX   L0200B4
         LDA   L0200B2
         PHX
         PHA
         LDA   L0200AE
         PHA
         LDA   L0200AC
         PHA
         PEA   $0000
         JSL   L0F06F8
         TAY
         TSC
         CLC
         ADC   #$000E
         TCS
         TYA
         PEA   $0000
         LDA   L0200AE
         CLC
         ADC   $F0
         PHA
         LDA   L0200AC
         CLC
         ADC   #$002E
         PHA
         LDA   L0200AE
         SEC
         SBC   #$0010
         PHA
         LDA   L0200AC
         CLC
         ADC   #$002E
         PHA
         JSL   L0D0000
         PLY
         PLY
         PLY
         PLY
         PLY
         JSL   L0D02FC
         JSL   L0D01E6
         LDA   $F0
         SEC
         SBC   #$0004
         STA   $F0
L0D0691  LDA   $F0
         SEC
         SBC   #$FFF0
         BEQ   L0D06AB
         BVS   L0D069E
         EOR   #$8000
L0D069E  BPL   L0D06AB
         LDA   L0200A3
         AND   #$00FF
         BNE   L0D06AB
         BRL   L0D05FF
L0D06AB  PEA   $0080
         PEA   $0020
         JSL   L05042F
         PLY
         PLY
         TSC
         CLC
         ADC   #$000C
         TCS
         PLD
         RTL

L0D06BF  ENT
         PHD
         TSC
         SEC
         SBC   #$00FB
         TCD
         ADC   #$00EA
         TCS
         JSL   L0D0214
         PEA   $0064
         JSL   L100926
         PLY
         LDA   #$0060
         STA   L0200B0
         STZ   $F4
         BRA   L0D0718
L0D06E0  LDA   $F4
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   #L03295B
         LDX   #^L03295B
         JSL   L010E15
         PLA
         PLX
         STA   $F6
         STX   $F8
         LDA   [$F6]
         PHA
         LDA   $F4
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   #L033D09
         LDX   #^L033D09
         JSL   L010E15
         PLA
         PLX
         STA   $F6
         STX   $F8
         PLA
         STA   [$F6]
         INC   $F4
L0D0718  LDA   $F4
         SEC
         SBC   #$0010
         BVS   L0D0723
         EOR   #$8000
L0D0723  BPL   L0D06E0
         STZ   L0200A8
         LDA   #$0060
         STA   L0200AA
         PEA   $04B0
         PEA   ^L03297B
         PEA   L03297B
         PEA   ^L03294D
         PEA   L03294D
         JSL   L100282
         PLY
         PLY
         PLY
         PLY
         PLY
         LDX   #$0000
L0D0749  LDAL  L03297B,X
         XBA
         STAL  L03297B,X
         INX
         INX
         CPX   #$04B0
         BNE   L0D0749
         STZ   $F4
         LDA   $F4
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   #L03297B
         LDX   #^L03297B
         JSL   L010E15
         PLA
         PLX
         STA   $F6
         STX   $F8
         LDA   [$F6]
         STA   L0200A8
         LDA   $F4
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   #L032BD3
         LDX   #^L032BD3
         JSL   L010E15
         PLA
         PLX
         STA   $F6
         STX   $F8
         LDA   [$F6]
         STA   L0200AA
         STZ   L0200AC
         LDA   #$0042
         STA   L0200AE
         PEA   $0060
         PEA   $00B0
         PEA   $0020
         PEA   $0020
         PEA   $00E1
         PEA   $2000
         LDA   L0200AA
         PHA
         LDA   L0200A8
         PHA
         LDX   L020135
         LDA   L020133
         PHX
         PHA
         JSL   L0D012B
         TAY
         TSC
         CLC
         ADC   #$0014
         TCS
         TYA
         PEA   ^L03295B
         PEA   L03295B
         JSL   L10056D
         PLY
         PLY
         PEA   $00A0
         JSL   L0605D9
         PLY
         PEA   $0000
         PEA   $0001
         PEA   ^L032915
         PEA   L032915
         JSL   L060719
         PLY
         PLY
         PLY
         PLY
         JSL   L010325
L0D07F8  LDA   L0200AC
         SEC
         SBC   #$0064
         BVS   L0D0804
         EOR   #$8000
L0D0804  BMI   L0D081E
         LDA   L0200A3
         AND   #$00FF
         BNE   L0D081E
         LDA   L0200AC
         CLC
         ADC   #$0003
         STA   L0200AC
         JSL   L0D0337
         BRA   L0D07F8
L0D081E  LDA   $F4
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   #L03297B
         LDX   #^L03297B
         JSL   L010E15
         PLA
         PLX
         STA   $F6
         STX   $F8
         LDA   [$F6]
         SEC
         SBC   #$0190
         BVS   L0D0841
         EOR   #$8000
L0D0841  BPL   L0D0846
         BRL   L0D0890
L0D0846  LDA   L0200A3
         AND   #$00FF
         BNE   L0D0890
         LDA   $F4
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   #L03297B
         LDX   #^L03297B
         JSL   L010E15
         PLA
         PLX
         STA   $F6
         STX   $F8
         LDA   [$F6]
         STA   L0200A8
         LDA   $F4
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   #L032BD3
         LDX   #^L032BD3
         JSL   L010E15
         PLA
         PLX
         STA   $F6
         STX   $F8
         LDA   [$F6]
         STA   L0200AA
         INC   $F4
         JSL   L0D0337
         BRA   L0D081E
L0D0890  LDA   #$004C
         STA   L0200B0
         STZ   $EC
         BRA   L0D08D4
L0D089A  LDA   L0200AC
         STA   $F2
         JSL   L080726
         AND   #$0003
         TAY
         BNE   L0D08BD
         JSL   L080726
         AND   #$0001
         PHA
         LDA   L0200AC
         PLX
         STX   $FA
         CLC
         ADC   $FA
         STA   L0200AC
L0D08BD  JSL   L0D0337
         LDA   $F2
         STA   L0200AC
         JSL   L100099
         TAY
         BEQ   L0D08D2
         LDA   #$0032
         STA   $EC
L0D08D2  INC   $EC
L0D08D4  LDA   $EC
         SEC
         SBC   #$0032
         BVS   L0D08DF
         EOR   #$8000
L0D08DF  BMI   L0D08E9
         LDA   L0200A3
         AND   #$00FF
         BEQ   L0D089A
L0D08E9  JSL   L0D03B1
L0D08ED  LDA   L0200AE
         SEC
         SBC   #$001E
         BEQ   L0D090E
         BVS   L0D08FB
         EOR   #$8000
L0D08FB  BPL   L0D090E
         LDA   L0200A3
         AND   #$00FF
         BNE   L0D090E
         DEC   L0200AE
         JSL   L0D0337
         BRA   L0D08ED
L0D090E  PEA   $FFFF
         JSL   L100926
         PLY
         PEA   $0000
         PEA   $0008
         JSL   L0607F0
         PLY
         PLY
         JSL   L06042E
         TSC
         CLC
         ADC   #$0010
         TCS
         PLD
         RTL

