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

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

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

L170000  ENT
         PHD
         TSC
         SEC
         SBC   #$00F5
         TCD
         ADC   #$00CC
         TCS
         LDA   $FF
         BNE   L170012
         BRL   L170178
L170012  STZ   $E8
         STZ   $EC
         PEA   $0000
         PEA   $0CEE
         JSL   L070000
         PLY
         PLY
         STX   L020139
         STA   L020137
         PEA   ^L033566
         PEA   L033566
         PEA   $0000
         TDC
         CLC
         ADC   #$00D2
         PHA
         JSL   L010882
         PLY
         PLY
         PLY
         PLY
         PEI   $FD
         PEI   $FB
         PEA   $0000
         TDC
         CLC
         ADC   #$00D2
         PHA
         JSL   L0107D7
         PLY
         PLY
         PLY
         PLY
         PEA   ^L03356E
         PEA   L03356E
         PEA   $0000
         TDC
         CLC
         ADC   #$00D2
         PHA
         JSL   L0107D7
         PLY
         PLY
         PLY
         PLY
         PEA   $0CEE
         LDX   L020139
         LDA   L020137
         PHX
         PHA
         PEA   $0000
         TDC
         CLC
         ADC   #$00D2
         PHA
         JSL   L1602D4
         PLY
         PLY
         PLY
         PLY
         PLY
L170088  LDA   $E8
         INC   $E8
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   #L033578
         LDX   #^L033578
         JSL   L010410
         PLA
         PLX
         STA   $F0
         STX   $F2
         LDA   $EC
         STA   [$F0]
         LDA   $EC
         CLC
         ADC   #$0002
         STA   $EC
         BRA   L1700B8
L1700B0  LDA   $EC
         CLC
         ADC   #$0004
         STA   $EC
L1700B8  LDA   $EC
         LDX   #$0000
         TAY
         BPL   L1700C1
         DEX
L1700C1  PHX
         PHA
         LDX   L020139
         LDA   L020137
         JSL   L010410
         PLA
         PLX
         STA   $F0
         STX   $F2
         LDA   [$F0]
         AND   #$00FF
         BNE   L1700B0
         LDA   $EC
         CLC
         ADC   #$0001
         LDX   #$0000
         TAY
         BPL   L1700E7
         DEX
L1700E7  PHX
         PHA
         LDX   L020139
         LDA   L020137
         JSL   L010410
         PLA
         PLX
         STA   $F0
         STX   $F2
         LDA   [$F0]
         AND   #$00FF
         BNE   L1700B0
         LDA   $EC
         CLC
         ADC   #$0002
         STA   $EC
         LDA   $EC
         LDX   #$0000
         TAY
         BPL   L170111
         DEX
L170111  PHX
         PHA
         LDX   L020139
         LDA   L020137
         JSL   L010410
         PLA
         PLX
         STA   $F0
         STX   $F2
         LDA   [$F0]
         AND   #$00FF
         BEQ   L17012D
         BRL   L170088
L17012D  LDA   $EC
         CLC
         ADC   #$0001
         LDX   #$0000
         TAY
         BPL   L17013A
         DEX
L17013A  PHX
         PHA
         LDX   L020139
         LDA   L020137
         JSL   L010410
         PLA
         PLX
         STA   $F0
         STX   $F2
         LDA   [$F0]
         AND   #$00FF
         BEQ   L170156
         BRL   L170088
L170156  PEI   $FD
         PEI   $FB
         JSL   L07031E
         PLY
         PLY
         STX   L020135
         STA   L020133
         PEA   ^L033573
         PEA   L033573
         JSL   L07031E
         PLY
         PLY
         STX   L02013D
         STA   L02013B
L170178  LDA   $E8
         TAY
         TSC
         CLC
         ADC   #$0028
         TCS
         TYA
         PLD
         RTL

L170184  ENT
         PHD
         TSC
         SEC
         SBC   #$00F5
         TCD
         ADC   #$00E0
         TCS
         LDA   $FB
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   #L033578
         LDX   #^L033578
         JSL   L010410
         PLA
         PLX
         STA   $F0
         STX   $F2
         LDA   [$F0]
         LDX   #$0000
         TAY
         BPL   L1701B0
         DEX
