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

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

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

L090000  ENT
         PHD
         TSC
         SEC
         SBC   #$00F7
         TCD
         ADC   #$00D4
         TCS
         LDA   #$000C
         STA   $D6
         LDA   $FD
         PHA
         LDA   #$001A
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L03059A
         LDX   #^L03059A
         JSL   L010410
         PLA
         PLX
         STX   $DE
         STA   $DC
         LDA   $DC
         CLC
         ADC   #$000C
         LDX   $DE
         BCC   L09003C
         INX
L09003C  STX   $EC
         STA   $EA
         LDA   $DC
         CLC
         ADC   #$000A
         LDX   $DE
         BCC   L09004B
         INX
L09004B  STX   $F0
         STA   $EE
         LDA   [$EE]
         LDX   #$0000
         TAY
         BPL   L090058
         DEX
L090058  STX   $F6
         ASL
         ROL   $F6
         ASL
         ROL   $F6
         LDX   $F6
         PHX
         PHA
         LDA   #L030476
         LDX   #^L030476
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDY   #$0002
         LDA   [$F2],Y
         TAX
         LDA   [$F2]
         STX   $E2
         STA   $E0
         LDY   #$0004
         LDA   [$DC],Y
         PHA
         LDA   #$0016
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L03082E
         LDX   #^L03082E
         JSL   L010410
         PLA
         PLX
         STX   $DA
         STA   $D8
         JSL   L0703A5
         AND   #$0007
         STA   $E4
         PEI   $FF
         PEI   $FD
         JSL   L0F0939
         PLY
         PLY
         LDY   #$0012
         LDA   [$DC],Y
         PHA
         LDY   #$0004
         LDA   [$DC],Y
         PLX
         STX   $F2
         CMP   $F2
         BNE   L09012F
         LDA   #$00BE
         CLC
         ADC   $E4
         LDY   #$000E
         STA   [$DC],Y
         LDA   #$0092
         LDY   #$0010
         STA   [$DC],Y
         LDA   $FD
         ASL
         ASL
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   #L0304DA
         LDX   #^L0304DA
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDA   #$0000
         LDY   #$0006
         STA   [$F2],Y
         LDY   #$0012
         LDA   [$DC],Y
         CMP   #$0059
         BNE   L090117
         LDA   #$0010
         STA   [$EE]
         LDA   #$005A
         LDY   #$0012
         STA   [$DC],Y
         BRA   L09012C
L090117  LDA   #$0002
         STA   [$EE]
         LDA   #$0001
         LDY   #$0014
         STA   [$DC],Y
         LDA   #$0000
         LDY   #$0012
         STA   [$DC],Y
L09012C  BRL   L09090A
L09012F  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
         BEQ   L090153
         BRL   L09051A
L090153  LDA   #$00BE
         CLC
         ADC   $E4
         LDY   #$000E
         STA   [$DC],Y
         LDA   #$0092
         LDY   #$0010
         STA   [$DC],Y
         LDA   [$EA]
         LDX   #$0000
         TAY
         BPL   L09016F
         DEX
L09016F  PEA   $0000
         PEA   $0006
         CLC
         JSL   L0105E1
         LDX   $E2
         LDA   $E0
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDA   [$F2]
         BRL   L0904E7
L09018D  BRL   L090517
L090190  LDA   #$FFFF
         STA   [$EE]
         LDA   $FD
         ASL
         ASL
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   #L0304DA
         LDX   #^L0304DA
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDA   #$0000
         LDY   #$0002
         STA   [$F2],Y
         LDA   #$0000
         LDY   #$0004
         STA   [$DC],Y
         LDA   #$0000
         STA   [$DC]
         LDA   #$0000
         LDY   #$0002
         STA   [$DC],Y
         PEI   $FD
         JSL   L0F085E
         PLY
         LDY   #$0012
         LDA   [$DC],Y
         CMP   #$0059
         BEQ   L0901E7
         LDY   #$0012
         LDA   [$DC],Y
         CMP   #$005A
         BNE   L090205
L0901E7  LDA   L02003B
         CMP   #$0004
         BNE   L090205
         LDA   $E4
         AND   #$0007
         CMP   #$0007
         BNE   L090205
         PEA   $0001
         PEA   $0059
         JSL   L0F0628
         PLY
         PLY
L090205  BRL   L090517
L090208  PEA   $0005
         PEI   $FD
         JSL   L0C0E26
         PLY
         PLY
         STA   $E6
         LDA   $E6
         CMP   #$FFFF
         BNE   L090256
         LDA   #$0001
         LDY   #$0014
         STA   [$DC],Y
         LDA   #$0000
         LDY   #$0012
         STA   [$DC],Y
         LDA   $FD
         ASL
         ASL
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   #L0304DA
         LDX   #^L0304DA
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDA   #$0000
         LDY   #$0006
         STA   [$F2],Y
         LDA   #$0002
         STA   [$EE]
         BRL   L090517
L090256  LDA   $FD
         ASL
         ASL
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   #L0304DA
         LDX   #^L0304DA
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDY   #$0006
         LDA   [$F2],Y
         PHA
         LDY   #$0004
         LDA   [$DC],Y
         PLX
         STX   $F2
         CMP   $F2
         BEQ   L090285
         BRL   L0903C7
L090285  LDA   #$0010
         STA   [$EE]
         LDY   #$0002
         LDA   [$DC],Y
         PHA
         LDY   #$0012
         LDA   [$DC],Y
         PHA
         LDA   #$0016
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L03082E
         LDX   #^L03082E
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDY   #$0004
         LDA   [$F2],Y
         PLX
         STX   $F2
         CMP   $F2
         BNE   L0902C3
         BRL   L090371
L0902C3  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   L0902E7
         BRL   L090371
L0902E7  LDY   #$0012
         LDA   [$DC],Y
         PHA
         LDA   #$0016
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L03082E
         LDX   #^L03082E
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDY   #$0004
         LDA   [$F2],Y
         PHA
         LDY   #$0004
         LDA   [$DC],Y
         PHA
         JSL   L0804DD
         PLY
         PLY
         PHA
         LDA   $FD
         ASL
         ASL
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   #L0304DA
         LDX   #^L0304DA
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         PLA
         LDY   #$0006
         STA   [$F2],Y
         LDY   #$0004
         LDA   [$DC],Y
         PHA
         LDA   $FD
         ASL
         ASL
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   #L0304DA
         LDX   #^L0304DA
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDY   #$0006
         LDA   [$F2],Y
         PLX
         STX   $F2
         CMP   $F2
         BEQ   L09036F
         LDA   #$0006
         STA   [$EE]
