Re: A83: wait 'til no key is pressed


[Prev][Next][Index][Thread]

Re: A83: wait 'til no key is pressed




Now I've written a new routine (code below). First, wait_clear waits for
clear key, then it calls wait_no_keys_pressed. There is a small routine that
waits a few cycles, so I can ignore key 'bounces'. But it still won't work!
And I don't know why. Could you tell me, please?

Here's the code:

wait_clear:
 ld a,0ffh
 out (1),a
 ld a,0fdh
 out (1),a
 in a,(1)
 cp 191
 jr nz,wait_clear
 call wait_no_keys_pressed
 ret

wait_no_keys_pressed:
 call wait
 ld b,0feh
 call wait_for_row
 ld b,0fdh
 call wait_for_row
 ld b,0fbh
 call wait_for_row
 ld b,0f7h
 call wait_for_row
 ld b,0efh
 call wait_for_row
 ld b,0dfh
 call wait_for_row
 ld b,0bfh
 call wait_for_row
 call wait
 ret

wait:
 ld a,255
 ld b,255
wait_loop:
 nop
 nop
 nop
 nop
 dec a
 cp 0
 jp nz,wait_loop
 dec b
 ld a,b
 cp 0
 jp nz,wait_loop
 ret

wait_for_row:
 ld a,0ffh
 out (1),a
 ld a,b
 out (1),a
 in a,(1)
 cp 255
 jp nz,wait_for_row
 ret

Thanks for help!


> Two things. Firstly the value read back is (as AsmGuru says) dependent on
> which keys are pressed but your routine only works if that is the only key
> pressed in the appropriate "key row".
...
> However, there is another issue. Keys "bounce". What this means is
> when you press or release a key you get a short period where the
> keys go on/off/on/off/on very fast (when the contacts are very close





References: