mirror of
https://github.com/cc65/cc65.git
synced 2024-11-19 21:32:19 +00:00
419eb700b5
The way we want to use the INITBSS segment - and especially the fact that it won't have the type bss on all ROM based targets - means that the name INITBSS is misleading. After all INIT is the best name from my perspective as it serves several purposes and therefore needs a rather generic name. Unfortunately this means that the current INIT segment needs to be renamed too. Looking for a short (ideally 4 letter) name I came up with ONCE as it contains all code (and data) accessed only once during initialization.
51 lines
1.6 KiB
ArmAsm
51 lines
1.6 KiB
ArmAsm
;
|
|
; char cgetc (void);
|
|
;
|
|
|
|
.constructor initcgetc
|
|
.export _cgetc
|
|
.import cursor
|
|
|
|
.include "osic1p.inc"
|
|
.include "extzp.inc"
|
|
.include "zeropage.inc"
|
|
|
|
; Initialize one-character buffer that is filled by kbhit()
|
|
.segment "ONCE"
|
|
initcgetc:
|
|
lda #$00
|
|
sta CHARBUF ; No character in buffer initially
|
|
rts
|
|
|
|
; Input routine from 65V PROM MONITOR, show cursor if enabled
|
|
.code
|
|
_cgetc:
|
|
lda CHARBUF ; character in buffer available?
|
|
beq nobuffer
|
|
tax ; save character in X
|
|
lda #$00
|
|
sta CHARBUF ; empty buffer
|
|
beq restorex ; restore X and return
|
|
nobuffer:
|
|
lda cursor ; show cursor?
|
|
beq nocursor
|
|
ldy CURS_X
|
|
lda (SCREEN_PTR),y ; fetch current character
|
|
sta tmp1 ; save it
|
|
lda #$A1 ; full white square
|
|
sta (SCREEN_PTR),y ; store at cursor position
|
|
nocursor:
|
|
jsr INPUTC ; get input character in A
|
|
ldx cursor
|
|
beq done ; was cursor on?
|
|
tax ; save A in X
|
|
lda tmp1 ; fetch saved character
|
|
ldy CURS_X
|
|
sta (SCREEN_PTR),y ; store at cursor position
|
|
|
|
restorex:
|
|
txa ; restore saved character from X
|
|
done:
|
|
ldx #$00 ; high byte of int return value
|
|
rts
|