irq_line1  = $45   ;before shortened screen / multiplex logo1

irq_line2  = $47   ;start black line 1
irq_line3  = $49   ;end black line 1

irq_line4  = $76   ;multiplex logo2

irq_line5  = $a0   ;multiplex logo3

irq_line6  = $ca   ;multiplex scrolltext

irq_line7  = $d1   ;end black line 2

irq_line8  = $e6   ;start black line 3
irq_line9  = $e8   ;end black line 3

irq_line10 = $ea   ;after shortened screen

;!align 256,0,0
!zone irq1
irq1:
        sta .atemp+1
        lsr $d019    ;as stated earlier this might fail only on exotic HW like c65 etc.
                     ;lda #$ff sta $d019 is equally fast, but uses two more bytes and
                     ;trashes A

        ;!fi 9, $ea ;NOP
        cmp (0,x) ; waste 6 cycles (2 bytes)
        cmp (0,x) ; waste 6 cycles (2 bytes)
        cmp (0,x) ; waste 6 cycles (2 bytes)
        cmp (0,x) ; waste 6 cycles (2 bytes)
        nop       ; waste 2 cycles (1 bytes)
        
        jsr switch_on_screen
        
        lda #irq_line2   ;this is how to tell at which rasterline we want the irq to be triggered
        sta $d012
        lda #<irq2  ;this is how we set up
        sta $fffe  ;the address of our interrupt code
        lda #>irq2
        sta $ffff

.atemp
        lda #$00
        rti

!zone irq2
irq2:
        sta .atemp+1
        lsr $d019    ;as stated earlier this might fail only on exotic HW like c65 etc.
                     ;lda #$ff sta $d019 is equally fast, but uses two more bytes and
                     ;trashes A

        ;!fi 9, $ea ;NOP
        cmp (0,x) ; waste 6 cycles (2 bytes)
        cmp (0,x) ; waste 6 cycles (2 bytes)
        cmp (0,x) ; waste 6 cycles (2 bytes)
        cmp (0,x) ; waste 6 cycles (2 bytes)
        nop       ; waste 2 cycles (1 bytes)
        
        jsr switch_off_screen
        
        lda #irq_line3   ;this is how to tell at which rasterline we want the irq to be triggered
        sta $d012
        lda #<irq3  ;this is how we set up
        sta $fffe  ;the address of our interrupt code
        lda #>irq3
        sta $ffff

.atemp
        lda #$00
        rti

!zone irq3
irq3:
        sta .atemp+1
        lsr $d019    ;as stated earlier this might fail only on exotic HW like c65 etc.
                     ;lda #$ff sta $d019 is equally fast, but uses two more bytes and
                     ;trashes A

        ;!fi 9, $ea ;NOP
        cmp (0,x) ; waste 6 cycles (2 bytes)
        cmp (0,x) ; waste 6 cycles (2 bytes)
        cmp (0,x) ; waste 6 cycles (2 bytes)
        cmp (0,x) ; waste 6 cycles (2 bytes)
        nop       ; waste 2 cycles (1 bytes)
        
        jsr switch_on_screen
        
        lda #irq_line4   ;this is how to tell at which rasterline we want the irq to be triggered
        sta $d012
        lda #<irq4  ;this is how we set up
        sta $fffe  ;the address of our interrupt code
        lda #>irq4
        sta $ffff

.atemp
        lda #$00
        rti
      
!zone irq4
irq4:
        sta .atemp+1
        stx .xtemp+1
        sty .ytemp+1
        
        lsr $d019    ;as stated earlier this might fail only on exotic HW like c65 etc.
                     ;lda #$ff sta $d019 is equally fast, but uses two more bytes and
                     ;trashes A
        jsr logo_set_line2

        SYSTEM_TYPE= *+1
        lda #$00
        cmp #$03
        beq +
        dec ntsc_frameskip
        bne +
        lda #$07
        sta ntsc_frameskip
        jmp ++
+       
        lax #$00
        tay
        jsr sidplay
++            
        ldy #irq_line5   ;this is how to tell at which rasterline we want the irq to be triggered
        sty $d012
        ldy #<irq5  ;this is how we set up
        sty $fffe  ;the address of our interrupt code
        ldy #>irq5
        sty $ffff

.atemp
        lda #$00
.xtemp:
        ldx #$00
.ytemp:
        ldy #$00
        rti
      
!zone irq5
irq5:
        sta .atemp+1
        stx .xtemp+1
        sty .ytemp+1
        
        lsr $d019    ;as stated earlier this might fail only on exotic HW like c65 etc.
                     ;lda #$ff sta $d019 is equally fast, but uses two more bytes and
                     ;trashes A
        jsr logo_set_line3

        lda please_copy_logo_flag
        cmp #$01
        bne +
        lda #$02
        sta worker_flag
+              
        ldy #irq_line6   ;this is how to tell at which rasterline we want the irq to be triggered
        sty $d012
        ldy #<irq6  ;this is how we set up
        sty $fffe  ;the address of our interrupt code
        ldy #>irq6
        sty $ffff

.atemp
        lda #$00
.xtemp:
        ldx #$00
.ytemp:
        ldy #$00
        rti
      
