diff --git a/CONFIG.md b/CONFIG.md index 3f385728..0817127b 100644 --- a/CONFIG.md +++ b/CONFIG.md @@ -113,13 +113,19 @@ Original keyboard support routine is just horrible. It does nothing to prevent g Uses old Open ROMs keyboard scanning routine, which is basically example routine by TWW/CTR, hacked to work within Kernal. It's greatest advantage is multi-key rollover, it's disadvantages - it's much less compatible (uses several bytes of memory which are normally free for user software - thus, it is considered legacy for now), does not support all the system variables (`RPTFLG` and `KEYLOG` are unsupported), and ignores the configuration options - this can be changed, but it requires some effort. -Needs 70-250 more space in KERNAL segment (depending on the features enabled for current default routine). If unsure - disable. +Needs 30-250 more space in KERNAL segment (depending on the features enabled for current default routine). If unsure - disable. ### `CONFIG_KEYBOARD_C128` Allows to use additional keys found on the C128 keyboard. NOTE: might be buggy, on VICE emulator I can't get all the keys working. -Needs about 125 bytes more space in KERNAL segment. If unsure - disable. +Needs about 130 bytes more space in KERNAL segment. If unsure - disable. + +### `CONFIG_KEYBOARD_C128_CAPS_LOCK` + +If C128 keyboard support is selected, allows to additionally support it's CAPS LOCK keys. Support is C64-safe (there is a protection against false-positive reading on the C64). + +Needs about 47 bytes more space in KERNAL segment. ### `CONFIG_KEY_REPEAT_DEFAULT` diff --git a/c64/,,config_generic.s b/c64/,,config_generic.s index 9d1ac95e..5d062164 100644 --- a/c64/,,config_generic.s +++ b/c64/,,config_generic.s @@ -50,6 +50,7 @@ // #define CONFIG_LEGACY_SCNKEY #define CONFIG_KEYBOARD_C128 +// #define CONFIG_KEYBOARD_C128_CAPS_LOCK // #define CONFIG_KEY_REPEAT_DEFAULT #define CONFIG_KEY_REPEAT_ALWAYS #define CONFIG_KEY_FAST_SCAN diff --git a/c64/,,config_mega65.s b/c64/,,config_mega65.s index e293a8c4..086b2994 100644 --- a/c64/,,config_mega65.s +++ b/c64/,,config_mega65.s @@ -52,6 +52,7 @@ #define CONFIG_LEGACY_SCNKEY // #define CONFIG_KEYBOARD_C128 +// #define CONFIG_KEYBOARD_C128_CAPS_LOCK // #define CONFIG_KEY_REPEAT_DEFAULT // #define CONFIG_KEY_REPEAT_ALWAYS #define CONFIG_KEY_FAST_SCAN diff --git a/c64/,,config_ultimate64.s b/c64/,,config_ultimate64.s index 05f45f59..75b3f702 100644 --- a/c64/,,config_ultimate64.s +++ b/c64/,,config_ultimate64.s @@ -50,6 +50,7 @@ // #define CONFIG_LEGACY_SCNKEY // #define CONFIG_KEYBOARD_C128 +// #define CONFIG_KEYBOARD_C128_CAPS_LOCK // #define CONFIG_KEY_REPEAT_DEFAULT // #define CONFIG_KEY_REPEAT_ALWAYS #define CONFIG_KEY_FAST_SCAN diff --git a/c64/aliases/,aliases_config.s b/c64/aliases/,aliases_config.s index 29fadfed..0f8c30c0 100644 --- a/c64/aliases/,aliases_config.s +++ b/c64/aliases/,aliases_config.s @@ -115,6 +115,19 @@ +// Check if keyboard options are correct + +{ +#if CONFIG_LEGACY_SCNKEY && CONFIG_KEYBOARD_C128 + .error "CONFIG_LEGACY_SCNKEY and CONFIG_KEYBOARD_C128 are mutually exclusive" +#endif +#if CONFIG_KEYBOARD_C128_CAPS_LOCK && !CONFIG_KEYBOARD_C128 + .error "CONFIG_KEYBOARD_C128_CAPS_LOCK requires CONFIG_KEYBOARD_C128" +#endif +} + + + // Handle processor configuration #if CONFIG_CPU_WDC_65C02 || CONFIG_CPU_CSG_65CE02 || CONFIG_CPU_WDC_65816 diff --git a/c64/aliases/,aliases_petscii_codes.s b/c64/aliases/,aliases_petscii_codes.s index 077944b4..c5152228 100644 --- a/c64/aliases/,aliases_petscii_codes.s +++ b/c64/aliases/,aliases_petscii_codes.s @@ -15,8 +15,9 @@ .const KEY_FLAG_SHIFT = %00000001 .const KEY_FLAG_VENDOR = %00000010 .const KEY_FLAG_CTRL = %00000100 -.const KEY_FLAG_ALT = %00001000 // C65 / C128 XXX implement this -.const KEY_FLAG_NO_SCRL = %00100000 // C65 / C128, Open ROMs unofficial XXX implement this +.const KEY_FLAG_ALT = %00001000 // C65 / C128 +.const KEY_CAPS_LOCK = %00010000 // C65 / C128 +.const KEY_FLAG_NO_SCRL = %00100000 // C65 / C128, Open ROMs unofficial // Note - the following PETSCII codes are currently unassigned, can be used for further extensions: diff --git a/c64/kernal/keyboard/scnkey.s b/c64/kernal/keyboard/scnkey.s index 48f59a4b..4c0575ab 100644 --- a/c64/kernal/keyboard/scnkey.s +++ b/c64/kernal/keyboard/scnkey.s @@ -52,7 +52,26 @@ SCNKEY: #endif - // Retrieve SHIFT / VENDOR / CTRL status + // Retrieve SHIFT / VENDOR / CTRL / ALT / CAPS LOCK status + +#if CONFIG_KEYBOARD_C128_CAPS_LOCK + + // First check if this is really a C128 - to avoid false positive + lda #$00 + sta VIC_XSCAN + lda #$FF + cmp VIC_XSCAN + beq !+ // branch if C64, C128 will keep some bits cleared + + lda CPU_R6510 + and #$40 + bne !+ // branch if no CAPS LOCK + + lda #KEY_CAPS_LOCK + sta SHFLAG +!: + +#endif ldy #(__kb_matrix_bucky_confmask_end - kb_matrix_bucky_confmask - 1) scnkey_bucky_loop: @@ -269,14 +288,41 @@ scnkey_output_key: // XXX this will be needed for extended screen editor // cmp KEY_TAB_FW // special handling for SHIFT+TAB - // bne scnkey_got_petscii + // bne scnkey_got_petscii // XXX or to scnkey_handle_caps_lock // lda SHFLAG // special handling for SHIFT+TAB // and #KEY_FLAG_SHIFT // bne !+ // lda KEY_TAB_FW // bne scnkey_got_petscii // branch alWAYS // !: - // lda KEY_TAB_BW + // lda KEY_TAB_BW // bne scnkey_got_petscii if CAPS LOCK is handled + +#if CONFIG_KEYBOARD_C128_CAPS_LOCK + + // Check if we need special handling for a CAPS LOCK key + // This is shorter than a separate set of tables + +scnkey_handle_caps_lock: + + tax + lda SHFLAG + and #(%00000111 + KEY_CAPS_LOCK) + cmp #KEY_CAPS_LOCK + bne !+ // branch if no special CAPS LOCK handling needed + + cpx #$41 // 'A' + bcc !+ + cpx #$5B // 'Z' + 1 + bcs !+ + + txa + clc + adc #$20 // turn lowercase into uppercase + tax +!: + txa + +#endif // CONFIG_KEYBOARD_C128_CAPS_LOCK #else