2014-11-08 23:58:32 +00:00
|
|
|
;
|
|
|
|
; char cgetc (void);
|
|
|
|
;
|
2015-02-21 19:24:58 +00:00
|
|
|
|
|
|
|
.constructor initcgetc
|
2014-11-08 23:58:32 +00:00
|
|
|
.export _cgetc
|
2014-11-29 19:07:30 +00:00
|
|
|
.import cursor
|
|
|
|
|
2015-02-03 21:42:35 +00:00
|
|
|
.include "osic1p.inc"
|
2014-11-29 19:07:30 +00:00
|
|
|
.include "extzp.inc"
|
2015-02-12 20:29:19 +00:00
|
|
|
.include "zeropage.inc"
|
2014-11-08 23:58:32 +00:00
|
|
|
|
2015-02-21 19:24:58 +00:00
|
|
|
; Initialize one-character buffer that is filled by kbhit()
|
|
|
|
initcgetc:
|
|
|
|
lda #$00
|
|
|
|
sta CHARBUF ; No character in buffer initially
|
|
|
|
rts
|
|
|
|
|
2014-11-29 19:07:30 +00:00
|
|
|
; Input routine from 65V PROM MONITOR, show cursor if enabled
|
|
|
|
_cgetc:
|
2015-02-21 19:24:58 +00:00
|
|
|
lda CHARBUF ; character in buffer available?
|
|
|
|
beq nobuffer
|
|
|
|
tax ; save character in X
|
|
|
|
lda #$00
|
|
|
|
sta CHARBUF ; empty buffer
|
2015-02-28 19:29:08 +00:00
|
|
|
beq restorex ; restore X and return
|
2015-02-21 19:24:58 +00:00
|
|
|
nobuffer:
|
2014-11-29 19:07:30 +00:00
|
|
|
lda cursor ; show cursor?
|
|
|
|
beq nocursor
|
|
|
|
ldy CURS_X
|
|
|
|
lda (SCREEN_PTR),y ; fetch current character
|
2015-02-12 20:29:19 +00:00
|
|
|
sta tmp1 ; save it
|
2014-11-29 19:07:30 +00:00
|
|
|
lda #$A1 ; full white square
|
|
|
|
sta (SCREEN_PTR),y ; store at cursor position
|
|
|
|
nocursor:
|
2015-02-13 18:53:02 +00:00
|
|
|
jsr INPUTC ; get input character in A
|
|
|
|
ldx cursor
|
|
|
|
beq done ; was cursor on?
|
|
|
|
tax ; save A in X
|
2015-02-12 20:29:19 +00:00
|
|
|
lda tmp1 ; fetch saved character
|
2014-11-29 19:07:30 +00:00
|
|
|
ldy CURS_X
|
|
|
|
sta (SCREEN_PTR),y ; store at cursor position
|
2015-02-21 19:24:58 +00:00
|
|
|
|
|
|
|
restorex:
|
2015-02-13 18:53:02 +00:00
|
|
|
txa ; restore saved character from X
|
|
|
|
done:
|
2015-02-21 19:24:58 +00:00
|
|
|
ldx #$00 ; high byte of int return value
|
2014-11-29 19:07:30 +00:00
|
|
|
rts
|