...
Tip: If you notice buggy behavior that may be attributed to ROM 920387, try reproducing it, then try again in ROM 920386, which uses the original keyboard scanner. You do not need to go back to the previous version of the core for this to be usefultest. Include reproduction steps and a description of the behavior in both ROMs in your bug report.
Remember: ROM 920387 will not work with older cores.
Known issues
The virtual keyboard registers are glitchy with the new keyboard scanner with regards to modifier keys. These registers are used by the
m65
tool's typing feature.m65 -T 'run "*"'
will sporadically type a2
instead of a"
.
Test plan
This change is not expected to break any ROM features or MEGA65 applications. Software that uses the ROM’s getin
entry point will benefit from the new typing accuracy automatically. This includes BASIC programs that use the GET
/ GETKEY
commands. The change is expected to be compatible with existing applications that use the documented ASCIIKEY register, or do their own keyboard scanning of the CIA lines. It is not expected to affect GO64 mode or older ROMs running on the latest core. (Legacy-style CIA keyboard scanning in software still functions.)
In theory, this change might violate pre- and post-conditions of keyboard related KERNAL entry points, described later in this document. In the context of the MEGA65, these behaviors are undocumented to an extent that MEGA65 applications should not be using them. For example, C64 coders might be used to manipulating the KERNAL’s keyboard buffer directly, and this no longer works the same way in the MEGA65. The keyboard buffer location and behavior is not documented for direct access by a program in the MEGA65 ROM.
...
The legacy scanner potentially misses keystrokes because of a limitation in how keys are wired to the CIA chip. The CIA can only detect so many keys pressed at one time, constrained to a pattern in the wiring. Fast typists tend to press the next key before releasing the previous key, and will notice that specific keys in specific words tend to get skipped more than others. (Personally, I can’t type the word “MOUNT” at my usual typing speed using the legacy keyboard scanner. It always comes out as “MONT” unless I slow down.) The MEGA65 core fully replicates this behavior of CIA chips.
...
The getin
KERNAL routine processes the hardware typing event queue. Each time the KERNAL or a program tries to read a key via this routine, it reads from either 1) the active function key macro, 2) an internal buffer, or 3) the hardware typing event queue, in that order. When it reads from the hardware queue, it dequeues what it reads. The screen editor only calls getin
when it is waiting for input, unlike the keyboard IRQ routine which is called 50/60 times per second regardless of what program is running.
...
When the user presses Ctrl-S, it appears on the typing event queue.
getin
always skips Ctrl-S when it finds it in the queue, allowing the KERNAL IRQ routine to handle it via CIA lines as before. (This is functionally identical to previous ROM behavior:getin
never returns Ctrl-S.)Mega + Shift and No Scroll do not appear on the typing event queue when typed alone because they are modifier keys and not considered typing events. The keyboard IRQ can detect these key presses by testing $d611, which presents the immediate state of the modifier keys independently of typing events.
The keyboard IRQ routine is still accessible via the
key
routine atjsr $ffdf
. It is still worth calling from a program if the program replaces the KERNAL IRQ and wants to support Mega + Shift and No Scroll. The routine no longer populates a buffer, because this is handled in the core.The KERNAL still has an internal key buffer to support BASIC65 AUTO, and possibly future KERNAL features that wish to inject keystrokes into the input stream. (These variables are still undocumented for now.)
The KERNAL routine that scans for Run/Stop at
jsr $ffe1
is unaffected by this change. It still reads it from the CIA lines.The code that initiates a function key macro now lives in
getin
instead of the keyboard IRQ. This is an implementation detail that won’t be noticed by programs, because only the next call togetin
is affected by activating a function key macro.All other changes to the flow are internal to the KERNAL and screen editor. There is an internal screen editor subroutine jump table not documented for use by programs, and its API has changed.
The C65 ROM has a collection of extension vectors that are intended for use by programs but not yet documented. For example, once documented, a program can replace the vector that points to the KERNAL’s implementation of
getin
with another routine, typically one that calls the original getin routine along with some new extended behavior. None of these vectors are considered documented yet. The new ROM changes the extension vector APIs that Commodore intended for the keyboard IRQ. The MEGA65 project will document these vectors once we are confident that they work, are well designed, and won’t need to change again.