mirror of
https://github.com/cc65/cc65.git
synced 2025-01-11 11:30:13 +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.
67 lines
1.4 KiB
ArmAsm
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
|