; Disassembly of SpcInv.bin
; Disassembled Tue Sep 18 22:17:29 2012
; Using DiStella v3.0
;
; Command Line: C:\USERS\DAVID\STELLA\DISTELLA.EXE -pafs SpcInv.bin 
;

      processor 6502
VSYNC   =  $00
VBLANK  =  $01
WSYNC   =  $02
RSYNC   =  $03
NUSIZ0  =  $04
NUSIZ1  =  $05
COLUP0  =  $06
COLUP1  =  $07
COLUPF  =  $08
COLUBK  =  $09
CTRLPF  =  $0A
REFP1   =  $0C
PF0     =  $0D
PF1     =  $0E
PF2     =  $0F
RESP0   =  $10
RESP1   =  $11
RESBL   =  $14
AUDC0   =  $15
AUDF0   =  $17
AUDV0   =  $19
GRP0    =  $1B
GRP1    =  $1C
ENABL   =  $1F
HMP0    =  $20
HMP1    =  $21
HMBL    =  $24
VDELP0  =  $25
VDELP1  =  $26
HMOVE   =  $2A
HMCLR   =  $2B
CXCLR   =  $2C
SWCHA   =  $0280
SWCHB   =  $0282
INTIM   =  $0284
TIM8T   =  $0295
TIM64T  =  $0296

       ORG $F000
LF000: STA    HMCLR   ;3
       LDA    $84     ;3
       BMI    LF006   ;2
LF006: AND    #$0F    ;2
       TAX            ;2
LF009: DEX            ;2
       BPL    LF009   ;2
LF00C: LDA    ($F8),Y ;5
       TAX            ;2
       LDA    ($EE),Y ;5
       STA    GRP0    ;3
       LDA    ($F0),Y ;5
       STA    GRP1    ;3
       LDA    ($F2),Y ;5
       STA    GRP0    ;3
       LDA    ($F4),Y ;5
       STA    GRP1    ;3
       LDA    ($F6),Y ;5
       STA    GRP0    ;3
       TXA            ;2
       STA    GRP1    ;3
       STA    GRP0    ;3
       DEC    $89     ;5
       DEY            ;2
       PHA            ;3
       PLA            ;4
       PHA            ;3
       PLA            ;4
       LDA    ($F8),Y ;5
       TAX            ;2
       LDA    ($EE),Y ;5
       STA    GRP0    ;3
       LDA    ($F0),Y ;5
       STA    GRP1    ;3
       LDA    ($F2),Y ;5
       STA    GRP0    ;3
       LDA    ($F4),Y ;5
       STA    GRP1    ;3
       LDA    ($F6),Y ;5
       STA    GRP0    ;3
       TXA            ;2
       STA    GRP1    ;3
       STA    GRP0    ;3
       LDA    $89     ;3
       CMP    #$04    ;2
       BCC    LF055   ;2
       LDA    #$00    ;2
       BCS    LF058   ;2
LF055: NOP            ;2
       LDA    #$02    ;2
LF058: STA.w  $001F   ;4
       DEY            ;2
       BPL    LF00C   ;2
       INY            ;2
       STY    GRP0    ;3
       STY    GRP1    ;3
       STY    HMCLR   ;3
       STY    GRP0    ;3
       STY    GRP1    ;3
       STA    WSYNC   ;3
       DEC    $89     ;5
       LDA    $89     ;3
       CMP    #$04    ;2
       BCC    LF077   ;2
       LDA    #$00    ;2
       BCS    LF07A   ;2
LF077: NOP            ;2
       LDA    #$02    ;2
LF07A: STA    ENABL   ;3
       LDY    $80     ;3
       LDA    WSYNC   ;3
       ORA    RSYNC   ;3
       ASL            ;2
       BMI    LF08B   ;2
       NOP            ;2
       NOP            ;2
       NOP            ;2
       NOP            ;2
       BPL    LF092   ;2
LF08B: LDA    $82     ;3
       ORA    LFCDC,Y ;4
       STA    $82     ;3
LF092: STA    CXCLR   ;3
       DEY            ;2
       DEC    $8C     ;5
       BPL    LF0A2   ;2
       LDA    #$00    ;2
       STA    VDELP0  ;3
       STA    VDELP1  ;3
       JMP    LF109   ;3
LF0A2: JSR    LFDE9   ;6
LF0A5: STY    $80     ;3
       LDA.wy $0092,Y ;4
       STA    $F8     ;3
       LDX    #$F4    ;2
LF0AE: LSR    $F8     ;5
       BCC    LF0B9   ;2
       LDA    LFCD6,Y ;4
       ADC    $8B     ;3
       BNE    LF0BD   ;2
LF0B9: PHA            ;3
       PLA            ;4
       LDA    #$00    ;2
LF0BD: STA    $FA,X   ;4
       INX            ;2
       INX            ;2
       BMI    LF0AE   ;2
       DEC    $89     ;5
       LDA    $89     ;3
       CMP    #$04    ;2
       BCC    LF0CF   ;2
       LDA    #$00    ;2
       BCS    LF0D2   ;2
LF0CF: NOP            ;2
       LDA    #$02    ;2
LF0D2: STA    ENABL   ;3
       LDA    $C8     ;3
       AND    #$38    ;2
       LSR            ;2
       LSR            ;2
       LSR            ;2
       CMP    $80     ;3
       BNE    LF0F5   ;2
       LDA    $C8     ;3
       AND    #$07    ;2
       ASL            ;2
       TAX            ;2
       LDA    $C8     ;3
       ROL            ;2
       ROL            ;2
       ROL            ;2
       AND    #$03    ;2
       TAY            ;2
       LDA    LFD1E,Y ;4
       STA    $EE,X   ;4
       JMP    LF0FA   ;3
LF0F5: LDX    #$05    ;2
LF0F7: DEX            ;2
       BPL    LF0F7   ;2
LF0FA: STA    HMCLR   ;3
       JSR    LFDB2   ;6
       LDX    #$06    ;2
LF101: DEX            ;2
       BPL    LF101   ;2
       LDY    #$09    ;2
       JMP    LF000   ;3
LF109: DEC    $8E     ;5
       BMI    LF113   ;2
       JSR    LFDB2   ;6
       JMP    LF109   ;3
LF113: BIT    $98     ;3
       BVS    LF11A   ;2
       JMP    LF1B2   ;3
LF11A: LDA    $DD     ;3
       STA    COLUP0  ;3
       LDA    #$01    ;2
       STA    $8E     ;3
       LDA    #$00    ;2
       STA    $EF     ;3
       STA    $F1     ;3
       STA    $F3     ;3
       LDA    #$AB    ;2
       STA    $EE     ;3
       LDA    #$B4    ;2
       STA    $F0     ;3
       LDA    #$BD    ;2
       STA    $F2     ;3
       LDA    #$11    ;2
       STA    WSYNC   ;3
       STA    HMCLR   ;3
       STA    $F4     ;3
       LDA    $85     ;3
       STA    HMP0    ;3
       AND    #$0F    ;2
       TAY            ;2
LF145: DEY            ;2
       BPL    LF145   ;2
       STA    RESP0   ;3
       DEC    $89     ;5
       LDA    $89     ;3
       CMP    #$04    ;2
       LDA    #$02    ;2
       BCC    LF155   ;2
       LSR            ;2
LF155: STA    ENABL   ;3
       STA    WSYNC   ;3
       STA    HMOVE   ;3
       LDY    #$00    ;2
       LDA    $85     ;3
       BPL    LF163   ;2
       LDA    $85     ;3
LF163: AND    #$0F    ;2
       TAX            ;2
       DEX            ;2
       DEX            ;2
LF168: DEX            ;2
       BPL    LF168   ;2
LF16B: LDA    ($EE),Y ;5
       STA    GRP0    ;3
       NOP            ;2
       LDA    ($F0),Y ;5
       STA    GRP0    ;3
       LDA    ($F2),Y ;5
       STA    GRP0    ;3
       DEC    $F4     ;5
       BMI    LF18E   ;2
       LDA    $F4     ;3
       LSR            ;2
       BCC    LF189   ;2
       INY            ;2
       LDA    #$20    ;2
LF184: LSR            ;2
       BNE    LF184   ;2
       BEQ    LF16B   ;2
LF189: JSR    LFDE9   ;6
       BPL    LF16B   ;2