L1701B0  PHX
         PHA
         LDX   L020139
         LDA   L020137
         JSL   L010410
         PLA
         PLX
         STX   $EE
         STA   $EC
         LDA   L0200D5
         CMP   $FB
         BNE   L1701D4
         LDA   L0200B8
         AND   #$00FF
         BNE   L1701D4
         BRL   L17059E
L1701D4  LDA   $FB
         STA   L0200D5
         PEA   $FFFF
         PEA   $FFFF
         PEA   $FFFF
         LDX   L020070
         LDA   L02006E
         PHX
         PHA
         JSL   L150000
         PLY
         PLY
         PLY
         PLY
         PLY
         LDA   $FD
         SEC
         SBC   #$0000
         BNE   L1701FE
         BRL   L170359
L1701FE  BVS   L170203
         EOR   #$8000
L170203  BMI   L170208
         BRL   L170359
L170208  LDX   L02013D
         LDA   L02013B
         PHX
         PHA
         LDX   L020070
         LDA   L02006E
         PHX
         PHA
         PEA   $00B3
         LDA   #$0000
         CLC
         ADC   $FF
         PHA
         PEA   $0001
         JSL   L130695
         TAY
         TSC
         CLC
         ADC   #$000E
         TCS
         TYA
         LDX   L02013D
         LDA   L02013B
         PHX
         PHA
         LDX   L020070
         LDA   L02006E
         PHX
         PHA
         PEA   $00B3
         LDA   #$00AE
         CLC
         ADC   $FF
         PHA
         PEA   $0002
         JSL   L130695
         TAY
         TSC
         CLC
         ADC   #$000E
         TCS
         TYA
         PEA   $0006
         PEA   $0097
         LDA   #$00AE
         CLC
         ADC   $FF
         PHA
         PEA   $0093
         LDA   #$003A
         CLC
         ADC   $FF
         PHA
         JSL   L1503A9
         PLY
         PLY
         PLY
         PLY
         PLY
         PEA   $000F
         PEA   $0092
         LDA   #$00AE
         CLC
         ADC   $FF
         PHA
         PEA   $0092
         LDA   #$003A
         CLC
         ADC   $FF
         PHA
         JSL   L150098
         PLY
         PLY
         PLY
         PLY
         PLY
         PEA   $0000
         PEA   $0098
         PEA   $00AE
         PEA   $0098
         LDA   #$003A
         CLC
         ADC   $FF
         PHA
         JSL   L150098
         PLY
         PLY
         PLY
         PLY
         PLY
         PEA   $000A
         PEA   $00B1
         LDA   #$00AE
         CLC
         ADC   $FF
         PHA
         PEA   $0099
         LDA   #$003A
         CLC
         ADC   $FF
         PHA
         JSL   L1503A9
         PLY
         PLY
         PLY
         PLY
         PLY
         PEA   $000B
         PEA   $0092
         LDA   #$00AE
         CLC
         ADC   $FF
         PHA
         PEA   $0032
         LDA   #$0000
         CLC
         ADC   $FF
         PHA
         JSL   L1503A9
         PLY
         PLY
         PLY
         PLY
         PLY
         PEA   $0007
         PEA   $0092
         LDA   #$00E8
         CLC
         ADC   $FF
         PHA
         PEA   $0032
         LDA   #$00AE
         CLC
         ADC   $FF
         PHA
         JSL   L1503A9
         PLY
         PLY
         PLY
         PLY
         PLY
         PEA   $0000
         PEA   $0092
         LDA   #$0039
         CLC
         ADC   $FF
         PHA
         PEA   $0032
         LDA   #$0039
         CLC
         ADC   $FF
         PHA
         JSL   L150098
         PLY
         PLY
         PLY
         PLY
         PLY
         PEA   $0000
         PEA   $0092
         LDA   #$00AE
         CLC
         ADC   $FF
         PHA
         PEA   $0032
         LDA   #$00AE
         CLC
         ADC   $FF
         PHA
         JSL   L150098
         PLY
         PLY
         PLY
         PLY
         PLY
         BRL   L1704AD
L170359  LDA   $FD
         SEC
         SBC   #$0000
         BVS   L170364
         EOR   #$8000
