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

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

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

L100000  PHD
         TSC
         SEC
         SBC   #$00FB
         TCD
         ADC   #$00F4
         TCS
         JSL   L0F0F81
         LDX   L0200A2
         LDA   L0200A0
         PEA   $0000
         PEA   $0005
         CLC
         JSL   L0105E1
         PLA
         PLX
         STX   L0200A2
         STA   L0200A0
         LDX   L02009E
         LDA   L02009C
         SEC
         SBC   L0200A0
         PHA
         TXA
         SBC   L0200A2
         TAX
         PLA
         STX   L0200A2
         STA   L0200A0
         LDA   L02003B
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   #L032031
         LDX   #^L032031
         JSL   L010410
         PLA
         PLX
         STA   $F6
         STX   $F8
         LDA   [$F6]
         LDX   #$0000
         SEC
         SBC   L0200A0
         PHA
         TXA
         SBC   L0200A2
         TAX
         PLA
         STX   L0200A2
         STA   L0200A0
         LDX   #$0000
         LDA   #$0E10
         PHX
         PHA
         LDX   L0200A2
         LDA   L0200A0
         CLC
         JSL   L0104A0
         PLY
         PLY
         STA   L0200DC
         LDX   #$0000
         LDA   #$003C
         PHX
         PHA
         LDX   #$0000
         LDA   #$0E10
         PHX
         PHA
         LDX   L0200A2
         LDA   L0200A0
         CLC
         JSL   L0104A0
         PLA
         PLX
         CLC
         JSL   L0104A0
         PLY
         PLY
         STA   L0200DE
         TSC
         CLC
         ADC   #$0006
         TCS
         PLD
         RTL

L1000B5  PHD
         TSC
         SEC
         SBC   #$00F3
         TCD
         ADC   #$00E8
         TCS
         LDA   #$002A
         STA   $EC
         LDA   #$0034
         STA   $EA
L1000CA  LDY   #$0002
         LDA   [$F9],Y
         TAX
         LDA   [$F9]
         STA   $EE
         STX   $F0
         LDA   [$EE]
         AND   #$00FF
         BEQ   L10011B
         LDY   #$0002
         LDA   [$F9],Y
         TAX
         LDA   [$F9]
         PHX
         PHA
         PEA   ^L032B15
         PEA   L032B15
         LDX   L020121
         LDA   L02011F
         PHX
         PHA
         PEI   $EA
         PEI   $EC
         JSL   L130403
         TAY
         TSC
         CLC
         ADC   #$0010
         TCS
         TYA
         LDA   $F9
         CLC
         ADC   #$0004
         STA   $F9
         BCC   L100111
         INC   $FB
L100111  LDA   $EA
         CLC
         ADC   #$0008
         STA   $EA
         BRA   L1000CA
L10011B  LDA   #$00A0
         STA   $EC
         LDA   #$0044
         STA   $EA
L100125  LDY   #$0002
         LDA   [$FD],Y
         TAX
         LDA   [$FD]
         STA   $EE
         STX   $F0
         LDA   [$EE]
         AND   #$00FF
         BEQ   L100176
         LDY   #$0002
         LDA   [$FD],Y
         TAX
         LDA   [$FD]
         PHX
         PHA
         PEA   ^L032B1D
         PEA   L032B1D
         LDX   L020121
         LDA   L02011F
         PHX
         PHA
         PEI   $EA
         PEI   $EC
         JSL   L130403
         TAY
         TSC
         CLC
         ADC   #$0010
         TCS
         TYA
         LDA   $FD
         CLC
         ADC   #$0004
         STA   $FD
         BCC   L10016C
         INC   $FF
L10016C  LDA   $EA
         CLC
         ADC   #$0008
         STA   $EA
         BRA   L100125
L100176  PEA   ^L032B25
         PEA   L032B25
         LDX   L020121
         LDA   L02011F
         PHX
         PHA
         PEA   $00AC
         PEA   $0032
         JSL   L130403
         TAY
         TSC
         CLC
         ADC   #$000C
         TCS
         TYA
         TSC
         CLC
         ADC   #$000A
         TCS
         PLD
         RTL

