1
0
mirror of https://github.com/cc65/cc65.git synced 2024-06-01 13:41:34 +00:00
cc65/libsrc/atmos/cgetc.s
Oliver Schmidt 419eb700b5 Renamed INITBSS to INIT and INIT to ONCE.
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.
2016-03-06 21:27:19 +01:00

67 lines
1.4 KiB
ArmAsm

;
; 2003-04-13, Ullrich von Bassewitz
; 2014-09-04, Greg King
;
; char cgetc (void);
;
.export _cgetc
.constructor initcgetc
.import cursor
.forceimport disable_caps
.include "atmos.inc"
; ------------------------------------------------------------------------
;
.proc _cgetc
lda KEYBUF ; Do we have a character?
bmi @L2 ; Yes: Get it
; No character, enable cursor and wait
lda cursor ; Should cursor be off?
beq @L1 ; Skip if so
lsr STATUS
sec ; Cursor ON
rol STATUS
@L1: lda KEYBUF
bpl @L1
; If the cursor was enabled, disable it now
ldx cursor
beq @L2
dec STATUS ; Clear bit zero
; We have the character, clear the "available" flag
@L2: and #$7F ; Mask out avail flag
sta KEYBUF
ldx #>$0000
ldy MODEKEY
cpy #FUNCTKEY
bne @L3
ora #$80 ; FUNCT-key pressed
; Done
@L3: rts
.endproc
; ------------------------------------------------------------------------
; Switch the cursor off. Code goes into the ONCE segment
; which may be reused after it is run.
.segment "ONCE"
initcgetc:
lsr STATUS
asl STATUS ; Clear bit zero
rts