2003-04-13 22:12:09 +00:00
|
|
|
;
|
|
|
|
; Ullrich von Bassewitz, 2003-04-13
|
|
|
|
;
|
|
|
|
; char cgetc (void);
|
|
|
|
;
|
|
|
|
|
|
|
|
.export _cgetc
|
2003-04-14 14:45:47 +00:00
|
|
|
.constructor initcgetc
|
2003-04-13 22:12:09 +00:00
|
|
|
.import cursor
|
|
|
|
|
|
|
|
.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 ; Cursor currently off?
|
|
|
|
beq @L1 ; Skip if so
|
2003-04-14 14:45:47 +00:00
|
|
|
lda STATUS
|
|
|
|
ora #%00000001 ; Cursor ON
|
|
|
|
sta 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
|
|
|
|
ldx #$00 ; Zero high byte
|
2003-04-13 22:12:09 +00:00
|
|
|
dec STATUS ; Clear bit zero
|
|
|
|
|
|
|
|
; We have the character, clear avail flag
|
|
|
|
|
|
|
|
@L2: and #$7F ; Mask out avail flag
|
|
|
|
sta KEYBUF
|
|
|
|
|
|
|
|
; Done
|
|
|
|
|
|
|
|
rts
|
|
|
|
|
|
|
|
.endproc
|
|
|
|
|
|
|
|
; ------------------------------------------------------------------------
|
2005-02-26 09:28:46 +00:00
|
|
|
; Switch the cursor off, disable capslock. Code goes into the INIT segment
|
|
|
|
; which may be reused after it is run.
|
|
|
|
|
|
|
|
.segment "INIT"
|
2003-04-13 22:12:09 +00:00
|
|
|
|
2003-04-14 14:45:47 +00:00
|
|
|
initcgetc:
|
2003-04-13 22:12:09 +00:00
|
|
|
lda STATUS
|
|
|
|
and #%11111110
|
|
|
|
sta STATUS
|
2003-04-14 14:45:47 +00:00
|
|
|
lda #$7F
|
|
|
|
sta CAPSLOCK
|
2003-04-13 22:12:09 +00:00
|
|
|
rts
|
|
|
|
|