on_int
        ld (on_int_hl),hl
        pop hl
        ld (on_int_jp),hl
        ld (on_int_sp),sp
        ld sp,intstack
        push af
        push bc
        push de
        ld hl,(on_int_sp)
        dec hl
        dec hl ;hl=spoiled stack addr
        ld a,h
        sub tilemap/256
        cp ((TILEMAPHGT+7)/8)*2
        jp nc,on_int_norestoretilemap
        ld a,l
       cpl 
        and 0x1f
        jr z,on_int_restoretilemapeol
;restore tilemap flags (pessimistic)
        ld (hl),FLAG_DRAWTILE
        inc l
        ld (hl),FLAG_DRAWTILE
;TODO if in show (how to tell? CY changes in procedures!!!):
;call drawleftandrighttiles (of they will show random) ;can hide a part of sprite if in show
        inc h
on_int_tilegfx=$+1
        ld b,tilegfx/256
        call drawleftandrighttiles_hl
        jp on_int_restoreq
on_int_restoretilemapeol
;restore tilemap eol
        INITEOL ;TODO fast by table, or else call initeol
        jp on_int_restoreq
on_int_norestoretilemap
        ld a,h
        cp sprites/256
        jp c,on_int_restoreq
        xor a
        ld (hl),a
        inc hl
        ld (hl),a
        ex de,hl
;restore sprites
        ld l,e
        ld h,sprites/256
        ld a,(hl)
        dup SPRMEMSIZE/256
        inc h
        xor (hl)
        edup
        ld (de),a
        dec de
        ld l,e
        ld a,(hl)
        dup SPRMEMSIZE/256
        dec h
        xor (hl)
        edup
        ld (de),a
on_int_restoreq
        ld hl,timer
        inc (hl)
        
        pop de
        pop bc
        pop af
on_int_sp=$+1
        ld sp,0
on_int_hl=$+1
        ld hl,0
        ei
on_int_jp=$+1
        jp 0
        
timer
        db 0
        
imerend=imer+3