L09036F  BRA   L0903C5
L090371  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   L0903C5
         LDA   $FD
         ASL
         ASL
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   #L0304DA
         LDX   #^L0304DA
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDA   #$0000
         LDY   #$0006
         STA   [$F2],Y
         LDA   #$0008
         STA   [$EE]
         PEI   $FD
         JSL   L0802D8
         PLY
         LDY   #$0008
         STA   [$DC],Y
L0903C5  BRA   L0903CC
L0903C7  LDA   #$0006
         STA   [$EE]
L0903CC  BRL   L090517
L0903CF  PEA   $0003
         PEI   $FD
         JSL   L0C0E26
         PLY
         PLY
         CMP   #$FFFF
         BEQ   L0903F4
         LDA   #$0007
         STA   [$EE]
         LDY   #$000E
         LDA   [$DC],Y
         CLC
         ADC   #$001E
         LDY   #$000E
         STA   [$DC],Y
         BRA   L090415
L0903F4  LDA   #$0005
         STA   [$EE]
         LDY   #$000E
         LDA   [$DC],Y
         SEC
         SBC   #$001E
         LDY   #$000E
         STA   [$DC],Y
         LDY   #$0010
         LDA   [$DC],Y
         CLC
         ADC   #$001E
         LDY   #$0010
         STA   [$DC],Y
L090415  BRL   L090517
L090418  JSL   L0703A5
         AND   #$0001
         TAY
         BEQ   L090427
         LDA   #$0002
         BRA   L09042A
L090427  LDA   #$0001
L09042A  LDY   #$0014
         STA   [$DC],Y
         LDY   #$0012
         LDA   [$DC],Y
         CMP   $FF
         BNE   L09043E
         LDA   #$0001
         STA   L02003F
L09043E  LDY   #$0012
         LDA   [$DC],Y
         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
         STA   $E6
         LDA   #$0002
         PHA
         LDY   #$0008
         LDA   [$DC],Y
         SEC
         JSL   L01041B
         PLY
         ASL
         LDX   #$0000
         PHX
         PHA
         LDY   #$0004
         LDA   [$DC],Y
         PHA
         LDA   #$0016
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L03082E
         LDX   #^L03082E
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDX   $F4
         LDA   #$0006
         CLC
         ADC   $F2
         BCC   L0904AD
         INX
L0904AD  JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDA   [$F2]
         CMP   $E6
         BNE   L0904E3
         LDY   #$0012
         LDA   [$DC],Y
         PHA
         JSL   L0F0C8A
         PLY
         SEC
         SBC   #$0004
         BVS   L0904D1
         EOR   #$8000
L0904D1  BMI   L0904E3
         LDY   #$0012
         LDA   [$DC],Y
         PHA
         PEI   $FF
         JSL   L081B87
         PLY
         PLY
         STA   $D6
L0904E3  BRA   L090517
         BRA   L090517
L0904E7  CMP   #$C001
         BNE   L0904EF
         BRL   L090190
L0904EF  CMP   #$C002
         BNE   L0904F7
         BRL   L090256
L0904F7  CMP   #$C003
         BNE   L0904FF
         BRL   L090418
L0904FF  CMP   #$C004
         BNE   L090507
         BRL   L0903CF
L090507  CMP   #$C007
         BNE   L09050F
         BRL   L090208
L09050F  CMP   #$FFFF
         BNE   L090517
         BRL   L09018D
L090517  BRL   L09090A
L09051A  LDA   [$EA]
         LDX   #$0000
         TAY
         BPL   L090523
         DEX
L090523  PEA   $0000
         PEA   $0006
         CLC
         JSL   L0105E1
         LDX   $E2
         LDA   $E0
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDA   [$F2]
         BRL   L0908DA
L090541  BRL   L09090A
L090544  LDA   #$FFFF
         STA   [$EE]
         LDA   $FD
         ASL
         ASL
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   #L0304DA
         LDX   #^L0304DA
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDA   #$0000
         LDY   #$0002
         STA   [$F2],Y
         LDA   #$0000
         LDY   #$0004
         STA   [$DC],Y
         LDA   #$0000
         STA   [$DC]
         LDA   #$0000
         LDY   #$0002
         STA   [$DC],Y
         PEI   $FD
         JSL   L0F085E
         PLY
         LDY   #$0012
         LDA   [$DC],Y
         CMP   #$0059
         BEQ   L09059B
         LDY   #$0012
         LDA   [$DC],Y
         CMP   #$005A
         BNE   L0905B9
L09059B  LDA   L02003B
         CMP   #$0004
         BNE   L0905B9
         LDA   $E4
         AND   #$0007
         CMP   #$0007
         BNE   L0905B9
         PEA   $0001
         PEA   $0059
         JSL   L0F0628
         PLY
         PLY
L0905B9  BRL   L09090A
L0905BC  PEA   $0001
         PEI   $FD
         JSL   L0C0E26
         PLY
         PLY
         LDY   #$0004
         LDA   [$DC],Y
         PHA
         LDA   #$0016
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L03082E
         LDX   #^L03082E
         JSL   L010410
         PLA
         PLX
         STX   $DA
         STA   $D8
         LDY   #$0012
         LDA   [$DC],Y
         PHA
         LDA   #$0016
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L03082E
         LDX   #^L03082E
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDY   #$0004
         LDA   [$F2],Y
         PHA
         LDY   #$0004
         LDA   [$D8],Y
         PLX
         STX   $F2
         CMP   $F2
         BNE   L090633
         LDA   [$D8]
         CMP   #$0003
         BNE   L090633
         LDA   #$0006
         STA   [$EE]
         BRL   L09090A
         BRL   L0906A6
L090633  LDA   $FD
         ASL
         ASL
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   #L0304DA
         LDX   #^L0304DA
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDY   #$0004
         LDA   [$F2],Y
         PHA
         INC
         LDY   #$0004
         STA   [$F2],Y
         PLA
         SEC
         SBC   #$000F
         BEQ   L0906A6
         BVS   L090665
         EOR   #$8000
