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:
Stephan Mühlstrasser
2015-02-21 20:24:58 +01:00
parent b1969ac16a
commit 222668c016
5 changed files with 27 additions and 6 deletions

View File

@@ -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