Because I like control, I like to fully control All the aspects of the program, and it provides some neat stuff
I have 2 timers (an 8 bit and a 16 bit), I use them to vsync the game and time events, I have 2 timers because weird things happend with the 8bit one if used for vsync (don't ask...)
I used to have a teacher key there (I'm glad that the one inside the key handler works...
)
For more control, I have an empty call there, and thus if any of the games (puzzle action, you know the one I'm making) needs additional timed events I can simply overwrite the address it calls
And ofcourse, it allows the arrow keys to repeat (first theres a large delay then a short one) because I think for games the standard large key delay is way to slow.
As an additional feature you can change any of the delays (standard 25 for largekeydelay, 15 for shortkeydelay)
Code: Select all
; If no arrow key is pressed, reset the timer to 'longkeydelay'
; Else decrement the timer,
; If it hits zero clear (lastkey) and reset the timer to 'shortkeydelay'
ld a, (lastkey)
or a
jr z, {+}
cp 5
jr nc, {+} ; Only the arrow keys are allowed to repeat
_keytimer .equ $ + 1 - interrupt_start + $8888
ld a, 1
dec a
ld (_keytimer), a
jr nz, {++}
ld (lastkey), a ; A is zero
ld a, (shortkeydelay)
ld (_keytimer), a
jr {++}
+ ld a, (longkeydelay)
ld (_keytimer), a
++
Feel free to use