LF18E: LDA    #$00    ;2
       STA    GRP0    ;3
       STA    WSYNC   ;3
       LDA    WSYNC   ;3
       ASL            ;2
       AND    #$80    ;2
       ORA    $82     ;3
       STA    $82     ;3
       STA    CXCLR   ;3
       JSR    LFDE9   ;6
       STA    HMCLR   ;3
       STA    WSYNC   ;3
       STA    WSYNC   ;3
LF1A8: DEC    $8E     ;5
       BMI    LF1B2   ;2
       JSR    LFDB2   ;6
       JMP    LF1A8   ;3
LF1B2: BIT    $98     ;3
       BPL    LF1B9   ;2
       JMP    LF282   ;3
LF1B9: JSR    LFDE9   ;6
       STA    HMCLR   ;3
       STA    WSYNC   ;3
       LDA    $DF     ;3
       STA    COLUP0  ;3
       LDA    $86     ;3
       STA    HMP0    ;3
       AND    #$0F    ;2
       TAY            ;2
LF1CB: DEY            ;2
       BPL    LF1CB   ;2
       STA    RESP0   ;3
       STA    WSYNC   ;3
       LDA    $E0     ;3
       STA    COLUP1  ;3
       LDA    $87     ;3
       STA    HMP1    ;3
       AND    #$0F    ;2
       TAY            ;2
LF1DD: DEY            ;2
       BPL    LF1DD   ;2
       STA    RESP1   ;3
       STA    WSYNC   ;3
       STA    HMOVE   ;3
       JSR    LFDE9   ;6
       LDA    #$00    ;2
       BIT    SWCHB   ;4
       BPL    LF1F2   ;2
       LDA    #$05    ;2
LF1F2: STA    NUSIZ1  ;3
       LDA    #$00    ;2
       BVC    LF1FA   ;2
       LDA    #$05    ;2
LF1FA: STA    NUSIZ0  ;3
       LDA    $98     ;3
       AND    #$10    ;2
       BEQ    LF204   ;2
       LDA    #$0A    ;2
LF204: STA    $F4     ;3
       LDA    $98     ;3
       AND    #$20    ;2
       BEQ    LF20E   ;2
       LDA    #$0A    ;2
LF20E: STA    $F6     ;3
       LDA    $AA     ;3
       LSR            ;2
       STA    WSYNC   ;3
       BCC    LF22E   ;2
       LDX    $C9     ;3
       LDA    LFD16,X ;4
       STA    $F8     ;3
       LDA    #$FF    ;2
       STA    $F9     ;3
       LDA    $CA     ;3
       AND    #$08    ;2
       BNE    LF22C   ;2
       STA    $F4     ;3
       STA    $F6     ;3
LF22C: BPL    LF253   ;2
LF22E: LDA    #$00    ;2
       STA    $F8     ;3
       LDA    $CA     ;3
       LSR            ;2
       LSR            ;2
       LSR            ;2
       LDA    $AA     ;3
       AND    #$04    ;2
       BEQ    LF245   ;2
       LDA    #$1E    ;2
       BCS    LF243   ;2
       LDA    #$14    ;2
LF243: STA    $F4     ;3
LF245: LDA    $AA     ;3
       AND    #$02    ;2
       BEQ    LF253   ;2
       LDA    #$14    ;2
       BCS    LF251   ;2
       LDA    #$1E    ;2
LF251: STA    $F6     ;3
LF253: LDX    #$09    ;2
       LDY    #$09    ;2
LF257: STA    WSYNC   ;3
       LDA    #$00    ;2
       STA    PF0     ;3
       LDA    ($F4),Y ;5
       STA    GRP0    ;3
       LDA    ($F6),Y ;5
       STA    GRP1    ;3
       TXA            ;2
       LSR            ;2
       TAY            ;2
       LDA    ($F8),Y ;5
       STA    PF0     ;3
       TXA            ;2
       LSR            ;2
       BCC    LF27D   ;2
       DEC    $89     ;5
       LDA    $89     ;3
       CMP    #$04    ;2
       LDA    #$02    ;2
       BCC    LF27B   ;2
       LSR            ;2
LF27B: STA    ENABL   ;3
LF27D: DEX            ;2
       TXA            ;2
       TAY            ;2
       BPL    LF257   ;2
LF282: STA    WSYNC   ;3
       LDA    #$00    ;2
       STA    NUSIZ0  ;3
       STA    NUSIZ1  ;3
       STA    PF0     ;3
       STA    ENABL   ;3
       STA    GRP0    ;3
       STA    GRP1    ;3
       LDA    $E4     ;3
       STA    COLUBK  ;3
       LDA    $81     ;3
       STA    RESP0   ;3
       LDX    #$04    ;2
LF29C: DEX            ;2
       BPL    LF29C   ;2
       STA    RESP1   ;3
       STA    HMCLR   ;3
       LDA    #$E0    ;2
       STA    HMP1    ;3
       STA    WSYNC   ;3
       STA    HMOVE   ;3
       LDA    #$C0    ;2
       STA    GRP0    ;3
       STA    GRP1    ;3
       LDX    #$04    ;2
       LDA    #$00    ;2
LF2B5: STA    $F3,X   ;4
       DEX            ;2
       BNE    LF2B5   ;2
       JSR    LFE08   ;6
       INX            ;2
       JSR    LFE08   ;6
       LDA    $AA     ;3
       AND    #$81    ;2
       BNE    LF2F6   ;2
       BIT    WSYNC   ;3
       BVC    LF2D1   ;2
       LDA    #$04    ;2
       BIT    $AA     ;3
       BEQ    LF2DC   ;2
LF2D1: DEX            ;2
       BIT    RSYNC   ;3
       BVC    LF2F6   ;2
       LDA    #$02    ;2
       BIT    $AA     ;3
       BNE    LF2F6   ;2
LF2DC: ORA    $AA     ;3
       STA    $AA     ;3
       STA    $C6     ;3
       JSR    LFE75   ;6
       LDA    #$06    ;2
       JSR    LFE7E   ;6
       LDA    $C7     ;3
       BNE    LF2F6   ;2
       BIT    $DB     ;3
       BVC    LF2F6   ;2
       LDA    #$02    ;2
       STA    $F4,X   ;4
LF2F6: STA    WSYNC   ;3
LF2F8: LDA    INTIM   ;4
       BNE    LF2F8   ;2
       STA    GRP0    ;3
       STA    GRP1    ;3
       LDA    #$C8    ;2
       STA    TIM8T   ;4
       LDA    #$00    ;2
       STA    $F1     ;3
       TAX            ;2
       LDA    $82     ;3
       BPL    LF36E   ;2
       LDA    $CA     ;3
       LSR            ;2
       BCC    LF316   ;2
       LDX    #$04    ;2
LF316: LDA    $D1,X   ;4
       CMP    #$49    ;2
       BCC    LF320   ;2
       CMP    #$58    ;2
       BCC    LF321   ;2
LF320: INX            ;2
LF321: CPX    #$03    ;2
       BCC    LF331   ;2
       LDA    #$09    ;2
       STA    $EF     ;3
       LDA    #$FF    ;2
       STA    $F2     ;3
       LDA    #$7F    ;2
       BNE    LF33B   ;2
LF331: LDA    #$FF    ;2
       STA    $EF     ;3
       LDA    #$01    ;2
       STA    $F2     ;3
       LDA    #$F6    ;2
LF33B: STA    $D1,X   ;4
       LDA    $D3,X   ;4
       LDY    #$03    ;2
       CLC            ;2
       SBC    $9B     ;3
LF344: DEY            ;2
       CLC            ;2
       ADC    #$E0    ;2
       BPL    LF344   ;2
       ADC    #$20    ;2
       TAX            ;2
       LDA    LFD13,Y ;4
       STA    $F0     ;3
       LDY    $EF     ;3
LF354: TYA            ;2
       CLC            ;2
       ADC    $F2     ;3
       TAY            ;2
       LDA    LFF4C,X ;4
       EOR    #$FF    ;2
       AND    ($F0),Y ;5
       BEQ    LF354   ;2
       JSR    LFD8F   ;6
       DEY            ;2
       JSR    LFD8B   ;6
       INY            ;2
       INY            ;2
       JSR    LFD8B   ;6
LF36E: LDA    $CA     ;3
       LSR            ;2
       BCS    LF376   ;2
       JMP    LF429   ;3
LF376: BIT    $82     ;3
       BVC    LF3A0   ;2
       LDA    $C8     ;3
       AND    #$39    ;2
       CMP    #$39    ;2
       BEQ    LF3A0   ;2
       LDA    #$39    ;2
       STA    $C8     ;3
       LDX    #$01    ;2
       LDA    $98     ;3
       AND    #$04    ;2
       BNE    LF38F   ;2
       DEX            ;2
