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

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

	 use	INFOGS.E.S
	 use	INFOGS.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
	
*-----------------------

L070000  ENT
         PHD
         TSC
         SEC
         SBC   #$00F7
         TCD
         ADC   #$00F0
         TCS
         LDA   $FD
         CMP   #$FFFF
         BNE   L070031
         LDA   $FF
         CMP   #$FFFF
         BNE   L070031
         PHX
         PHA
         _FreeMem
         BCS   L070027
         LDA   #$0000
L070027  STAL  L020010
         PLA
         PLX
         BRA   L07003B
         BRA   L07003B
L070031  PEI   $FF
         PEI   $FD
         JSL   L1601A2
         PLY
         PLY
L07003B  TAY
         TSC
         CLC
         ADC   #$0006
         TCS
         TYA
         PLD
         RTL

L070045  ENT
         PHD
         TSC
         SEC
         SBC   #$00F7
         TCD
         ADC   #$00F0
         TCS
         PEI   $FF
         PEI   $FD
         JSL   L160228
         PLY
         PLY
         TSC
         CLC
         ADC   #$0006
         TCS
         PLD
         RTL

L070062  ENT
         PHD
         TSC
         SEC
         SBC   #$00FB
         TCD
         ADC   #$00F4
         TCS
         TDC
         TAY
         SEP   #$20
         LDAL  STATEREG
         ORA   #$30
         STAL  STATEREG
         LDA   #$16
         STAL  SHADOW
         REP   #$20
         LDA   #$9C00
         SEC
         LDX   #$007D
L07008A  TCD
         LDA   #$0000
         TSB   $FE
         TSB   $FC
         TSB   $FA
         TSB   $F8
         TSB   $F6
         TSB   $F4
         TSB   $F2
         TSB   $F0
         TSB   $EE
         TSB   $EC
         TSB   $EA
         TSB   $E8
         TSB   $E6
         TSB   $E4
         TSB   $E2
         TSB   $E0
         TSB   $DE
         TSB   $DC
         TSB   $DA
         TSB   $D8
         TSB   $D6
         TSB   $D4
         TSB   $D2
         TSB   $D0
         TSB   $CE
         TSB   $CC
         TSB   $CA
         TSB   $C8
         TSB   $C6
         TSB   $C4
         TSB   $C2
         TSB   $C0
         TSB   $BE
         TSB   $BC
         TSB   $BA
         TSB   $B8
         TSB   $B6
         TSB   $B4
         TSB   $B2
         TSB   $B0
         TSB   $AE
         TSB   $AC
         TSB   $AA
         TSB   $A8
         TSB   $A6
         TSB   $A4
         TSB   $A2
         TSB   $A0
         TSB   $9E
         TSB   $9C
         TSB   $9A
         TSB   $98
         TSB   $96
         TSB   $94
         TSB   $92
         TSB   $90
         TSB   $8E
         TSB   $8C
         TSB   $8A
         TSB   $88
         TSB   $86
         TSB   $84
         TSB   $82
         TSB   $80
         TSB   $7E
         TSB   $7C
         TSB   $7A
         TSB   $78
         TSB   $76
         TSB   $74
         TSB   $72
         TSB   $70
         TSB   $6E
         TSB   $6C
         TSB   $6A
         TSB   $68
         TSB   $66
         TSB   $64
         TSB   $62
         TSB   $60
         TSB   $5E
         TSB   $5C
         TSB   $5A
         TSB   $58
         TSB   $56
         TSB   $54
         TSB   $52
         TSB   $50
         TSB   $4E
         TSB   $4C
         TSB   $4A
         TSB   $48
         TSB   $46
         TSB   $44
         TSB   $42
         TSB   $40
         TSB   $3E
         TSB   $3C
         TSB   $3A
         TSB   $38
         TSB   $36
         TSB   $34
         TSB   $32
         TSB   $30
         TSB   $2E
         TSB   $2C
         TSB   $2A
         TSB   $28
         TSB   $26
         TSB   $24
         TSB   $22
         TSB   $20
         TSB   $1E
         TSB   $1C
         TSB   $1A
         TSB   $18
         TSB   $16
         TSB   $14
         TSB   $12
         TSB   $10
         TSB   $0E
         TSB   $0C
         TSB   $0A
         TSB   $08
         TSB   $06
         TSB   $04
         TSB   $02
         TSB   $00
         TDC
         SBC   #$0100
         DEX
         BEQ   L070198
         BRL   L07008A
L070198  SEP   #$20
         LDAL  STATEREG
         AND   #$CF
         STAL  STATEREG
         LDA   #$1E
         STAL  SHADOW
         REP   #$20
         TYA
         TCD
         TSC
         CLC
         ADC   #$0006
         TCS
         PLD
         RTL

L0701B6  ENT
         PHD
         TSC
         SEC
         SBC   #$00FB
         TCD
         ADC   #$00F2
         TCS
         JSL   L16015B
         LDX   #$0001
         LDA   #$2000
         STX   L0200A6
         STA   L0200A4
         STZ   $F4
         BRA   L070203