L090665  BPL   L0906A6
         LDY   #$0012
         LDA   [$DC],Y
         CMP   #$0059
         BEQ   L0906A6
         LDA   #$0001
         LDY   #$0014
         STA   [$DC],Y
         LDA   $FD
         ASL
         ASL
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   #L0304DA
         LDX   #^L0304DA
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDA   #$0000
         LDY   #$0006
         STA   [$F2],Y
         LDA   #$0000
         LDY   #$0012
         STA   [$DC],Y
         BRL   L09090A
L0906A6  STZ   $E4
         LDY   #$0012
         LDA   [$DC],Y
         PHA
         LDA   #$0016
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L03082E
         LDX   #^L03082E
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDY   #$0002
         LDA   [$F2],Y
         STA   $E8
         LDY   #$0012
         LDA   [$DC],Y
         PHA
         LDA   #$0016
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L03082E
         LDX   #^L03082E
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDA   [$F2]
         CMP   #$0004
         BNE   L090701
         BRL   L0907D5
L090701  LDY   #$0002
         LDA   [$D8],Y
         CMP   $E8
         BEQ   L09070D
         BRL   L0907D5
L09070D  STZ   $E6
         BRL   L0907BE
L090712  LDA   $E6
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   $D8
         CLC
         ADC   #$0006
         LDX   $DA
         BCC   L090725
         INX
L090725  JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDA   [$F2]
         STA   $E8
         LDA   $E8
         CMP   #$FFFF
         BNE   L09073D
         BRL   L0907BC
L09073D  LDA   $E8
         AND   #$8000
         TAY
         BNE   L090748
         BRL   L0907BC
L090748  LDA   $E8
         AND   #$7FFF
         PHA
         LDA   #$0016
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L03082E
         LDX   #^L03082E
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDY   #$0004
         LDA   [$F2],Y
         PHA
         LDY   #$0012
         LDA   [$DC],Y
         PHA
         LDA   #$0016
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L03082E
         LDX   #^L03082E
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDY   #$0004
         LDA   [$F2],Y
         PLX
         STX   $F2
         CMP   $F2
         BNE   L0907BC
         LDA   $E6
         PHA
         LDA   #$0002
         SEC
         JSL   L01059C
         PLA
         CLC
         ADC   #$0001
         LDY   #$0008
         STA   [$DC],Y
         LDA   #$0001
         STA   $E4
L0907BC  INC   $E6
L0907BE  LDA   $E6
         SEC
         SBC   #$0004
         BVS   L0907C9
         EOR   #$8000
L0907C9  BMI   L0907D2
         LDA   $E4
         BNE   L0907D2
         BRL   L090712
L0907D2  BRL   L090876
L0907D5  STZ   $E6
         BRL   L090862
L0907DA  LDA   $E6
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   $D8
         CLC
         ADC   #$0006
         LDX   $DA
         BCC   L0907ED
         INX
L0907ED  JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDA   [$F2]
         STA   $E8
         LDA   $E8
         CMP   #$FFFF
         BEQ   L090860
         LDA   $E8
         AND   #$8000
         TAY
         BEQ   L090860
         LDA   $E8
         AND   #$7FFF
         PHA
         LDA   #$0016
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L03082E
         LDX   #^L03082E
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDY   #$0002
         LDA   [$F2],Y
         PHA
         LDY   #$0002
         LDA   [$D8],Y
         PLX
         STX   $F2
         SEC
         SBC   $F2
         BVS   L090844
         EOR   #$8000
L090844  BMI   L090860
         LDA   $E6
         PHA
         LDA   #$0002
         SEC
         JSL   L01059C
         PLA
         CLC
         ADC   #$0001
         LDY   #$0008
         STA   [$DC],Y
         LDA   #$0001
         STA   $E4
L090860  INC   $E6
L090862  LDA   $E6
         SEC
         SBC   #$0004
         BVS   L09086D
         EOR   #$8000
L09086D  BMI   L090876
         LDA   $E4
         BNE   L090876
         BRL   L0907DA
L090876  LDA   $E4
         BNE   L090886
         PEI   $FD
         JSL   L0802D8
         PLY
         LDY   #$0008
         STA   [$DC],Y
L090886  LDA   #$0008
         STA   [$EE]
         LDA   #$0002
         PHA
         LDY   #$0008
         LDA   [$DC],Y
         SEC
         JSL   L01041B
         PLY
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   $D8
         CLC
         ADC   #$0006
         LDX   $DA
         BCC   L0908AB
         INX
L0908AB  JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDA   [$F2]
         PHA
         JSL   L081048
         PLY
         STA   $E6
         TAY
         BEQ   L0908D6
         LDA   #$0001
         STA   [$EE]
         LDA   $E6
         LDY   #$0012
         STA   [$DC],Y
         LDA   #$0002
         LDY   #$0014
         STA   [$DC],Y
L0908D6  BRA   L09090A
         BRA   L09090A
L0908DA  CMP   #$C001
         BNE   L0908E2
         BRL   L090544
L0908E2  CMP   #$C002
         BNE   L0908EA
         BRL   L0906A6
L0908EA  CMP   #$C004
         BNE   L0908F2
         BRL   L0906A6
L0908F2  CMP   #$C006
         BNE   L0908FA
         BRL   L0905BC
L0908FA  CMP   #$C007
         BNE   L090902
         BRL   L0906A6
L090902  CMP   #$FFFF
         BNE   L09090A
         BRL   L090541
L09090A  LDA   #$0000
         STA   [$EA]
         LDA   $D6
         TAY
         TSC
         CLC
         ADC   #$0022
         TCS
         TYA
         PLD
         RTL

L09091B  ENT
         PHD
         TSC
         SEC
         SBC   #$00F9
         TCD
         ADC   #$00D8
         TCS
         LDA   $FF
         PHA
         LDA   #$001A
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L03059A
         LDX   #^L03059A
         JSL   L010410
         PLA
         PLX
         STX   $E0
         STA   $DE
         LDA   $DE
         CLC
         ADC   #$000C
         LDX   $E0
         BCC   L090952
         INX
L090952  STX   $EE
         STA   $EC
         LDA   $DE
         CLC
         ADC   #$000A
         LDX   $E0
         BCC   L090961
         INX
L090961  STX   $F2
         STA   $F0
         LDA   [$F0]
         LDX   #$0000
         TAY
         BPL   L09096E
         DEX
