*
* 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/Util.Macs
	
*-----------------------

L0E0000  ENT
         PHD
         TSC
         SEC
         SBC   #$00F7
         TCD
         ADC   #$00F0
         TCS
         LDA   $FD
         CMP   #$FFFF
         BNE   L0E0031
         LDA   $FF
         CMP   #$FFFF
         BNE   L0E0031
         PHX
         PHA
         _FreeMem
         BCS   L0E0027
         LDA   #$0000
L0E0027  STAL  L020010
         PLA
         PLX
         BRA   L0E003B
         BRA   L0E003B
L0E0031  PEI   $FF
         PEI   $FD
         JSL   L10018A
         PLY
         PLY
L0E003B  TAY
         TSC
         CLC
         ADC   #$0006
         TCS
         TYA
         PLD
         RTL

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

L0E0062  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
L0E008A  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   L0E0198
         BRL   L0E008A
L0E0198  SEP   #$20
         LDAL  STATEREG
         AND   #$CF
         STAL  STATEREG
         LDA   #$1E
         STAL  SHADOW
         REP   #$20
         TYA
         TCD
         TSC
         CLC
         ADC   #$0006
         TCS
         PLD
         RTL

L0E01B6  ENT
         PHD
         TSC
         SEC
         SBC   #$00F7
         TCD
         ADC   #$00F0
         TCS
         LDA   $FD
         LDX   $FF
         JSL   L011296
         TSC
         CLC
         ADC   #$0006
         TCS
         PLD
         RTL

L0E01D1  ENT
         PHD
         TSC
         SEC
         SBC   #$00FB
         TCD
         ADC   #$00F2
         TCS
         JSL   L100143
         LDX   #$0001
         LDA   #$2000
         STX   L0200B4
         STA   L0200B2
         STZ   $F4
         BRA   L0E021E
L0E01F0  LDA   $F4
         PHA
         LDA   #$00A0
         CLC
         JSL   L010FAB
         LDA   $F4
         LDX   #$0000
         STX   $FA
         ASL
         ROL   $FA
         LDX   $FA
         PHX
         PHA
         LDA   #L033ED8
         LDX   #^L033ED8
         JSL   L010E15
         PLA
         PLX
         STA   $F6
         STX   $F8
         PLA
         STA   [$F6]
         INC   $F4
L0E021E  LDA   $F4
         CMP   #$00C9
         BNE   L0E01F0
         TSC
         CLC
         ADC   #$0008
         TCS
         PLD
         RTL

L0E022D  ENT
         PHD
         TSC
         SEC
         SBC   #$00F1
         TCD
         ADC   #$00EA
         TCS
         TSC
         CLC
         ADC   #$0006
         TCS
         PLD
         RTL

L0E0240  ENT
         PHD
         TSC
         SEC
         SBC   #$00FB
         TCD
         ADC   #$00F4
         TCS
         TSC
         CLC
         ADC   #$0006
         TCS
         PLD
         RTL

L0E0253  ENT
         PHD
         TSC
         SEC
         SBC   #$00FB
         TCD
         ADC   #$00F4
         TCS
         TSC
         CLC
         ADC   #$0006
         TCS
         PLD
         RTL

L0E0266  ENT
         PHD
         TSC
         SEC
         SBC   #$00FB
         TCD
         ADC   #$00F4
         TCS
         TSC
         CLC
         ADC   #$0006
         TCS
         PLD
         RTL

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

L0E02A3  ENT
         PHD
         TSC
         SEC
         SBC   #$00F9
         TCD
         ADC   #$00DA
         TCS
         STZ   $F2
L0E02B0  LDA   #$000A
         PHA
         LDA   $FF
         CLC
         JSL   L010E20
         LDA   $F2
         INC   $F2
         ASL
         LDX   #$0000
         PHX
         PHA
         LDX   #$0000
         TDC
         CLC
         ADC   #$00DC
         JSL   L010E15
         PLA
         PLX
         STA   $F4
         STX   $F6
         PLA
         STA   [$F4]
         LDA   #$000A
         PHA
         LDA   $FF
         CLC
         JSL   L010E20
         PLY
         STA   $FF
         LDA   $FF
         BNE   L0E02B0
         STZ   $F0
L0E02EE  LDA   $F2
         BEQ   L0E0337
         DEC   $F2
         LDA   $F2
         ASL
         LDX   #$0000
         PHX
         PHA
         LDX   #$0000
         TDC
         CLC
         ADC   #$00DC
         JSL   L010E15
         PLA
         PLX
         STA   $F4
         STX   $F6
         LDA   [$F4]
         CLC
         ADC   #$0030
         PHA
         LDA   $F0
         INC   $F0
         LDX   #$0000
         PHX
         PHA
         LDA   #L032E2B
         LDX   #^L032E2B
         JSL   L010E15
         PLA
         PLX
         STA   $F4
         STX   $F6
         PLA
         SEP   #$20
         STA   [$F4]
         REP   #$20
         BRA   L0E02EE
L0E0337  LDA   $F0
         LDX   #$0000
         PHX
         PHA
         LDA   #L032E2B
         LDX   #^L032E2B
         JSL   L010E15
         PLA
         PLX
         STA   $F4
         STX   $F6
         LDA   #$0000
         SEP   #$20
         STA   [$F4]
         REP   #$20
         LDA   #L032E2B
         LDX   #^L032E2B
         TAY
         TSC
         CLC
         ADC   #$001E
         TCS
         TYA
         PLD
         RTL