LF38F: LDA    #$04    ;2
       STA    $C6     ;3
       LSR            ;2
       BIT    $DB     ;3
       BVC    LF399   ;2
       LSR            ;2
LF399: STA    $F4,X   ;4
       LDA    #$05    ;2
       JSR    LFE8B   ;6
LF3A0: LDA    #$06    ;2
       STA    $F0     ;3
LF3A4: DEC    $F0     ;5
       BPL    LF3AB   ;2
       JMP    LF4CF   ;3
LF3AB: LDX    $F0     ;3
       LDA    $82     ;3
       AND    LFCDC,X ;4
       BEQ    LF3A4   ;2
       LDY    #$01    ;2
       LDA    #$35    ;2
       SEC            ;2
       SBC    LFD31,X ;4
       CLC            ;2
       ADC    $90     ;3
       CMP    #$52    ;2
       BCS    LF426   ;2
       CMP    $D5     ;3
       BCS    LF3CE   ;2
       ADC    #$0D    ;2
       CMP    $D5     ;3
       BCC    LF3CE   ;2
       DEY            ;2
LF3CE: STY    $EE     ;3
       LDX    $EE     ;3
       LDY    #$FF    ;2
       LDA    $9A     ;3
       CLC            ;2
       ADC    #$FD    ;2
LF3D9: INY            ;2
       ADC    #$10    ;2
       CMP    $D7,X   ;4
       BCC    LF3D9   ;2
       STY    $EF     ;3
       LDX    $F0     ;3
       LDA    LFCDC,Y ;4
       AND    $92,X   ;4
       BEQ    LF426   ;2
       EOR    $92,X   ;4
       STA    $92,X   ;4
       LDY    $EE     ;3
       LDA    LFCDE,Y ;4
       LDY    #$01    ;2
       AND    $98     ;3
       BNE    LF3FB   ;2
       DEY            ;2
LF3FB: LDA    LFD2B,X ;4
       STA.wy $00F6,Y ;5
       LDA    #$02    ;2
       JSR    LFE7E   ;6
       DEC    $91     ;5
       BNE    LF414   ;2
       LDA    $AA     ;3
       ORA    #$08    ;2
       STA    $AA     ;3
       LDA    #$61    ;2
       STA    $CA     ;3
LF414: JSR    LFBED   ;6
       TXA            ;2
       ASL            ;2
       ASL            ;2
       ASL            ;2
       ORA    $EF     ;3
       STA    $C8     ;3
       LDA    #$F6    ;2
       LDY    $EE     ;3
       STA.wy $00D5,Y ;5
LF426: JMP    LF3A4   ;3
LF429: LSR            ;2
       BCS    LF459   ;2
       LDA    $C8     ;3
       AND    #$39    ;2
       CMP    #$39    ;2
       BEQ    LF459   ;2
       LDA    $9E     ;3
       CMP    #$B4    ;2
       BEQ    LF459   ;2
       LDA    $98     ;3
       LSR            ;2
       BCS    LF445   ;2
       DEC    $9E     ;5
       BNE    LF459   ;2
       BEQ    LF44D   ;2
LF445: INC    $9E     ;5
       LDA    $9E     ;3
       CMP    #$98    ;2
       BCC    LF459   ;2
LF44D: LDA    #$B4    ;2
       STA    $9E     ;3
       LDA    #$00    ;2
       STA    $CC     ;3
       LDA    #$04    ;2
       STA    $C6     ;3
LF459: LDA    SWCHA   ;4
       TAY            ;2
       ASL            ;2
       ASL            ;2
       ASL            ;2
       ASL            ;2
       STA    $EE     ;3
       AND    #$80    ;2
       STA    $81     ;3
       LDA    $DB     ;3
       CMP    #$90    ;2
       BNE    LF475   ;2
       BIT    $AA     ;3
       BVC    LF47F   ;2
       LDY    $EE     ;3
       BVS    LF47F   ;2
LF475: AND    #$02    ;2
       BEQ    LF47F   ;2
       TYA            ;2
       AND    #$40    ;2
       ORA    $81     ;3
       TAY            ;2
LF47F: LDX    #$01    ;2
LF481: LDA    $AA     ;3
       AND    LFD60,X ;4
       BNE    LF4A0   ;2
       BIT    $EE     ;3
       BMI    LF48E   ;2
       INC    $9C,X   ;6
LF48E: BVS    LF492   ;2
       DEC    $9C,X   ;6
LF492: LDA    $9C,X   ;4
       CMP    #$76    ;2
       BCC    LF49A   ;2
       DEC    $9C,X   ;6
LF49A: CMP    #$23    ;2
       BCS    LF4A0   ;2
       INC    $9C,X   ;6
LF4A0: STY    $EE     ;3
       DEX            ;2
       BPL    LF481   ;2
       LDA    $CA     ;3
       LSR            ;2
       LSR            ;2
       LSR            ;2
       BCS    LF4CF   ;2
       LDA    $DC     ;3
       LSR            ;2
       BCC    LF4CF   ;2
       LDA    $AA     ;3
       AND    #$10    ;2
       BEQ    LF4C1   ;2
       INC    $9B     ;5
       LDA    $9B     ;3
       CMP    #$35    ;2
       BCC    LF4CF   ;2
       BCS    LF4C9   ;2
LF4C1: DEC    $9B     ;5
       LDA    $9B     ;3
       CMP    #$21    ;2
       BCS    LF4CF   ;2
LF4C9: LDA    $AA     ;3
       EOR    #$10    ;2
       STA    $AA     ;3
LF4CF: LDA    INTIM   ;4
       BNE    LF4CF   ;2
LF4D4: LDA    #$02    ;2
       STA    VBLANK  ;3
       STA    WSYNC   ;3
       BIT    $AA     ;3
       BMI    LF4F1   ;2
       SED            ;2
       LDX    #$01    ;2
LF4E1: LDA    $E8,X   ;4
       CLC            ;2
       ADC    $F6,X   ;4
       STA    $E8,X   ;4
       LDA    $E6,X   ;4
       ADC    $F4,X   ;4
       STA    $E6,X   ;4
       DEX            ;2
       BPL    LF4E1   ;2
LF4F1: CLD            ;2
       STA    WSYNC   ;3
       LDA    $CA     ;3
       AND    #$07    ;2
       BNE    LF50C   ;2
       LDA    $C8     ;3
       CLC            ;2
       ADC    #$40    ;2
       STA    $C8     ;3
       CMP    #$40    ;2
       BCS    LF50C   ;2
       JSR    LFBF1   ;6
       LDA    #$30    ;2
       STA    $C8     ;3
LF50C: LDA    #$02    ;2
       STA    WSYNC   ;3
       STA    VSYNC   ;3
       STA    WSYNC   ;3
       STA    WSYNC   ;3
       LDA    #$30    ;2
       STA    TIM64T  ;4
       LDA    #$00    ;2
       STA    WSYNC   ;3
       STA    VSYNC   ;3
       LDA    $CA     ;3
       LSR            ;2
       BCC    LF549   ;2
       LDX    #$01    ;2
LF528: LDA    $D5,X   ;4
       CMP    #$79    ;2
       BNE    LF532   ;2
       LDA    #$F6    ;2
       STA    $D5,X   ;4
LF532: LDA    $D5,X   ;4
       CMP    #$EC    ;2
       BCS    LF544   ;2
       LDA    $D5,X   ;4
       ADC    #$FE    ;2
       CMP    #$03    ;2
       BCS    LF542   ;2
       LDA    #$F6    ;2
LF542: STA    $D5,X   ;4
LF544: DEX            ;2
       BPL    LF528   ;2
       BMI    LF5A2   ;2
LF549: LDA    $CA     ;3
       AND    #$0F    ;2
       CMP    #$0F    ;2
       BEQ    LF556   ;2
       JSR    LFDFB   ;6
       STA    $DA     ;3
LF556: LDA    $DC     ;3
       AND    #$04    ;2
       LSR            ;2
       LSR            ;2
       LSR            ;2
       LDA    #$01    ;2
       TAX            ;2
       BCC    LF563   ;2
       ASL            ;2
LF563: STA    $81     ;3
LF565: LDA    $D1,X   ;4
       CMP    #$EC    ;2
       BCS    LF59F   ;2
       LDA    $DC     ;3
       AND    #$02    ;2
       BEQ    LF590   ;2
       LDA    $DA     ;3
       CPX    #$00    ;2
       BEQ    LF579   ;2
       ASL            ;2
       ASL            ;2
