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

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

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

L0D0000  PHD
         TSC
         SEC
         SBC   #$00EB
         TCD
         ADC   #$00E4
         TCS
         LDA   [$F1]
         SEC
         SBC   $F9
         BVS   L0D0015
         EOR   #$8000
L0D0015  BMI   L0D001D
         LDA   $F9
         STA   [$F1]
         BRA   L0D002F
L0D001D  LDA   [$F1]
         SEC
         SBC   $FD
         BEQ   L0D002F
         BVS   L0D0029
         EOR   #$8000
L0D0029  BPL   L0D002F
         LDA   $FD
         STA   [$F1]
L0D002F  LDA   [$F5]
         SEC
         SBC   $FB
         BVS   L0D0039
         EOR   #$8000
L0D0039  BMI   L0D0041
         LDA   $FB
         STA   [$F5]
         BRA   L0D0053
L0D0041  LDA   [$F5]
         SEC
         SBC   $FF
         BEQ   L0D0053
         BVS   L0D004D
         EOR   #$8000
L0D004D  BPL   L0D0053
         LDA   $FF
         STA   [$F5]
L0D0053  TSC
         CLC
         ADC   #$0006
         TCS
         PLD
         RTL

L0D005B  PHD
         TSC
         SEC
         SBC   #$00F5
         TCD
         ADC   #$00EC
         TCS
         STZ   $EE
         LDA   $FD
         CLC
         ADC   #$0006
         STA   $FD
         LDA   $FF
         CLC
         ADC   #$0006
         STA   $FF
         LDA   $FB
         LDX   #$0000
         TAY
         BPL   L0D0081
         DEX
L0D0081  STX   $F4
         ASL
         ROL   $F4
         LDX   $F4
         PHX
         PHA
         LDA   #L031724
         LDX   #^L031724
         JSL   L010410
         PLA
         PLX
         STA   $F0
         STX   $F2
         LDA   [$F0]
         CLC
         ADC   #$000A
         SEC
         SBC   $FD
         BVS   L0D00A8
         EOR   #$8000
L0D00A8  BPL   L0D00AD
         BRL   L0D01A0
L0D00AD  LDA   $FB
         LDX   #$0000
         TAY
         BPL   L0D00B6
         DEX
L0D00B6  STX   $F4
         ASL
         ROL   $F4
         LDX   $F4
         PHX
         PHA
         LDA   #L031730
         LDX   #^L031730
         JSL   L010410
         PLA
         PLX
         STA   $F0
         STX   $F2
         LDA   [$F0]
         SEC
         SBC   #$000A
         SEC
         SBC   $FF
         BNE   L0D00DD
         BRL   L0D01A0
L0D00DD  BVS   L0D00E2
         EOR   #$8000
L0D00E2  BMI   L0D00E7
         BRL   L0D01A0
L0D00E7  LDA   $FB
         LDX   #$0000
         TAY
         BPL   L0D00F0
         DEX
L0D00F0  PHX
         PHA
         LDA   #L031718
         LDX   #^L031718
         JSL   L010410
         PLA
         PLX
         STA   $F0
         STX   $F2
         LDA   [$F0]
         AND   #$00FF
         PHA
         LDA   $FB
         LDX   #$0000
         TAY
         BPL   L0D0111
         DEX
L0D0111  STX   $F4
         ASL
         ROL   $F4
         LDX   $F4
         PHX
         PHA
         LDA   #L031724
         LDX   #^L031724
         JSL   L010410
         PLA
         PLX
         STA   $F0
         STX   $F2
         LDA   [$F0]
         PLX
         STX   $F4
         CLC
         ADC   $F4
         SEC
         SBC   #$000A
         SEC
         SBC   $FD
         BEQ   L0D01A0
         BVS   L0D0140
         EOR   #$8000
L0D0140  BPL   L0D01A0
         LDA   $FB
         LDX   #$0000
         TAY
         BPL   L0D014B
         DEX
L0D014B  PHX
         PHA
         LDA   #L03171E
         LDX   #^L03171E
         JSL   L010410
         PLA
         PLX
         STA   $F0
         STX   $F2
         LDA   [$F0]
         AND   #$00FF
         PHA
         LDA   $FB
         LDX   #$0000
         TAY
         BPL   L0D016C
         DEX
L0D016C  STX   $F4
         ASL
         ROL   $F4
         LDX   $F4
         PHX
         PHA
         LDA   #L031730
         LDX   #^L031730
         JSL   L010410
         PLA
         PLX
         STA   $F0
         STX   $F2
         LDA   [$F0]
         PLX
         STX   $F4
         SEC
         SBC   $F4
         CLC
         ADC   #$000A
         SEC
         SBC   $FF
         BVS   L0D0199
         EOR   #$8000
L0D0199  BMI   L0D01A0
         LDA   #$0001
         STA   $EE
L0D01A0  LDA   $EE
         TAY
         TSC
         CLC
         ADC   #$0008
         TCS
         TYA
         PLD
         RTL

L0D01AC  PHD
         TSC
         SEC
         SBC   #$00F5
         TCD
         ADC   #$00E8
         TCS
         STZ   $EE
         BRL   L0D04AA
L0D01BC  LDA   $EE
         LDX   #$0000
         TAY
         BPL   L0D01C5
         DEX
L0D01C5  STX   $F4
         ASL
         ROL   $F4
         LDX   $F4
         PHX
         PHA
         LDA   #L031700
         LDX   #^L031700
         JSL   L010410
         PLA
         PLX
         STA   $F0
         STX   $F2
         LDA   [$F0]
         STA   $EC
         PEI   $FF
         PEI   $FD
         PEI   $EE
         JSL   L0D005B
         PLY
         PLY
         PLY
         TAY
         BNE   L0D01F5
         BRL   L0D04A8
L0D01F5  LDA   $EC
         ASL
         ASL
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   #L0304DA
         LDX   #^L0304DA
         JSL   L010410
         PLA
         PLX
         STA   $F0
         STX   $F2
         LDY   #$0002
         LDA   [$F0],Y
         BNE   L0D0219
         BRL   L0D04A8
L0D0219  LDA   $EC
         PHA
         LDA   #$001A
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L03059A
         LDX   #^L03059A
         JSL   L010410
         PLA
         PLX
         STA   $F0
         STX   $F2
         LDY   #$000A
         LDA   [$F0],Y
         CMP   #$0000
         BNE   L0D0247
         BRL   L0D04A8
L0D0247  LDA   $EC
         PHA
         LDA   #$001A
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L03059A
         LDX   #^L03059A
         JSL   L010410
         PLA
         PLX
         STA   $F0
         STX   $F2
         LDA   #$0000
         LDY   #$000A
         STA   [$F0],Y
         LDA   $EC
         SEC
         SBC   #$0006
         BVS   L0D027B
         EOR   #$8000