L10019E  PHD
         TSC
         SEC
         SBC   #$00FB
         TCD
         ADC   #$00EA
         TCS
         LDA   #$0028
         STA   $F4
         LDA   #$002E
         STA   $F2
         LDA   #$010E
         STA   $F0
         LDA   #$00B6
         STA   $EE
         PEA   $000F
         PEA   $00B8
         PEA   $0110
         PEA   $002C
         PEA   $0026
         JSL   L15030E
         PLY
         PLY
         PLY
         PLY
         PLY
         PEA   $000F
         PEA   $00B7
         PEA   $010F
         PEA   $002D
         PEA   $0027
         JSL   L15030E
         PLY
         PLY
         PLY
         PLY
         PLY
L1001ED  LDA   $F4
         SEC
         SBC   $F0
         BVS   L1001F7
         EOR   #$8000
L1001F7  BMI   L100236
         LDA   $F2
         SEC
         SBC   $EE
         BVS   L100203
         EOR   #$8000
L100203  BMI   L100236
         PEA   $0000
         PEI   $EE
         PEI   $F0
         PEI   $F2
         PEI   $F4
         JSL   L15030E
         PLY
         PLY
         PLY
         PLY
         PLY
         INC   $F4
         INC   $F2
         DEC   $F0
         DEC   $EE
         STZ   $EC
         BRA   L100227
L100225  INC   $EC
L100227  LDA   $EC
         SEC
         SBC   #$05DC
         BVS   L100232
         EOR   #$8000
L100232  BPL   L100225
         BRA   L1001ED
L100236  PEA   $0000
         PEI   $EE
         PEI   $F0
         PEI   $F2
         PEI   $F4
         JSL   L150098
         PLY
         PLY
         PLY
         PLY
         PLY
         PEA   $000F
         PEA   $00A6
         PEA   $009E
         PEA   $003D
         PEA   $009E
         JSL   L150098
         PLY
         PLY
         PLY
         PLY
         PLY
         TSC
         CLC
         ADC   #$0010
         TCS
         PLD
         RTL

L10026A  ENT
         PHD
         TSC
         SEC
         SBC   #$00FB
         TCD
         ADC   #$00D0
         TCS
         STZ   $D6
         STZ   $D8
         STZ   $D2
         STZ   $D4
         JSL   L04042E
         JSL   L100000
         JSL   L1705C2
         JSL   L160484
         JSL   L131225
         SEP   #$20
         STZ   L0200DB
         REP   #$20
         STZ   $D6
         STZ   $D8
         PEA   $FFFF
         LDX   L0200A6
         LDA   L0200A4
         PHX
         PHA
         LDX   L0200A6
         LDA   L0200A4
         PHX
         PHA
         JSL   L150000
         PLY
         PLY
         PLY
         PLY
         PLY
         LDA   #$0000
         STA   $E2
         STA   $E4
         LDA   #$013F
         STA   $E0
         LDA   #$00C7
         STA   $DE
L1002C9  LDA   $E4
         SEC
         SBC   $E0
         BVS   L1002D3
         EOR   #$8000
L1002D3  BMI   L10032A
         LDA   $E2
         SEC
         SBC   $DE
         BVS   L1002DF
         EOR   #$8000
L1002DF  BMI   L10032A
         PEA   $0000
         PEI   $DE
         PEI   $E0
         PEI   $E2
         PEI   $E4
         JSL   L15030E
         PLY
         PLY
         PLY
         PLY
         PLY
         LDA   $E4
         CLC
         ADC   #$0002
         STA   $E4
         LDA   $E2
         CLC
         ADC   #$0002
         STA   $E2
         LDA   $E0
         SEC
         SBC   #$0002
         STA   $E0
         LDA   $DE
         SEC
         SBC   #$0002
         STA   $DE
         STZ   $EE
         BRA   L10031B
L100319  INC   $EE
L10031B  LDA   $EE
         SEC
         SBC   #$03E8
         BVS   L100326
         EOR   #$8000
L100326  BPL   L100319
         BRA   L1002C9
L10032A  LDA   #$0001
         STA   $E2
         STA   $E4
         LDA   #$013E
         STA   $E0
         LDA   #$00C6
         STA   $DE
L10033B  LDA   $E4
         SEC
         SBC   $E0
         BVS   L100345
         EOR   #$8000