L170364  BMI   L170389
         PEA   $000B
         PEA   $00B1
         LDA   #$00E8
         CLC
         ADC   $FF
         PHA
         PEA   $0032
         LDA   #$0000
         CLC
         ADC   $FF
         PHA
         JSL   L1503A9
         PLY
         PLY
         PLY
         PLY
         PLY
         BRL   L1704AD
L170389  LDX   L02013D
         LDA   L02013B
         PHX
         PHA
         LDX   L020070
         LDA   L02006E
         PHX
         PHA
         PEA   $00B3
         PEI   $FF
         PEA   $0000
         JSL   L130695
         TAY
         TSC
         CLC
         ADC   #$000E
         TCS
         TYA
         PEA   $000B
         PEA   $0084
         LDA   #$0051
         CLC
         ADC   $FF
         PHA
         PEA   $0032
         LDA   #$0000
         CLC
         ADC   $FF
         PHA
         JSL   L1503A9
         PLY
         PLY
         PLY
         PLY
         PLY
         PEA   $0007
         PEA   $0084
         LDA   #$00E8
         CLC
         ADC   $FF
         PHA
         PEA   $0032
         LDA   #$0051
         CLC
         ADC   $FF
         PHA
         JSL   L1503A9
         PLY
         PLY
         PLY
         PLY
         PLY
         PEA   $0000
         PEA   $0085
         LDA   #$0051
         CLC
         ADC   $FF
         PHA
         PEA   $0032
         LDA   #$0051
         CLC
         ADC   $FF
         PHA
         JSL   L150098
         PLY
         PLY
         PLY
         PLY
         PLY
         PEA   $0006
         PEA   $0089
         LDA   #$00E8
         CLC
         ADC   $FF
         PHA
         PEA   $0086
         LDA   #$0050
         CLC
         ADC   $FF
         PHA
         JSL   L1503A9
         PLY
         PLY
         PLY
         PLY
         PLY
         PEA   $000B
         PEA   $0084
         LDA   #$00E8
         CLC
         ADC   $FF
         PHA
         PEA   $0084
         LDA   #$0050
         CLC
         ADC   $FF
         PHA
         JSL   L150098
         PLY
         PLY
         PLY
         PLY
         PLY
         PEA   $0001
         PEA   $0085
         LDA   #$00E8
         CLC
         ADC   $FF
         PHA
         PEA   $0085
         LDA   #$0050
         CLC
         ADC   $FF
         PHA
         JSL   L150098
         PLY
         PLY
         PLY
         PLY
         PLY
         PEA   $0000
         PEA   $008A
         LDA   #$00E8
         CLC
         ADC   $FF
         PHA
         PEA   $008A
         LDA   #$0050
         CLC
         ADC   $FF
         PHA
         JSL   L150098
         PLY
         PLY
         PLY
         PLY
         PLY
         PEA   $000A
         PEA   $00B1
         LDA   #$00E8
         CLC
         ADC   $FF
         PHA
         PEA   $008B
         LDA   #$0050
         CLC
         ADC   $FF
         PHA
         JSL   L1503A9
         PLY
         PLY
         PLY
         PLY
         PLY
L1704AD  PEA   $FFFF
         PEA   $FFFF
         PEA   $FFFF
         LDX   L0200A6
         LDA   L0200A4
         PHX
         PHA
         JSL   L150000
         PLY
         PLY
         PLY
         PLY
         PLY
         LDX   $EE
         LDA   $EC
         CLC
         ADC   #$0002
         PHA
         TXA
         ADC   #$0000
         TAX
         PLA
         STX   $EE
         STA   $EC
L1704DA  LDA   [$EC]
         AND   #$00FF
         BNE   L1704EE
         LDY   #$0001
         LDA   [$EC],Y
         AND   #$00FF
         BNE   L1704EE
         BRL   L17056E