L0D027B  BPL   L0D0280
         BRL   L0D02ED
L0D0280  LDA   $EC
         PHA
         LDA   #$001A
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L03059A
         LDX   #^L03059A
         JSL   L010410
         PLA
         PLX
         STA   $F0
         STX   $F2
         LDA   #$000E
         LDY   #$000A
         STA   [$F0],Y
         LDA   L0200D5
         SEC
         SBC   #$0080
         BVS   L0D02B5
         EOR   #$8000
L0D02B5  BMI   L0D02EA
         LDA   L0200D5
         PHA
         LDA   #$0006
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L031782
         LDX   #^L031782
         JSL   L010410
         PLA
         PLX
         STA   $F0
         STX   $F2
         LDY   #$0005
         LDA   [$F0],Y
         PHA
         INC
         SEP   #$20
         LDY   #$0005
         STA   [$F0],Y
         REP   #$20
         PLA
L0D02EA  BRL   L0D0401
L0D02ED  LDA   $EC
         SEC
         SBC   #$0014
         BVS   L0D02F8
         EOR   #$8000
L0D02F8  BMI   L0D02FD
         BRL   L0D03C0
L0D02FD  LDA   $EC
         PHA
         LDA   #$001A
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L03059A
         LDX   #^L03059A
         JSL   L010410
         PLA
         PLX
         STA   $F0
         STX   $F2
         LDY   #$000A
         LDA   [$F0],Y
         CMP   #$000F
         BNE   L0D032B
         BRL   L0D03C0
L0D032B  LDA   $EC
         PHA
         LDA   #$001A
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L03059A
         LDX   #^L03059A
         JSL   L010410
         PLA
         PLX
         STA   $F0
         STX   $F2
         LDA   #$000F
         LDY   #$000A
         STA   [$F0],Y
         LDA   $EC
         PHA
         LDA   #$001A
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L03059A
         LDX   #^L03059A
         JSL   L010410
         PLA
         PLX
         STA   $F0
         STX   $F2
         LDA   #$FFFF
         LDY   #$0012
         STA   [$F0],Y
         LDA   L0200D5
         SEC
         SBC   #$0080
         BVS   L0D0389
         EOR   #$8000
L0D0389  BMI   L0D03BE
         LDA   L0200D5
         PHA
         LDA   #$0006
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L031782
         LDX   #^L031782
         JSL   L010410
         PLA
         PLX
         STA   $F0
         STX   $F2
         LDY   #$0004
         LDA   [$F0],Y
         PHA
         INC
         SEP   #$20
         LDY   #$0004
         STA   [$F0],Y
         REP   #$20
         PLA
L0D03BE  BRA   L0D0401
L0D03C0  LDA   L0200D5
         SEC
         SBC   #$0080
         BVS   L0D03CC
         EOR   #$8000
L0D03CC  BMI   L0D0401
         LDA   L0200D5
         PHA
         LDA   #$0006
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L031782
         LDX   #^L031782
         JSL   L010410
         PLA
         PLX
         STA   $F0
         STX   $F2
         LDY   #$0003
         LDA   [$F0],Y
         PHA
         INC
         SEP   #$20
         LDY   #$0003
         STA   [$F0],Y
         REP   #$20
         PLA
L0D0401  LDA   $EC
         PHA
         LDA   #$001A
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L03059A
         LDX   #^L03059A
         JSL   L010410
         PLA
         PLX
         STA   $F0
         STX   $F2
         LDA   #$0000
         LDY   #$000C
         STA   [$F0],Y
         LDA   $EC
         PHA
         LDA   #$001A
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L03059A
         LDX   #^L03059A
         JSL   L010410
         PLA
         PLX
         STA   $F0
         STX   $F2
         LDA   #$0004
         LDY   #$0016
         STA   [$F0],Y
         LDA   $FB
         ASL
         ASL
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   #L0304DA
         LDX   #^L0304DA
         JSL   L010410
         PLA
         PLX
         STA   $F0
         STX   $F2
         LDA   [$F0]
         CMP   #$0003
         BNE   L0D04A0
         LDA   $FB
         PHA
         LDA   #$001A
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L03059A
         LDX   #^L03059A
         JSL   L010410
         PLA
         PLX
         STA   $F0
         STX   $F2
         LDA   [$F0]
         PHA
         PEI   $FB
         JSL   L0F012D
         PLY
         PLY
L0D04A0  LDA   #$0001
         STA   L020041
         BRA   L0D04BA
L0D04A8  INC   $EE
L0D04AA  LDA   $EE
         SEC
         SBC   L02007E
         BVS   L0D04B5
         EOR   #$8000
L0D04B5  BMI   L0D04BA
         BRL   L0D01BC
L0D04BA  TSC
         CLC
         ADC   #$000C
         TCS
         PLD
         RTL

L0D04C2  PHD
         TSC
         SEC
         SBC   #$00F7
         TCD
         ADC   #$00E2
         TCS
         LDA   $FD
         PHA
         LDA   #$0006
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L0316A0
         LDX   #^L0316A0
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDX   $F4
         LDA   #$0002
         CLC
         ADC   $F2
         BCC   L0D04F9
         INX
L0D04F9  STX   $EA
         STA   $E8
         LDA   $FD
         PHA
         LDA   #$0006
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L0316A0
         LDX   #^L0316A0
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDX   $F4
         LDA   #$0004
         CLC
         ADC   $F2
         BCC   L0D0529
         INX
L0D0529  STX   $E6
         STA   $E4
         LDA   #L0316D8
         LDX   #^L0316D8
         STX   L02007C
         STA   L02007A
         LDA   $FD
         ASL
         ASL
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   #L0304DA
         LDX   #^L0304DA
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDA   [$F2]
         CMP   #$0004
         BEQ   L0D055D
         BRL   L0D0681
L0D055D  LDA   [$E8]
         SEC
         SBC   #$00A5
         BVS   L0D0568
         EOR   #$8000
L0D0568  BMI   L0D0590
         LDX   L02007C
         LDA   L02007A
         PHX
         PHA
         CLC
         ADC   #$0002
         STA   L02007A
         LDA   L02007C
         BCC   L0D057F
         INC
L0D057F  STA   L02007C
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDA   #$0003
         STA   [$F2]
         BRL   L0D0618
L0D0590  LDA   [$E8]
         SEC
         SBC   #$00BE
         BVS   L0D059B
         EOR   #$8000
L0D059B  BMI   L0D05C3
         LDX   L02007C
         LDA   L02007A
         PHX
         PHA
         CLC
         ADC   #$0002
         STA   L02007A
         LDA   L02007C
         BCC   L0D05B2
         INC
L0D05B2  STA   L02007C
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDA   #$0004
         STA   [$F2]
         BRL   L0D0618