L0701D5  LDA   $F4
         PHA
         LDA   #$00A0
         CLC
         JSL   L01059C
         LDA   $F4
         LDX   #$0000
         STX   $FA
         ASL
         ROL   $FA
         LDX   $FA
         PHX
         PHA
         LDA   #L033394
         LDX   #^L033394
         JSL   L010410
         PLA
         PLX
         STA   $F6
         STX   $F8
         PLA
         STA   [$F6]
         INC   $F4
L070203  LDA   $F4
         CMP   #$00C9
         BNE   L0701D5
         PEA   $FFFF
         PEA   $00E1
         PEA   $2000
         LDX   L0200A6
         LDA   L0200A4
         PHX
         PHA
         JSL   L150000
         PLY
         PLY
         PLY
         PLY
         PLY
         JSL   L130047
         TSC
         CLC
         ADC   #$0008
         TCS
         PLD
         RTL

L070230  ENT
         PHD
         TSC
         SEC
         SBC   #$00F7
         TCD
         ADC   #$00F0
         TCS
         PEA   $0000
         PEI   $FF
         PEI   $FD
         _SetColorTable
         BCS   L07024E
         LDA   #$0000
L07024E  STAL  L020010
         TSC
         CLC
         ADC   #$0006
         TCS
         PLD
         RTL

L07025A  ENT
         PHD
         TSC
         SEC
         SBC   #$00F9
         TCD
         ADC   #$00DA
         TCS
         STZ   $F2
L070267  LDA   #$000A
         PHA
         LDA   $FF
         CLC
         JSL   L01041B
         LDA   $F2
         INC   $F2
         ASL
         LDX   #$0000
         PHX
         PHA
         LDX   #$0000
         TDC
         CLC
         ADC   #$00DC
         JSL   L010410
         PLA
         PLX
         STA   $F4
         STX   $F6
         PLA
         STA   [$F4]
         LDA   #$000A
         PHA
         LDA   $FF
         CLC
         JSL   L01041B
         PLY
         STA   $FF
         LDA   $FF
         BNE   L070267
         STZ   $F0
L0702A5  LDA   $F2
         BEQ   L0702EE
         DEC   $F2
         LDA   $F2
         ASL
         LDX   #$0000
         PHX
         PHA
         LDX   #$0000
         TDC
         CLC
         ADC   #$00DC
         JSL   L010410
         PLA
         PLX
         STA   $F4
         STX   $F6
         LDA   [$F4]
         CLC
         ADC   #$0030
         PHA
         LDA   $F0
         INC   $F0
         LDX   #$0000
         PHX
         PHA
         LDA   #L031B42
         LDX   #^L031B42
         JSL   L010410
         PLA
         PLX
         STA   $F4
         STX   $F6
         PLA
         SEP   #$20
         STA   [$F4]
         REP   #$20
         BRA   L0702A5
L0702EE  LDA   $F0
         LDX   #$0000
         PHX
         PHA
         LDA   #L031B42
         LDX   #^L031B42
         JSL   L010410
         PLA
         PLX
         STA   $F4
         STX   $F6
         LDA   #$0000
         SEP   #$20
         STA   [$F4]
         REP   #$20
         LDA   #L031B42
         LDX   #^L031B42
         TAY
         TSC
         CLC
         ADC   #$001E
         TCS
         TYA
         PLD
         RTL

L07031E  ENT
         PHD
         TSC
         SEC
         SBC   #$00F7
         TCD
         ADC   #$00CA
         TCS
         PEA   ^L031B4A
         PEA   L031B4A
         PEA   $0000
         TDC
         CLC
         ADC   #$00D4
         PHA
         JSL   L010882
         PLY
         PLY
         PLY
         PLY
         PEI   $FF
         PEI   $FD
         PEA   $0000
         TDC
         CLC
         ADC   #$00D4
         PHA
         JSL   L0107D7
         PLY
         PLY
         PLY
         PLY
         PEA   ^L031B52
         PEA   L031B52
         PEA   $0000
         TDC
         CLC
         ADC   #$00D4
         PHA
         JSL   L0107D7
         PLY
         PLY
         PLY
         PLY
         PEA   $0000
         TDC
         CLC
         ADC   #$00D4
         PHA
         JSL   L160334
         PLY
         PLY
         STX   $D2
         STA   $D0
         PEI   $D2
         PEI   $D0
         JSL   L130FE9
         PLY
         PLY
         STX   $CE
         STA   $CC
         PEI   $D2
         PEI   $D0
         JSL   L160228
         PLY
         PLY
         LDX   $CE
         LDA   $CC
         TAY
         TSC
         CLC
         ADC   #$002C
         TCS
         TYA
         PLD
         RTL

L0703A5  ENT
         LDAL  L0200AC
         INC
         STAL  L0200AC
         PHX
         TAX
         LDAL  $FE0F00,X
         ADCL  $FE7F00,X
         ADCL  $FEFF00,X
         PLX
         RTL

