RESET               = $FCE2
!zone check_key
.keydown:
!byte $00       ;byte of keydown

checkkey:
        lda $dc01
        cmp .keydown
        bne .newkey
        lda #$ff      ;returns $ff in no change
        jmp .no_key
.newkey:
        sta .keydown
        cmp #$ef      ;new key is spacebar
        beq .key_space
.no_key:
        rts
        
.key_space:
reset_in_irq:

        jsr switch_off_screen

        lax #$00
        tay
;        lda #%00000000
        sta VIC_SPRITE_SWITCH

        jsr sidinit
        
          
        asl $d019   ;Ack all IRQ's
        lda $dc0d
        lda $dd0d        
        lda #$81    ;reset CIA 1 IRQ

-  
      addr1=*+1   
        lda $e000   ;restore memory
      addr2=*+1  
        sta $2800
        
        inc addr1
        inc addr2
        bne -
        inc addr1+1
        inc addr2+1

        lda addr2+1
        cmp #$43
        bne -
  
        ldx #$00    ;remove raster IRQ
        ldy #$37    ;reset MMU to roms
        sta $dc0d
        stx $d01a
        sty $01
        ldx #$ff    ;clear the stack
        txs
        cli         ;reenable IRQ's

        jmp *