L0D05C3  LDA   [$E8]
         SEC
         SBC   #$00D7
         BVS   L0D05CE
         EOR   #$8000
L0D05CE  BMI   L0D05F5
         LDX   L02007C
         LDA   L02007A
         PHX
         PHA
         CLC
         ADC   #$0002
         STA   L02007A
         LDA   L02007C
         BCC   L0D05E5
         INC
L0D05E5  STA   L02007C
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDA   #$0005
         STA   [$F2]
         BRA   L0D0618
L0D05F5  LDX   L02007C
         LDA   L02007A
         PHX
         PHA
         CLC
         ADC   #$0002
         STA   L02007A
         LDA   L02007C
         BCC   L0D060A
         INC
L0D060A  STA   L02007C
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDA   #$0006
         STA   [$F2]
L0D0618  LDX   L02007C
         LDA   L02007A
         PHX
         PHA
         CLC
         ADC   #$0002
         STA   L02007A
         LDA   L02007C
         BCC   L0D062D
         INC
L0D062D  STA   L02007C
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDA   #$00B2
         STA   [$F2]
         LDX   L02007C
         LDA   L02007A
         PHX
         PHA
         CLC
         ADC   #$0002
         STA   L02007A
         LDA   L02007C
         BCC   L0D0650
         INC
L0D0650  STA   L02007C
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDA   #$00B2
         STA   [$F2]
         LDX   L02007C
         LDA   L02007A
         PHX
         PHA
         CLC
         ADC   #$0002
         STA   L02007A
         LDA   L02007C
         BCC   L0D0673
         INC
L0D0673  STA   L02007C
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDA   #$0003
         STA   [$F2]
L0D0681  LDA   $FF
         CMP   #$000B
         BEQ   L0D068B
         BRL   L0D06E9
L0D068B  LDA   $FD
         PHA
         LDA   #$0006
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L0316A0
         LDX   #^L0316A0
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDA   #$0000
         STA   [$F2]
         LDA   $FD
         PHA
         LDA   #$001A
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L03059A
         LDX   #^L03059A
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDA   #$0000
         LDY   #$000C
         STA   [$F2],Y
         LDA   #L0316D8
         LDX   #^L0316D8
         STX   L02007C
         STA   L02007A
         BRL   L0D0925
L0D06E9  LDA   $FF
         AND   #$0080
         TAY
         BNE   L0D06F4
         BRL   L0D080C
L0D06F4  LDA   #$0001
         STA   L02003D
         LDA   [$E4]
         PHA
         LDA   [$E8]
         PHA
         PEI   $FD
         JSL   L0D01AC
         PLY
         PLY
         PLY
         JSL   L0703A5
         AND   #$0003
         STA   $EE
         JSL   L0703A5
         AND   #$0003
         STA   $EC
         LDA   $EE
         AND   #$0001
         TAY
         BEQ   L0D0733
         LDA   $EE
         EOR   #$FFFF
         INC
         STA   $EE
         LDA   $EC
         EOR   #$FFFF
         INC
         STA   $EC
L0D0733  LDA   [$E8]
         CLC
         ADC   $EE
         STA   [$E8]
         LDA   [$E4]
         SEC
         SBC   $EC
         STA   [$E4]
         LDA   $FD
         ASL
         ASL
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   #L0304DA
         LDX   #^L0304DA
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDA   [$F2]
         CMP   #$0004
         BNE   L0D0776
         LDA   L0200D1
         BEQ   L0D0776
         LDAL  L0316D8
         CLC
         ADC   #$0004
         STAL  L0316D8
         BRL   L0D080C
L0D0776  LDA   L0200D1
         BNE   L0D077E
         BRL   L0D080C
L0D077E  LDX   L02007C
         LDA   L02007A
         PHX
         PHA
         CLC
         ADC   #$0002
         STA   L02007A
         LDA   L02007C
         BCC   L0D0793
         INC
L0D0793  STA   L02007C
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDA   #$0000
         STA   [$F2]
         LDA   [$E8]
         PHA
         LDX   L02007C
         LDA   L02007A
         PHX
         PHA
         CLC
         ADC   #$0002
         STA   L02007A
         LDA   L02007C
         BCC   L0D07B9
         INC
L0D07B9  STA   L02007C
         PLA
         PLX
         STA   $F2
         STX   $F4
         PLA
         STA   [$F2]
         LDA   [$E4]
         PHA
         LDX   L02007C
         LDA   L02007A
         PHX
         PHA
         CLC
         ADC   #$0002
         STA   L02007A
         LDA   L02007C
         BCC   L0D07DD
         INC
L0D07DD  STA   L02007C
         PLA
         PLX
         STA   $F2
         STX   $F4
         PLA
         STA   [$F2]
         LDX   L02007C
         LDA   L02007A
         PHX
         PHA
         CLC
         ADC   #$0002
         STA   L02007A
         LDA   L02007C
         BCC   L0D07FE
         INC
L0D07FE  STA   L02007C
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDA   #$0001
         STA   [$F2]
L0D080C  LDA   $FF
         AND   #$007F
         STA   $FF
         LDA   $FD
         ASL
         ASL
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   #L0304DA
         LDX   #^L0304DA
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDA   [$F2]
         CMP   #$0003
         BNE   L0D085D
         LDA   $FF
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   #L031F85
         LDX   #^L031F85
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDA   [$F2]
         ASL
         ASL
         PHA
         LDA   [$E8]
         PLX
         STX   $F6
         CLC
         ADC   $F6
         STA   [$E8]
         BRA   L0D0882
L0D085D  LDA   $FF
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   #L031F85
         LDX   #^L031F85
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDA   [$F2]
         PHA
         LDA   [$E8]
         PLX
         STX   $F6
         CLC
         ADC   $F6
         STA   [$E8]
L0D0882  LDA   $FF
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   #L031F97
         LDX   #^L031F97
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDA   [$F2]
         PHA
         LDA   [$E4]
         PLX
         STX   $F6
         CLC
         ADC   $F6
         STA   [$E4]
         LDA   $FD
         ASL
         ASL
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   #L0304DA
         LDX   #^L0304DA
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDA   [$F2]
         BRL   L0D0915
L0D08C6  PEA   $0082
         PEA   $0128
         PEA   $004A
         PEA   $008C
         PEI   $E6
         PEI   $E4
         PEI   $EA
         PEI   $E8
         JSL   L0D0000
         TAY
         TSC
         CLC
         ADC   #$0010
         TCS
         TYA
         BRL   L0D0925
L0D08E9  PEA   $0082
         PEA   $00F0
         PEA   $0042
         PEA   $008C
         PEI   $E6
         PEI   $E4
         PEI   $EA
         PEI   $E8
         JSL   L0D0000
         TAY
         TSC
         CLC
         ADC   #$0010
         TCS
         TYA
         BRL   L0D0925