L09096E  STX   $F8
         ASL
         ROL   $F8
         ASL
         ROL   $F8
         LDX   $F8
         PHX
         PHA
         LDA   #L030476
         LDX   #^L030476
         JSL   L010410
         PLA
         PLX
         STA   $F4
         STX   $F6
         LDY   #$0002
         LDA   [$F4],Y
         TAX
         LDA   [$F4]
         STX   $E4
         STA   $E2
         LDY   #$0004
         LDA   [$DE],Y
         PHA
         LDA   #$0016
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L03082E
         LDX   #^L03082E
         JSL   L010410
         PLA
         PLX
         STX   $DC
         STA   $DA
         JSL   L0703A5
         AND   #$0007
         STA   $E6
         LDA   $FF
         ASL
         ASL
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   #L0304DA
         LDX   #^L0304DA
         JSL   L010410
         PLA
         PLX
         STA   $F4
         STX   $F6
         LDA   [$F4]
         CMP   #$0003
         BEQ   L0909E7
         BRL   L090D71
L0909E7  LDA   #$00BE
         CLC
         ADC   $E6
         LDY   #$000E
         STA   [$DE],Y
         LDA   #$0092
         LDY   #$0010
         STA   [$DE],Y
         LDA   [$EC]
         LDX   #$0000
         TAY
         BPL   L090A03
         DEX
L090A03  PEA   $0000
         PEA   $0006
         CLC
         JSL   L0105E1
         LDX   $E4
         LDA   $E2
         JSL   L010410
         PLA
         PLX
         STA   $F4
         STX   $F6
         LDA   [$F4]
         BRL   L090D3E
L090A21  BRL   L090D6E
L090A24  LDA   #$FFFF
         STA   [$F0]
         LDA   $FF
         ASL
         ASL
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   #L0304DA
         LDX   #^L0304DA
         JSL   L010410
         PLA
         PLX
         STA   $F4
         STX   $F6
         LDA   #$0000
         LDY   #$0002
         STA   [$F4],Y
         LDA   #$0000
         LDY   #$0004
         STA   [$DE],Y
         LDA   #$0000
         STA   [$DE]
         LDA   #$0000
         LDY   #$0002
         STA   [$DE],Y
         PEI   $FF
         JSL   L0F085E
         PLY
         BRL   L090D6E
L090A6A  LDA   $FF
         ASL
         ASL
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   #L0304DA
         LDX   #^L0304DA
         JSL   L010410
         PLA
         PLX
         STA   $F4
         STX   $F6
         LDY   #$0006
         LDA   [$F4],Y
         PHA
         LDY   #$0004
         LDA   [$DE],Y
         PLX
         STX   $F4
         CMP   $F4
         BEQ   L090A99
         BRL   L090BDB
L090A99  LDA   #$0010
         STA   [$F0]
         LDY   #$0002
         LDA   [$DE],Y
         PHA
         LDY   #$0012
         LDA   [$DE],Y
         PHA
         LDA   #$001A
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L03059A
         LDX   #^L03059A
         JSL   L010410
         PLA
         PLX
         STA   $F4
         STX   $F6
         LDY   #$0002
         LDA   [$F4],Y
         PLX
         STX   $F4
         CMP   $F4
         BNE   L090AD7
         BRL   L090B85
L090AD7  LDA   $FF
         ASL
         ASL
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   #L0304DA
         LDX   #^L0304DA
         JSL   L010410
         PLA
         PLX
         STA   $F4
         STX   $F6
         LDA   [$F4]
         CMP   #$0004
         BNE   L090AFB
         BRL   L090B85
L090AFB  LDY   #$0012
         LDA   [$DE],Y
         PHA
         LDA   #$001A
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L03059A
         LDX   #^L03059A
         JSL   L010410
         PLA
         PLX
         STA   $F4
         STX   $F6
         LDY   #$0002
         LDA   [$F4],Y
         PHA
         LDY   #$0004
         LDA   [$DE],Y
         PHA
         JSL   L0804DD
         PLY
         PLY
         PHA
         LDA   $FF
         ASL
         ASL
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   #L0304DA
         LDX   #^L0304DA
         JSL   L010410
         PLA
         PLX
         STA   $F4
         STX   $F6
         PLA
         LDY   #$0006
         STA   [$F4],Y
         LDY   #$0004
         LDA   [$DE],Y
         PHA
         LDA   $FF
         ASL
         ASL
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   #L0304DA
         LDX   #^L0304DA
         JSL   L010410
         PLA
         PLX
         STA   $F4
         STX   $F6
         LDY   #$0006
         LDA   [$F4],Y
         PLX
         STX   $F4
         CMP   $F4
         BEQ   L090B83
         LDA   #$0006
         STA   [$F0]
L090B83  BRA   L090BD9
L090B85  LDA   $FF
         ASL
         ASL
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   #L0304DA
         LDX   #^L0304DA
         JSL   L010410
         PLA
         PLX
         STA   $F4
         STX   $F6
         LDA   [$F4]
         CMP   #$0004
         BNE   L090BD9
         LDA   $FF
         ASL
         ASL
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   #L0304DA
         LDX   #^L0304DA
         JSL   L010410
         PLA
         PLX
         STA   $F4
         STX   $F6
         LDA   #$0000
         LDY   #$0006
         STA   [$F4],Y
         LDA   #$0008
         STA   [$F0]
         PEI   $FF
         JSL   L0802D8
         PLY
         LDY   #$0008
         STA   [$DE],Y
L090BD9  BRA   L090BE0
L090BDB  LDA   #$0006
         STA   [$F0]
L090BE0  BRL   L090D6E
L090BE3  PEA   $0003
         PEI   $FF
         JSL   L0C0E26
         PLY
         PLY
         CMP   #$FFFF
         BEQ   L090C08
         LDA   #$0007
         STA   [$F0]
         LDY   #$000E
         LDA   [$DE],Y
         CLC
         ADC   #$001E
         LDY   #$000E
         STA   [$DE],Y
         BRA   L090C29
L090C08  LDA   #$0005
         STA   [$F0]
         LDY   #$000E
         LDA   [$DE],Y
         SEC
         SBC   #$001E
         LDY   #$000E
         STA   [$DE],Y
         LDY   #$0010
         LDA   [$DE],Y
         CLC
         ADC   #$001E
         LDY   #$0010
         STA   [$DE],Y
