From 9377573f982fc37593df6204103daf3272345e94 Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Mon, 14 Oct 2019 21:10:56 +0200 Subject: [PATCH] completed RPTFLG support --- c64/,,config_ultimate64.s | 2 +- c64/kernal/keyboard/kb_matrix_alwaysrepeat.s | 23 ++++++++++++ c64/kernal/keyboard/scnkey.s | 38 ++++++++++++-------- 3 files changed, 48 insertions(+), 15 deletions(-) create mode 100644 c64/kernal/keyboard/kb_matrix_alwaysrepeat.s diff --git a/c64/,,config_ultimate64.s b/c64/,,config_ultimate64.s index aa0ce73d..a993bd6e 100644 --- a/c64/,,config_ultimate64.s +++ b/c64/,,config_ultimate64.s @@ -49,7 +49,7 @@ // #define CONFIG_SCNKEY_TWW_CTR // XXX document this -#define CONFIG_KEY_REPEAT // XXX document this +// #define CONFIG_KEY_REPEAT // XXX document this #define CONFIG_JOY1_CURSOR // XXX document this #define CONFIG_JOY2_CURSOR // XXX document this diff --git a/c64/kernal/keyboard/kb_matrix_alwaysrepeat.s b/c64/kernal/keyboard/kb_matrix_alwaysrepeat.s new file mode 100644 index 00000000..3a6caa78 --- /dev/null +++ b/c64/kernal/keyboard/kb_matrix_alwaysrepeat.s @@ -0,0 +1,23 @@ + +// +// Matrix ids of keys which should be repeated regardless of RPTFLG +// +// Values based on: +// - [CM64] Compute's Mapping the Commodore 64 - page 58 +// + + +#if !CONFIG_SCNKEY_TWW_CTR + + +kb_matrix_alwaysrepeat: + + .byte $3C // SPACE + .byte $02 // CRSR LEFT/RIGHT + .byte $07 // CRSR UP/DOWN + .byte $00 // INS/DEL + +__kb_matrix_alwaysrepeat_end: + + +#endif // no CONFIG_SCNKEY_TWW_CTR diff --git a/c64/kernal/keyboard/scnkey.s b/c64/kernal/keyboard/scnkey.s index 05ef1b54..cbe99753 100644 --- a/c64/kernal/keyboard/scnkey.s +++ b/c64/kernal/keyboard/scnkey.s @@ -24,7 +24,6 @@ // XXX add Commodore 128 keyboard support // XXX add Commodore 65 keybopard support // XXX fix support for joystick port 2 to move cursor keys -// XXX add support for keys which are repeated always #if !CONFIG_SCNKEY_TWW_CTR @@ -78,17 +77,18 @@ scnkey_bucky_loop: // Check for control port 2 activity - // ldx #$00 - // stx CIA1_DDRA // set port to input to read joystick + ldx #$00 + stx CIA1_DDRA // set port to input to read joystick - // lda CIA1_PRA // read the joystick 2 status + lda CIA1_PRA // read the joystick 2 status - // dex - // stx CIA1_DDRA // set port back to output + ldx #$FF + stx CIA1_DDRA // set port back to output - // and #%00001111 // filter out anything but joystick movement - // cmp #%00001111 - // bne scnkey_joystick_filtered + and #%00001111 // filter out anything but joystick movement + cmp #%00001111 + + bne scnkey_joystick_filtered #endif @@ -207,7 +207,7 @@ scnkey_joystick_filtered: scnkey_got_key: // .Y should now contain the key offset in matrix pointed by KEYTAB cpy LSTX - beq scnkey_handle_repeat // branch if the same key as previously + beq scnkey_try_repeat // branch if the same key as previously sty LSTX // Reset key repeat counters - see [CM64] page 58 @@ -251,13 +251,23 @@ scnkey_done: rts -scnkey_handle_repeat: +scnkey_try_repeat: - // Check whether we should repeat keys - // XXX always repeat SPACE, cvursors, ins/del + // Check whether we should repeat keys - first the flag, afterwards hardcoded list lda RPTFLG - bpl scnkey_done // branch if we should do no repeat + bmi scnkey_handle_repeat // branch if we should repeat always + + tya + ldx #(__kb_matrix_alwaysrepeat_end - kb_matrix_alwaysrepeat - 1) +!: + cmp kb_matrix_alwaysrepeat, x + beq scnkey_handle_repeat + dex + bpl !- + bmi scnkey_done + +scnkey_handle_repeat: // Countdown before first repeat