new SCNKEY now supports key repeating
This commit is contained in:
1 parent
bb2b4981b8
commit
5c8a29095b
2 files changed
+33
-16
No files matched your search
@@ -186,7 +186,7 @@
|
|||||||
.label GDCOL = $287 // color of character under cursor
|
.label GDCOL = $287 // color of character under cursor
|
||||||
.label HIBASE = $288 // high byte of start of screen
|
.label HIBASE = $288 // high byte of start of screen
|
||||||
.label XMAX = $289 // max keyboard buffer size
|
.label XMAX = $289 // max keyboard buffer size
|
||||||
.label RPTFLG = $28A // -- NOT IMPLEMENTED --
|
.label RPTFLG = $28A // whether to repeat keys (highest bit set = repeat)
|
||||||
.label KOUNT = $28B // key repeat counter
|
.label KOUNT = $28B // key repeat counter
|
||||||
.label DELAY = $28C // -- NOT IMPLEMENTED --
|
.label DELAY = $28C // -- NOT IMPLEMENTED --
|
||||||
.label SHFLAG = $28D // bucky keys (SHIFT/CTRL/C=) flags
|
.label SHFLAG = $28D // bucky keys (SHIFT/CTRL/C=) flags
|
||||||
|
|||||||
@@ -18,9 +18,9 @@
|
|||||||
// - LSTX - matrix coordinate of last pressed key
|
// - LSTX - matrix coordinate of last pressed key
|
||||||
// - LSTSHF - previous status of SHFLAG
|
// - LSTSHF - previous status of SHFLAG
|
||||||
// - MODE - flag, whether charset toggle (SHIFT+VENDOR) is allowed
|
// - MODE - flag, whether charset toggle (SHIFT+VENDOR) is allowed
|
||||||
|
// - RPTFLG - whether key repeat is allowed
|
||||||
|
|
||||||
|
|
||||||
// XXX add RPTFLG support
|
|
||||||
// XXX add Commodore 128 keyboard support
|
// XXX add Commodore 128 keyboard support
|
||||||
// XXX add Commodore 65 keybopard support
|
// XXX add Commodore 65 keybopard support
|
||||||
// XXX add support for using joystick to move sursor keys
|
// XXX add support for using joystick to move sursor keys
|
||||||
@@ -110,9 +110,12 @@ scnkey_matrix_loop_next:
|
|||||||
dey
|
dey
|
||||||
bpl scnkey_matrix_loop
|
bpl scnkey_matrix_loop
|
||||||
|
|
||||||
|
txa // XXX switch registers upwards!!!
|
||||||
|
tay
|
||||||
|
|
||||||
// Scanning complete
|
// Scanning complete
|
||||||
|
|
||||||
cpx #$FF
|
cpy #$FF
|
||||||
bne scnkey_got_key
|
bne scnkey_got_key
|
||||||
|
|
||||||
// FALLTROUGH
|
// FALLTROUGH
|
||||||
@@ -126,16 +129,14 @@ scnkey_no_keys:
|
|||||||
|
|
||||||
rts
|
rts
|
||||||
|
|
||||||
scnkey_got_key: // .X should now contain the key offset in matrix pointed by KEYTAB
|
scnkey_got_key: // .Y should now contain the key offset in matrix pointed by KEYTAB
|
||||||
|
|
||||||
cpx LSTX
|
cpy LSTX
|
||||||
beq scnkey_handle_repeat // branch if the same key as previously
|
beq scnkey_handle_repeat // branch if the same key as previously
|
||||||
stx LSTX
|
sty LSTX
|
||||||
|
|
||||||
// Reset key repeat counters - see [CM64] page 58
|
// Reset key repeat counters - see [CM64] page 58
|
||||||
|
|
||||||
lda #$04
|
|
||||||
sta KOUNT
|
|
||||||
lda #$10
|
lda #$10
|
||||||
sta DELAY
|
sta DELAY
|
||||||
|
|
||||||
@@ -143,10 +144,12 @@ scnkey_got_key: // .X should now contain the key offset in matrix pointed by KEY
|
|||||||
|
|
||||||
scnkey_output_key:
|
scnkey_output_key:
|
||||||
|
|
||||||
// Output PETSCII code to the keyboard buffer
|
// Reinitialize secondary couter
|
||||||
|
|
||||||
txa // XXX switch registers!!!
|
lda #$06
|
||||||
tay
|
sta KOUNT
|
||||||
|
|
||||||
|
// Output PETSCII code to the keyboard buffer
|
||||||
|
|
||||||
lda (KEYTAB), y
|
lda (KEYTAB), y
|
||||||
beq scnkey_no_keys // branch if we have no PETSCII code for this key
|
beq scnkey_no_keys // branch if we have no PETSCII code for this key
|
||||||
@@ -154,18 +157,32 @@ scnkey_output_key:
|
|||||||
sta KEYD, y
|
sta KEYD, y
|
||||||
inc NDX
|
inc NDX
|
||||||
|
|
||||||
|
// FALLTROUGH
|
||||||
|
|
||||||
|
scnkey_done:
|
||||||
|
|
||||||
rts
|
rts
|
||||||
|
|
||||||
scnkey_handle_repeat:
|
scnkey_handle_repeat:
|
||||||
|
|
||||||
// Handle repeat timer
|
// Check whether we should repeat keys
|
||||||
|
|
||||||
|
lda RPTFLG
|
||||||
|
bpl scnkey_done // branch if we should do no repeat
|
||||||
|
|
||||||
|
// First countdown (for the first repeat)
|
||||||
|
|
||||||
|
lda DELAY
|
||||||
|
beq !+
|
||||||
|
dec DELAY
|
||||||
|
|
||||||
|
rts
|
||||||
|
!:
|
||||||
|
// Second countdown (for both first and subsequential repeats)
|
||||||
|
|
||||||
lda KOUNT
|
lda KOUNT
|
||||||
beq !+
|
beq scnkey_output_key // if second counter is also 0, we can repeat the key
|
||||||
dec KOUNT
|
dec KOUNT
|
||||||
!:
|
|
||||||
|
|
||||||
// XXX
|
|
||||||
|
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user