better handling of the cursor, use kernal function to read key, not the UART directly

This commit is contained in:
mrdudz
2025-06-25 21:39:03 +02:00
parent ef1b101538
commit a7e509cd43
7 changed files with 66 additions and 73 deletions

View File

@@ -244,4 +244,5 @@ UDTIM := $FFEA
KBDREAD := $D8C1 KBDREAD := $D8C1
.elseif .def(__C65__) || .def(__MEGA65__) .elseif .def(__C65__) || .def(__MEGA65__)
; CLRSCR := $E0EC ; ??? ; CLRSCR := $E0EC ; ???
KBDREAD := $E006
.endif .endif

32
libsrc/c65/cgetc.s Normal file
View File

@@ -0,0 +1,32 @@
.include "cbm_kernal.inc"
.import cursor
.export _cgetc
_cgetc:
lda cursor
beq nocursor
; enable the cursor
clc
jsr CURSOR
nocursor:
; wait for a key
; FIXME: is $d610 mega65 specific?
:
lda $d610
beq :-
jsr KBDREAD
pha
; disable the cursor
sec
jsr CURSOR
pla
ldx #0
rts

View File

@@ -1,26 +0,0 @@
;
; unsigned char cursor (unsigned char onoff);
;
.include "cbm_kernal.inc"
.export _cursor
.import cursor
.proc _cursor
pha
; A != 0 to enable, 0 to disable
cmp #0
beq disable ; C = 1
clc
disable:
; C = 0 to enable, 1 to disable
jsr CURSOR
ply ; onoff into Y
ldx #0 ; High byte of result
lda cursor ; Get old value
sty cursor ; Set new value
rts
.endproc

View File

@@ -1,17 +1,7 @@
; FIXME: is $d610 mega65 specific? ; FIXME: is $d610 mega65 specific?
; FIXME: this should rather use the kernal (with keyboard buffer etc) ; FIXME: this should rather use the kernal (with keyboard buffer etc)
.export _cgetc
_cgetc:
: lda $d610
beq :-
ldx #0
stx $d610
rts
.export _kbhit .export _kbhit
_kbhit: _kbhit:
lda $d610 lda $d610
@@ -19,6 +9,6 @@ _kbhit:
lda #1 lda #1
: :
ldx #0 ldx #>$0000
rts rts

32
libsrc/mega65/cgetc.s Normal file
View File

@@ -0,0 +1,32 @@
.include "cbm_kernal.inc"
.import cursor
.export _cgetc
_cgetc:
lda cursor
beq nocursor
; enable the cursor
clc
jsr CURSOR
nocursor:
; wait for a key
; FIXME: is $d610 mega65 specific?
:
lda $d610
beq :-
jsr KBDREAD
pha
; disable the cursor
sec
jsr CURSOR
pla
ldx #0
rts

View File

@@ -1,26 +0,0 @@
;
; unsigned char cursor (unsigned char onoff);
;
.include "cbm_kernal.inc"
.export _cursor
.import cursor
.proc _cursor
pha
; A != 0 to enable, 0 to disable
cmp #0
beq disable ; C = 1
clc
disable:
; C = 0 to enable, 1 to disable
jsr CURSOR
ply ; onoff into Y
ldx #0 ; High byte of result
lda cursor ; Get old value
sty cursor ; Set new value
rts
.endproc

View File

@@ -1,17 +1,7 @@
; FIXME: is $d610 mega65 specific? ; FIXME: is $d610 mega65 specific?
; FIXME: this should rather use the kernal (with keyboard buffer etc) ; FIXME: this should rather use the kernal (with keyboard buffer etc)
.export _cgetc
_cgetc:
: lda $d610
beq :-
ldx #0
stx $d610
rts
.export _kbhit .export _kbhit
_kbhit: _kbhit:
lda $d610 lda $d610