2000-05-28 13:40:48 +00:00
|
|
|
;
|
|
|
|
; Ullrich von Bassewitz, 06.08.1998
|
|
|
|
;
|
|
|
|
; char cgetc (void);
|
|
|
|
;
|
|
|
|
|
|
|
|
.export _cgetc
|
2003-12-20 23:13:26 +00:00
|
|
|
.import plot, write_crtc, sys_bank, restore_bank
|
2000-05-28 13:40:48 +00:00
|
|
|
.import cursor
|
2003-12-20 23:13:26 +00:00
|
|
|
.import sysp0: zp, sysp3: zp
|
2000-05-28 13:40:48 +00:00
|
|
|
|
2002-05-26 09:08:52 +00:00
|
|
|
.include "cbm610.inc"
|
2000-05-28 13:40:48 +00:00
|
|
|
|
|
|
|
|
2003-12-20 23:13:26 +00:00
|
|
|
_cgetc: lda IndReg
|
|
|
|
pha
|
|
|
|
lda #$0F
|
|
|
|
sta IndReg ; Switch to the system bank
|
|
|
|
|
|
|
|
ldy #$D1
|
|
|
|
lda (sysp0),y ; Get number of keys in keyboard buffer
|
2000-05-28 13:40:48 +00:00
|
|
|
bne L2 ; Jump if there are already chars waiting
|
|
|
|
|
|
|
|
; Switch on the cursor if needed
|
|
|
|
|
|
|
|
lda cursor
|
2003-12-20 23:13:26 +00:00
|
|
|
beq L0 ; Jump if no cursor
|
2000-05-28 13:40:48 +00:00
|
|
|
|
|
|
|
jsr plot ; Set the current cursor position
|
2003-12-20 23:13:26 +00:00
|
|
|
ldy #$D4
|
|
|
|
lda (sysp0),y ; Get the cursor format
|
2000-05-28 13:40:48 +00:00
|
|
|
ldy #10
|
2003-12-20 23:13:26 +00:00
|
|
|
jsr write_crtc ; Set the cursor format
|
2000-05-28 13:40:48 +00:00
|
|
|
|
2003-12-20 23:13:26 +00:00
|
|
|
L0: ldy #$D1
|
|
|
|
L1: lda (sysp0),y ; Get the number of keys in the buffer
|
|
|
|
beq L1 ; Wait until we have some keys
|
2000-05-28 13:40:48 +00:00
|
|
|
|
|
|
|
ldy #10
|
|
|
|
lda #$20 ; Cursor off
|
|
|
|
jsr write_crtc
|
|
|
|
|
2003-12-20 23:13:26 +00:00
|
|
|
L2: ldy #$D1
|
|
|
|
lda (sysp0),y ; Get number of chars in buffer
|
|
|
|
tax
|
|
|
|
ldy #$AB
|
|
|
|
lda (sysp3),y ; Get first char from keyboard buffer
|
|
|
|
sta c ; Save for return
|
|
|
|
dex
|
|
|
|
txa
|
|
|
|
ldy #$D1
|
|
|
|
sta (sysp0),y
|
|
|
|
sei
|
|
|
|
jmp L4
|
|
|
|
L3: iny
|
|
|
|
lda (sysp3),y
|
|
|
|
dey
|
|
|
|
sta (sysp3),y
|
|
|
|
iny
|
|
|
|
L4: dex
|
|
|
|
bpl L3
|
|
|
|
cli
|
|
|
|
|
|
|
|
pla
|
|
|
|
sta IndReg ; Restore old segment
|
2000-05-28 13:40:48 +00:00
|
|
|
|
|
|
|
ldx #$00 ; High byte
|
2003-12-20 23:13:26 +00:00
|
|
|
lda c ; First char from buffer
|
2000-05-28 13:40:48 +00:00
|
|
|
rts
|
|
|
|
|
2003-12-20 23:13:26 +00:00
|
|
|
.bss
|
|
|
|
|
|
|
|
c: .byte 0
|