L0D090C  BRL   L0D0925
L0D090F  DA    L0D08C6
         DA    L0D08E9
         DA    L0D090C
L0D0915  DEC
         DEC
         DEC
         CMP   #$0002
         BCC   L0D0920
         LDA   #$0002
L0D0920  ASL
         TAX
         JMP   (L0D090F,X)

L0D0925  LDX   L02007C
         LDA   L02007A
         STA   $F2
         STX   $F4
         LDA   #$FFFF
         STA   [$F2]
         TSC
         CLC
         ADC   #$0014
         TCS
         PLD
         RTL

L0D093C  ENT
         PHD
         TSC
         SEC
         SBC   #$00F9
         TCD
         ADC   #$00F0
         TCS
         LDA   $FF
         PHA
         LDA   #$001A
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L03059A
         LDX   #^L03059A
         JSL   L010410
         PLA
         PLX
         STA   $F4
         STX   $F6
         LDA   [$F4]
         SEC
         SBC   #$0001
         STA   $F2
         LDA   $F2
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   #L031F79
         LDX   #^L031F79
         JSL   L010410
         PLA
         PLX
         STA   $F4
         STX   $F6
         LDA   [$F4]
         PHA
         LDX   L020086
         LDA   L020084
         STA   $F4
         STX   $F6
         PLA
         LDY   #$000E
         STA   [$F4],Y
         LDA   $F2
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   #L031F7F
         LDX   #^L031F7F
         JSL   L010410
         PLA
         PLX
         STA   $F4
         STX   $F6
         LDA   [$F4]
         PHA
         LDX   L020086
         LDA   L020084
         STA   $F4
         STX   $F6
         PLA
         LDY   #$0016
         STA   [$F4],Y
         TSC
         CLC
         ADC   #$0008
         TCS
         PLD
         RTL

L0D09CE  ENT
         PHD
         TSC
         SEC
         SBC   #$00F9
         TCD
         ADC   #$00F2
         TCS
         LDA   #L0316C4
         LDX   #^L0316C4
         STX   L020078
         STA   L020076
         LDA   #L0316D8
         LDX   #^L0316D8
         STX   L02007C
         STA   L02007A
         LDA   $FF
         ASL
         ASL
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   #L0304DA
         LDX   #^L0304DA
         JSL   L010410
         PLA
         PLX
         STA   $F4
         STX   $F6
         LDA   #$0000
         LDY   #$0004
         STA   [$F4],Y
         LDA   $FF
         ASL
         ASL
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   #L0304DA
         LDX   #^L0304DA
         JSL   L010410
         PLA
         PLX
         STA   $F4
         STX   $F6
         LDA   [$F4]
         BRL   L0D0A54
L0D0A32  PEI   $FF
         JSL   L0C0AB5
         PLY
         BRL   L0D0A64
L0D0A3C  PEI   $FF
         JSL   L0C0B67
         PLY
         BRL   L0D0A64
L0D0A46  BRL   L0D0A64
L0D0A49  BRL   L0D0A64
L0D0A4C  DA    L0D0A32
         DA    L0D0A3C
         DA    L0D0A46
         DA    L0D0A49
L0D0A54  DEC
         DEC
         DEC
         CMP   #$0003
         BCC   L0D0A5F
         LDA   #$0003
L0D0A5F  ASL
         TAX
         JMP   (L0D0A4C,X)

L0D0A64  LDX   L020078
         LDA   L020076
         STA   $F4
         STX   $F6
         LDA   #$FFFF
         STA   [$F4]
         LDA   $FF
         PHA
         LDA   #$0006
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L0316A0
         LDX   #^L0316A0
         JSL   L010410
         PLA
         PLX
         STA   $F4
         STX   $F6
         LDA   [$F4]
         BEQ   L0D0AA3
         PEA   $0000
         PEI   $FF
         JSL   L0D04C2
         PLY
         PLY
L0D0AA3  LDX   L02007C
         LDA   L02007A
         STA   $F4
         STX   $F6
         LDA   #$FFFF
         STA   [$F4]
         TSC
         CLC
         ADC   #$0006
         TCS
         PLD
         RTL

L0D0ABA  ENT
         PHD
         TSC
         SEC
         SBC   #$00F7
         TCD
         ADC   #$00E4
         TCS
         STZ   $EE
         LDA   $FD
         PHA
         LDA   #$001A
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L03059A
         LDX   #^L03059A
         JSL   L010410
         PLA
         PLX
         STX   $E8
         STA   $E6
         LDA   [$E6]
         STA   $EC
         LDY   #$0002
         LDA   [$E6],Y
         STA   $EA
         LDA   #L0316C4
         LDX   #^L0316C4
         STX   L020078
         STA   L020076
         LDA   #L0316D8
         LDX   #^L0316D8
         STX   L02007C
         STA   L02007A
         LDX   L020078
         LDA   L020076
         STA   $F2
         STX   $F4
         LDA   #$FFFF
         STA   [$F2]
         LDX   L02007C
         LDA   L02007A
         STA   $F2
         STX   $F4
         LDA   #$FFFF
         STA   [$F2]
         LDA   $FD
         PHA
         LDA   #$0006
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L0316A0
         LDX   #^L0316A0
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDA   [$F2]
         BEQ   L0D0B5B
         PEI   $FF
         PEI   $FD
         JSL   L0D04C2
         PLY
         PLY
         BRL   L0D0E32
L0D0B5B  LDA   $FF
         AND   #$0080
         TAY
         BEQ   L0D0B66
         BRL   L0D0DF1
L0D0B66  LDA   $FF
         SEC
         SBC   #$000B
         BVS   L0D0B71
         EOR   #$8000
L0D0B71  BPL   L0D0B76
         BRL   L0D0DF1
L0D0B76  PEI   $FF
         PEI   $FD
         JSL   L0C0E26
         PLY
         PLY
         STA   $F0
         SEC
         SBC   #$0000
         BNE   L0D0B8B
         BRL   L0D0D6C
L0D0B8B  BVS   L0D0B90
         EOR   #$8000
L0D0B90  BMI   L0D0B95
         BRL   L0D0D6C
L0D0B95  PEI   $FD
         JSL   L0C0300
         PLY
         PEI   $FD
         JSL   L0D09CE
         PLY
         LDA   [$E6]
         CMP   $EC
         BEQ   L0D0BB7
         PEI   $FD
         JSL   L0D093C
         PLY
         PEI   $FD
         JSL   L0F02BB
         PLY
L0D0BB7  LDA   $FD
         SEC
         SBC   #$0003
         LDX   #$0000
         TAY
         BPL   L0D0BC4
         DEX
L0D0BC4  STX   $F6
         ASL
         ROL   $F6
         LDX   $F6
         PHX
         PHA
         LDA   #L03177C
         LDX   #^L03177C
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDA   [$F2]
         AND   #$8000
         TAY
         BNE   L0D0BE8
         BRL   L0D0D69
