further work on new keyboard scanning routine
This commit is contained in:
1 parent
5c02adae3e
commit
7e2a2f8e5d
7 files changed
+94
-18
No files matched your search
@@ -5,6 +5,10 @@
|
||||
// Please read CONFIG.md before modifying this file!
|
||||
//
|
||||
|
||||
// Idea:
|
||||
// - sane defaults for the original Commodore 64 machine
|
||||
// - do not enable features which are a significant compatibility risk
|
||||
|
||||
|
||||
// Hardware platform and variant
|
||||
|
||||
|
||||
@@ -5,6 +5,12 @@
|
||||
// Please read CONFIG.md before modifying this file!
|
||||
//
|
||||
|
||||
// Idea:
|
||||
// - sane defaults for the Mega 65 FPGA computer
|
||||
// - enable compatibility-risky features too
|
||||
// - unless VICE gains Commodore 65 (or at least Flash8 cartridge) emulation support,
|
||||
// do not enable CPU-specific optimizations; ROMs would be hard to test
|
||||
|
||||
|
||||
// Hardware platform and variant
|
||||
|
||||
|
||||
@@ -5,6 +5,10 @@
|
||||
// Please read CONFIG.md before modifying this file!
|
||||
//
|
||||
|
||||
// Idea:
|
||||
// - sane defaults for the Ultimate 64 FPGA computer
|
||||
// - do not enable features which are a significant compatibility risk
|
||||
|
||||
|
||||
// Hardware platform and variant
|
||||
|
||||
|
||||
@@ -13,6 +13,9 @@
|
||||
// and converting the values
|
||||
|
||||
|
||||
// XXX to be extra compatible (someone could change the KEYLOG), we should make sure
|
||||
// we are using the same matrix format as the original ROM does
|
||||
|
||||
|
||||
kb_matrix:
|
||||
|
||||
|
||||
@@ -12,7 +12,8 @@
|
||||
|
||||
kb_matrix_row_keys:
|
||||
|
||||
// values for CIA1_PRA to connect only the given row
|
||||
// - values for CIA1_PRA to connect only the given row
|
||||
// - also used to scan a single row
|
||||
|
||||
.byte %01111111
|
||||
.byte %10111111
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
|
||||
//
|
||||
// Helper values to quickly determine row offset from the start of keyboard matrix
|
||||
//
|
||||
|
||||
|
||||
#if !CONFIG_SCNKEY_TWW_CTR
|
||||
|
||||
|
||||
kb_matrix_row_offsets:
|
||||
|
||||
// - offsets (in bytes) to the first bytes of keyboard matrix rows
|
||||
|
||||
.byte 0*8
|
||||
.byte 1*8
|
||||
.byte 2*8
|
||||
.byte 3*8
|
||||
.byte 4*8
|
||||
.byte 5*8
|
||||
.byte 6*8
|
||||
.byte 7*8
|
||||
|
||||
#endif // no CONFIG_SCNKEY_TWW_CTR
|
||||
@@ -20,20 +20,19 @@
|
||||
// - MODE - flag, whether charset toggle (SHIFT+VENDOR) is allowed
|
||||
|
||||
|
||||
// XXX add Commodore 128 keyboard support
|
||||
// XXX add Commodore 65 keybopard support
|
||||
// XXX add support for using joystick to move sursor keys
|
||||
// XXX prevent joystick port 1 interference
|
||||
|
||||
#if !CONFIG_SCNKEY_TWW_CTR
|
||||
|
||||
// Routine is heavily inspired by TWW/CTR proposal, see here:
|
||||
// Routine takes some ideas from TWW/CTR proposal, see here:
|
||||
// - http://codebase64.org/doku.php?id=base:scanning_the_keyboard_the_correct_and_non_kernal_way
|
||||
|
||||
|
||||
SCNKEY:
|
||||
|
||||
// Handle repeat timer
|
||||
|
||||
lda KOUNT
|
||||
beq !+
|
||||
dec KOUNT
|
||||
!:
|
||||
// Prepare for SHFLAG update
|
||||
|
||||
lda SHFLAG
|
||||
@@ -47,11 +46,12 @@ SCNKEY:
|
||||
|
||||
lda #$00
|
||||
sta CIA1_PRA // connect all the rows
|
||||
lda #$FF
|
||||
cmp CIA1_PRB
|
||||
ldx #$FF
|
||||
cpx CIA1_PRB
|
||||
beq scnkey_no_keys
|
||||
|
||||
// Retrieve SHIFT / VENDOR / CTRL status
|
||||
// Use .X to detect 2 or more keys pressed (should be $FF now)
|
||||
ldy #$03
|
||||
scnkey_bucky_loop:
|
||||
lda kb_matrix_bucky_confmask, y
|
||||
@@ -70,34 +70,69 @@ scnkey_bucky_loop:
|
||||
|
||||
jsr scnkey_via_keylog // XXX for some CPUs we have indirect jsr
|
||||
|
||||
// XXX check if there is space in keyboard buffer
|
||||
// XXX check for joystick activity
|
||||
|
||||
// Scan the keyboard matrix
|
||||
|
||||
ldy #$07
|
||||
ldy #$07 // XXX adapt for C128 and C65 keyboards
|
||||
ldx #$FF // offset in key matrix table, $FF for not found yet
|
||||
scnkey_matrix_loop:
|
||||
lda kb_matrix_row_keys, y
|
||||
sta CIA1_PRA
|
||||
lda kb_matrix_bucky_filter, y
|
||||
lda kb_matrix_bucky_filter, y // filter out bucky keys
|
||||
ora CIA1_PRB
|
||||
|
||||
// XXX
|
||||
cmp #$FF
|
||||
beq scnkey_matrix_loop_next // skip if no key pressed from this row
|
||||
cpx #$FF
|
||||
bne scnkey_no_keys // clash, more than one key pressed
|
||||
// We have at least one key pressed in this row, we need to find which one exactly
|
||||
ldx #$07
|
||||
scnkey_matrix_loop_inner:
|
||||
cmp kb_matrix_row_keys, x
|
||||
bne !+ // not this particular key
|
||||
txa // now .A contains key offset within a row
|
||||
sec
|
||||
adc kb_matrix_row_offsets, y // now .A contains key offset from the matrix start
|
||||
tax
|
||||
jmp scnkey_matrix_loop_next
|
||||
!:
|
||||
dex
|
||||
bpl scnkey_matrix_loop_inner
|
||||
bmi scnkey_no_keys // branch always, multiple keys must have been pressed
|
||||
scnkey_matrix_loop_next:
|
||||
dey
|
||||
bpl scnkey_matrix_loop
|
||||
|
||||
// Scanning complete
|
||||
|
||||
cpx #$FF
|
||||
bne scnkey_got_key
|
||||
|
||||
|
||||
|
||||
// XXX
|
||||
// FALLTROUGH
|
||||
|
||||
scnkey_no_keys:
|
||||
|
||||
lda #$FF
|
||||
// XXX
|
||||
|
||||
lda #$40 // XXX adapt value for C128 and C65 keyboards
|
||||
sta LSTX
|
||||
|
||||
rts
|
||||
|
||||
scnkey_got_key: // .X should now contain the key offset in matrix pointed by KEYTAB
|
||||
|
||||
// Handle repeat timer
|
||||
|
||||
.break
|
||||
lda KOUNT
|
||||
beq !+
|
||||
dec KOUNT
|
||||
!:
|
||||
|
||||
// XXX
|
||||
rts
|
||||
|
||||
scnkey_via_keylog:
|
||||
jmp (KEYLOG)
|
||||
|
||||
|
||||
Reference in new issue
Block a user