L090C29  BRL   L090D6E
L090C2C  PEA   $0007
         PEI   $FF
         JSL   L0C0E26
         PLY
         PLY
         CMP   #$FFFF
         BEQ   L090C5F
         LDA   #$0005
         STA   [$F0]
         LDY   #$000E
         LDA   [$DE],Y
         SEC
         SBC   #$001E
         LDY   #$000E
         STA   [$DE],Y
         LDY   #$000E
         LDA   [$DE],Y
         CLC
         ADC   #$001E
         LDY   #$000E
         STA   [$DE],Y
         BRA   L090C72
L090C5F  LDA   #$0007
         STA   [$F0]
         LDY   #$0010
         LDA   [$DE],Y
         CLC
         ADC   #$001E
         LDY   #$0010
         STA   [$DE],Y
L090C72  BRL   L090D6E
L090C75  PEA   $0005
         PEI   $FF
         JSL   L0C0E26
         PLY
         PLY
         STA   $E8
         LDY   #$0002
         LDA   [$DE],Y
         PHA
         LDY   #$0012
         LDA   [$DE],Y
         PHA
         LDA   #$001A
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L03059A
         LDX   #^L03059A
         JSL   L010410
         PLA
         PLX
         STA   $F4
         STX   $F6
         LDY   #$0002
         LDA   [$F4],Y
         PLX
         STX   $F4
         CMP   $F4
         BEQ   L090CBF
         LDA   $E8
         CMP   #$FFFF
         BNE   L090CF8
L090CBF  LDA   #$0002
         STA   [$F0]
         LDA   #$0002
         LDY   #$0014
         STA   [$DE],Y
         LDA   #$0000
         LDY   #$0012
         STA   [$DE],Y
         LDA   $FF
         ASL
         ASL
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   #L0304DA
         LDX   #^L0304DA
         JSL   L010410
         PLA
         PLX
         STA   $F4
         STX   $F6
         LDA   #$0000
         LDY   #$0006
         STA   [$F4],Y
         BRA   L090D3A
L090CF8  LDA   $FF
         ASL
         ASL
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   #L0304DA
         LDX   #^L0304DA
         JSL   L010410
         PLA
         PLX
         STA   $F4
         STX   $F6
         LDA   [$F4]
         CMP   #$0004
         BNE   L090D2C
         LDA   #$0008
         STA   [$F0]
         PEI   $FF
         JSL   L0802D8
         PLY
         LDY   #$0008
         STA   [$DE],Y
         BRA   L090D3A
L090D2C  LDY   #$0012
         LDA   [$DE],Y
         PHA
         PEI   $FF
         JSL   L081C57
         PLY
         PLY
L090D3A  BRA   L090D6E
         BRA   L090D6E
L090D3E  CMP   #$C001
         BNE   L090D46
         BRL   L090A24
L090D46  CMP   #$C002
         BNE   L090D4E
         BRL   L090A6A
L090D4E  CMP   #$C004
         BNE   L090D56
         BRL   L090BE3
L090D56  CMP   #$C005
         BNE   L090D5E
         BRL   L090C2C
L090D5E  CMP   #$C007
         BNE   L090D66
         BRL   L090C75
L090D66  CMP   #$FFFF
         BNE   L090D6E
         BRL   L090A21
L090D6E  BRL   L091071
L090D71  LDA   [$EC]
         LDX   #$0000
         TAY
         BPL   L090D7A
         DEX
L090D7A  PEA   $0000
         PEA   $0006
         CLC
         JSL   L0105E1
         LDX   $E4
         LDA   $E2
         JSL   L010410
         PLA
         PLX
         STA   $F4
         STX   $F6
         LDA   [$F4]
         BRL   L091041
L090D98  BRL   L091071
L090D9B  LDA   #$FFFF
         STA   [$F0]
         LDA   $FF
         ASL
         ASL
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   #L0304DA
         LDX   #^L0304DA
         JSL   L010410
         PLA
         PLX
         STA   $F4
         STX   $F6
         LDA   #$0000
         LDY   #$0002
         STA   [$F4],Y
         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   #$0000
         LDY   #$0004
         STA   [$F4],Y
         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   #$0000
         STA   [$F4]
         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   #$0000
         LDY   #$0002
         STA   [$F4],Y
         PEI   $FF
         JSL   L0F085E
         PLY
         BRL   L091071
L090E44  PEA   $0001
         PEI   $FF
         JSL   L0C0E26
         PLY
         PLY
         STA   $E8
         LDY   #$0004
         LDA   [$DE],Y
         PHA
         LDA   #$0016
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L03082E
         LDX   #^L03082E
         JSL   L010410
         PLA
         PLX
         STX   $DC
         STA   $DA
         LDA   $FF
         ASL
         ASL
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   #L0304DA
         LDX   #^L0304DA
         JSL   L010410
         PLA
         PLX
         STA   $F4
         STX   $F6
         LDA   [$F4]
         CMP   #$0003
         BNE   L090EA8
         LDA   #$0002
         STA   [$F0]
         LDA   #$0002
         LDY   #$0014
         STA   [$DE],Y
         BRL   L091071
         BRA   L090F0E
L090EA8  LDA   $FF
         ASL
         ASL
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   #L0304DA
         LDX   #^L0304DA
         JSL   L010410
         PLA
         PLX
         STA   $F4
         STX   $F6
         LDY   #$0004
         LDA   [$F4],Y
         PHA
         INC
         LDY   #$0004
         STA   [$F4],Y
         PLA
         SEC
         SBC   #$0014
         BEQ   L090F0E
         BVS   L090EDA
         EOR   #$8000
L090EDA  BPL   L090F0E
         LDA   #$0001
         LDY   #$0014
         STA   [$DE],Y
         LDA   #$0000
         LDY   #$0012
         STA   [$DE],Y
         LDA   $FF
         ASL
         ASL
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   #L0304DA
         LDX   #^L0304DA
         JSL   L010410
         PLA
         PLX
         STA   $F4
         STX   $F6
         LDA   #$0000
         LDY   #$0006
         STA   [$F4],Y
L090F0E  STZ   $E6
         STZ   $E8
         BRL   L090FC9
L090F15  LDA   $E8
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   $DA
         CLC
         ADC   #$0006
         LDX   $DC
         BCC   L090F28
         INX
L090F28  JSL   L010410
         PLA
         PLX
         STA   $F4
         STX   $F6
         LDA   [$F4]
         STA   $EA
         LDA   $EA
         CMP   #$FFFF
         BNE   L090F40
         BRL   L090FC7
L090F40  LDA   $EA
         AND   #$8000
         TAY
         BNE   L090F4B
         BRL   L090FC7
L090F4B  LDA   $EA
         AND   #$7FFF
         PHA
         LDA   #$0016
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L03082E
         LDX   #^L03082E
         JSL   L010410
         PLA
         PLX
         STA   $F4
         STX   $F6
         LDY   #$0004
         LDA   [$F4],Y
         PHA
         LDY   #$0012
         LDA   [$DE],Y
         PHA
         LDA   #$001A
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L03059A
         LDX   #^L03059A
         JSL   L010410
         PLA
         PLX
         STA   $F4
         STX   $F6
         LDY   #$0002
         LDA   [$F4],Y
         PLX
         STX   $F4
         CMP   $F4
         BNE   L090FC7
         LDA   $E8
         PHA
         LDA   #$0002
         SEC
         JSL   L01059C
         PLA
         CLC
         ADC   #$0001
         LDY   #$0008
         STA   [$DE],Y
         LDA   #$0002
         LDY   #$0014
         STA   [$DE],Y
         LDA   #$0001
         STA   $E6
L090FC7  INC   $E8
L090FC9  LDA   $E8
         SEC
         SBC   #$0004
         BVS   L090FD4
         EOR   #$8000
L090FD4  BMI   L090FDD
         LDA   $E6
         BNE   L090FDD
         BRL   L090F15
L090FDD  LDA   $E6
         BNE   L090FED
         PEI   $FF
         JSL   L0802D8
         PLY
         LDY   #$0008
         STA   [$DE],Y
L090FED  LDA   #$0008
         STA   [$F0]
         LDA   #$0002
         PHA
         LDY   #$0008
         LDA   [$DE],Y
         SEC
         JSL   L01041B
         PLY
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   $DA
         CLC
         ADC   #$0006
         LDX   $DC
         BCC   L091012
         INX
L091012  JSL   L010410
         PLA
         PLX
         STA   $F4
         STX   $F6
         LDA   [$F4]
         PHA
         JSL   L081048
         PLY
         STA   $E8
         TAY
         BEQ   L09103D
         LDA   #$0001
         STA   [$F0]
         LDA   $E8
         LDY   #$0012
         STA   [$DE],Y
         LDA   #$0002
         LDY   #$0014
         STA   [$DE],Y
L09103D  BRA   L091071
         BRA   L091071
L091041  CMP   #$C001
         BNE   L091049
         BRL   L090D9B
L091049  CMP   #$C002
         BNE   L091051
         BRL   L090F0E
L091051  CMP   #$C004
         BNE   L091059
         BRL   L090F0E
L091059  CMP   #$C006
         BNE   L091061
         BRL   L090E44
L091061  CMP   #$C007
         BNE   L091069
         BRL   L090F0E
L091069  CMP   #$FFFF
         BNE   L091071
         BRL   L090D98
L091071  LDA   #$0000
         STA   [$EC]
         TSC
         CLC
         ADC   #$0020
         TCS
         PLD
         RTL

L09107E  ENT
         PHD
         TSC
         SEC
         SBC   #$00F7
         TCD
         ADC   #$00D0
         TCS
         LDA   #$000C
         STA   $D2
         LDA   $FD
         PHA
         LDA   #$001A
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L03059A
         LDX   #^L03059A
         JSL   L010410
         PLA
         PLX
         STX   $DC
         STA   $DA
         JSL   L0703A5
         STA   $E4
         STZ   $E2
         LDA   $DA
         CLC
         ADC   #$000C
         LDX   $DC
         BCC   L0910C2
         INX
L0910C2  STX   $EC
         STA   $EA
         LDA   $DA
         CLC
         ADC   #$000A
         LDX   $DC
         BCC   L0910D1
         INX
L0910D1  STX   $F0
         STA   $EE
         LDA   [$EE]
         LDX   #$0000
         TAY
         BPL   L0910DE
         DEX
L0910DE  STX   $F6
         ASL
         ROL   $F6
         ASL
         ROL   $F6
         LDX   $F6
         PHX
         PHA
         LDA   #L030476
         LDX   #^L030476
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDY   #$0002
         LDA   [$F2],Y
         TAX
         LDA   [$F2]
         STX   $E0
         STA   $DE
         LDY   #$0004
         LDA   [$DA],Y
         PHA
         LDA   #$0016
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L03082E
         LDX   #^L03082E
         JSL   L010410
         PLA
         PLX
         STX   $D8
         STA   $D6
         LDA   #$0001
         PHA
         LDY   #$0008
         LDA   [$DA],Y
         SEC
         JSL   L01076A
         PLA
         STA   $D4
         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
         BEQ   L09115F
         BRL   L0915AB
L09115F  LDA   $E4
         AND   #$0007
         PHA
         LDA   #$00BE
         PLX
         STX   $F6
         CLC
         ADC   $F6
         LDY   #$000E
         STA   [$DA],Y
         LDA   #$0092
         LDY   #$0010
         STA   [$DA],Y
         LDA   [$EA]
         LDX   #$0000
         TAY
         BPL   L091184
         DEX
L091184  PEA   $0000
         PEA   $0006
         CLC
         JSL   L0105E1
         LDX   $E0
         LDA   $DE
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDA   [$F2]
         BRL   L091573
L0911A2  BRL   L0915A8
L0911A5  LDA   #$FFFF
         STA   [$EE]
         LDA   $FD
         ASL
         ASL
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   #L0304DA
         LDX   #^L0304DA
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDA   #$0000
         LDY   #$0002
         STA   [$F2],Y
         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   #$0004
         STA   [$F2],Y
         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
         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   #$0002
         STA   [$F2],Y
         PEI   $FD
         JSL   L0F085E
         PLY
         BRL   L0915A8
L09124E  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   $E2
         LDA   #$0003
         STA   $E6
         BRA   L0912D7