L0D0BE8  LDA   $FD
         SEC
         SBC   #$0003
         LDX   #$0000
         TAY
         BPL   L0D0BF5
         DEX
L0D0BF5  STX   $F6
         ASL
         ROL   $F6
         LDX   $F6
         PHX
         PHA
         LDA   #L03177C
         LDX   #^L03177C
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDA   [$F2]
         AND   #$00FF
         PHA
         LDA   #$001A
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L03059A
         LDX   #^L03059A
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDY   #$0002
         LDA   [$F2],Y
         CMP   $EA
         BEQ   L0D0C3E
         BRL   L0D0D69
L0D0C3E  LDA   $FD
         SEC
         SBC   #$0003
         LDX   #$0000
         TAY
         BPL   L0D0C4B
         DEX
L0D0C4B  STX   $F6
         ASL
         ROL   $F6
         LDX   $F6
         PHX
         PHA
         LDA   #L03177C
         LDX   #^L03177C
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDA   [$F2]
         AND   #$00FF
         STA   [$F2]
         LDA   $FD
         SEC
         SBC   #$0003
         LDX   #$0000
         TAY
         BPL   L0D0C78
         DEX
L0D0C78  STX   $F6
         ASL
         ROL   $F6
         LDX   $F6
         PHX
         PHA
         LDA   #L03177C
         LDX   #^L03177C
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDA   [$F2]
         SEC
         SBC   #$0014
         LDX   #$0000
         TAY
         BPL   L0D0C9E
         DEX
L0D0C9E  PEA   $0000
         PEA   $0006
         CLC
         JSL   L0105E1
         LDA   #L031764
         LDX   #^L031764
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDA   #$0001
         STA   [$F2]
         LDA   $FD
         SEC
         SBC   #$0003
         LDX   #$0000
         TAY
         BPL   L0D0CCB
         DEX
L0D0CCB  STX   $F6
         ASL
         ROL   $F6
         LDX   $F6
         PHX
         PHA
         LDA   #L03177C
         LDX   #^L03177C
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDA   [$F2]
         SEC
         SBC   #$0014
         LDX   #$0000
         TAY
         BPL   L0D0CF1
         DEX
L0D0CF1  PEA   $0000
         PEA   $0006
         CLC
         JSL   L0105E1
         LDA   #L031764
         LDX   #^L031764
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDA   $FD
         LDY   #$0002
         STA   [$F2],Y
         LDA   $FD
         SEC
         SBC   #$0003
         LDX   #$0000
         TAY
         BPL   L0D0D20
         DEX
L0D0D20  STX   $F6
         ASL
         ROL   $F6
         LDX   $F6
         PHX
         PHA
         LDA   #L03177C
         LDX   #^L03177C
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDA   [$F2]
         SEC
         SBC   #$0014
         LDX   #$0000
         TAY
         BPL   L0D0D46
         DEX
L0D0D46  PEA   $0000
         PEA   $0006
         CLC
         JSL   L0105E1
         LDA   #L031764
         LDX   #^L031764
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDA   #$0016
         LDY   #$0004
         STA   [$F2],Y
L0D0D69  BRL   L0D0DEF
L0D0D6C  LDA   $F0
         SEC
         SBC   #$0000
         BVS   L0D0D77
         EOR   #$8000
L0D0D77  BMI   L0D0D80
         JSL   L060000
         BRL   L0D0DEF
L0D0D80  LDA   $F0
         BNE   L0D0DE5
         LDA   $FD
         ASL
         ASL
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   #L0304DA
         LDX   #^L0304DA
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDA   [$F2]
         CMP   #$0003
         BNE   L0D0DE5
         LDA   $FF
         CMP   #$0001
         BEQ   L0D0DE5
         LDA   #$0001
         STA   L0200B4
         LDA   #$0001
         PHA
         LDA   $FF
         SEC
         JSL   L01076A
         LDA   #$0005
         PLX
         STX   $F6
         CLC
         ADC   $F6
         LDY   #$000A
         STA   [$E6],Y
         LDA   #$0000
         LDY   #$000C
         STA   [$E6],Y
         LDA   #$0082
         LDY   #$000E
         STA   [$E6],Y
         LDA   #$00B2
         LDY   #$0010
         STA   [$E6],Y
         BRA   L0D0DEF
L0D0DE5  STZ   L0200B4
         PEI   $FD
         JSL   L0D09CE
         PLY
L0D0DEF  BRA   L0D0E32
L0D0DF1  LDA   $FF
         AND   #$0080
         TAY
         BEQ   L0D0E32
         LDA   $FD
         PHA
         LDA   #$0006
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L0316A0
         LDX   #^L0316A0
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDA   #$0001
         STA   [$F2]
         LDA   #$0001
         LDY   #$000C
         STA   [$E6],Y
         PEA   $0000
         PEI   $FD
         JSL   L0D04C2
         PLY
         PLY
L0D0E32  LDA   $EE
         TAY
         TSC
         CLC
         ADC   #$0012
         TCS
         TYA
         PLD
         RTL

L0D0E3E  ENT
         PHD
         TSC
         SEC
         SBC   #$00F7
         TCD
         ADC   #$00EE
         TCS
         LDA   #$FFFF
         STA   $F0
         LDA   $FD
         PHA
         LDA   #$001A
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L03059A
         LDX   #^L03059A
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDY   #$0008
         LDA   [$F2],Y
         PHA
         LDA   $FF
         PHA
         LDA   #$001A
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L03059A
         LDX   #^L03059A
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDY   #$0008
         LDA   [$F2],Y
         PLX
         STX   $F2
         CMP   $F2
         BNE   L0D0ECB
         LDA   $FF
         SEC
         SBC   #$0006
         BVS   L0D0EAD
         EOR   #$8000
L0D0EAD  BMI   L0D0EB6
         LDA   #$0011
         STA   $F0
         BRA   L0D0EC8
L0D0EB6  LDA   $FF
         SEC
         SBC   #$0014
         BVS   L0D0EC1
         EOR   #$8000
L0D0EC1  BMI   L0D0EC8
         LDA   #$0010
         STA   $F0
L0D0EC8  BRL   L0D1024
L0D0ECB  LDA   $FD
         PHA
         LDA   #$001A
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L03059A
         LDX   #^L03059A
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDY   #$0008
         LDA   [$F2],Y
         PHA
         LDA   $FF
         PHA
         LDA   #$001A
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L03059A
         LDX   #^L03059A
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDY   #$0008
         LDA   [$F2],Y
         EOR   #$0004
         PLX
         STX   $F2
         CMP   $F2
         BNE   L0D0F25
         BRL   L0D1024
