Background: The Original PET Keyboard and PETSCII
Most of these keys have their roots in the original Commodore
PET 2001 keyboard:
The scanning and conversion was complex and seems to have
varied somewhat by ROM version, but eventually a PETSCII code would
be produced from a keypress. For the original keyboard, typing a key
with a printable character would produce that PETSCII character, and
holding shift would produce the same character code but with the high
bit set (128 added to it) to give the graphic symbol printed on the
shifted portion of the key.
The other keys produced PETSCII control characters very similiar to
ASCII control characters. As you can see from the table at line
551 of petdoc.txt
, these were:
Lower Shifted Code
--------------------------------------------------
RETURN ^M (CR or carriage return)
RVS RVS OFF ^R
STOP RUN ^C (CAN, cancel)
HOME CLR ^S
CRSR ↓ CRSR ↑ ^Q
CRSR → CRSR ← ^]
DEL INST ^T
Using shift with the above keys (excepting RETURN) would
also set the high bit, just as with the other keys, giving a PETSCII
code in the "high control" area.
STOP/RUN and HOME/CLR
The STOP/RUN and HOME/CLR keys, along with
DEL/INST, CRSR↓/↑, CRSR→/←, do just
what they did on the PET: they send the appropriate key codes which
are then interpreted by the screen editor or, when embedded into a
BASIC string and printed, perform their action. From BASIC you can
also print the PETSCII code directly with, e.g. CHR$(19)
or
CHR$(128+19)
to home the cursor or clear the screen, just as if
you'd pressed or stored the HOME/CLR key.
The CTRL key on the Commodore 64 allows input of the same
characters as all of the unshifted keys above; CTRL S will
do the same thing as pressing HOME. However,
CTRL SHIFT combinations don't work.
The one exception here is STOP/RUN. Neither its unshifted
(CHR$(3)
) nor shifted (CHR$(128+3)
) code does anything when
printed. Additionally, the shifted key does not embed when typing into
a quoted BASIC string and will always type its LOAD
followed by
RUN
sequence.
The Commodore C= Key
The VIC-20 removed the numeric keypad that the PET keyboards had,
combining the numeric and punctuation keys on the top row with the
unshifted keystrokes giving numbers and the shifted keystrokes giving
punctuation (!
, "
, etc.). They also added colour and assigned
character codes to change the colour of the text. A good guess would
be that this is the reason they added the C=: it's a second
kind of shift that now allows three PETSCII codes to be produced from
each key rather than just two. This allows all the original graphics
codes still to be produced and adds enough extra keystroke inputs to
cover the new colours as well. The same keyboard and decoding was used
on the C64, with a few extra color codes added.
Thus, while SHIFT L produced PETSCII code 204 (lower left
box) on both the PET and the C64, SHIFT 6 produced code 182
(right half-box) on the PET but an ampersand &
on the C64, and to
get that code 182 on the C64 you'd instead use C= L.
The RESTORE Key
As others have pointed out, the new RESTORE key added on
the VIC-20 isn't actually connected to the keyboard matrix; it's
connected to the CPU's non-maskable interrupt (NMI) line - this connection is routed through a VIA 6520 interface chip on the VIC-20, but it was turned into a direct connection through a minimal filtering circuit on the C-64. This allows
you to send an interrupt that can't be blocked (like RESET) but makes
it easier to have the running code do a "soft reset" when pressed,
which is a reasonable enough idea. The standard ROMs intercept this
and, if the STOP/RUN is held down while RESTORE
is pressed, do a soft reset, returning you to a clear screen and BASIC
prompt with memory left intact.
down
,del
,"*",8
shift+up
shift+run
would be fewer keystrokes.