L09127D  LDA   $E6
         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   $E2
         BNE   L0912D5
         LDA   $FD
         ASL
         ASL
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   #L0304DA
         LDX   #^L0304DA
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDA   #$0001
         LDY   #$0004
         STA   [$F2],Y
         PEI   $E6
         PEI   $FD
         JSL   L081A07
         PLY
         PLY
         BRA   L0912E4
L0912D5  INC   $E6
L0912D7  LDA   $E6
         SEC
         SBC   #$0006
         BVS   L0912E2
         EOR   #$8000
L0912E2  BPL   L09127D
L0912E4  LDA   $FD
         ASL
         ASL
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   #L0304DA
         LDX   #^L0304DA
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDY   #$0004
         LDA   [$F2],Y
         BNE   L09134F
         LDA   $E4
         AND   #$0003
         TAY
         BNE   L09133B
         LDA   $D4
         EOR   #$0002
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   $D6
         CLC
         ADC   #$0006
         LDX   $D8
         BCC   L091323
         INX
L091323  JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDA   [$F2]
         CMP   #$FFFF
         BEQ   L09133B
         LDA   #$0010
         STA   [$EE]
         BRA   L09134F
L09133B  LDA   $E4
         AND   #$0001
         TAY
         BEQ   L09134A
         LDA   #$0004
         STA   [$EE]
         BRA   L09134F
L09134A  LDA   #$0006
         STA   [$EE]
L09134F  JSL   L0703A5
         AND   #$000F
         PHA
         LDY   #$000E
         LDA   [$DA],Y
         PLX
         STX   $F6
         CLC
         ADC   $F6
         LDY   #$000E
         STA   [$DA],Y
         BRL   L0915A8
L09136A  LDY   #$0012
         LDA   [$DA],Y
         CMP   $FF
         BNE   L091379
         LDA   #$0001
         STA   L02003F
L091379  LDA   $D4
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   $D6
         CLC
         ADC   #$0006
         LDX   $D8
         BCC   L09138C
         INX
L09138C  JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDA   [$F2]
         PHA
         LDY   #$0012
         LDA   [$DA],Y
         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
         BNE   L0913CC
         BRL   L091411
L0913CC  LDA   $E4
         AND   #$0003
         BRL   L091401
L0913D4  LDA   #$0004
         STA   [$EE]
         BRL   L09140E
L0913DC  LDA   #$0006
         STA   [$EE]
         BRL   L09140E
L0913E4  LDA   #$0010
         STA   [$EE]
         BRL   L09140E
L0913EC  LDA   #$0003
         STA   [$EE]
         BRL   L09140E
L0913F4  BRL   L09140E
L0913F7  DA    L0913D4
         DA    L0913DC
         DA    L0913E4
         DA    L0913EC
         DA    L0913F4
L091401  CMP   #$0004
         BCC   L091409
         LDA   #$0004
L091409  ASL
         TAX
         JMP   (L0913F7,X)

L09140E  BRL   L09147B
L091411  LDY   #$0012
         LDA   [$DA],Y
         PHA
         JSL   L0F0C8A
         PLY
         STA   $E4
         LDA   $E4
         AND   #$0007
         BRL   L09146E
L091426  LDY   #$0012
         LDA   [$DA],Y
         PHA
         PEI   $FF
         JSL   L081B87
         PLY
         PLY
         STA   $D2
         BRL   L09147B
L091439  LDA   #$0010
         STA   [$EE]
         BRL   L09147B
L091441  LDA   #$0003
         STA   [$EE]
         BRL   L09147B
L091449  LDA   #$0006
         STA   [$EE]
         BRL   L09147B
L091451  LDA   #$0004
         STA   [$EE]
         BRL   L09147B
L091459  BRL   L09147B
L09145C  DA    L091426
         DA    L091426
         DA    L091426
         DA    L091426
         DA    L091439
         DA    L091441
         DA    L091449
         DA    L091451
         DA    L091459
L09146E  CMP   #$0008
         BCC   L091476
         LDA   #$0008
L091476  ASL
         TAX
         JMP   (L09145C,X)

L09147B  JSL   L0703A5
         AND   #$000F
         PHA
         LDY   #$000E
         LDA   [$DA],Y
         PLX
         STX   $F6
         CLC
         ADC   $F6
         LDY   #$000E
         STA   [$DA],Y
         BRL   L0915A8
L091496  PEA   $0007
         PEI   $FD
         JSL   L0C0E26
         PLY
         PLY
         CMP   #$FFFF
         BEQ   L0914C9
         LDA   #$0005
         STA   [$EE]
         LDY   #$000E
         LDA   [$DA],Y
         SEC
         SBC   #$001E
         LDY   #$000E
         STA   [$DA],Y
         LDY   #$000E
         LDA   [$DA],Y
         CLC
         ADC   #$001E
         LDY   #$000E
         STA   [$DA],Y
         BRA   L0914DC
L0914C9  LDA   #$0007
         STA   [$EE]
         LDY   #$0010
         LDA   [$DA],Y
         CLC
         ADC   #$001E
         LDY   #$0010
         STA   [$DA],Y
L0914DC  BRL   L0915A8
L0914DF  PEA   $0003
         PEI   $FD
         JSL   L0C0E26
         PLY
         PLY
         CMP   #$FFFF
         BEQ   L091504
         LDA   #$0007
         STA   [$EE]
         LDY   #$000E
         LDA   [$DA],Y
         CLC
         ADC   #$001E
         LDY   #$000E
         STA   [$DA],Y
         BRA   L091525
L091504  LDA   #$0005
         STA   [$EE]
         LDY   #$000E
         LDA   [$DA],Y
         SEC
         SBC   #$001E
         LDY   #$000E
         STA   [$DA],Y
         LDY   #$0010
         LDA   [$DA],Y
         CLC
         ADC   #$001E
         LDY   #$0010
         STA   [$DA],Y
L091525  BRL   L0915A8
L091528  PEI   $FF
         PEI   $FD
         JSL   L0F0939
         PLY
         PLY
         TAY
         BEQ   L09155F
         LDA   #$0001
         LDY   #$0014
         STA   [$DA],Y
         LDA   $FD
         ASL
         ASL
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   #L0304DA
         LDX   #^L0304DA
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDA   #$0000
         LDY   #$0006
         STA   [$F2],Y
