}
MEMORY {
# for size of ZP see runtime/zeropage.s and c1p/extzp.s
- ZP: file = "", define = yes, start = $0002, size = $001A + $0004;
+ ZP: file = "", define = yes, start = $0002, size = $001A + $0005;
RAM: file = %O, define = yes, start = %S, size = __HIMEM__ - __STACKSIZE__ - %S;
}
SEGMENTS {
;\r
; char cgetc (void);\r
;\r
+\r
+ .constructor initcgetc\r
.export _cgetc\r
.import cursor\r
\r
.include "extzp.inc"\r
.include "zeropage.inc"\r
\r
+; Initialize one-character buffer that is filled by kbhit()\r
+initcgetc:\r
+ lda #$00\r
+ sta CHARBUF ; No character in buffer initially\r
+ rts\r
+\r
; Input routine from 65V PROM MONITOR, show cursor if enabled\r
_cgetc:\r
+ lda CHARBUF ; character in buffer available?\r
+ beq nobuffer\r
+ tax ; save character in X\r
+ lda #$00\r
+ sta CHARBUF ; empty buffer\r
+ jmp restorex ; restore X and return\r
+nobuffer:\r
lda cursor ; show cursor?\r
beq nocursor\r
ldy CURS_X\r
lda tmp1 ; fetch saved character\r
ldy CURS_X\r
sta (SCREEN_PTR),y ; store at cursor position\r
+\r
+restorex:\r
txa ; restore saved character from X\r
- ldx #$00 ; high byte of int return value\r
done:\r
+ ldx #$00 ; high byte of int return value\r
rts\r
; ------------------------------------------------------------------------
- .globalzp CURS_X, CURS_Y, SCREEN_PTR
+ .globalzp CURS_X, CURS_Y, SCREEN_PTR, CHARBUF
CURS_X: .res 1
CURS_Y: .res 1
SCREEN_PTR: .res 2
+CHARBUF: .res 1
-; size 4
-; Adjust size of this segment in osic1p.cfg if the size changes
+; size 5
+; Adjust size of the ZP segment in osic1p.cfg if the size changes
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