LF579: ASL            ;2
       BCC    LF590   ;2
       BPL    LF588   ;2
       LDA    $D3,X   ;4
       CMP    #$81    ;2
       BCS    LF590   ;2
       INC    $D3,X   ;6
       BNE    LF590   ;2
LF588: LDA    $D3,X   ;4
       CMP    #$17    ;2
       BCC    LF590   ;2
       DEC    $D3,X   ;6
LF590: LDA    $D1,X   ;4
       CLC            ;2
       ADC    $81     ;3
       STA    $D1,X   ;4
       CMP    #$6C    ;2
       BCC    LF59F   ;2
       LDA    #$F6    ;2
       STA    $D1,X   ;4
LF59F: DEX            ;2
       BPL    LF565   ;2
LF5A2: DEC    $CA     ;5
       BEQ    LF5A9   ;2
       JMP    LF68C   ;3
LF5A9: LDA    $C7     ;3
       BEQ    LF5B1   ;2
       INC    $C7     ;5
       INC    $C7     ;5
LF5B1: BIT    $E5     ;3
       BMI    LF622   ;2
       LDA    $AA     ;3
       AND    #$08    ;2
       BEQ    LF5E5   ;2
       EOR    $AA     ;3
       STA    $AA     ;3
       LDX    $99     ;3
       LDA    LFD0F,X ;4
       STA    $90     ;3
       CPX    #$03    ;2
       BCS    LF5CC   ;2
       INC    $99     ;5
LF5CC: BIT    $98     ;3
       BMI    LF5DF   ;2
       JSR    LFEFA   ;6
       LDA    $AA     ;3
       AND    #$06    ;2
       BNE    LF5E5   ;2
       LDA    $AA     ;3
       ORA    #$01    ;2
       STA    $AA     ;3
LF5DF: LDA    #$40    ;2
       STA    $CA     ;3
       BNE    LF61F   ;2
LF5E5: BIT    $98     ;3
       BPL    LF5F7   ;2
       BIT    $A7     ;3
       BMI    LF60F   ;2
       LDA    $DB     ;3
       CMP    #$10    ;2
       BNE    LF60F   ;2
       LDA    #$00    ;2
       BEQ    LF628   ;2
LF5F7: LDA    $AA     ;3
       AND    #$01    ;2
       BEQ    LF622   ;2
       EOR    $AA     ;3
       STA    $AA     ;3
       LDA    #$50    ;2
       STA    $D9     ;3
       LDA    #$05    ;2
       STA    $C6     ;3
       LDA    $C9     ;3
       BNE    LF65C   ;2
       INC    $C9     ;5
LF60F: LDA    $E5     ;3
       ORA    #$80    ;2
       STA    $E5     ;3
       LDA    $C7     ;3
       BNE    LF622   ;2
       LDA    #$BF    ;2
       STA    $C7     ;3
       BPL    LF622   ;2
LF61F: JMP    LF689   ;3
LF622: LDA    $AA     ;3
       AND    #$06    ;2
       BEQ    LF668   ;2
LF628: ORA    #$01    ;2
       EOR    $AA     ;3
       STA    $AA     ;3
       LDA    #$23    ;2
       STA    $9C     ;3
       LDA    #$75    ;2
       STA    $9D     ;3
       LDA    $DB     ;3
       CMP    #$10    ;2
       BNE    LF65A   ;2
       BIT    $A7     ;3
       BMI    LF65A   ;2
       LDX    #$0A    ;2
LF642: LDY    $90,X   ;4
       LDA    $9F,X   ;4
       STA    $90,X   ;4
       STY    $9F,X   ;4
       DEX            ;2
       BPL    LF642   ;2
       JSR    LFF3A   ;6
       LDA    $AA     ;3
       EOR    #$40    ;2
       STA    $AA     ;3
       AND    #$40    ;2
       BNE    LF65C   ;2
LF65A: DEC    $C9     ;5
LF65C: LDA    #$40    ;2
       STA    $CA     ;3
       LDA    #$B4    ;2
       STA    $9E     ;3
       LDA    #$00    ;2
       STA    $CC     ;3
LF668: DEC    $C6     ;5
       BNE    LF689   ;2
       LDA    $91     ;3
       CMP    #$07    ;2
       BCC    LF689   ;2
       JSR    LFDFB   ;6
       AND    #$01    ;2
       EOR    $98     ;3
       STA    $98     ;3
       LSR            ;2
       LDA    #$98    ;2
       BCC    LF682   ;2
       LDA    #$00    ;2
LF682: STA    $9E     ;3
       LDA    #$04    ;2
       JSR    LFE8B   ;6
LF689: JMP    LF875   ;3
LF68C: LDA    $CA     ;3
       LSR            ;2
       BCS    LF694   ;2
       JMP    LF7DB   ;3
LF694: LDA    SWCHB   ;4
       AND    #$03    ;2
       CMP    #$02    ;2
       BNE    LF6A3   ;2
       JSR    LFEB2   ;6
       JMP    LF744   ;3
LF6A3: LDA    SWCHB   ;4
       AND    #$02    ;2
       BEQ    LF6B3   ;2
       LDA    $AA     ;3
       STA    $ED     ;3
       BMI    LF6EE   ;2
       JMP    LF747   ;3
LF6B3: LDA    #$B1    ;2
       STA    $C7     ;3
       BIT    $AA     ;3
       BMI    LF6C9   ;2
       LDA    $AA     ;3
       AND    #$B0    ;2
       ORA    #$80    ;2
       STA    $ED     ;3
       JSR    LFEC0   ;6
       JMP    LF744   ;3
LF6C9: INC    $ED     ;5
       LDA    $ED     ;3
       CMP    #$0F    ;2
       BCC    LF6EE   ;2
       LDA    SWCHB   ;4
       LSR            ;2
       LDA    #$0D    ;2
       BCC    LF6DB   ;2
       LDA    #$02    ;2
LF6DB: STA    $ED     ;3
       LDA    $98     ;3
       AND    #$F3    ;2
       STA    $98     ;3
       LDA    $DC     ;3
       CLC            ;2
       ADC    #$91    ;2
       BEQ    LF6EC   ;2
       ADC    #$70    ;2
LF6EC: STA    $DC     ;3
LF6EE: LDA    $AA     ;3
       ORA    #$80    ;2
       STA    $AA     ;3
       LDA    $DC     ;3
       LSR            ;2
       LSR            ;2
       LSR            ;2
       LSR            ;2
       STA    $EC     ;3
       TAY            ;2
       LDA    LFD4B,Y ;4
       STA    $DB     ;3
       LDA    $98     ;3
       AND    #$CF    ;2
       ORA    LFD52,Y ;4
       STA    $98     ;3
       LDA    #$AA    ;2
       STA    $E7     ;3
       LDA    #$A2    ;2
       STA    $E9     ;3
       LDY    #$00    ;2
       TYA            ;2
       SEC            ;2
       ADC    $DC     ;3
LF719: CMP    #$0A    ;2
       BCC    LF723   ;2
       INY            ;2
       SBC    #$0A    ;2
       JMP    LF719   ;3
LF723: ADC    LFD39,Y ;4
       STA    $E8     ;3
       LDA    $DC     ;3
       CMP    #$63    ;2
       LDA    #$AA    ;2
       BCC    LF732   ;2
       LDA    #$A1    ;2
LF732: STA    $E6     ;3
       LDA    $DC     ;3
       CMP    #$10    ;2
       BCS    LF73C   ;2
       DEC    $E9     ;5
LF73C: CMP    #$09    ;2
       BCS    LF744   ;2
       ADC    #$A1    ;2
       STA    $E8     ;3
LF744: JMP    LF875   ;3
LF747: LDA    $CA     ;3
       LSR            ;2
       BCS    LF74F   ;2
LF74C: JMP    LF7DB   ;3
LF74F: LDA    $C7     ;3
       BNE    LF74C   ;2
       BIT    $98     ;3
       BMI    LF769   ;2
       LDA    $AA     ;3
       AND    #$07    ;2
       BNE    LF769   ;2
       LDA    $DB     ;3
       AND    #$10    ;2
       BEQ    LF7BB   ;2
       LDA    $D5     ;3
       CMP    #$EC    ;2
       BCS    LF76C   ;2
LF769: JMP    LF7D8   ;3
LF76C: LDA    $DB     ;3
       CMP    #$14    ;2
       BEQ    LF77A   ;2
       CMP    #$90    ;2
       BNE    LF77F   ;2
       BIT    $AA     ;3
       BVC    LF79B   ;2
