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

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

	 use	APROY.X.S
	 
*-----------------------

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

L040000  PHD
         TSC
         SEC
         SBC   #$00FB
         TCD
         ADC   #$00E4
         TCS
         PEA   $0000
         PEA   $3E80
         JSL   L10018A
         PLY
         PLY
         STX   L02001B
         STA   L020019
         JSL   L0708A4
         LDA   #$0000
         STA   $EC
         STA   $F0
         STZ   $F4
         STZ   $F2
L04002C  LDA   $F0
         LDX   #$0000
         TAY
         BPL   L040035
         DEX
L040035  PEA   $0000
         PEA   $001C
         CLC
         JSL   L010FF0
         LDA   #L032787
         LDX   #^L032787
         JSL   L010E15
         PLA
         PLX
         STX   $E8
         STA   $E6
         PEI   $F0
         PEI   $E8
         PEI   $E6
         PEI   $F2
         JSL   L0B0000
         PLY
         PLY
         PLY
         PLY
         LDA   L02015B
         BEQ   L0400A0
         LDA   #$001B
         SEP   #$20
         STA   L0200B6
         REP   #$20
         LDA   #$0080
         SEP   #$20
         STA   L0200B8
         REP   #$20
         PEI   $F0
         LDA   $F0
         LDX   #$0000
         TAY
         BPL   L040084
         DEX
L040084  PEA   $0000
         PEA   $001C
         CLC
         JSL   L010FF0
         LDA   #L032787
         LDX   #^L032787
         JSL   L010E15
         JSL   L0A0DDA
         PLY
         PLY
         PLY
L0400A0  JSL   L010325
L0400A4  JSL   L010320
         TAY
         BNE   L0400AE
         BRL   L0400FC
L0400AE  PEA   ^L07062C
         PEA   L07062C
         JSL   L0E01B6
         PLY
         PLY
L0400BA  LDA   L0200B6
         AND   #$00FF
         CMP   #$0070
         BEQ   L0400D0
         LDA   L0200B6
         AND   #$00FF
         CMP   #$0050
         BNE   L0400D2
L0400D0  BRA   L0400BA
L0400D2  SEP   #$20
         STZ   L0200B6
         REP   #$20
         SEP   #$20
         STZ   L0200B8
         REP   #$20
         JSL   L01032D
         LDX   L020117
         LDA   L020115
         STX   L02011B
         STA   L020119
         PEA   ^L07067E
         PEA   L07067E
         JSL   L0E01B6
         PLY
         PLY
L0400FC  LDA   $F0
         LDX   #$0000
         TAY
         BPL   L040105
         DEX
L040105  PEA   $0000
         PEA   $001C
         CLC
         JSL   L010FF0
         LDA   #L032787
         LDX   #^L032787
         JSL   L010E15
         PLA
         PLX
         STX   $E8
         STA   $E6
         JSL   L070763
         LDX   L0200B4
         LDA   L0200B2
         CLC
         ADC   #$2800
         PHA
         TXA
         ADC   #$0000
         TAX
         PLA
         CLC
         ADC   #$0008
         PHA
         TXA
         ADC   #$0000
         TAX
         PLA
         STX   L020113
         STA   L020111
         LDA   $F4
         EOR   #$0001
         STA   $F4
         LDA   $F2
         EOR   #$0001
         STA   $F2
         PEI   $E8
         PEI   $E6
         JSL   L070AEB
         PLY
         PLY
         PHA
         JSL   L070CA4
         PLY
         PEI   $E8
         PEI   $E6
         JSL   L080742
         PLY
         PLY
         PEI   $E8
         PEI   $E6
         JSL   L070BFC
         PLY
         PLY
         PEI   $E8
         PEI   $E6
         JSL   L080185
         PLY
         PLY
         PEA   $FFFF
         PEI   $E8
         PEI   $E6
         PEI   $F2
         JSL   L0A0EAE
         PLY
         PLY
         PLY
         PLY
         PEI   $F4
         JSL   L070000
         PLY
         STZ   L020102
         LDA   #$012C
         STA   L0200BC
         STZ   L0200C0
         LDA   #$012C
         STA   L0200BE
         STZ   L0200C2
         LDA   L020104
         BNE   L0401D5
         PEI   $E8
         PEI   $E6
         JSL   L080456
         PLY
         PLY
         PEI   $F4
         JSL   L070219
         PLY
         LDA   L02001F
         CMP   #$FFFF
         BNE   L0401D3
         LDA   #$0001
         STA   L020102