L0D0F25  LDA   $FF
         SEC
         SBC   #$0006
         BVS   L0D0F30
         EOR   #$8000
L0D0F30  BMI   L0D0F3A
         LDA   #$0012
         STA   $F0
         BRL   L0D0FA7
L0D0F3A  LDA   $FF
         SEC
         SBC   #$0014
         BVS   L0D0F45
         EOR   #$8000
L0D0F45  BMI   L0D0FA7
         LDA   #$000A
         STA   $F0
         LDA   $FF
         PHA
         LDA   #$001A
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L03059A
         LDX   #^L03059A
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDY   #$000A
         LDA   [$F2],Y
         CMP   #$0008
         BNE   L0D0FA7
         LDA   $FF
         PHA
         LDA   #$001A
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L03059A
         LDX   #^L03059A
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDY   #$000C
         LDA   [$F2],Y
         CMP   #$0001
         BNE   L0D0FA7
         LDA   #$000B
         STA   $F0
L0D0FA7  LDA   #$0001
         PHA
         LDA   $FD
         PHA
         LDA   #$001A
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L03059A
         LDX   #^L03059A
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDY   #$0008
         LDA   [$F2],Y
         SEC
         JSL   L01076A
         PLA
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   #L031FCB
         LDX   #^L031FCB
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDA   [$F2]
         PHA
         LDA   $FF
         PHA
         LDA   #$001A
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L03059A
         LDX   #^L03059A
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDY   #$0008
         LDA   [$F2],Y
         PLX
         STX   $F2
         CMP   $F2
         BNE   L0D1024
         LDA   $F0
         ORA   #$8000
         STA   $F0
L0D1024  LDA   $F0
         TAY
         TSC
         CLC
         ADC   #$0008
         TCS
         TYA
         PLD
         RTL

L0D1030  ENT
         PHD
         TSC
         SEC
         SBC   #$00F7
         TCD
         ADC   #$00E4
         TCS
         LDA   $FD
         PHA
         LDA   #$001A
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L03059A
         LDX   #^L03059A
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDA   [$F2]
         STA   $EC
         LDAL  L031752
         TAX
         LDAL  L031750
         PHX
         PHA
         LDX   L020070
         LDA   L02006E
         PHX
         PHA
         PEA   $006E
         PEI   $FF
         LDA   $EC
         SEC
         SBC   #$0001
         PHA
         JSL   L130695
         TAY
         TSC
         CLC
         ADC   #$000E
         TCS
         TYA
         PEA   $0004
         JSL   L1504CE
         PLY
         LDA   #$0003
         STA   $EE
         BRL   L0D1444
L0D109B  LDA   $EE
         ASL
         ASL
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   #L0304DA
         LDX   #^L0304DA
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDY   #$0002
         LDA   [$F2],Y
         BNE   L0D10BF
         BRL   L0D1442
L0D10BF  LDA   $EE
         PHA
         LDA   #$001A
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L03059A
         LDX   #^L03059A
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDA   [$F2]
         CMP   $EC
         BEQ   L0D10E9
         BRL   L0D1442
L0D10E9  LDA   $EE
         PHA
         LDA   #$001A
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L03059A
         LDX   #^L03059A
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDY   #$0004
         LDA   [$F2],Y
         PHA
         LDA   #$0002
         SEC
         JSL   L01059C
         PLA
         STA   $F0
         LDX   L020070
         LDA   L02006E
         PHX
         PHA
         LDA   $F0
         CLC
         ADC   #$0001
         LDX   #$0000
         TAY
         BPL   L0D1130
         DEX
L0D1130  PHX
         PHA
         LDA   #L03150E
         LDX   #^L03150E
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDA   [$F2]
         AND   #$00FF
         PHA
         LDA   #$002E
         PLX
         STX   $F6
         CLC
         ADC   $F6
         PHA
         LDA   $F0
         LDX   #$0000
         TAY
         BPL   L0D115B
         DEX
L0D115B  PHX
         PHA
         LDA   #L03150E
         LDX   #^L03150E
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDA   [$F2]
         AND   #$00FF
         PHA
         LDA   $FF
         PLX
         STX   $F6
         CLC
         ADC   $F6
         PHA
         JSL   L1504ED
         PLY
         PLY
         PLY
         PLY
         LDA   $EE
         CMP   $FD
         BEQ   L0D118D
         BRL   L0D1442
L0D118D  LDA   $EE
         PHA
         LDA   #$001A
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L03059A
         LDX   #^L03059A
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDY   #$0008
         LDA   [$F2],Y
         STA   $E6
         LDA   #$0004
         PHA
         LDA   $E6
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   #L031F85
         LDX   #^L031F85
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDA   [$F2]
         SEC
         JSL   L01041B
         PLY
         PHA
         LDA   $F0
         LDX   #$0000
         TAY
         BPL   L0D11E3
         DEX
L0D11E3  PHX
         PHA
         LDA   #L03150E
         LDX   #^L03150E
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDA   [$F2]
         AND   #$00FF
         PHA
         LDA   $FF
         PLX
         STX   $F6
         CLC
         ADC   $F6
         PLX
         STX   $F6
         CLC
         ADC   $F6
         STA   $EA
         LDA   #$0004
         PHA
         LDA   $E6
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   #L031FA9
         LDX   #^L031FA9
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDA   [$F2]
         SEC
         JSL   L01041B
         PLY
         PHA
         LDA   $F0
         CLC
         ADC   #$0001
         LDX   #$0000
         TAY
         BPL   L0D123D
         DEX
