Hello there.
There's a common bug with the ON key that i'm pretty sure all DCS users already experienced at least once.
When the key was just released, it's quite often interpreted as pressed right after.
I believe that's basically the result of a bouncing behaviour.
I quite recently performed some deep tests to identify the bouncing duration on TI-8X models (monochrome screen), and it appears it's actually pretty huge.
So, if you're looking for a basic (but safe) debouncing algorithm, here is the one i came up with after my tests :
Code:
EDIT : interrupts assumed to be disabled
There's a common bug with the ON key that i'm pretty sure all DCS users already experienced at least once.
When the key was just released, it's quite often interpreted as pressed right after.
I believe that's basically the result of a bouncing behaviour.
I quite recently performed some deep tests to identify the bouncing duration on TI-8X models (monochrome screen), and it appears it's actually pretty huge.
So, if you're looking for a basic (but safe) debouncing algorithm, here is the one i came up with after my tests :
Code:
;keybdebounce
;DESCRIPTION
;Waits long enough for released keys to stop bouncing.
;Recommended right after a key state just went from pressed to released.
;OUT
;a = ?
;f = %???????0
;bc = $0000
;stack : 2 bytes (call included)
keybdebounce
ld bc,102
in a,($02)
rla
jr nc,keybdebounce_wait
in a,($20)
or a
jr z,keybdebounce_wait
ld c,255
keybdebounce_wait
ld a,(bc)
djnz keybdebounce_wait
dec c
jp nz,keybdebounce_wait
ret
EDIT : interrupts assumed to be disabled