;
-; Ullrich von Bassewitz, 2003-04-13
+; 2003-04-13, Ullrich von Bassewitz
+; 2014-09-04, Greg King
;
; char cgetc (void);
;
- .export _cgetc
- .constructor cursoroff
- .destructor cursoron
- .import cursor
+ .export _cgetc
+ .constructor initcgetc
- .include "atmos.inc"
+ .import cursor
+ .forceimport disable_caps
+ .include "atmos.inc"
; ------------------------------------------------------------------------
; No character, enable cursor and wait
- lda cursor ; Cursor currently off?
+ lda cursor ; Should cursor be off?
beq @L1 ; Skip if so
- jsr cursoron
+ lsr STATUS
+ sec ; Cursor ON
+ rol STATUS
@L1: lda KEYBUF
bpl @L1
; If the cursor was enabled, disable it now
ldx cursor
- beq @L3
+ beq @L2
dec STATUS ; Clear bit zero
-; We have the character, clear avail flag
+; 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: ldx #$00
- rts
+@L3: rts
.endproc
; ------------------------------------------------------------------------
-; Switch the cursor on
+; Switch the cursor off. Code goes into the INIT segment
+; which may be reused after it is run.
-cursoron:
- lda STATUS
- ora #%00000001
- sta STATUS
- rts
+.segment "INIT"
-; ------------------------------------------------------------------------
-; Switch the cursor off
-
-cursoroff:
- lda STATUS
- and #%11111110
- sta STATUS
+initcgetc:
+ lsr STATUS
+ asl STATUS ; Clear bit zero
rts
-