L0D123D  PHX
         PHA
         LDA   #L03150E
         LDX   #^L03150E
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDA   [$F2]
         AND   #$00FF
         PHA
         LDA   #$002E
         PLX
         STX   $F6
         CLC
         ADC   $F6
         PLX
         STX   $F6
         CLC
         ADC   $F6
         STA   $E8
         LDX   L020070
         LDA   L02006E
         PHX
         PHA
         PEI   $E8
         PEI   $EA
         JSL   L1504ED
         PLY
         PLY
         PLY
         PLY
         LDA   #$0004
         PHA
         LDA   $E6
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   #L031F85
         LDX   #^L031F85
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDA   [$F2]
         SEC
         JSL   L01041B
         PLY
         PHA
         LDA   $EA
         PLX
         STX   $F6
         CLC
         ADC   $F6
         STA   $EA
         LDA   #$0004
         PHA
         LDA   $E6
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   #L031FA9
         LDX   #^L031FA9
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDA   [$F2]
         SEC
         JSL   L01041B
         PLY
         PHA
         LDA   $E8
         PLX
         STX   $F6
         CLC
         ADC   $F6
         STA   $E8
         LDX   L020070
         LDA   L02006E
         PHX
         PHA
         PEI   $E8
         PEI   $EA
         JSL   L1504ED
         PLY
         PLY
         PLY
         PLY
         LDX   L020070
         LDA   L02006E
         PHX
         PHA
         LDA   #$0004
         PHA
         LDA   $E6
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   #L031FA9
         LDX   #^L031FA9
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDA   [$F2]
         SEC
         JSL   L01041B
         PLY
         PHA
         LDA   $E8
         PLX
         STX   $F6
         CLC
         ADC   $F6
         PHA
         LDA   #$0004
         PHA
         LDA   $E6
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   #L031F85
         LDX   #^L031F85
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDA   [$F2]
         SEC
         JSL   L01041B
         PLY
         PHA
         LDA   $EA
         PLX
         STX   $F6
         CLC
         ADC   $F6
         PHA
         JSL   L1504ED
         PLY
         PLY
         PLY
         PLY
         LDA   $E6
         CLC
         ADC   #$0002
         AND   #$0007
         STA   $E6
         LDX   L020070
         LDA   L02006E
         PHX
         PHA
         LDA   #$0004
         PHA
         LDA   $E6
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   #L031FA9
         LDX   #^L031FA9
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDA   [$F2]
         SEC
         JSL   L01041B
         PLY
         PHA
         LDA   $E8
         PLX
         STX   $F6
         CLC
         ADC   $F6
         PHA
         LDA   #$0004
         PHA
         LDA   $E6
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   #L031F85
         LDX   #^L031F85
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDA   [$F2]
         SEC
         JSL   L01041B
         PLY
         PHA
         LDA   $EA
         PLX
         STX   $F6
         CLC
         ADC   $F6
         PHA
         JSL   L1504ED
         PLY
         PLY
         PLY
         PLY
         LDA   $E6
         EOR   #$0004
         STA   $E6
         LDX   L020070
         LDA   L02006E
         PHX
         PHA
         LDA   #$0004
         PHA
         LDA   $E6
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   #L031FA9
         LDX   #^L031FA9
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDA   [$F2]
         SEC
         JSL   L01041B
         PLY
         PHA
         LDA   $E8
         PLX
         STX   $F6
         CLC
         ADC   $F6
         PHA
         LDA   #$0004
         PHA
         LDA   $E6
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   #L031F85
         LDX   #^L031F85
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDA   [$F2]
         SEC
         JSL   L01041B
         PLY
         PHA
         LDA   $EA
         PLX
         STX   $F6
         CLC
         ADC   $F6
         PHA
         JSL   L1504ED
         PLY
         PLY
         PLY
         PLY
L0D1442  INC   $EE
L0D1444  LDA   $EE
         SEC
         SBC   #$0006
         BVS   L0D144F
         EOR   #$8000
L0D144F  BMI   L0D1454
         BRL   L0D109B
L0D1454  PEA   $000C
         JSL   L1504CE
         PLY
         LDA   #$0014
         STA   $EE
         BRL   L0D157C
L0D1464  LDA   $EE
         ASL
         ASL
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   #L0304DA
         LDX   #^L0304DA
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDY   #$0002
         LDA   [$F2],Y
         BNE   L0D1488
         BRL   L0D157A
L0D1488  LDA   $EE
         PHA
         LDA   #$001A
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L03059A
         LDX   #^L03059A
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDY   #$0004
         LDA   [$F2],Y
         PHA
         LDA   $FD
         PHA
         LDA   #$001A
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L03059A
         LDX   #^L03059A
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDY   #$0004
         LDA   [$F2],Y
         PLX
         STX   $F2
         CMP   $F2
         BEQ   L0D14DF
         BRL   L0D157A
L0D14DF  LDA   $EE
         PHA
         LDA   #$001A
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L03059A
         LDX   #^L03059A
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDY   #$0004
         LDA   [$F2],Y
         PHA
         LDA   #$0002
         SEC
         JSL   L01059C
         PLA
         STA   $F0
         LDX   L020070
         LDA   L02006E
         PHX
         PHA
         LDA   $F0
         CLC
         ADC   #$0001
         LDX   #$0000
         TAY
         BPL   L0D1526
         DEX
L0D1526  PHX
         PHA
         LDA   #L03150E
         LDX   #^L03150E
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDA   [$F2]
         AND   #$00FF
         PHA
         LDA   #$002E
         PLX
         STX   $F6
         CLC
         ADC   $F6
         PHA
         LDA   $F0
         LDX   #$0000
         TAY
         BPL   L0D1551
         DEX
L0D1551  PHX
         PHA
         LDA   #L03150E
         LDX   #^L03150E
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDA   [$F2]
         AND   #$00FF
         PHA
         LDA   $FF
         PLX
         STX   $F6
         CLC
         ADC   $F6
         PHA
         JSL   L1504ED
         PLY
         PLY
         PLY
         PLY
L0D157A  INC   $EE
L0D157C  LDA   $EE
         SEC
         SBC   #$0018
         BVS   L0D1587
         EOR   #$8000
L0D1587  BMI   L0D158C
         BRL   L0D1464
L0D158C  LDA   L020039
         CMP   #$0002
         BNE   L0D1597
         BRL   L0D19F7
L0D1597  PEA   $0001
         JSL   L1504CE
         PLY
         LDA   L020039
         CMP   #$0000
         BEQ   L0D15AA
         BRL   L0D17BB
L0D15AA  LDA   #$0006
         STA   $EE
         BRL   L0D169D
L0D15B2  LDA   $EE
         ASL
         ASL
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   #L0304DA
         LDX   #^L0304DA
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDY   #$0002
         LDA   [$F2],Y
         BNE   L0D15D6
         BRL   L0D169B
L0D15D6  LDA   $EE
         PHA
         LDA   #$001A
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L03059A
         LDX   #^L03059A
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDA   [$F2]
         CMP   $EC
         BEQ   L0D1600
         BRL   L0D169B
L0D1600  LDA   $EE
         PHA
         LDA   #$001A
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L03059A
         LDX   #^L03059A
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDY   #$0004
         LDA   [$F2],Y
         PHA
         LDA   #$0002
         SEC
         JSL   L01059C
         PLA
         STA   $F0
         LDX   L020070
         LDA   L02006E
         PHX
         PHA
         LDA   $F0
         CLC
         ADC   #$0001
         LDX   #$0000
         TAY
         BPL   L0D1647
         DEX
L0D1647  PHX
         PHA
         LDA   #L03150E
         LDX   #^L03150E
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDA   [$F2]
         AND   #$00FF
         PHA
         LDA   #$002E
         PLX
         STX   $F6
         CLC
         ADC   $F6
         PHA
         LDA   $F0
         LDX   #$0000
         TAY
         BPL   L0D1672
         DEX
L0D1672  PHX
         PHA
         LDA   #L03150E
         LDX   #^L03150E
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDA   [$F2]
         AND   #$00FF
         PHA
         LDA   $FF
         PLX
         STX   $F6
         CLC
         ADC   $F6
         PHA
         JSL   L1504ED
         PLY
         PLY
         PLY
         PLY