LF77A: BIT    PF0     ;3
       JMP    LF79D   ;3
LF77F: LDA    $DB     ;3
       BPL    LF78D   ;2
       DEC    $D9     ;5
       BNE    LF78D   ;2
       BIT    $AA     ;3
       BVC    LF79F   ;2
       BVS    LF7AB   ;2
LF78D: BIT    $AA     ;3
       BVS    LF7A7   ;2
       LDA    $DB     ;3
       AND    #$20    ;2
       BEQ    LF79B   ;2
       BIT    PF0     ;3
       BPL    LF79F   ;2
LF79B: BIT    REFP1   ;3
LF79D: BMI    LF7D8   ;2
LF79F: LDA    $98     ;3
       AND    #$FB    ;2
       LDX    #$00    ;2
       BPL    LF7B1   ;2
LF7A7: BIT    PF0     ;3
       BMI    LF7D8   ;2
LF7AB: LDX    #$01    ;2
       LDA    $98     ;3
       ORA    #$04    ;2
LF7B1: STA    $98     ;3
       LDY    #$00    ;2
       JSR    LFBAF   ;6
       JMP    LF7D8   ;3
LF7BB: LDY    #$01    ;2
LF7BD: LDX    #$01    ;2
       LDA    $98     ;3
       AND    LFCDE,Y ;4
       BNE    LF7C7   ;2
       DEX            ;2
LF7C7: LDA.wy $00D5,Y ;4
       CMP    #$EC    ;2
       BCC    LF7D5   ;2
       LDA    REFP1,X ;4
       BMI    LF7D5   ;2
       JSR    LFBAF   ;6
LF7D5: DEY            ;2
       BPL    LF7BD   ;2
LF7D8: JMP    LF875   ;3
LF7DB: LDA    $AA     ;3
       AND    #$07    ;2
       BNE    LF7D8   ;2
       TAY            ;2
       LDA    $91     ;3
       BEQ    LF7D8   ;2
       LDA    #$EB    ;2
       STA    $EE     ;3
       CMP    $D2     ;3
       BCS    LF7D8   ;2
       JSR    LFDFB   ;6
       BPL    LF80D   ;2
       AND    #$03    ;2
       ASL            ;2
       STA    $EE     ;3
       LDA    $EA     ;3
       LSR            ;2
       LSR            ;2
       TAX            ;2
LF7FD: TXA            ;2
       SEC            ;2
       ADC    $EE     ;3
       AND    #$07    ;2
       TAX            ;2
       LDA    LFCDC,X ;4
       AND    $EB     ;3
       BEQ    LF7FD   ;2
       BNE    LF83C   ;2
LF80D: LDA    $98     ;3
       AND    #$04    ;2
       BEQ    LF814   ;2
       INY            ;2
LF814: LDX    #$05    ;2
LF816: LDA    LFCDC,X ;4
       AND    $EB     ;3
       BEQ    LF82D   ;2
       LDA    $9A     ;3
       CLC            ;2
       ADC    #$FD    ;2
       CLC            ;2
       ADC    LFD39,X ;4
       CMP.wy $009C,Y ;4
       BCC    LF831   ;2
       STX    $EE     ;3
LF82D: DEX            ;2
       BPL    LF816   ;2
       INX            ;2
LF831: LDA    $EA     ;3
       AND    #$10    ;2
       BNE    LF83C   ;2
       LDA    $EE     ;3
       BMI    LF83C   ;2
       TAX            ;2
LF83C: STX    $EF     ;3
       LDA    LFCDC,X ;4
       STA    $F0     ;3
       LDX    #$FF    ;2
LF845: INX            ;2
       CPX    #$06    ;2
       BCS    LF875   ;2
       LDA    $92,X   ;4
       AND    $F0     ;3
       BEQ    LF845   ;2
       LDA    #$3C    ;2
       ADC    $90     ;3
       SBC    LFD31,X ;4
       STA    $D2     ;3
       SEC            ;2
       SBC    $D1     ;3
       CMP    #$10    ;2
       BCC    LF871   ;2
       CMP    #$F1    ;2
       BCS    LF871   ;2
       LDY    $EF     ;3
       LDA    $9A     ;3
       ADC    LFD39,Y ;4
       ADC    #$04    ;2
       STA    $D4     ;3
       BNE    LF875   ;2
LF871: LDA    #$F6    ;2
       STA    $D2     ;3
LF875: LDA    $AA     ;3
       AND    #$07    ;2
       BNE    LF8F5   ;2
       BIT    $98     ;3
       BMI    LF8F5   ;2
       LDY    #$FF    ;2
       LDA    $91     ;3
       BEQ    LF8F5   ;2
LF885: INY            ;2
       CMP    LFCE4,Y ;4
       BCC    LF885   ;2
       LDA    LFCF6,Y ;4
       STA    $EE     ;3
       LDA    LFCED,Y ;4
       STA    $EF     ;3
       LDA    $CA     ;3
       AND    #$3F    ;2
       STA    $F0     ;3
       CLC            ;2
       ADC    $EF     ;3
       CMP    #$41    ;2
       BCS    LF8F5   ;2
       LDA    $F0     ;3
LF8A4: BEQ    LF8AF   ;2
       CMP    $EF     ;3
       BCC    LF8F5   ;2
       SBC    $EF     ;3
       JMP    LF8A4   ;3
LF8AF: BIT    $8B     ;3
       LDA    #$09    ;2
       BVS    LF8B7   ;2
       LDA    #$FF    ;2
LF8B7: STA    $8B     ;3
       LDA    #$01    ;2
       JSR    LFE7E   ;6
       LDA    $98     ;3
       AND    #$02    ;2
       BEQ    LF8D3   ;2
       LDA    $9A     ;3
       CLC            ;2
       ADC    $EE     ;3
       STA    $9A     ;3
       CMP    $8D     ;3
       BCC    LF8F5   ;2
       LDA    $8D     ;3
       BNE    LF8E0   ;2
LF8D3: LDA    $9A     ;3
       SEC            ;2
       SBC    $EE     ;3
       STA    $9A     ;3
       CMP    #$17    ;2
       BCS    LF8F5   ;2
       LDA    #$17    ;2
LF8E0: STA    $9A     ;3
       LDA    $98     ;3
       EOR    #$02    ;2
       STA    $98     ;3
       BMI    LF8F5   ;2
       BIT    $AA     ;3
       BMI    LF8F5   ;2
       LDA    $90     ;3
       CLC            ;2
       ADC    #$05    ;2
       STA    $90     ;3
LF8F5: LDA    #$05    ;2
       STA    $8C     ;3
       LDA    #$0B    ;2
       SEC            ;2
       SBC    $90     ;3
       STA    $8E     ;3
       BIT    $98     ;3
       BVS    LF90B   ;2
       LDA    $8E     ;3
       CLC            ;2
       ADC    #$0C    ;2
       STA    $8E     ;3
LF90B: LDX    #$FB    ;2
LF90D: LDA    $97,X   ;4
       BNE    LF91D   ;2
       DEC    $8C     ;5
       LDA    $8E     ;3
       CLC            ;2
       ADC    #$09    ;2
       STA    $8E     ;3
       INX            ;2
       BNE    LF90D   ;2
LF91D: LDA    $8E     ;3
       BPL    LF952   ;2
       LDA    $98     ;3
       AND    #$40    ;2
       BEQ    LF934   ;2
       EOR    $98     ;3
       STA    $98     ;3
       LDA    $8E     ;3
       CLC            ;2
       ADC    #$0C    ;2
       STA    $8E     ;3
       BPL    LF952   ;2
LF934: LDA    #$00    ;2
       STA    $8E     ;3
       LDA    $98     ;3
       BMI    LF952   ;2
       ORA    #$80    ;2
       STA    $98     ;3
       LDY    $8C     ;3
       LDA    $90     ;3
       CLC            ;2
       ADC    LFFF2,Y ;4
       STA    $90     ;3
       JSR    LFE75   ;6
       LDA    #$06    ;2
       JSR    LFE7E   ;6
LF952: LDX    #$05    ;2
       LDA    #$00    ;2
LF956: ORA    $92,X   ;4
       DEX            ;2
       BPL    LF956   ;2
       STA    $EB     ;3
LF95D: LDA    $EB     ;3
       BEQ    LF98E   ;2
       LSR            ;2
       BCS    LF97C   ;2
       JSR    LFBED   ;6
       LDA    #$3A    ;2
       STA    $C8     ;3
       LDX    #$05    ;2