L09155F  PEA   $0005
         PEI   $FD
         JSL   L0C0E26
         PLY
         PLY
         LDA   #$0002
         STA   [$EE]
         BRA   L0915A8
         BRA   L0915A8
L091573  CMP   #$C001
         BNE   L09157B
         BRL   L0911A5
L09157B  CMP   #$C002
         BNE   L091583
         BRL   L09124E
L091583  CMP   #$C003
         BNE   L09158B
         BRL   L09136A
L09158B  CMP   #$C004
         BNE   L091593
         BRL   L0914DF
L091593  CMP   #$C005
         BNE   L09159B
         BRL   L091496
L09159B  CMP   #$C007
         BEQ   L091528
         CMP   #$FFFF
         BNE   L0915A8
         BRL   L0911A2
L0915A8  BRL   L091850
L0915AB  LDA   #$00BE
         LDY   #$000E
         STA   [$DA],Y
         LDA   #$0092
         LDY   #$0010
         STA   [$DA],Y
         LDA   [$EA]
         LDX   #$0000
         TAY
         BPL   L0915C4
         DEX
L0915C4  PEA   $0000
         PEA   $0006
         CLC
         JSL   L0105E1
         LDX   $E0
         LDA   $DE
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDA   [$F2]
         BRL   L091818
L0915E2  BRL   L091850
L0915E5  LDA   #$FFFF
         STA   [$EE]
         LDA   $FD
         ASL
         ASL
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   #L0304DA
         LDX   #^L0304DA
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDA   #$0000
         LDY   #$0002
         STA   [$F2],Y
         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   #$0004
         STA   [$F2],Y
         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
         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   #$0002
         STA   [$F2],Y
         PEI   $FD
         JSL   L0F085E
         PLY
         BRL   L091850
L09168E  PEI   $FD
         JSL   L0818DF
         PLY
         STA   [$EE]
         BRL   L091850
L09169A  LDY   #$0012
         LDA   [$DA],Y
         CMP   $FF
         BNE   L0916A9
         LDA   #$0001
         STA   L02003F
L0916A9  PEI   $FD
         JSL   L0818DF
         PLY
         STA   [$EE]
         CMP   #$0001
         BNE   L0916DD
         LDY   #$0012
         LDA   [$DA],Y
         PHA
         JSL   L0F0C8A
         PLY
         SEC
         SBC   #$0004
         BVS   L0916CB
         EOR   #$8000
L0916CB  BMI   L0916DD
         LDY   #$0012
         LDA   [$DA],Y
         PHA
         PEI   $FF
         JSL   L081B87
         PLY
         PLY
         STA   $D2
L0916DD  BRL   L091850
L0916E0  PEI   $FF
         PEI   $FD
         JSL   L0F0939
         PLY
         PLY
         TAY
         BEQ   L091717
         LDA   #$0001
         LDY   #$0014
         STA   [$DA],Y
         LDA   $FD
         ASL
         ASL
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   #L0304DA
         LDX   #^L0304DA
         JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDA   #$0000
         LDY   #$0006
         STA   [$F2],Y
L091717  PEA   $0001
         PEI   $FD
         JSL   L0C0E26
         PLY
         PLY
         LDY   #$0004
         LDA   [$DA],Y
         PHA
         LDA   #$0016
         CLC
         JSL   L01059C
         PLA
         LDX   #$0000
         PHX
         PHA
         LDA   #L03082E
         LDX   #^L03082E
         JSL   L010410
         PLA
         PLX
         STX   $D8
         STA   $D6
         LDA   $E4
         AND   #$0003
         TAY
         BNE   L091751
         BRL   L0917FD
L091751  LDA   [$D6]
         CMP   #$0004
         BEQ   L09175B
         BRL   L0917FD
L09175B  LDA   #$0002
         PHA
         LDY   #$0008
         LDA   [$DA],Y
         SEC
         JSL   L01041B
         PLY
         STA   $E4
         LDA   $E4
         STA   $E6
         BRA   L0917E6
L091772  LDA   $E6
         AND   #$0003
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   $D6
         CLC
         ADC   #$0006
         LDX   $D8
         BCC   L091788
         INX
L091788  JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDA   [$F2]
         CMP   #$FFFF
         BEQ   L0917E4
         LDA   $E6
         AND   #$0003
         ASL
         CLC
         ADC   #$0001
         LDY   #$0008
         STA   [$DA],Y
         LDA   $E6
         AND   #$0003
         ASL
         LDX   #$0000
         PHX
         PHA
         LDA   $D6
         CLC
         ADC   #$0006
         LDX   $D8
         BCC   L0917BE
         INX
L0917BE  JSL   L010410
         PLA
         PLX
         STA   $F2
         STX   $F4
         LDA   [$F2]
         AND   #$7FFF
         PHA
         JSL   L081048
         PLY
         TAY
         BNE   L0917DD
         LDA   #$0008
         STA   [$EE]
         BRA   L0917E2
L0917DD  LDA   #$0002
         STA   [$EE]
L0917E2  BRA   L0917FB
L0917E4  INC   $E6
L0917E6  LDA   $E4
         CLC
         ADC   #$0004
         SEC
         SBC   $E6
         BEQ   L0917FB
         BVS   L0917F6
         EOR   #$8000
L0917F6  BPL   L0917FB
         BRL   L091772
L0917FB  BRA   L091814
L0917FD  LDA   [$D6]
         CMP   #$0004
         BNE   L09180F
         PEI   $FD
         JSL   L0818DF
         PLY
         STA   [$EE]
         BRA   L091814
L09180F  LDA   #$0002
         STA   [$EE]
L091814  BRA   L091850
         BRA   L091850
L091818  CMP   #$C001
         BNE   L091820
         BRL   L0915E5
L091820  CMP   #$C002
         BNE   L091828
         BRL   L09168E
L091828  CMP   #$C003
         BNE   L091830
         BRL   L09169A
L091830  CMP   #$C004
         BNE   L091838
         BRL   L09168E
L091838  CMP   #$C006
         BNE   L091840
         BRL   L0916E0
L091840  CMP   #$C007
         BNE   L091848
         BRL   L09168E
L091848  CMP   #$FFFF
         BNE   L091850
         BRL   L0915E2
L091850  LDA   #$0000
         STA   [$EA]
         LDA   $D2
         TAY
         TSC
         CLC
         ADC   #$0026
         TCS
         TYA
         PLD
         RTL

