mirror of
https://github.com/cc65/cc65.git
synced 2024-12-25 17:29:50 +00:00
970af0cdb2
The constructor now is first. Used a more expressive literal zero.
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 INIT segment
|
|
; which may be reused after it is run.
|
|
|
|
.segment "INIT"
|
|
|
|
initcgetc:
|
|
lsr STATUS
|
|
asl STATUS ; Clear bit zero
|
|
rts
|