Implemented a one-character buffer for kbhit() and cgetc().
If kbhit() detects that a key is pressed, it fetches and buffers the character. If cgetc() detects a buffered character, this one is returned instead of fetching one with the PROM routine.
This commit is contained in:
@@ -19,10 +19,13 @@ scan:
|
||||
rol a ; Rotate row select to next bit position
|
||||
cmp #$FF ; Done?
|
||||
bne scan ; If not, continue
|
||||
ldx #$00 ; High byte of return is always zero
|
||||
lda #$00 ; Return false
|
||||
tax ; High byte of return is also zero
|
||||
sta CHARBUF ; No character in buffer
|
||||
rts
|
||||
keypressed:
|
||||
jsr INPUTC ; Get input character in A
|
||||
sta CHARBUF ; Save in buffer
|
||||
ldx #$00 ; High byte of return is always zero
|
||||
lda #$01 ; Return true
|
||||
rts
|
||||
|
||||
Reference in New Issue
Block a user