I'm trying to make the main loop of my program run at 30Hz. Here is how I set up timer 1 at the beginning of my app:
;set timer 1 to not loop, not interrupt
ld a, $00
out ($31), a
;set timer 1 to 993Hz
ld a, $41
out ($30), a
;set timer 1 count down from 33 for effective framerate of ~30Hz
ld a, 33
out ($32), a
And at the beginning of my loop (which is copied to appBackupScreen), I have this:
in a, ($32)
cp 0
jp nz, appBackupScreen
ld a, 33
out ($32), a
ld a, $00
out ($31), a
;rest of code goes here
I'm pretty sure what I am doing is setting the timer to 993Hz, disabling repeats and interrupts, and at the beginning of the loop polling the timer until it is zero, then continuing with the rest of the code. However, it gets stuck in the polling loop. According to Wabbitemu's debugger, register A has a value of 33 (decimal), indicating the timer is not counting down. If I jump over the polling loop in my code, everything else runs perfectly.