LF96D: LSR    $92,X   ;6
       DEX            ;2
       BPL    LF96D   ;2
       LDA    $9A     ;3
       ADC    #$10    ;2
       STA    $9A     ;3
       LSR    $EB     ;5
       BNE    LF95D   ;2
LF97C: LDX    #$06    ;2
LF97E: DEX            ;2
       LDA    LFCDC,X ;4
       AND    $EB     ;3
       BEQ    LF97E   ;2
       LDA    #$82    ;2
       SEC            ;2
       SBC    LFD39,X ;4
       STA    $8D     ;3
LF98E: LDA    $90     ;3
       STA    $8F     ;3
       LDX    #$04    ;2
LF994: LDA    $99,X   ;4
       JSR    LFD67   ;6
       DEX            ;2
       BNE    LF994   ;2
       LDA    SWCHB   ;4
       AND    #$08    ;2
       TAY            ;2
       BEQ    LF9A6   ;2
       LDA    #$F7    ;2
LF9A6: ORA    #$07    ;2
       STA    $EE     ;3
       LDX    #$F8    ;2
LF9AC: LDA    LFCFF,Y ;4
       EOR    $C7     ;3
       AND    $EE     ;3
       STA    $E5,X   ;4
       INY            ;2
       INX            ;2
       BMI    LF9AC   ;2
       BIT    $AA     ;3
       BMI    LF9C1   ;2
       LDA    $C7     ;3
       BNE    LF9D3   ;2
LF9C1: LDA    $C8     ;3
       AND    #$38    ;2
       CMP    #$30    ;2
       BNE    LF9D3   ;2
       LDA    $DC     ;3
       AND    #$08    ;2
       BEQ    LF9D3   ;2
       LDA    $E3     ;3
       STA    $E1     ;3
LF9D3: LDA    $DE     ;3
       STA    COLUP0  ;3
       LDA    $E3     ;3
       STA    COLUBK  ;3
       LDA    $E2     ;3
       STA    COLUPF  ;3
       LDA    $CA     ;3
       LSR            ;2
       LDX    #$04    ;2
       BCS    LF9E8   ;2
       LDX    #$00    ;2
LF9E8: STX    $EF     ;3
       LDA    $D1,X   ;4
       CMP    $D2,X   ;4
       BCC    LFA1B   ;2
       STA    $81     ;3
       LDA    $D2,X   ;4
       STA    $D1,X   ;4
       LDA    $81     ;3
       STA    $D2,X   ;4
       LDA    $D3,X   ;4
       STA    $81     ;3
       LDA    $D4,X   ;4
       STA    $D3,X   ;4
       LDA    $81     ;3
       STA    $D4,X   ;4
       LDA    $CA     ;3
       LSR            ;2
       BCC    LFA1B   ;2
       LDA    $98     ;3
       AND    #$0C    ;2
       LSR            ;2
       LSR            ;2
       TAY            ;2
       LDA    $98     ;3
       AND    #$F3    ;2
       ORA    LFD1A,Y ;4
       STA    $98     ;3
LFA1B: LDA    $D4,X   ;4
       LDX    #$05    ;2
       JSR    LFD67   ;6
       LDX    $EF     ;3
       LDA    $D1,X   ;4
       STA    $89     ;3
       LDA    $D2,X   ;4
       CMP    #$EC    ;2
       BCS    LFA31   ;2
       SEC            ;2
       SBC    $D1,X   ;4
LFA31: STA    $8A     ;3
       LDA    $D3,X   ;4
       LDX    #$00    ;2
       JSR    LFD67   ;6
       LDX    #$04    ;2
       JSR    LFD7E   ;6
       STA    WSYNC   ;3
       STA    HMOVE   ;3
LFA43: LDA    INTIM   ;4
       BNE    LFA43   ;2
       STA    VBLANK  ;3
       STA    CXCLR   ;3
       LDX    #$00    ;2
       LDA    #$EA    ;2
       STA    WSYNC   ;3
       STA    TIM64T  ;4
       STA    HMCLR   ;3
       BIT    $AA     ;3
       BMI    LFA64   ;2
       LDA    $9E     ;3
       CMP    #$B4    ;2
       BEQ    LFA64   ;2
       JMP    LFB0D   ;3
LFA64: LDX    #$07    ;2
       LDY    #$03    ;2
LFA68: LDA.wy $00E6,Y ;4
       AND    #$0F    ;2
       STA    $F0     ;3
       ASL            ;2
       ASL            ;2
       ADC    $F0     ;3
       ADC    #$54    ;2
       STA    $F0,X   ;4
       DEX            ;2
       LDA.wy $00E6,Y ;4
       LSR            ;2
       LSR            ;2
       LSR            ;2
       LSR            ;2
       STA    $F0     ;3
       ASL            ;2
       ASL            ;2
       ADC    $F0     ;3
       ADC    #$54    ;2
       STA    $F0,X   ;4
       DEX            ;2
       DEY            ;2
       BPL    LFA68   ;2
       STA    WSYNC   ;3
       LDA    $DF     ;3
       STA    COLUP0  ;3
       LDA    #$02    ;2
       STA    CTRLPF  ;3
       LDA    $E0     ;3
       STA    COLUP1  ;3
       LDA    #$04    ;2
       STA    $EE     ;3
       LDA    #$FF    ;2
       STA    $EF     ;3
       NOP            ;2
       NOP            ;2
       LDX    #$05    ;2
LFAA7: DEX            ;2
       BPL    LFAA7   ;2
LFAAA: LDY    $F0     ;3
       LDA    ($EE),Y ;5
       STA    PF0     ;3
       LDA    #$00    ;2
       STA    PF1     ;3
       LDY    $F5     ;3
       LDA    ($EE),Y ;5
       LSR            ;2
       LSR            ;2
       LSR            ;2
       LSR            ;2
       STA    PF2     ;3
       LDY    $F2     ;3
       LDA    ($EE),Y ;5
       STA    PF0     ;3
       LDY    $F7     ;3
       LDA    ($EE),Y ;5
       LSR            ;2
       LSR            ;2
       LSR            ;2
       LSR            ;2
       STA    PF2     ;3
       LDY    $F4     ;3
       LDA    ($EE),Y ;5
       AND    #$0F    ;2
       STA    $81     ;3
       LDY    $F1     ;3
       LDA    ($EE),Y ;5
       ASL            ;2
       ASL            ;2
       ASL            ;2
       ASL            ;2
       ORA    $81     ;3
       STA    PF1     ;3
       LDA    #$00    ;2
       STA    PF0     ;3
       STA    PF2     ;3
       LDY    $F6     ;3
       LDA    ($EE),Y ;5
       AND    #$0F    ;2
       STA    $81     ;3
       LDY    $F3     ;3
       LDA    ($EE),Y ;5
       ASL            ;2
       ASL            ;2
       ASL            ;2
       ASL            ;2
       ORA    $81     ;3
       STA    PF1     ;3
       DEC    $EE     ;5
       BPL    LFAAA   ;2
       LDA    $89     ;3
       CLC            ;2
       ADC    #$F9    ;2
       STA    $89     ;3
       LDA    #$00    ;2
       STA    PF1     ;3
       BEQ    LFB55   ;2
LFB0D: JSR    LFD67   ;6
       JSR    LFD7E   ;6
       JSR    LFDE9   ;6
       LDA    #$A0    ;2
       STA    $EE     ;3
       LDA    #$FC    ;2
       STA    $EF     ;3
       LDA    #$00    ;2
       STA    NUSIZ0  ;3
       STA    WSYNC   ;3
       STA    HMOVE   ;3
       LDA    $C8     ;3
       AND    #$39    ;2
       CMP    #$39    ;2
       BNE    LFB3C   ;2
       LDA    $C8     ;3
       ROL            ;2
       ROL            ;2
       ROL            ;2
       ROL            ;2
       AND    #$03    ;2
       TAY            ;2
       LDA    LFD1E,Y ;4
       STA    $EE     ;3
LFB3C: STA    WSYNC   ;3
       STA    HMCLR   ;3
       JSR    LFDE9   ;6
       LDY    #$09    ;2
LFB45: STA    WSYNC   ;3
       LDA    ($EE),Y ;5
       STA    GRP0    ;3
       TYA            ;2
       LSR            ;2
       BCS    LFB52   ;2
       JSR    LFDE9   ;6
LFB52: DEY            ;2
       BPL    LFB45   ;2