!zone irq6
irq6:
        sta .atemp+1
        stx .xtemp+1
        sty .ytemp+1
        
        lsr $d019    ;as stated earlier this might fail only on exotic HW like c65 etc.
                     ;lda #$ff sta $d019 is equally fast, but uses two more bytes and
                     ;trashes A
        jsr scroller_reinit_sprites
        ;!fi 6, $ea ;NOP          
        jsr switch_off_screen

        ;set ECM background colors
        lda #$01
        sta $d021
        lda #$0b
        sta $d022
        lda #$0c
        sta $d023
        lda #$0f
        sta $d024   

        lda #irq_line7   ;this is how to tell at which rasterline we want the irq to be triggered
        sta $d012
        lda #<irq7  ;this is how we set up
        sta $fffe  ;the address of our interrupt code
        lda #>irq7
        sta $ffff

.atemp
        lda #$00
.xtemp:
        ldx #$00
.ytemp:
        ldy #$00
        rti

!zone irq7
irq7:
        sta .atemp+1
        lsr $d019    ;as stated earlier this might fail only on exotic HW like c65 etc.
                     ;lda #$ff sta $d019 is equally fast, but uses two more bytes and
                     ;trashes A
        ;!fi 10, $ea ;NOP  
        cmp (0,x) ; waste 6 cycles (2 bytes)
;        cmp (0,x) ; waste 6 cycles (2 bytes)
ntsc_sprite_rasterbar_patch:                
        bit 3     ; waste 3 cycles (2 bytes)
        nop       ; waste 2 cycles (1 bytes)
        nop       ; waste 2 cycles (1 bytes)
        nop       ; waste 2 cycles (1 bytes)
        nop       ; waste 2 cycles (1 bytes)
        nop       ; waste 2 cycles (1 bytes)
        nop       ; waste 2 cycles (1 bytes)
        
        jsr switch_on_screen
        lda #irq_line8   ;this is how to tell at which rasterline we want the irq to be triggered
        sta $d012
        lda #<irq8  ;this is how we set up
        sta $fffe  ;the address of our interrupt code
        lda #>irq8
        sta $ffff

.atemp
        lda #$00
        rti
      
!zone irq8
irq8:
        sta .atemp+1
        lsr $d019    ;as stated earlier this might fail only on exotic HW like c65 etc.
                     ;lda #$ff sta $d019 is equally fast, but uses two more bytes and
                     ;trashes A

        ;!fi 10, $ea ;NOP    
        cmp (0,x) ; waste 6 cycles (2 bytes)
        cmp (0,x) ; waste 6 cycles (2 bytes)
        cmp (0,x) ; waste 6 cycles (2 bytes)
        nop       ; waste 2 cycles (2 bytes)
        
        jsr switch_off_screen

        ;set ECM background colors
        lda #$07 ;yellow
        sta $d021
        lda #$02 ;red
        sta $d022
        lda #$06 ;blue
        sta $d023
        lda #$03 ;cyan
        sta $d024   
        
        lda #irq_line9   ;this is how to tell at which rasterline we want the irq to be triggered
        sta $d012
        lda #<irq9  ;this is how we set up
        sta $fffe  ;the address of our interrupt code
        lda #>irq9
        sta $ffff

.atemp
        lda #$00
        rti

!zone irq9
irq9:
        sta .atemp+1
        lsr $d019    ;as stated earlier this might fail only on exotic HW like c65 etc.
                     ;lda #$ff sta $d019 is equally fast, but uses two more bytes and
                     ;trashes A

        ;!fi 14, $ea ;NOP
        cmp (0,x) ; waste 6 cycles (2 bytes)
        cmp (0,x) ; waste 6 cycles (2 bytes)
        cmp (0,x) ; waste 6 cycles (2 bytes)
        cmp (0,x) ; waste 6 cycles (2 bytes)
        nop       ; waste 2 cycles (2 bytes)
        nop       ; waste 2 cycles (2 bytes)
        
        jsr switch_on_screen
        
        lda #irq_line10   ;this is how to tell at which rasterline we want the irq to be triggered
        sta $d012
        lda #<irq10  ;this is how we set up
        sta $fffe  ;the address of our interrupt code
        lda #>irq10
        sta $ffff

.atemp
        lda #$00
        rti

!zone irq10
irq10:
        sta .atemp+1
        stx .xtemp+1
        sty .ytemp+1

        lsr $d019    ;as stated earlier this might fail only on exotic HW like c65 etc.
                     ;lda #$ff sta $d019 is equally fast, but uses two more bytes and
                     ;trashes A

        ;!fi 9, $ea ;NOP
        cmp (0,x) ; waste 6 cycles (2 bytes)
        cmp (0,x) ; waste 6 cycles (2 bytes)
        cmp (0,x) ; waste 6 cycles (2 bytes)
        
        jsr switch_off_screen
        
;        lda #$01 ;enable turbo c128/chameleon
;        sta $d030
        
        jsr hardscroll_screen
        jsr shift_colors
        jsr sprite_logo_sinus_move
        ;jsr black_out
        jsr logo_reinit_sprites
        jsr scroll_sprite_text
        jsr checkkey
        
        lda wait_worker
        cmp #$00
        beq +
        dec wait_worker
+        
        lda #irq_line1   ;this is how to tell at which rasterline we want the irq to be triggered
        sta $d012
        lda #<irq1  ;this is how we set up
        sta $fffe  ;the address of our interrupt code
        lda #>irq1
        sta $ffff

.atemp
        lda #$00
.xtemp:
        ldx #$00
.ytemp:
        ldy #$00
        rti