L100345  BMI   L10039C
         LDA   $E2
         SEC
         SBC   $DE
         BVS   L100351
         EOR   #$8000
L100351  BMI   L10039C
         PEA   $0000
         PEI   $DE
         PEI   $E0
         PEI   $E2
         PEI   $E4
         JSL   L15030E
         PLY
         PLY
         PLY
         PLY
         PLY
         LDA   $E4
         CLC
         ADC   #$0002
         STA   $E4
         LDA   $E2
         CLC
         ADC   #$0002
         STA   $E2
         LDA   $E0
         SEC
         SBC   #$0002
         STA   $E0
         LDA   $DE
         SEC
         SBC   #$0002
         STA   $DE
         STZ   $EE
         BRA   L10038D
L10038B  INC   $EE
L10038D  LDA   $EE
         SEC
         SBC   #$03E8
         BVS   L100398
         EOR   #$8000
L100398  BPL   L10038B
         BRA   L10033B
L10039C  PEA   $0000
         PEI   $DE
         PEI   $E0
         PEI   $E2
         PEI   $E4
         JSL   L150098
         PLY
         PLY
         PLY
         PLY
         PLY
         PEA   ^L032B46
         PEA   L032B46
         JSL   L160334
         PLY
         PLY
         STX   L0200E8
         STA   L0200E6
         PEA   $0000
         LDX   L0200A6
         LDA   L0200A4
         PHX
         PHA
         LDX   L0200E8
         LDA   L0200E6
         PHX
         PHA
         JSL   L150060
         PLY
         PLY
         PLY
         PLY
         PLY
         PEA   $FFFF
         PEA   $00E1
         PEA   $2000
         LDX   L0200A6
         LDA   L0200A4
         PHX
         PHA
         JSL   L150000
         PLY
         PLY
         PLY
         PLY
         PLY
         JSL   L070062
         PEA   $00A0
         JSL   L0405F2
         PLY
         PEA   $0001
         PEA   ^L03162E
         PEA   L03162E
         JSL   L040732
         PLY
         PLY
         PLY
         LDX   L0200A6
         LDA   L0200A4
         PHX
         PHA
         PEA   $00E1
         PEA   $2000
         JSL   L1607F3
         PLY
         PLY
         PLY
         PLY
         LDX   L0200E8
         LDA   L0200E6
         PHX
         PHA
         JSL   L1605C8
         PLY
         PLY
L100438  JSL   L150027
         AND   #$0080
         TAY
         BEQ   L100444
         BRA   L100438
L100444  JSL   L150027
         AND   #$0080
         TAY
         BNE   L100450
         BRA   L100444
L100450  JSL   L150027
         AND   #$0080
         TAY
         BEQ   L10045C
         BRA   L100450
L10045C  STZ   $DA
         STZ   $DC
         STZ   $EC
         STZ   $EA
         STZ   $E8
         STZ   $F4
         BRA   L100495
L10046A  LDA   $F4
         ASL
         ASL
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   #L0304DA
         LDX   #^L0304DA
         JSL   L010410
         PLA
         PLX
         STA   $F6
         STX   $F8
         LDY   #$0002
         LDA   [$F6],Y
         BNE   L100493
         LDA   $DA
         CLC
         ADC   #$0001
         STA   $DA
L100493  INC   $F4
L100495  LDA   $F4
         SEC
         SBC   #$0003
         BVS   L1004A0
         EOR   #$8000
L1004A0  BPL   L10046A
         LDA   #$0003
         STA   $F4
         BRA   L1004D4
L1004A9  LDA   $F4
         ASL
         ASL
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   #L0304DA
         LDX   #^L0304DA
         JSL   L010410
         PLA
         PLX
         STA   $F6
         STX   $F8
         LDY   #$0002
         LDA   [$F6],Y
         BNE   L1004D2
         LDA   $DC
         CLC
         ADC   #$0001
         STA   $DC
L1004D2  INC   $F4
L1004D4  LDA   $F4
         SEC
         SBC   #$0006
         BVS   L1004DF
         EOR   #$8000
L1004DF  BPL   L1004A9
         LDA   $DC
         CLC
         ADC   $DA
         STA   $EC
         LDA   #$0006
         STA   $F4
         BRA   L10051A