LFB55: LDA    #$00    ;2
       STA    WSYNC   ;3
       STA    GRP0    ;3
       LDA    $84     ;3
       STA    HMP1    ;3
       STA    HMP0    ;3
       AND    #$0F    ;2
       TAY            ;2
LFB64: DEY            ;2
       BPL    LFB64   ;2
       STA    RESP0   ;3
       LDA    #$06    ;2
       STA    RESP1   ;3
       STA    WSYNC   ;3
       STA    HMOVE   ;3
       STA    NUSIZ0  ;3
       STA    NUSIZ1  ;3
       LDX    #$0A    ;2
       LDA    #$FC    ;2
LFB79: STA    $EF,X   ;4
       DEX            ;2
       DEX            ;2
       BPL    LFB79   ;2
       JSR    LFDE9   ;6
       LDA    WSYNC   ;3
       AND    #$40    ;2
       STA    $82     ;3
       STA    CXCLR   ;3
       STA    HMCLR   ;3
       LDA    #$F0    ;2
       STA    HMP1    ;3
       STA    WSYNC   ;3
       STA    HMOVE   ;3
       LDA    $E1     ;3
       STA    COLUP0  ;3
       STA    COLUP1  ;3
LFB9A: DEC    $8F     ;5
       BPL    LFBA9   ;2
       LDY    #$05    ;2
       LDA    #$01    ;2
       STA    VDELP0  ;3
       STA    VDELP1  ;3
       JMP    LF0A5   ;3
LFBA9: JSR    LFDB2   ;6
       JMP    LFB9A   ;3
LFBAF: STX    $F2     ;3
       LDX    LFD38,Y ;4
       LDA    $D5,X   ;4
       CMP    #$56    ;2
       BCS    LFBBE   ;2
       CMP    #$45    ;2
       BCS    LFBEC   ;2
LFBBE: LDX    $F2     ;3
       LDA    #$55    ;2
       STA.wy $00D5,Y ;5
       LDA    LFCE2,X ;4
       AND    SWCHB   ;4
       CLC            ;2
       BEQ    LFBD0   ;2
       LDA    #$04    ;2
LFBD0: ADC    #$05    ;2
       ADC    $9C,X   ;4
       STA.wy $00D7,Y ;5
       LDA    #$03    ;2
       JSR    LFE8B   ;6
       LDA    $DB     ;3
       AND    #$80    ;2
       BEQ    LFBEC   ;2
       LDA    $AA     ;3
       EOR    #$40    ;2
       STA    $AA     ;3
       LDA    #$50    ;2
       STA    $D9     ;3
LFBEC: RTS            ;6

LFBED: LDA    $C8     ;3
       AND    #$39    ;2
LFBF1: CMP    #$39    ;2
       BNE    LFBFD   ;2
       LDA    #$B4    ;2
       STA    $9E     ;3
       LDA    #$00    ;2
       STA    $CC     ;3
LFBFD: RTS            ;6

LFBFE: .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$FE,$FE,$7C,$FE
       .byte $38,$38,$7C,$38,$38,$10,$B6,$BE,$5D,$6B,$59,$63,$3C,$4C,$14,$28
       .byte $B6,$BE,$5D,$5B,$24,$85,$66,$64,$28,$10,$90,$88,$88,$44,$42,$42
       .byte $FF,$DB,$5A,$18,$09,$11,$11,$22,$42,$42,$FF,$DB,$7E,$18,$A5,$A5
       .byte $A5,$99,$99,$A5,$FF,$5A,$7E,$3C,$42,$5A,$5A,$5A,$99,$A5,$FF,$5A
       .byte $7E,$3C,$C3,$24,$18,$18,$18,$5A,$BD,$A5,$81,$81,$24,$42,$24,$A5
       .byte $99,$99,$BD,$5A,$18,$00,$81,$42,$42,$24,$24,$3C,$7E,$EB,$7E,$3C
       .byte $00,$24,$5A,$42,$24,$3C,$7E,$D7,$7E,$3C,$77,$44,$44,$44,$5C,$FF
       .byte $F3,$F3,$7E,$3C,$EE,$22,$22,$22,$3A,$FF,$CF,$CF,$7E,$3C,$E7,$42
       .byte $7E,$7E,$6B,$3E,$98,$A4,$42,$01,$C6,$42,$7E,$7E,$56,$7C,$19,$25
       .byte $42,$80,$00,$38,$7C,$FE,$FE,$AA,$FE,$7C,$38,$00,$00,$00,$00,$24
       .byte $3C,$76,$5C,$28,$00,$00,$00,$00,$00,$01,$24,$95,$48,$C7,$24,$90
       .byte $20,$40,$5D,$BB,$B6,$77,$CC,$2D,$7E,$CD,$DA,$6D,$77,$77,$82,$54
       .byte $25,$53,$C3,$54,$93,$A5,$99,$81
LFCD6: .byte $28,$78,$64,$50,$3C,$8C
LFCDC: .byte $01,$02
LFCDE: .byte $04,$08,$10,$20
LFCE2: .byte $40,$80
LFCE4: .byte $22,$16,$0C,$08,$05,$04,$03,$02,$00
LFCED: .byte $20,$20,$15,$15,$10,$0B,$07,$07,$04
LFCF6: .byte $01,$01,$02,$02,$03,$03,$03,$04,$05
;LFCFF: .byte $0F,$0E,$0F,$00,$02,$00,$04,$02,$34,$52,$CC,$F6,$14,$0F,$00,$E2 ; NTSC colours
LFCFF: .byte $0F,$0E,$0F,$00,$02,$00,$04,$02,$42,$82,$5C,$F6,$24,$0F,$00,$32 ; PAL colours for PAL60
LFD0F: .byte $05,$0A,$0F,$14
LFD13: .byte $BD,$B4,$AB
LFD16: .byte $54,$59,$5E,$63
LFD1A: .byte $00,$08,$04,$0C
LFD1E: .byte $AA,$B6,$C0,$CC
LFD22: .byte $3C,$7E,$7E,$7E,$7E,$FF,$FF,$FF,$C3
LFD2B: .byte $05,$10,$15,$20,$25,$30
LFD31: .byte $00,$09,$12,$1B,$24,$2D,$36
LFD38: .byte $01
LFD39: .byte $00,$10,$20,$30,$40,$50,$60,$70,$80,$90,$00
LFD44: .byte $10,$8B,$D1,$BF,$9D,$D1,$D1
LFD4B: .byte $18,$10,$61,$D1,$32,$90,$14
LFD52: .byte $10,$10,$30,$30,$10,$10,$10
LFD59: .byte $00,$00,$08,$00,$00,$00,$00
LFD60: .byte $05
LFD61: .byte $03,$17,$2B,$23,$75,$B4
LFD67: LDY    #$FF    ;2
       SEC            ;2
LFD6A: INY            ;2
       SBC    #$0F    ;2
       BCS    LFD6A   ;2
       EOR    #$FF    ;2
       SBC    #$06    ;2
       ASL            ;2
       ASL            ;2
       ASL            ;2
       ASL            ;2
       STY    $83,X   ;4
       ORA    $83,X   ;4
       STA    $83,X   ;4
       RTS            ;6

LFD7E: STA    WSYNC   ;3
       NOP            ;2
       INY            ;2
       STA    HMP0,X  ;4
       NOP            ;2
LFD85: DEY            ;2
       BPL    LFD85   ;2
       STA    RESP0,X ;4
       RTS            ;6

LFD8B: CPY    #$09    ;2
       BCS    LFDB1   ;2
LFD8F: STX    $EE     ;3
       INX            ;2
       JSR    LFDFB   ;6
       AND    #$20    ;2
       BNE    LFD9B   ;2
       DEX            ;2
       DEX            ;2
LFD9B: CPX    #$08    ;2
       BCS    LFDA8   ;2
       LDA    $EA     ;3
       CMP    #$C0    ;2
       BCC    LFDA8   ;2
       JSR    LFDAA   ;6
LFDA8: LDX    $EE     ;3
LFDAA: LDA    ($F0),Y ;5
       AND    LFF4C,X ;4
       STA    ($F0),Y ;6
LFDB1: RTS            ;6

LFDB2: DEC    $89     ;5
       LDA    $89     ;3
       BMI    LFDC7   ;2
       CMP    #$04    ;2
       LDA    #$02    ;2
       BCC    LFDBF   ;2
       LSR            ;2
LFDBF: STA    ENABL   ;3
       STA    WSYNC   ;3
       STA    HMCLR   ;3
       BPL    LFDE4   ;2