L1704EE  LDY   #$0001
         LDA   [$EC],Y
         AND   #$00FF
         PHA
         LDA   [$EC]
         AND   #$00FF
         PHA
         LDA   #$0100
         SEC
         JSL   L01059C
         PLA
         PLX
         STX   $F4
         CLC
         ADC   $F4
         SEC
         SBC   #$0001
         STA   $EA
         LDY   #$0002
         LDA   [$EC],Y
         AND   #$00FF
         CLC
         ADC   $FF
         STA   $E8
         LDY   #$0003
         LDA   [$EC],Y
         AND   #$00FF
         CLC
         ADC   #$002E
         CLC
         ADC   #$0004
         STA   $E6
         LDX   L020135
         LDA   L020133
         PHX
         PHA
         LDX   L020070
         LDA   L02006E
         PHX
         PHA
         LDA   $E6
         CLC
         ADC   #$0001
         PHA
         PEI   $E8
         PEI   $EA
         JSL   L130695
         TAY
         TSC
         CLC
         ADC   #$000E
         TCS
         TYA
         LDX   $EE
         LDA   $EC
         CLC
         ADC   #$0004
         PHA
         TXA
         ADC   #$0000
         TAX
         PLA
         STX   $EE
         STA   $EC
         BRL   L1704DA
L17056E  LDX   L020070
         LDA   L02006E
         STX   $E4
         STA   $E2
         LDA   $FF
         LSR
         CLC
         ADC   $E2
         STA   $E2
         LDY   #$6F40
         LDA   #$2DFF
         STA   [$E2],Y
         LDY   #$6F44
         LDA   #$2222
L17058E  STA   [$E2],Y
         INY
         INY
         CPY   #$6FB4
         BNE   L17058E
         SEP   #$20
         STZ   L0200B8
         REP   #$20
L17059E  LDA   $FB
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   #L033578
         LDX   #^L033578
         JSL   L010410
         PLA
         PLX
         STA   $F0
         STX   $F2
         LDA   [$F0]
         TAY
         TSC
         CLC
         ADC   #$0014
         TCS
         TYA
         PLD
         RTL

L1705C2  ENT
         PHD
         TSC
         SEC
         SBC   #$00FB
         TCD
         ADC   #$00F4
         TCS
         LDX   L020139
         LDA   L020137
         PHX
         PHA
         JSL   L070045
         PLY
         PLY
         LDX   L020135
         LDA   L020133
         PHX
         PHA
         JSL   L130E59
         PLY
         PLY
         LDX   L02013D
         LDA   L02013B
         PHX
         PHA
         JSL   L130E59
         PLY
         PLY
         TSC
         CLC
         ADC   #$0006
         TCS
         PLD
         RTL

L1705FF  ENT
         PHD
         TSC
         SEC
         SBC   #$00FB
         TCD
         ADC   #$00ED
         TCS
         LDA   L0200D5
         PHA
         LDA   #$0006
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L031782
         LDX   #^L031782
         JSL   L010410
         PLA
         PLX
         STA   $F6
         STX   $F8
         LDY   #$0001
         LDA   [$F6],Y
         STA   $F4
L170633  LDA   $F4
         BNE   L17063A
         BRL   L170701
L17063A  JSL   L0703A5
         AND   #$003F
         STA   $F2
         JSL   L0703A5
         AND   #$000F
         STA   $F0
         JSL   L0703A5
         AND   #$0001
         TAY
         BEQ   L17065E
         LDA   $F2
         EOR   #$FFFF
         INC
         STA   $F2
L17065E  JSL   L0703A5
         AND   #$0001
         TAY
         BEQ   L170670
         LDA   $F0
         EOR   #$FFFF
         INC
         STA   $F0
L170670  JSL   L0703A5
         AND   #$0007
         TAY
         BNE   L1706B0
         LDAL  L031742
         TAX
         LDAL  L031740
         PHX
         PHA
         LDX   L020070
         LDA   L02006E
         PHX
         PHA
         LDA   $F0
         CLC
         ADC   #$0064
         CLC
         ADC   #$0001
         PHA
         LDA   $F2
         CLC
         ADC   #$00D2
         PHA
         PEA   $0000
         JSL   L130695
         TAY
         TSC
         CLC
         ADC   #$000E
         TCS
         TYA
         BRA   L1706FC
