2003-04-13 22:12:09 +00:00
|
|
|
;
|
2013-07-26 07:33:54 +00:00
|
|
|
; 2003-04-13, Ullrich von Bassewitz
|
2014-09-04 21:37:41 +00:00
|
|
|
; 2014-09-04, Greg King
|
2003-04-13 22:12:09 +00:00
|
|
|
;
|
|
|
|
; char cgetc (void);
|
|
|
|
;
|
|
|
|
|
2013-05-09 11:56:54 +00:00
|
|
|
.export _cgetc
|
2014-08-22 21:19:58 +00:00
|
|
|
|
2013-05-09 11:56:54 +00:00
|
|
|
.import cursor
|
2014-08-22 21:19:58 +00:00
|
|
|
.forceimport disable_caps
|
2003-04-13 22:12:09 +00:00
|
|
|
|
2013-05-09 11:56:54 +00:00
|
|
|
.include "atmos.inc"
|
2003-04-13 22:12:09 +00:00
|
|
|
|
|
|
|
|
|
|
|
; ------------------------------------------------------------------------
|
|
|
|
;
|
|
|
|
|
|
|
|
.proc _cgetc
|
|
|
|
|
|
|
|
lda KEYBUF ; Do we have a character?
|
|
|
|
bmi @L2 ; Yes: Get it
|
|
|
|
|
|
|
|
; No character, enable cursor and wait
|
|
|
|
|
2014-08-21 14:46:25 +00:00
|
|
|
lda cursor ; Should cursor be off?
|
2003-04-13 22:12:09 +00:00
|
|
|
beq @L1 ; Skip if so
|
2014-08-21 14:46:25 +00:00
|
|
|
lsr STATUS
|
|
|
|
sec ; Cursor ON
|
|
|
|
rol STATUS
|
2003-04-13 22:12:09 +00:00
|
|
|
@L1: lda KEYBUF
|
|
|
|
bpl @L1
|
|
|
|
|
|
|
|
; If the cursor was enabled, disable it now
|
|
|
|
|
|
|
|
ldx cursor
|
2003-04-14 14:45:47 +00:00
|
|
|
beq @L2
|
2003-04-13 22:12:09 +00:00
|
|
|
dec STATUS ; Clear bit zero
|
|
|
|
|
2014-09-04 21:37:41 +00:00
|
|
|
; We have the character, clear the "available" flag
|
2003-04-13 22:12:09 +00:00
|
|
|
|
|
|
|
@L2: and #$7F ; Mask out avail flag
|
|
|
|
sta KEYBUF
|
2014-09-04 21:37:41 +00:00
|
|
|
ldx #>$0000
|
2013-07-26 07:33:54 +00:00
|
|
|
ldy MODEKEY
|
|
|
|
cpy #FUNCTKEY
|
2009-01-24 16:35:42 +00:00
|
|
|
bne @L3
|
2014-09-04 21:37:41 +00:00
|
|
|
ora #$80 ; FUNCT-key pressed
|
2003-04-13 22:12:09 +00:00
|
|
|
|
|
|
|
; Done
|
|
|
|
|
2009-01-24 16:35:42 +00:00
|
|
|
@L3: rts
|
2003-04-13 22:12:09 +00:00
|
|
|
|
|
|
|
.endproc
|