L0D169B  INC   $EE
L0D169D  LDA   $EE
         SEC
         SBC   #$0014
         BVS   L0D16A8
         EOR   #$8000
L0D16A8  BMI   L0D16AD
         BRL   L0D15B2
L0D16AD  PEA   $000C
         JSL   L1504CE
         PLY
         LDA   #$0014
         STA   $EE
         BRL   L0D17A8
L0D16BD  LDA   $EE
         ASL
         ASL
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   #L0304DA
         LDX   #^L0304DA
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDY   #$0002
         LDA   [$F2],Y
         BNE   L0D16E1
         BRL   L0D17A6
L0D16E1  LDA   $EE
         PHA
         LDA   #$001A
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L03059A
         LDX   #^L03059A
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDA   [$F2]
         CMP   $EC
         BEQ   L0D170B
         BRL   L0D17A6
L0D170B  LDA   $EE
         PHA
         LDA   #$001A
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L03059A
         LDX   #^L03059A
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDY   #$0004
         LDA   [$F2],Y
         PHA
         LDA   #$0002
         SEC
         JSL   L01059C
         PLA
         STA   $F0
         LDX   L020070
         LDA   L02006E
         PHX
         PHA
         LDA   $F0
         CLC
         ADC   #$0001
         LDX   #$0000
         TAY
         BPL   L0D1752
         DEX
L0D1752  PHX
         PHA
         LDA   #L03150E
         LDX   #^L03150E
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDA   [$F2]
         AND   #$00FF
         PHA
         LDA   #$002E
         PLX
         STX   $F6
         CLC
         ADC   $F6
         PHA
         LDA   $F0
         LDX   #$0000
         TAY
         BPL   L0D177D
         DEX
L0D177D  PHX
         PHA
         LDA   #L03150E
         LDX   #^L03150E
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDA   [$F2]
         AND   #$00FF
         PHA
         LDA   $FF
         PLX
         STX   $F6
         CLC
         ADC   $F6
         PHA
         JSL   L1504ED
         PLY
         PLY
         PLY
         PLY
L0D17A6  INC   $EE
L0D17A8  LDA   $EE
         SEC
         SBC   #$0018
         BVS   L0D17B3
         EOR   #$8000
L0D17B3  BMI   L0D17B8
         BRL   L0D16BD
L0D17B8  BRL   L0D19F7
L0D17BB  LDA   $FD
         PHA
         LDA   #$001A
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L03059A
         LDX   #^L03059A
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDY   #$0002
         LDA   [$F2],Y
         STA   $E6
         LDA   #$0006
         STA   $EE
         BRL   L0D18D9
L0D17EB  LDA   $EE
         ASL
         ASL
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   #L0304DA
         LDX   #^L0304DA
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDY   #$0002
         LDA   [$F2],Y
         BNE   L0D180F
         BRL   L0D18D7
L0D180F  LDA   $EE
         PHA
         LDA   #$001A
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L03059A
         LDX   #^L03059A
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDY   #$0002
         LDA   [$F2],Y
         CMP   $E6
         BEQ   L0D183C
         BRL   L0D18D7
L0D183C  LDA   $EE
         PHA
         LDA   #$001A
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L03059A
         LDX   #^L03059A
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDY   #$0004
         LDA   [$F2],Y
         PHA
         LDA   #$0002
         SEC
         JSL   L01059C
         PLA
         STA   $F0
         LDX   L020070
         LDA   L02006E
         PHX
         PHA
         LDA   $F0
         CLC
         ADC   #$0001
         LDX   #$0000
         TAY
         BPL   L0D1883
         DEX
L0D1883  PHX
         PHA
         LDA   #L03150E
         LDX   #^L03150E
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDA   [$F2]
         AND   #$00FF
         PHA
         LDA   #$002E
         PLX
         STX   $F6
         CLC
         ADC   $F6
         PHA
         LDA   $F0
         LDX   #$0000
         TAY
         BPL   L0D18AE
         DEX
L0D18AE  PHX
         PHA
         LDA   #L03150E
         LDX   #^L03150E
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDA   [$F2]
         AND   #$00FF
         PHA
         LDA   $FF
         PLX
         STX   $F6
         CLC
         ADC   $F6
         PHA
         JSL   L1504ED
         PLY
         PLY
         PLY
         PLY
L0D18D7  INC   $EE
L0D18D9  LDA   $EE
         SEC
         SBC   #$0014
         BVS   L0D18E4
         EOR   #$8000
L0D18E4  BMI   L0D18E9
         BRL   L0D17EB
L0D18E9  PEA   $000C
         JSL   L1504CE
         PLY
         LDA   #$0014
         STA   $EE
         BRL   L0D19E7
L0D18F9  LDA   $EE
         ASL
         ASL
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   #L0304DA
         LDX   #^L0304DA
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDY   #$0002
         LDA   [$F2],Y
         BNE   L0D191D
         BRL   L0D19E5
L0D191D  LDA   $EE
         PHA
         LDA   #$001A
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L03059A
         LDX   #^L03059A
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDY   #$0002
         LDA   [$F2],Y
         CMP   $E6
         BEQ   L0D194A
         BRL   L0D19E5
L0D194A  LDA   $EE
         PHA
         LDA   #$001A
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L03059A
         LDX   #^L03059A
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDY   #$0004
         LDA   [$F2],Y
         PHA
         LDA   #$0002
         SEC
         JSL   L01059C
         PLA
         STA   $F0
         LDX   L020070
         LDA   L02006E
         PHX
         PHA
         LDA   $F0
         CLC
         ADC   #$0001
         LDX   #$0000
         TAY
         BPL   L0D1991
         DEX
L0D1991  PHX
         PHA
         LDA   #L03150E
         LDX   #^L03150E
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDA   [$F2]
         AND   #$00FF
         PHA
         LDA   #$002E
         PLX
         STX   $F6
         CLC
         ADC   $F6
         PHA
         LDA   $F0
         LDX   #$0000
         TAY
         BPL   L0D19BC
         DEX
L0D19BC  PHX
         PHA
         LDA   #L03150E
         LDX   #^L03150E
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDA   [$F2]
         AND   #$00FF
         PHA
         LDA   $FF
         PLX
         STX   $F6
         CLC
         ADC   $F6
         PHA
         JSL   L1504ED
         PLY
         PLY
         PLY
         PLY
L0D19E5  INC   $EE
L0D19E7  LDA   $EE
         SEC
         SBC   #$0018
         BVS   L0D19F2
         EOR   #$8000
L0D19F2  BMI   L0D19F7
         BRL   L0D18F9
L0D19F7  TSC
         CLC
         ADC   #$0012
         TCS
         PLD
         RTL