L1706B0  PEA   $0000
         JSL   L1504CE
         PLY
         LDX   L020070
         LDA   L02006E
         PHX
         PHA
         LDA   #$0064
         CLC
         ADC   $F0
         PHA
         LDA   #$00D2
         CLC
         ADC   $F2
         PHA
         JSL   L1504ED
         PLY
         PLY
         PLY
         PLY
         PEA   $0007
         JSL   L1504CE
         PLY
         LDX   L020070
         LDA   L02006E
         PHX
         PHA
         LDA   #$0064
         CLC
         ADC   $F0
         PHA
         LDA   #$00D3
         CLC
         ADC   $F2
         PHA
         JSL   L1504ED
         PLY
         PLY
         PLY
         PLY
L1706FC  DEC   $F4
         BRL   L170633
L170701  LDA   L0200D5
         PHA
         LDA   #$0006
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L031782
         LDX   #^L031782
         JSL   L010410
         PLA
         PLX
         STA   $F6
         STX   $F8
         LDY   #$0003
         LDA   [$F6],Y
         SEP   #$20
         STA   $EF
         REP   #$20
         LDA   $EF
         AND   #$00FF
         SEC
         SBC   #$0005
         BEQ   L170749
         BVS   L17073E
         EOR   #$8000
L17073E  BPL   L170749
         LDA   #$0005
         SEP   #$20
         STA   $EF
         REP   #$20
L170749  LDA   $EF
         AND   #$00FF
         BNE   L170753
         BRL   L1707E8
L170753  LDA   $EF
         AND   #$00FF
         SEC
         SBC   #$0004
         BVS   L170761
         EOR   #$8000
L170761  BMI   L1707A2
         LDAL  L03173E
         TAX
         LDAL  L03173C
         PHX
         PHA
         LDX   L020070
         LDA   L02006E
         PHX
         PHA
         PEA   $00A0
         LDA   $EF
         AND   #$00FF
         PHA
         LDA   #$001E
         SEC
         JSL   L01059C
         LDA   #$008C
         PLX
         STX   $FA
         CLC
         ADC   $FA
         PHA
         PEA   $0016
         JSL   L130695
         TAY
         TSC
         CLC
         ADC   #$000E
         TCS
         TYA
         BRA   L1707DF
L1707A2  LDAL  L03173E
         TAX
         LDAL  L03173C
         PHX
         PHA
         LDX   L020070
         LDA   L02006E
         PHX
         PHA
         PEA   $00AA
         LDA   $EF
         AND   #$00FF
         PHA
         LDA   #$001E
         SEC
         JSL   L01059C
         LDA   #$004D
         PLX
         STX   $FA
         CLC
         ADC   $FA
         PHA
         PEA   $0016
         JSL   L130695
         TAY
         TSC
         CLC
         ADC   #$000E
         TCS
         TYA
L1707DF  SEP   #$20
         DEC   $EF
         REP   #$20
         BRL   L170749
L1707E8  LDA   L0200D5
         PHA
         LDA   #$0006
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L031782
         LDX   #^L031782
         JSL   L010410
         PLA
         PLX
         STA   $F6
         STX   $F8
         LDY   #$0004
         LDA   [$F6],Y
         SEP   #$20
         STA   $EF
         REP   #$20
         LDA   $EF
         AND   #$00FF
         BEQ   L170844
         LDAL  L03173E
         TAX
         LDAL  L03173C
         PHX
         PHA
         LDX   L020070
         LDA   L02006E
         PHX
         PHA
         PEA   $009B
         PEA   $00BC
         PEA   $0018
         JSL   L130695
         TAY
         TSC
         CLC
         ADC   #$000E
         TCS
         TYA
L170844  LDA   L0200D5
         PHA
         LDA   #$0006
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L031782
         LDX   #^L031782
         JSL   L010410
         PLA
         PLX
         STA   $F6
         STX   $F8
         LDY   #$0005
         LDA   [$F6],Y
         SEP   #$20
         STA   $EF
         REP   #$20
         LDA   $EF
         AND   #$00FF
         BEQ   L1708A0
         LDAL  L03173E
         TAX
         LDAL  L03173C
         PHX
         PHA
         LDX   L020070
         LDA   L02006E
         PHX
         PHA
         PEA   $009E
         PEA   $00C8
         PEA   $0017
         JSL   L130695
         TAY
         TSC
         CLC
         ADC   #$000E
         TCS
         TYA
L1708A0  TSC
         CLC
         ADC   #$000D
         TCS
         PLD
         RTL