L0401D3  BRA   L040222
L0401D5  PEI   $E8
         PEI   $E6
         JSL   L080456
         PLY
         PLY
         PEI   $F4
         JSL   L070219
         PLY
         PEI   $E8
         PEI   $E6
         JSL   L080925
         PLY
         PLY
         LDA   L02001F
         BEQ   L040222
         LDY   #$0018
         LDA   [$E6],Y
         PHA
         INC
         LDY   #$0018
         STA   [$E6],Y
         PLA
         LDY   #$0018
         LDA   [$E6],Y
         PHA
         LDY   #$001A
         LDA   [$E6],Y
         PLX
         STX   $F6
         SEC
         SBC   $F6
         BVS   L040218
         EOR   #$8000
L040218  BMI   L040222
         LDA   #$0000
         LDY   #$0012
         STA   [$E6],Y
L040222  PEI   $F4
         JSL   L0702D5
         PLY
         JSL   L010C02
         PEI   $F4
         JSL   L07036C
         PLY
         LDA   $EC
         BEQ   L040246
         PEI   $F0
         JSL   L080C60
         PLY
         STZ   L0200FE
         JSL   L070763
L040246  LDA   L02008F
         BNE   L040292
         LDA   L020091
         AND   #$00FF
         BNE   L040292
         LDA   L020081
         AND   #$00FF
         BNE   L040263
         LDA   L020083
         AND   #$00FF
         BNE   L040290
L040263  JSL   L080726
         AND   #$0003
         PHA
         LDA   #$001E
         PLX
         STX   $FA
         CLC
         ADC   $FA
         PHA
         PEA   $0001
         PEA   ^L030583
         PEA   L030583
         JSL   L060719
         PLY
         PLY
         PLY
         PLY
         LDA   #$0001
         SEP   #$20
         STA   L020091
         REP   #$20
L040290  BRA   L040295
L040292  DEC   L02008F
L040295  LDA   L0200FC
         BEQ   L0402CB
         LDA   #$001B
         SEP   #$20
         STA   L0200B6
         REP   #$20
         PEI   $F0
         LDA   $F0
         LDX   #$0000
         TAY
         BPL   L0402AF
         DEX
L0402AF  PEA   $0000
         PEA   $001C
         CLC
         JSL   L010FF0
         LDA   #L032787
         LDX   #^L032787
         JSL   L010E15
         JSL   L0A0DDA
         PLY
         PLY
         PLY
L0402CB  LDA   $EC
         BEQ   L040305
         STZ   $EC
         LDA   #$C350
         STA   $EA
         SEP   #$20
         STZ   L0200B6
         REP   #$20
L0402DD  JSL   L100099
         TAY
         BNE   L0402F5
         LDA   L0200B6
         AND   #$00FF
         BNE   L0402F5
         LDA   $EA
         DEC   $EA
         TAY
         BEQ   L0402F5
         BRA   L0402DD
L0402F5  PEA   $0100
         PEA   $0080
         PEA   $2808
         JSL   L0F0BD6
         PLY
         PLY
         PLY
L040305  LDY   #$0002
         LDA   [$E6],Y
         PHA
         JSL   L070AA8
         PLY
         TAY
         BEQ   L040353
         PEI   $F0
         LDA   $F0
         LDX   #$0000
         TAY
         BPL   L04031E
         DEX
L04031E  PEA   $0000
         PEA   $001C
         CLC
         JSL   L010FF0
         LDA   #L032787
         LDX   #^L032787
         JSL   L010E15
         JSL   L0A0DDA
         PLY
         PLY
         PLY
         STA   $EE
         LDA   $F0
         CMP   $EE
         BNE   L040347
         LDA   L02015D
         BEQ   L040353
L040347  LDA   $EE
         STA   $F0
         LDA   #$0001
         STA   $EC
         STZ   L02015D
