From 470c4bded68185f2393822279e712f96e0c44209 Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Wed, 16 Oct 2019 18:57:13 +0200 Subject: [PATCH] finished the new keyboard scanning routine --- CONFIG.md | 40 +++++++++++++++++++++++++++++ STATUS.md | 4 +-- c64/,,config_generic.s | 14 +++++----- c64/,,config_mega65.s | 14 +++++----- c64/,,config_ultimate64.s | 14 +++++----- c64/kernal/keyboard/kb_matrix_128.s | 4 +-- c64/kernal/keyboard/scnkey.s | 20 ++++++++------- c64/kernal/keyboard/scnkey_128.s | 4 +-- 8 files changed, 78 insertions(+), 36 deletions(-) diff --git a/CONFIG.md b/CONFIG.md index 0003def2..49cbef82 100644 --- a/CONFIG.md +++ b/CONFIG.md @@ -105,6 +105,46 @@ Cause the system to support SIDs in `$D4xx` and `$D5xx` ranges, respectively. Each of them needs a couple of bytes in KERNAL segment - but they can share some code, and `$D4xx` range support replaces the standard `$D400` address handling, so exact amount depends on the exact configuration. +## Keyboard + +Original keyboard support routine is just horrible. It does nothing to prevent ghosting - press A+S+D at the same time - it prints F. Try to use joystick connected to control port 1 - it outputs phantom characters. The Open ROMs provides much more sophisticated routines to prevent such problems. + +### `CONFIG_LEGACY_SCNKEY` + +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. + +### `CONFIG_KEYBOARD_C128` + +Allows to use additional keys found on the C128 keyboard. + +Needs 128 bytes more space in KERNAL segment. If unsure - disable. + +### `CONFIG_KEY_REPEAT_DEFAULT` + +Enables key repetition by default during the startup (sets `RPTFLG`). + +Needs 5 bytes more space in KERNAL segment. + +### `CONFIG_KEY_REPEAT_ALWAYS` + +Enables the key repetition and ignores `RPTFLG`. + +Saves 22 bytes from KERNAL segment. + +### `CONFIG_KEY_FAST_SCAN` + +Performs somee speed optimizations in the keyboard scanning routine, at the eexpense of some more ROM space. + +Needs 13 bytes more space in KERNAL segment. Only disable if you are running out of ROM space. + +### `CONFIG_JOY1_CURSOR` and `CONFIG_JOY2_CURSOR` + +Joystick movement also moves the cursor. + +Needs about 65 bytes of ROM space to handle both joysticks. + ## Eye candy ### `CONFIG_BANNER_SIMPLE`, `CONFIG_BANNER_FANCY`, `CONFIG_BANNER_VARIANT` diff --git a/STATUS.md b/STATUS.md index 347d799b..40464b97 100644 --- a/STATUS.md +++ b/STATUS.md @@ -3,8 +3,8 @@ Here are the features of the Open ROMs not found in the original ROMs from the 80s (many of them are [configurable](CONFIG.md)): -* improved keyboard scanning, supports multi-key roll-over and rejection of spurious joystick input -* joystick (port 1) can be used to move text cursor +* improved keyboard scanning, supports anti-ghosting and is resistant to joystick interference (one variant even supports multi-keyy rollover) +* joystick can be used to move text cursor * uses RAM under ROM and I/O: 61438 bytes free * cold/warm start silences multiple SID chips - all $D4xx and $D5xx addresses * wark start due to BRK prints out the instruction address diff --git a/c64/,,config_generic.s b/c64/,,config_generic.s index 2659f198..20fcf7d7 100644 --- a/c64/,,config_generic.s +++ b/c64/,,config_generic.s @@ -48,13 +48,13 @@ // Keyboard settings -// #define CONFIG_LEGACY_SCNKEY // XXX document this -#define CONFIG_KEYBOARD_C128 // XXX document this -// #define CONFIG_KEY_REPEAT_DEFAULT // XXX document this -// #define CONFIG_KEY_REPEAT_ALWAYS // XXX document this -#define CONFIG_KEY_FAST_SCAN // XXX document this -#define CONFIG_JOY1_CURSOR // XXX document this -#define CONFIG_JOY2_CURSOR // XXX document this +// #define CONFIG_LEGACY_SCNKEY +#define CONFIG_KEYBOARD_C128 +// #define CONFIG_KEY_REPEAT_DEFAULT +// #define CONFIG_KEY_REPEAT_ALWAYS +#define CONFIG_KEY_FAST_SCAN +#define CONFIG_JOY1_CURSOR +// #define CONFIG_JOY2_CURSOR // Eye candy diff --git a/c64/,,config_mega65.s b/c64/,,config_mega65.s index 3fce219e..e293a8c4 100644 --- a/c64/,,config_mega65.s +++ b/c64/,,config_mega65.s @@ -50,13 +50,13 @@ // Keyboard settings -#define CONFIG_LEGACY_SCNKEY // XXX document this -// #define CONFIG_KEYBOARD_C128 // XXX document this -// #define CONFIG_KEY_REPEAT_DEFAULT // XXX document this -// #define CONFIG_KEY_REPEAT_ALWAYS // XXX document this -#define CONFIG_KEY_FAST_SCAN // XXX document this -#define CONFIG_JOY1_CURSOR // XXX document this -#define CONFIG_JOY2_CURSOR // XXX document this +#define CONFIG_LEGACY_SCNKEY +// #define CONFIG_KEYBOARD_C128 +// #define CONFIG_KEY_REPEAT_DEFAULT +// #define CONFIG_KEY_REPEAT_ALWAYS +#define CONFIG_KEY_FAST_SCAN +#define CONFIG_JOY1_CURSOR +#define CONFIG_JOY2_CURSOR // Eye candy diff --git a/c64/,,config_ultimate64.s b/c64/,,config_ultimate64.s index f1f55f9d..05f45f59 100644 --- a/c64/,,config_ultimate64.s +++ b/c64/,,config_ultimate64.s @@ -48,13 +48,13 @@ // Keyboard settings -// #define CONFIG_LEGACY_SCNKEY // XXX document this -// #define CONFIG_KEYBOARD_C128 // XXX document this -// #define CONFIG_KEY_REPEAT_DEFAULT // XXX document this -// #define CONFIG_KEY_REPEAT_ALWAYS // XXX document this -#define CONFIG_KEY_FAST_SCAN // XXX document this -#define CONFIG_JOY1_CURSOR // XXX document this -#define CONFIG_JOY2_CURSOR // XXX document this +// #define CONFIG_LEGACY_SCNKEY +// #define CONFIG_KEYBOARD_C128 +// #define CONFIG_KEY_REPEAT_DEFAULT +// #define CONFIG_KEY_REPEAT_ALWAYS +#define CONFIG_KEY_FAST_SCAN +#define CONFIG_JOY1_CURSOR +#define CONFIG_JOY2_CURSOR // Eye candy diff --git a/c64/kernal/keyboard/kb_matrix_128.s b/c64/kernal/keyboard/kb_matrix_128.s index 40657284..105693e0 100644 --- a/c64/kernal/keyboard/kb_matrix_128.s +++ b/c64/kernal/keyboard/kb_matrix_128.s @@ -7,7 +7,7 @@ // -#if CONFIG_KEYBOARD_C128 +#if CONFIG_KEYBOARD_C128 && !CONFIG_LEGACY_SCNKEY kb_matrix_128: @@ -27,4 +27,4 @@ kb_matrix_128_bucky_filter: -#endif // CONFIG_KEYBOARD_C128 +#endif // CONFIG_KEYBOARD_C128 and no CONFIG_LEGACY_SCNKEY diff --git a/c64/kernal/keyboard/scnkey.s b/c64/kernal/keyboard/scnkey.s index 3f43cc2a..a3fb99c5 100644 --- a/c64/kernal/keyboard/scnkey.s +++ b/c64/kernal/keyboard/scnkey.s @@ -273,15 +273,17 @@ scnkey_output_key: !: lda kb_matrix_128 - $40, y // retrieve key code from C128 extended matrix - cmp KEY_TAB_FW // special handling for SHIFT+TAB - bne scnkey_got_petscii - 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 + + // XXX this will be needed for extended screen editor + // cmp KEY_TAB_FW // special handling for SHIFT+TAB + // bne scnkey_got_petscii + // 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 #else diff --git a/c64/kernal/keyboard/scnkey_128.s b/c64/kernal/keyboard/scnkey_128.s index 6763a201..a6d14acf 100644 --- a/c64/kernal/keyboard/scnkey_128.s +++ b/c64/kernal/keyboard/scnkey_128.s @@ -6,7 +6,7 @@ // -#if CONFIG_KEYBOARD_C128 +#if CONFIG_KEYBOARD_C128 && !CONFIG_LEGACY_SCNKEY // Inlining this within SCNKEY would both overcomplicate the implementation @@ -74,4 +74,4 @@ scnkey_128_no_keys: jmp scnkey_no_keys // pass controll to original routine -#endif // CONFIG_KEYBOARD_C128 +#endif // CONFIG_KEYBOARD_C128 and no CONFIG_LEGACY_SCNKEY