2005-03-26 17:03:30 +00:00
|
|
|
;
|
|
|
|
; Kevin Ruland
|
|
|
|
;
|
|
|
|
; char cgetc (void);
|
|
|
|
;
|
|
|
|
; If open_apple key is pressed then the high-bit of the key is set.
|
|
|
|
;
|
2000-05-28 13:40:48 +00:00
|
|
|
|
2016-06-19 13:03:20 +00:00
|
|
|
.export _cgetc
|
|
|
|
.import cursor, putchardirect
|
2005-03-26 17:03:30 +00:00
|
|
|
|
2016-06-19 13:03:20 +00:00
|
|
|
.include "apple2.inc"
|
2000-05-28 13:40:48 +00:00
|
|
|
|
|
|
|
_cgetc:
|
2016-06-19 13:03:20 +00:00
|
|
|
; Cursor on ?
|
|
|
|
lda cursor
|
|
|
|
beq :+
|
2005-03-26 17:03:30 +00:00
|
|
|
|
2016-06-19 13:03:20 +00:00
|
|
|
; Show caret.
|
|
|
|
.ifdef __APPLE2ENH__
|
|
|
|
lda #$7F | $80 ; Checkerboard, screen code
|
|
|
|
.else
|
|
|
|
lda #' ' | $40 ; Blank, flashing
|
|
|
|
.endif
|
|
|
|
jsr putchardirect ; Returns old character in X
|
|
|
|
|
|
|
|
; Wait for keyboard strobe.
|
2018-09-08 16:44:30 +00:00
|
|
|
: inc RNDL ; Increment random counter low
|
|
|
|
bne :+
|
|
|
|
inc RNDH ; Increment random counter high
|
2016-06-19 13:03:20 +00:00
|
|
|
: lda KBD
|
2018-09-08 16:44:30 +00:00
|
|
|
bpl :-- ; If < 128, no key pressed
|
2016-06-19 13:03:20 +00:00
|
|
|
|
|
|
|
; Cursor on ?
|
|
|
|
ldy cursor
|
|
|
|
beq :+
|
|
|
|
|
|
|
|
; Restore old character.
|
|
|
|
pha
|
|
|
|
txa
|
|
|
|
jsr putchardirect
|
|
|
|
pla
|
|
|
|
|
|
|
|
; At this time, the high bit of the key pressed is set.
|
|
|
|
: bit KBDSTRB ; Clear keyboard strobe
|
2005-04-08 19:27:07 +00:00
|
|
|
.ifdef __APPLE2ENH__
|
2013-05-09 11:56:54 +00:00
|
|
|
bit BUTN0 ; Check if OpenApple is down
|
2005-04-08 19:27:07 +00:00
|
|
|
bmi done
|
|
|
|
.endif
|
2013-05-09 11:56:54 +00:00
|
|
|
and #$7F ; If not down, then clear high bit
|
2016-06-19 13:03:20 +00:00
|
|
|
done: ldx #>$0000
|
2005-03-26 17:03:30 +00:00
|
|
|
rts
|