LFDC7: CLC            ;2
       ADC    $8A     ;3
       STA    $89     ;3
       LDA    #$00    ;2
       STA    WSYNC   ;3
       STA    HMCLR   ;3
       STA    ENABL   ;3
       LDA    $88     ;3
       STA    HMBL    ;3
       AND    #$0F    ;2
       TAY            ;2
LFDDB: DEY            ;2
       BPL    LFDDB   ;2
       STA    RESBL   ;3
       LDA    #$7C    ;2
       STA    $8A     ;3
LFDE4: STA    WSYNC   ;3
       STA    HMOVE   ;3
       RTS            ;6

LFDE9: DEC    $89     ;5
       LDA    $89     ;3
       CMP    #$04    ;2
       BCC    LFDF5   ;2
       LDA    #$00    ;2
       BCS    LFDF8   ;2
LFDF5: NOP            ;2
       LDA    #$02    ;2
LFDF8: STA    ENABL   ;3
       RTS            ;6

LFDFB: LDA    $EA     ;3
       ASL            ;2
       ASL            ;2
       CLC            ;2
       ADC    $EA     ;3
       CLC            ;2
       ADC    #$59    ;2
       STA    $EA     ;3
       RTS            ;6

LFE08: LDA    $C7     ;3
       BNE    LFE68   ;2
       INC    $CD,X   ;6
       LDY    $CB,X   ;4
       BEQ    LFE68   ;2
       CPY    #$05    ;2
       BEQ    LFE1A   ;2
       CPY    #$02    ;2
       BNE    LFE3E   ;2
LFE1A: LDY    $CD,X   ;4
       CPY    #$08    ;2
       BNE    LFE28   ;2
       LDA    $CB,X   ;4
       CMP    #$05    ;2
       BEQ    LFE6C   ;2
       BNE    LFE68   ;2
LFE28: LDA    LFFEA,Y ;4
       STA    AUDF0,X ;4
       LDA    #$0C    ;2
       STA    AUDC0,X ;4
       LDA    #$CB    ;2
       CMP    #$05    ;2
       LDA    #$04    ;2
       BCC    LFE3B   ;2
       LDA    #$08    ;2
LFE3B: STA    AUDV0,X ;4
       RTS            ;6

LFE3E: LDA    LFD44,Y ;4
       STA    $EE     ;3
       LDA    #$FF    ;2
       STA    $EF     ;3
       LDY    $CF,X   ;4
       LDA    ($EE),Y ;5
       CMP    $CD,X   ;4
       BNE    LFE67   ;2
       INY            ;2
       LDA    ($EE),Y ;5
       BMI    LFE68   ;2
       CMP    #$3F    ;2
       BEQ    LFE6C   ;2
       STA    AUDF0,X ;4
       INY            ;2
       LDA    ($EE),Y ;5
       STA    AUDC0,X ;4
       INY            ;2
       LDA    ($EE),Y ;5
       INY            ;2
       STY    $CF,X   ;4
       STA    AUDV0,X ;4
LFE67: RTS            ;6

LFE68: LDA    #$00    ;2
       STA    $CB,X   ;4
LFE6C: LDA    #$00    ;2
       STA    AUDV0,X ;4
       STA    $CD,X   ;4
       STA    $CF,X   ;4
       RTS            ;6

LFE75: LDA    $CA     ;3
       AND    #$01    ;2
       ORA    #$80    ;2
       STA    $CA     ;3
       RTS            ;6

LFE7E: CMP    $CB     ;3
       BCC    LFE8A   ;2
       STA    $CB     ;3
       LDA    #$00    ;2
       STA    $CD     ;3
       STA    $CF     ;3
LFE8A: RTS            ;6

LFE8B: CMP    $CC     ;3
       BCC    LFE97   ;2
       STA    $CC     ;3
       LDA    #$00    ;2
       STA    $CE     ;3
       STA    $D0     ;3
LFE97: RTS            ;6


START:
       CLD            ;2
       SEI            ;2
       LDX    #$00    ;2
       TXA            ;2
LFE9D: STA    VSYNC,X ;4
       INX            ;2
       BNE    LFE9D   ;2
       DEX            ;2
       TXS            ;2
       JSR    LFEB2   ;6
       LDA    #$C5    ;2
       STA    $C7     ;3
       LDA    #$80    ;2
       STA    $AA     ;3
       JMP    LF4D4   ;3
LFEB2: LDA    #$00    ;2
       STA    $E6     ;3
       STA    $E8     ;3
       STA    $E7     ;3
       STA    $E9     ;3
       STA    $C7     ;3
       LDA    #$01    ;2
LFEC0: STA    $AA     ;3
       LDA    #$00    ;2
       STA    $90     ;3
       STA    $99     ;3
       STA    $C6     ;3
       JSR    LFE75   ;6
       LDA    #$03    ;2
       STA    $C9     ;3
       LDA    #$FF    ;2
       STA    $8B     ;3
       LDA    $98     ;3
       AND    #$53    ;2
       LDY    $EC     ;3
       ORA    LFD52,Y ;4
       ORA    LFD59,Y ;4
       STA    $98     ;3
       LDA    $E5     ;3
       AND    #$7F    ;2
       STA    $E5     ;3
       JSR    LFEFA   ;6
       LDX    #$0A    ;2
LFEEE: LDA    $90,X   ;4
       STA    $9F,X   ;4
       DEX            ;2
       BPL    LFEEE   ;2
       LDA    #$6E    ;2
       STA    $A7     ;3
       RTS            ;6

LFEFA: LDX    #$05    ;2
       LDA    #$3F    ;2
LFEFE: STA    $92,X   ;4
       DEX            ;2
       BPL    LFEFE   ;2
       STA    $EB     ;3
       STA    $D7     ;3
       STA    $D8     ;3
       STA    $D3     ;3
       STA    $D4     ;3
       LDA    #$F6    ;2
       STA    $D5     ;3
       STA    $D6     ;3
       STA    $D1     ;3
       STA    $D2     ;3
       LDX    #$05    ;2
LFF19: LDA    LFD61,X ;4
       STA    $99,X   ;4
       DEX            ;2
       BNE    LFF19   ;2
       TXA            ;2
       STA    $CB     ;3
       STA    $CC     ;3
       LDA    #$24    ;2
       STA    $91     ;3
       LDA    #$42    ;2
       ORA    $98     ;3
       STA    $98     ;3
       LDA    #$30    ;2
       STA    $C8     ;3
       LDA    $AA     ;3
       AND    #$F7    ;2
       STA    $AA     ;3
LFF3A: LDX    #$1A    ;2
       LDY    #$08    ;2
LFF3E: LDA    LFD22,Y ;4
       STA    $AB,X   ;4
       DEY            ;2
       BPL    LFF48   ;2
       LDY    #$08    ;2
LFF48: DEX            ;2
       BPL    LFF3E   ;2
       RTS            ;6

LFF4C: .byte $7F,$BF,$DF,$EF,$F7,$FB,$FD,$FE,$E7,$A5,$A5,$A5,$E7,$E7,$42,$42
       .byte $66,$42,$E7,$24,$E7,$81,$E7,$E7,$81,$E7,$81,$E7,$81,$81,$E7,$A5
       .byte $A5,$E7,$81,$E7,$24,$E7,$E7,$A5,$E7,$24,$24,$81,$81,$81,$81,$E7
       .byte $E7,$A5,$E7,$A5,$E7,$81,$81,$E7,$A5,$E7,$00,$00,$00,$00,$00,$01
       .byte $16,$09,$0A,$02,$19,$08,$0A,$03,$1F,$0C,$08,$04,$16,$0E,$07,$06
       .byte $FF,$01,$18,$0C,$03,$03,$16,$0C,$03,$05,$14,$0C,$03,$07,$12,$0C
       .byte $03,$09,$10,$0C,$03,$0B,$0E,$0C,$03,$0D,$0D,$0C,$03,$0F,$10,$0C
       .byte $03,$11,$3F,$01,$18,$08,$07,$04,$19,$08,$05,$10,$1C,$08,$02,$30
       .byte $1E,$08,$01,$50,$FF,$01,$18,$03,$0C,$09,$10,$0A,$08,$11,$12,$0E
       .byte $0F,$19,$16,$0E,$08,$29,$1A,$0E,$04,$39,$1D,$0E,$02,$49
LFFEA: .byte $FF,$10,$0D,$0A,$08,$07,$06,$05
LFFF2: .byte $06,$07,$03,$04,$05,$06,$00,$00,$98,$FE,$98,$FE,$98,$FE
