Enso,
That is not quite right. It does require a non-blocking (no wait for key press loop) routine. The routine should exit with Carry clear if there was no key pressed. The contents of the Accumulator are not tested and do not need to be cleared. If a key was pressed, then it is loaded into the Accumulator and the routine exits with Carry Set.
If you are setting the carry and clearing the Accumulator, you are essentially telling EhBASIC that you are pressing a lot of "Null" keys. It will do nothing but that is not the desired effect.
Here is my typical input code for a non-blocking routine using a serial interface:
Code:
UARTA_Read
LDA UART + SRA ; read status register
lsr ; move bit 0 to carry (test if data ready)
bcc UARTA_rd1 ; nothing to read exit with C=0
LDA UART + RXA ; get character and exit with C=1
UARTA_Rd1
rts
I was able to shift the data ready bit into the C flag directly, making the code efficient.
Here is an example of a 6551 routine:
Code:
ACIA1_Scan clc ; pre-clear Carry
lda ACIA1Sta ; Serial port status
and #$08 ; mask rcvr full bit
beq ACIA1_scan2 ; no character ready exit with carry clear
lda ACIA1dat ; get chr
sec ; set carry
ACIA1_scan2 rts
I hope this helps!
Daryl
_________________
Please visit my website ->
https://sbc.rictor.org/