L1004EF  LDA   $F4
         ASL
         ASL
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   #L0304DA
         LDX   #^L0304DA
         JSL   L010410
         PLA
         PLX
         STA   $F6
         STX   $F8
         LDY   #$0002
         LDA   [$F6],Y
         BNE   L100518
         LDA   $E8
         CLC
         ADC   #$0001
         STA   $E8
L100518  INC   $F4
L10051A  LDA   $F4
         SEC
         SBC   #$0014
         BVS   L100525
         EOR   #$8000
L100525  BPL   L1004EF
         LDA   #$0014
         STA   $F4
         BRA   L100559
L10052E  LDA   $F4
         ASL
         ASL
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   #L0304DA
         LDX   #^L0304DA
         JSL   L010410
         PLA
         PLX
         STA   $F6
         STX   $F8
         LDY   #$0002
         LDA   [$F6],Y
         BNE   L100557
         LDA   $EA
         CLC
         ADC   #$0001
         STA   $EA
L100557  INC   $F4
L100559  LDA   $F4
         SEC
         SBC   #$0018
         BVS   L100564
         EOR   #$8000
L100564  BPL   L10052E
         STZ   $E6
         LDA   $EA
         BNE   L1005A2
         LDA   L02004A
         BEQ   L1005A2
         LDA   $EC
         BNE   L100583
         STZ   $E6
         LDA   #$0001
         SEP   #$20
         STA   L0200DB
         REP   #$20
         BRA   L1005A2
L100583  LDA   $DC
         CMP   #$0003
         BEQ   L10059D
         LDA   #$0001
         STA   $E6
         LDA   $EC
         CMP   #$0001
         BNE   L10059B
         LDA   #$0006
         STA   $E6
L10059B  BRA   L1005A2
L10059D  LDA   #$0002
         STA   $E6
L1005A2  LDA   $EA
         BEQ   L1005E3
         LDA   L02004A
         BEQ   L1005E3
         LDA   L02004C
         BEQ   L1005C4
         LDA   #$0003
         STA   $E6
         LDA   L02004C
         CMP   #$0001
         BNE   L1005C2
         LDA   #$0008
         STA   $E6
L1005C2  BRA   L1005E3
L1005C4  LDA   $DC
         CMP   #$0003
         BEQ   L1005DE
         LDA   #$0009
         STA   $E6
         LDA   $EA
         CMP   #$0003
         BNE   L1005DC
         LDA   #$000A
         STA   $E6
L1005DC  BRA   L1005E3
L1005DE  LDA   #$0002
         STA   $E6
L1005E3  LDA   L02004A
         BNE   L1005ED
         LDA   #$0005
         STA   $E6
L1005ED  LDA   L0200DC
         BEQ   L100619
         LDA   L0200DC
         PHA
         JSL   L07025A
         PLY
         STA   $F6
         STX   $F8
         LDA   [$F6]
         PHA
         LDAL  L03212B+2
         TAX
         LDAL  L03212B
         STA   $F6
         STX   $F8
         PLA
         SEP   #$20
         STA   [$F6]
         REP   #$20
         BRL   L100656
L100619  LDAL  L032127+2
         TAX
         LDAL  L032127
         STX   $D8
         STA   $D6
         LDAL  L03212B+2
         TAX
         LDAL  L03212B
         STX   $D4
         STA   $D2
         LDX   $D8
         LDA   $D6
         PHA
         TXA
         STAL  L03212B+2
         PLA
         STAL  L03212B
         LDAL  L03211B+2
         TAX
         LDAL  L03211B
         PHA
         TXA
         STAL  L032127+2
         PLA
         STAL  L032127
L100656  LDA   L0200DE
         PHA
         JSL   L07025A
         PLY
         STA   $F6
         STX   $F8
         LDA   [$F6]
         PHA
         LDAL  L03212F+2
         TAX
         LDAL  L03212F
         STA   $F6
         STX   $F8
         PLA
         SEP   #$20
         STA   [$F6]
         REP   #$20
         LDA   L0200DE
         CMP   #$000A
         BCC   L1006AE
         LDA   L0200DE
         PHA
         JSL   L07025A
         PLY
         STA   $F6
         STX   $F8
         LDY   #$0001
         LDA   [$F6],Y
         PHA
         LDAL  L03212F+2
         TAX
         LDAL  L03212F
         STA   $F6
         STX   $F8
         PLA
         SEP   #$20
         LDY   #$0001
         STA   [$F6],Y
         REP   #$20
         BRA   L1006C7
L1006AE  LDAL  L03212F+2
         TAX
         LDAL  L03212F
         STA   $F6
         STX   $F8
         LDA   #$0020
         SEP   #$20
         LDY   #$0001
         STA   [$F6],Y
         REP   #$20
L1006C7  PEI   $EC
         JSL   L07025A
         PLY
         STA   $F6
         STX   $F8
         LDA   [$F6]
         PHA
         LDAL  L0321DF+2
         TAX
         LDAL  L0321DF
         STA   $F6
         STX   $F8
         PLA
         SEP   #$20
         LDY   #$000D
         STA   [$F6],Y
         REP   #$20
         LDA   $E8
         SEC
         SBC   #$000A
         BVS   L1006F7
         EOR   #$8000
L1006F7  BPL   L100745
         PEI   $E8
         JSL   L07025A
         PLY
         STA   $F6
         STX   $F8
         LDA   [$F6]
         PHA
         LDAL  L0321F3+2
         TAX
         LDAL  L0321F3
         STA   $F6
         STX   $F8
         PLA
         SEP   #$20
         STA   [$F6]
         REP   #$20
         PEI   $E8
         JSL   L07025A
         PLY
         STA   $F6
         STX   $F8
         LDY   #$0001
         LDA   [$F6],Y
         PHA
         LDAL  L0321F3+2
         TAX
         LDAL  L0321F3
         STA   $F6
         STX   $F8
         PLA
         SEP   #$20
         LDY   #$0001
         STA   [$F6],Y
         REP   #$20
         BRA   L100780
L100745  LDAL  L0321F3+2
         TAX
         LDAL  L0321F3
         STA   $F6
         STX   $F8
         LDA   #$0020
         SEP   #$20
         STA   [$F6]
         REP   #$20
         PEI   $E8
         JSL   L07025A
         PLY
         STA   $F6
         STX   $F8
         LDA   [$F6]
         PHA
         LDAL  L0321F3+2
         TAX
         LDAL  L0321F3
         STA   $F6
         STX   $F8
         PLA
         SEP   #$20
         LDY   #$0001
         STA   [$F6],Y
         REP   #$20
L100780  LDA   $E8
         SEC
         SBC   #$000A
         BVS   L10078B
         EOR   #$8000
L10078B  BPL   L1007D9
         PEI   $E8
         JSL   L07025A
         PLY
         STA   $F6
         STX   $F8
         LDA   [$F6]
         PHA
         LDAL  L032723+2
         TAX
         LDAL  L032723
         STA   $F6
         STX   $F8
         PLA
         SEP   #$20
         STA   [$F6]
         REP   #$20
         PEI   $E8
         JSL   L07025A
         PLY
         STA   $F6
         STX   $F8
         LDY   #$0001
         LDA   [$F6],Y
         PHA
         LDAL  L032723+2
         TAX
         LDAL  L032723
         STA   $F6
         STX   $F8
         PLA
         SEP   #$20
         LDY   #$0001
         STA   [$F6],Y
         REP   #$20
         BRA   L100814
L1007D9  LDAL  L032723+2
         TAX
         LDAL  L032723
         STA   $F6
         STX   $F8
         LDA   #$0020
         SEP   #$20
         STA   [$F6]
         REP   #$20
         PEI   $E8
         JSL   L07025A
         PLY
         STA   $F6
         STX   $F8
         LDA   [$F6]
         PHA
         LDAL  L032723+2
         TAX
         LDAL  L032723
         STA   $F6
         STX   $F8
         PLA
         SEP   #$20
         LDY   #$0001
         STA   [$F6],Y
         REP   #$20