L040353  LDA   $EC
         BNE   L04035F
         LDA   L020108
         BNE   L04035F
         BRL   L0400A4
L04035F  LDA   L020108
         BNE   L040367
         BRL   L04002C
L040367  LDX   L02001B
         LDA   L020019
         PHX
         PHA
         JSL   L100210
         PLY
         PLY
         TSC
         CLC
         ADC   #$0016
         TCS
         PLD
         RTL

L04037D  ENT
         PHD
         TSC
         SEC
         SBC   #$00FB
         TCD
         ADC   #$00EC
         TCS
         JSL   L0E01D1
         PEA   $FFFF
         PEA   $00E1
         PEA   $2000
         LDX   L0200B4
         LDA   L0200B2
         PHX
         PHA
         JSL   L0E022D
         PLY
         PLY
         PLY
         PLY
         PLY
         JSL   L0E0240
         JSL   L0605F8
         JSL   L080CE8
         JSL   L0F0047
         JSL   L100000
         JSL   L10073D
         JSL   L0508F8
         PEA   $0004
         PEA   $00E1
         PEA   $2000
         PEA   ^L030042
         PEA   L030042
         JSL   L050342
         PLY
         PLY
         PLY
         PLY
         PLY
         PEA   $0001
         PEA   ^L02012B
         PEA   L02012B
         PEA   ^L020127
         PEA   L020127
         PEA   ^L0337FC
         PEA   L0337FC
         PEA   ^L033807
         PEA   L033807
         JSL   L080000
         TAY
         TSC
         CLC
         ADC   #$0012
         TCS
         TYA
         PEA   $002D
         PEA   $0000
         PEA   ^L030047
         PEA   L030047
         JSL   L060633
         PLY
         PLY
         PLY
         PLY
         PEA   $0038
         PEA   $0001
         PEA   ^L030050
         PEA   L030050
         JSL   L060633
         PLY
         PLY
         PLY
         PLY
         PEA   $001E
         PEA   $0002
         PEA   ^L030058
         PEA   L030058
         JSL   L060633
         PLY
         PLY
         PLY
         PLY
         PEA   $001E
         PEA   $0003
         PEA   ^L03005F
         PEA   L03005F
         JSL   L060633
         PLY
         PLY
         PLY
         PLY
         PEA   $001E
         PEA   $0004
         PEA   ^L030066
         PEA   L030066
         JSL   L060633
         PLY
         PLY
         PLY
         PLY
         PEA   $0036
         PEA   $0005
         PEA   ^L03006D
         PEA   L03006D
         JSL   L060633
         PLY
         PLY
         PLY
         PLY
         PEA   $0030
         PEA   $0006
         PEA   ^L030074
         PEA   L030074
         JSL   L060633
         PLY
         PLY
         PLY
         PLY
         PEA   $0030
         PEA   $0007
         PEA   ^L03007A
         PEA   L03007A
         JSL   L060633
         PLY
         PLY
         PLY
         PLY
         LDAL  L051241		; was JSL to password protection
         JSL   L0B0654
         STZ   L020097
         PEA   $0001
         LDX   L0200B4
         LDA   L0200B2
         PHX
         PHA
         PEA   ^L0337ED
         PEA   L0337ED
         JSL   L080145
         PLY
         PLY
         PLY
         PLY
         PLY
         JSL   L0E0062
         PEA   $00C8
         PEA   $0000
         LDX   L020135
         LDA   L020133
         PHX
         PHA
         PEA   $0000
         PEA   $00E1
         PEA   $2000
         JSL   L1007BF
         TAY
         TSC
         CLC
         ADC   #$000E
         TCS
         TYA
         PEA   $0001
         JSL   L0B0DF1
         PLY
         PEA   ^L030080
         PEA   L030080
         PEA   $00E1
         PEA   $2000
         PEA   $0064
         PEA   $007E
         JSL   L0F0421
         TAY
         TSC
         CLC
         ADC   #$000C
         TCS
         TYA
         PEA   ^L030092
         PEA   L030092
         PEA   $00E1
         PEA   $2000
         PEA   $0063
         PEA   $007D
         JSL   L0F0421
         TAY
         TSC
         CLC
         ADC   #$000C
         TCS
         TYA
         PEA   $002D
         PEA   $0000
         PEA   ^L0300A4
         PEA   L0300A4
         JSL   L060633
         PLY
         PLY
         PLY
         PLY
         PEA   $002D
         PEA   $0001
         PEA   ^L0300AA
         PEA   L0300AA
         JSL   L060633
         PLY
         PLY
         PLY
         PLY
         PEA   $002D
         PEA   $0002
         PEA   ^L0300B0
         PEA   L0300B0
         JSL   L060633
         PLY
         PLY
         PLY
         PLY
         PEA   $0021
         PEA   $0003
         PEA   ^L0300B6
         PEA   L0300B6
         JSL   L060633
         PLY
         PLY
         PLY
         PLY
         PEA   $001F
         PEA   $0004
         PEA   ^L0300BE
         PEA   L0300BE
         JSL   L060633
         PLY
         PLY
         PLY
         PLY
         PEA   $0028
         PEA   $0005
         PEA   ^L0300C9
         PEA   L0300C9
         JSL   L060633
         PLY
         PLY
         PLY
         PLY
         PEA   $0028
         PEA   $0006
         PEA   ^L0300D0
         PEA   L0300D0
         JSL   L060633
         PLY
         PLY
         PLY
         PLY
         PEA   $0028
         PEA   $0007
         PEA   ^L0300D7
         PEA   L0300D7
         JSL   L060633
         PLY
         PLY
         PLY
         PLY
         PEA   $0028
         PEA   $0008
         PEA   ^L0300DE
         PEA   L0300DE
         JSL   L060633
         PLY
         PLY
         PLY
         PLY
         PEA   $0028
         PEA   $0009
         PEA   ^L0300E5
         PEA   L0300E5
         JSL   L060633
         PLY
         PLY
         PLY
         PLY
         PEA   $001E
         PEA   $000A
         PEA   ^L0300EC
         PEA   L0300EC
         JSL   L060633
         PLY
         PLY
         PLY
         PLY
         PEA   $001E
         PEA   $000B
         PEA   ^L0300F3
         PEA   L0300F3
         JSL   L060633
         PLY
         PLY
         PLY
         PLY
         PEA   $001E
         PEA   $000C
         PEA   ^L0300FA
         PEA   L0300FA
         JSL   L060633
         PLY
         PLY
         PLY
         PLY
         PEA   $0020
         PEA   $000D
         PEA   ^L030101
         PEA   L030101
         JSL   L060633
         PLY
         PLY
         PLY
         PLY
         LDA   #$000A
         STAL  L030587
         LDA   #$000B
         STAL  L030589
         LDA   #$000C
         STAL  L03058B
         PEA   ^L033818
         PEA   L033818
         JSL   L01044B
         PLY
         PLY
         PHA
         TXA
         STAL  L033DC7
         PLA
         STAL  L033DC5
         PEA   ^L033820
         PEA   L033820
         JSL   L01044B
         PLY
         PLY
         PHA
         TXA
         STAL  L033DCB
         PLA
         STAL  L033DC9
         PEA   ^L033828
         PEA   L033828
         JSL   L01044B
         PLY
         PLY
         PHA
         TXA
         STAL  L033DCF
         PLA
         STAL  L033DCD
         PEA   ^L033830
         PEA   L033830
         JSL   L01044B
         PLY
         PLY
         PHA
         TXA
         STAL  L033DD3
         PLA
         STAL  L033DD1
         PEA   ^L033853
         PEA   L033853
         JSL   L01044B
         PLY
         PLY
         PHA
         TXA
         STAL  L033DE7
         PLA
         STAL  L033DE5
         PEA   ^L030106
         PEA   L030106
         JSL   L1002E2
         PLY
         PLY
         STX   L020139
         STA   L020137
         PEA   $00C8
         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   ^L030115
         PEA   L030115
         LDX   L0200B4
         LDA   L0200B2
         PHX
         PHA
         PEA   $0064
         PEA   $004C
         JSL   L0F0421
         TAY
         TSC
         CLC
         ADC   #$000C
         TCS
         TYA
         PEA   ^L030130
         PEA   L030130
         LDX   L0200B4
         LDA   L0200B2
         PHX
         PHA
         PEA   $0063
         PEA   $004B
         JSL   L0F0421
         TAY
         TSC
         CLC
         ADC   #$000C
         TCS
         TYA
         JSL   L0E0062
         PEA   $00C8
         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
         STZ   $F2
         BRA   L04078C
