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

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

	 use	MYSTDIO.X.S
	 
*-----------------------

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

L110000  ENT
         PHD
         TSC
         SEC
         SBC   #$00F7
         TCD
         ADC   #$00EE
         TCS
         LDA   #$0001
         STA   $F0
L110010  LDA   [$FD]
         AND   #$00FF
         BEQ   L11004A
         LDX   $FF
         LDA   $FD
         INC   $FD
         BNE   L110021
         INC   $FF
L110021  STA   $F2
         STX   $F4
         LDA   [$F2]
         PHA
         LDA   $F0
         LDX   #$0000
         PHX
         PHA
         LDA   #L0340AA
         LDX   #^L0340AA
         JSL   L010E15
         PLA
         PLX
         STA   $F2
         STX   $F4
         PLA
         SEP   #$20
         STA   [$F2]
         REP   #$20
         INC   $F0
         BRA   L110010
L11004A  LDA   $F0
         SEC
         SBC   #$0001
         SEP   #$20
         STAL  L0340AA
         REP   #$20
         LDA   #L0340AA
         LDX   #^L0340AA
         TAY
         TSC
         CLC
         ADC   #$0008
         TCS
         TYA
         PLD
         RTL

L110068  ENT
         PHD
         TSC
         SEC
         SBC   #$00F7
         TCD
         ADC   #$00E0
         TCS
         LDA   #$0000
         STA   $E8
         PEI   $FF
         PEI   $FD
         JSL   L110000
         PLY
         PLY
         STX   $EC
         STA   $EA
         LDX   #$0000
         TDC
         CLC
         ADC   #$00E4
         STX   $F0
         STA   $EE
         PEA   $0010	; P16 OPEN
         PEA   $0000
         TDC
         CLC
         ADC   #$00E8
         PHA
         JSL   L01120A
         LDA   L020010
         BEQ   L1100AE
         LDA   #$FFFF
         BRA   L1100B0
         BRA   L1100B0
L1100AE  LDA   $E8
L1100B0  TAY
         TSC
         CLC
         ADC   #$0016
         TCS
         TYA
         PLD
         RTL

L1100BA  ENT
         PHD
         TSC
         SEC
         SBC   #$00F3
         TCD
         ADC   #$00DE
         TCS
         LDA   $F9
         STA   $E0
         LDX   $FD
         LDA   $FB
         STX   $E4
         STA   $E2
         LDA   $FF
         LDX   #$0000
         PHX
         PHA
         LDX   #$0000
         LDA   #$0000
         JSL   L010E15
         PLA
         PLX
         STX   $E8
         STA   $E6
         LDX   #$0000
         LDA   #$0000
         STX   $EC
         STA   $EA
         PEA   $0012	; P16 READ
         PEA   $0000
         TDC
         CLC
         ADC   #$00E0
         PHA
         JSL   L01120A
         LDX   $EC
         LDA   $EA
         TAY
         TSC
         CLC
         ADC   #$0014
         TCS
         TYA
         PLD
         RTL

L110110  ENT
         PHD
         TSC
         SEC
         SBC   #$00F9
         TCD
         ADC   #$00E4
         TCS
         LDA   $FF
         STA   $E6
         PEA   $0014	; P16 CLOSE
         PEA   $0000
         TDC
         CLC
         ADC   #$00E6
         PHA
         JSL   L01120A
         TSC
         CLC
         ADC   #$0014
         TCS
         PLD
         RTL

L110137  ENT
         PHD
         TSC
         SEC
         SBC   #$00F9
         TCD
         ADC   #$00EC
         TCS
         LDA   $FF
         STA   $EE
         PEA   $0019	; P16 GET_EOF
         PEA   $0000
         TDC
         CLC
         ADC   #$00EE
         PHA
         JSL   L01120A
         LDA   L020010
         BEQ   L110169
         LDA   #$FFFF
         LDX   #$0000
         TAY
         BPL   L110165
         DEX
L110165  BRA   L11016D
         BRA   L11016D
L110169  LDX   $F2
         LDA   $F0
L11016D  TAY
         TSC
         CLC
         ADC   #$000C
         TCS
         TYA
         PLD
         RTL

         PHD
         TSC
         SEC
         SBC   #$00F5
         TCD
         ADC   #$00E8
         TCS
         LDA   $FB
         STA   $EA
         LDX   $FF
         LDA   $FD
         STX   $EE
         STA   $EC
         PEA   $0016	; P16 SET_MARK
         PEA   $0000
         TDC
         CLC
         ADC   #$00EA
         PHA
         JSL   L01120A
         LDA   L020010
         BEQ   L1101AD
         LDX   #$FFFF
         LDA   #$FFFF
         BRA   L1101B1
         BRA   L1101B1
L1101AD  LDX   $EE
         LDA   $EC
L1101B1  TAY
         TSC
         CLC
         ADC   #$000C
         TCS
         TYA
         PLD
         RTL