L100814  LDA   #$0004
         SEC
         SBC   $EA
         PHA
         JSL   L07025A
         PLY
         STA   $F6
         STX   $F8
         LDA   [$F6]
         PHA
         LDAL  L032A9D+2
         TAX
         LDAL  L032A9D
         STA   $F6
         STX   $F8
         PLA
         SEP   #$20
         LDY   #$0005
         STA   [$F6],Y
         REP   #$20
         PEI   $EA
         JSL   L07025A
         PLY
         STA   $F6
         STX   $F8
         LDA   [$F6]
         PHA
         LDAL  L03251E+2
         TAX
         LDAL  L03251E
         STA   $F6
         STX   $F8
         PLA
         SEP   #$20
         STA   [$F6]
         REP   #$20
         PEI   $EC
         JSL   L07025A
         PLY
         STA   $F6
         STX   $F8
         LDA   [$F6]
         PHA
         LDAL  L0323AC+2
         TAX
         LDAL  L0323AC
         STA   $F6
         STX   $F8
         PLA
         SEP   #$20
         STA   [$F6]
         REP   #$20
         PEA   $FFFF
         PEA   $00E1
         PEA   $2000
         PEA   $00E1
         PEA   $2000
         JSL   L150000
         PLY
         PLY
         PLY
         PLY
         PLY
         LDA   L02003B
         CMP   #$0000
         BEQ   L10090C
         JSL   L10019E
         LDA   $E6
         PHA
         LDA   #$0002
         SEC
         JSL   L01059C
         PLA
         CLC
         ADC   #$0001
         ASL
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   #L032ABD
         LDX   #^L032ABD
         JSL   L010410
         PLA
         PLX
         STA   $F6
         STX   $F8
         LDY   #$0002
         LDA   [$F6],Y
         TAX
         LDA   [$F6]
         PHX
         PHA
         LDA   $E6
         PHA
         LDA   #$0002
         SEC
         JSL   L01059C
         PLA
         ASL
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   #L032ABD
         LDX   #^L032ABD
         JSL   L010410
         PLA
         PLX
         STA   $F6
         STX   $F8
         LDY   #$0002
         LDA   [$F6],Y
         TAX
         LDA   [$F6]
         PHX
         PHA
         JSL   L1000B5
         PLY
         PLY
         PLY
         PLY
L10090C  LDX   $D8
         LDA   $D6
         STX   $F6
         ORA   $F6
         BEQ   L100934
         LDX   $D8
         LDA   $D6
         PHA
         TXA
         STAL  L032127+2
         PLA
         STAL  L032127
         LDX   $D4
         LDA   $D2
         PHA
         TXA
         STAL  L03212B+2
         PLA
         STAL  L03212B
L100934  PEA   $7530
         JSL   L140D0A
         PLY
L10093C  JSL   L150027
         AND   #$0080
         TAY
         BEQ   L100948
         BRA   L10093C
L100948  JSL   L150027
         AND   #$0080
         TAY
         BNE   L100954
         BRA   L100948
L100954  JSL   L150027
         AND   #$0080
         TAY
         BEQ   L100960
         BRA   L100954
L100960  PEA   $FFFF
         PEA   $00E1
         PEA   $2000
         LDX   L0200A4+2
         LDA   L0200A4
         PHX
         PHA
         JSL   L150000
         PLY
         PLY
         PLY
         PLY
         PLY
         LDX   L0200E6+2
         LDA   L0200E6
         PHX
         PHA
         JSL   L070045
         PLY
         PLY
         LDX   L02009C+2
         LDA   L02009C
         PEA   $0000
         PEA   $0032
         CLC
         JSL   L0105E1
         PLA
         PLX
         STX   L02009E
         STA   L02009C
         JSL   L0F0FE2
         LDA   #$0001
         STA   L02004A
         STZ   L02004C
         STZ   $F4
         BRA   L100A06
L1009B2  LDA   $F4
         PHA
         LDA   #$0006
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L03080A
         LDX   #^L03080A
         JSL   L010410
         PLA
         PLX
         STA   $F6
         STX   $F8
         LDA   #$0000
         LDY   #$0002
         STA   [$F6],Y
         LDA   $F4
         PHA
         LDA   #$0006
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L03080A
         LDX   #^L03080A
         JSL   L010410
         PLA
         PLX
         STA   $F6
         STX   $F8
         LDA   #$0000
         LDY   #$0004
         STA   [$F6],Y
         INC   $F4
L100A06  LDA   $F4
         SEC
         SBC   #$0003
         BVS   L100A11
         EOR   #$8000
L100A11  BPL   L1009B2
         TSC
         CLC
         ADC   #$002A
         TCS
         PLD
         RTL

