Setting up the interrupts:
;set up interrupt vector table from $9900 to $9A00 to always go to $9A9A
ld hl, $9900
ld b, 0
ld d, $9A
IvtLoop:
ld (hl), d
inc hl
djnz IvtLoop
ld (hl), d
;disable all other interrupts
ld a, %01000
out ($03), a
ld a, $99
ld i, a
im 2
ei
Cleanup:
di
;turn off timers
ld a, 0
out ($30), a
out ($31), a
out ($32), a
out ($33), a
out ($34), a
out ($35), a
out ($36), a
out ($37), a
out ($38), a
;restore regular interrupts
ld a, 0
out ($03), a
ld a, $0B
out ($03), a
;set LCD to row auto increment
ld a, $05
call LCD_BUSY_QUICK
out ($10), a
;set CPU to 6MHz
ld a, 0
out ($20), a
;statVars was used to store code, so it needs to be invalidated
b_call _DelRes
;enable auto power down
set apdAble,(IY+apdFlags)
im 1
ei
bjump(_JForceCmdNoChar)
EDIT: Tried thepenguin77's code, and it looks like interrupts are not the problem.