L040775  STZ   $F4
         BRA   L040783
L040779  LDA   $EE
         CLC
         ADC   #$000A
         STA   $F0
         INC   $F4
L040783  LDA   $F4
         CMP   #$7530
         BNE   L040779
         INC   $F2
L04078C  LDA   $F2
         CMP   #$0003
         BNE   L040775
         JSL   L070CF9
         JSL   L040000
         JSL   L0A0C6F
         JSL   L06042E
         SEP   #$20
         STZ   L020081
         REP   #$20
         SEP   #$20
         STZ   L020083
         REP   #$20
         PEA   ^L033D09
         PEA   L033D09
         PEA   ^L03014B
         PEA   L03014B
         JSL   L050408
         PLY
         PLY
         PLY
         PLY
         JSL   L0C06E8
         PEA   $000D
         JSL   L0607BC
         PLY
         PEA   $000C
         JSL   L0607BC
         PLY
         PEA   $000B
         JSL   L0607BC
         PLY
         PEA   $000A
         JSL   L0607BC
         PLY
         PEA   $0009
         JSL   L0607BC
         PLY
         PEA   $0008
         JSL   L0607BC
         PLY
         PEA   $0007
         JSL   L0607BC
         PLY
         PEA   $0006
         JSL   L0607BC
         PLY
         PEA   $0005
         JSL   L0607BC
         PLY
         PEA   $0004
         JSL   L0607BC
         PLY
         PEA   $0003
         JSL   L0607BC
         PLY
         PEA   $0002
         JSL   L0607BC
         PLY
         PEA   $0001
         JSL   L0607BC
         PLY
         PEA   $0000
         JSL   L0607BC
         PLY
         JSL   L0D06BF
         PEA   $0001
         JSL   L0B0DBE
         PLY
         SEP   #$20
         STZ   L020081
         REP   #$20
         SEP   #$20
         STZ   L020083
         REP   #$20
         JSL   L06061C
         JSL   L0C0750
         JSL   L080D31
         PEA   $0000
         PEA   $00E1
         PEA   $2000
         PEA   ^L03015B
         PEA   L03015B
         JSL   L050342
         PLY
         PLY
         PLY
         PLY
         PLY
         PEA   ^L033D09
         PEA   L033D09
         PEA   ^L030161
         PEA   L030161
         JSL   L050408
         PLY
         PLY
         PLY
         PLY
         PEA   $0001
         JSL   L0B0DF1
         PLY
         PEA   $0000
         PEA   $7D00
         JSL   L0E0000
         PLY
         PLY
         STX   L020135
         STA   L020133
         PEA   $00C8
         PEA   $0000
         LDX   L020135
         LDA   L020133
         PHX
         PHA
         PEA   $0000
         PEA   $00E1
         PEA   $2000
         JSL   L1007BF
         TAY
         TSC
         CLC
         ADC   #$000E
         TCS
         TYA
         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   $00C8
         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   L0E0062
         PEA   ^L030171
         PEA   L030171
         PEA   $00E1
         PEA   $2000
         PEA   $0064
         PEA   $007E
         JSL   L0F0421
         TAY
         TSC
         CLC
         ADC   #$000C
         TCS
         TYA
         PEA   ^L030183
         PEA   L030183
         PEA   $00E1
         PEA   $2000
         PEA   $0063
         PEA   $007D
         JSL   L0F0421
         TAY
         TSC
         CLC
         ADC   #$000C
         TCS
         TYA
         LDX   L020135
         LDA   L020133
         PHX
         PHA
         JSL   L0E0045
         PLY
         PLY
         JSL   L0E0253
         JSL   L0E0266
         TSC
         CLC
         ADC   #$000E
         TCS
         PLD
         RTL

