ti/kbd: improve debouncing
Previously, on real hardware (emulator behaved fine), we would routinely get repeat keys unless pressing the button very fast. This commit solves that.
This commit is contained in:
parent
418af5f626
commit
9c37471780
@ -126,13 +126,20 @@ kbdGetC:
|
|||||||
ret
|
ret
|
||||||
.debounce:
|
.debounce:
|
||||||
; wait until all keys are de-pressed
|
; wait until all keys are de-pressed
|
||||||
|
; To avoid repeat keys, we require 64 subsequent polls to indicate all
|
||||||
|
; depressed keys
|
||||||
push af ; --> lvl 1
|
push af ; --> lvl 1
|
||||||
|
push bc ; --> lvl 2
|
||||||
|
.pressed:
|
||||||
|
ld b, 64
|
||||||
.wait:
|
.wait:
|
||||||
xor a
|
xor a
|
||||||
call .get
|
call .get
|
||||||
inc a ; if a was 0xff, will become 0 (nz test)
|
inc a ; if a was 0xff, will become 0 (nz test)
|
||||||
jr nz, .wait ; non-zero? something is pressed
|
jr nz, .pressed ; non-zero? something is pressed
|
||||||
|
djnz .wait
|
||||||
|
|
||||||
|
pop bc ; <-- lvl 2
|
||||||
pop af ; <-- lvl 1
|
pop af ; <-- lvl 1
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user