PETSCII


PETSCII, also known as CBM ASCII, is the character set used in Commodore Business Machines 's 8-bit home computers, starting with the PET from 1977 and including the C16, C64, C116, C128, CBM-II, Plus/4, and VIC-20.

History

The character set was largely designed by Leonard Tramiel and PET designer Chuck Peddle. The graphic characters of PETSCII were one of the extensions Commodore specified for Commodore BASIC when laying out desired changes to Microsoft's existing 6502 BASIC to Microsoft's Ric Weiland in 1977. The VIC-20 used the same pixel-for-pixel font as the PET, although the characters appeared wider due to the VIC's 22-column screen. The Commodore 64, however, used a slightly re-designed, heavy upper-case font, essentially a thicker version of the PET's, in order to avoid color artifacts created by the machine's higher resolution screen. The C64's lowercase characters are identical to the lowercase characters in the Atari 800's system font.
Peddle claims the inclusion of card suit symbols was spurred by the demand that it should be easy to write card games on the PET.

Specifications

PETSCII is based on the 1963 version of ASCII. Assuming the graphics mode is unshifted, PETSCII has only uppercase letters in its powerup state, an up-arrow instead of a caret in position $5E and a left-arrow instead of an underscore in position $5F, these two variants are common in ASCII-1963. Also, in the VIC-20 and C64 version, the backslash in position $5C is occupied by a British pound sign . In unshifted mode, codes $60-$7F and $A0-$FF are allotted to CBM-specific block graphics characters. Ranges $00-$1F and $80-$9F have control codes.
The Commodore PET's lack of a programmable bitmap-mode for computer graphics, as well as it having no redefinable character set capability, may be one of the reasons PETSCII was developed; by creatively using the well thought-out block graphics, a higher degree of sophistication in screen graphics is attainable than by using plain ASCII's letter/digit/punctuation characters. In addition to the relatively diverse set of geometrical shapes that can thus be produced, PETSCII allows for several grayscale levels by its provision of differently hatched checkerboard squares/half-squares. Finally, the reverse-video mode is used to complete the range of graphics characters, in that it provides mirrored half-square blocks.
PETSCII also has a text mode, in which lowercase letters occupy the range $41-$5A, and uppercase letters occupy the range $C1-$DA. The mode is toggled by holding one of the SHIFT keys and then pressing and releasing the Commodore key. Regardless of whether the chip has undergone this graphic "shift", there are block graphic characters in the range of $E0-FF. This serves to distinguish PETSCII from those kinds of ASCII that go back no farther than ASCII-1967, so any text transfer between an 8-bit Commodore machine and one that uses 1967-derived ASCII would result in text where uppercase letters appear to be lowercase, and lowercase letters uppercase. There is no easy Boolean operation to change these cases to the proper case. Thus, as with other computers based on non-standard-ASCII character sets, software conversion is needed when exchanging text files and/or telecommunicating with standard ASCII systems. The other ranges are unchanged in shifted mode; this means that the other characters added in ASCII-1967 besides lowercase lettersi.e. the grave accent, curly braces, vertical bar, and tildedo not exist in PETSCII.
Included in PETSCII are cursor and screen control codes, such as , , , and . The control codes appeared in program listings as reverse-video graphic characters, although some computer magazines, in their efforts to provide more clearly readable listings, pretty-printed the codes using their actual names, like the above examples. Such names were commonly enclosed in curly braces in the listings. This prevented ambiguity, since, as mentioned, PETSCII had no curly brace characters. The screen control codes were essentially similar to escape codes for text based computer terminals.
As indicated above, PETSCII provides for shifting between the power-on default uppercase+graphics character set and the alternative lower+uppercase set. The shift between modes is done by POKEing location 59468 with the value 14 to select the alternative set or 12 to revert to standard. On C64 the sets are alternated by flipping bit 2 of the byte 53272. On some models of PET this can also be achieved via special control code PRINT CHR$ which adjust the line spacing as well as changing the character set; the POKE method is still available and does not alter the line spacing. Thus, screen editor state changes, rather than the employment of separate ASCII codes, are used to choose between single-case and dual case. In the VIC-20, C64, and later machines, color codes supplement the other screen control codes.

Character set

Not all of the characters encoded by PETSCII are 'graphic' and not all of them have a corresponding Unicode representation. The following table shows for PETSCII characters the corresponding Unicode character and code point. Control characters and other non-printing characters are represented by their names. Where a particular code point encodes both a shifted and unshifted character, both characters are shown, with the unshifted character on the left and the shifted character on the right. Row and column headings indicate the hexadecimal digit combinations to produce the eight-bit code value; e.g., the letter L is at code value $4C.
Note that the table below is for the Commodore 64, Commodore 16, and Commodore 128. Control characters differ between these machines and are presented in [|separate tables]. Other Commodore machines used slightly different versions of PETSCII, which used different control characters and in some cases different graphic characters. For example, on CBM machines prior to the VIC-20, characters $2C and $6C both produced a comma character, albeit with slightly different semantics.
The actual character generator ROM used a different set of assignments. For example, to display the characters "@ABC" on screen by directly writing into the screen memory, one would POKE the decimal values 0, 1, 2, and 3 rather than 64, 65, 66, and 67.

Control characters

Some PETSCII codes cannot be printed and are only used for keyboard input.

Commodore 64 control characters

Commodore 16 control characters

Commodore 128, 40-column mode control characters

Commodore 128, 80-column mode control characters

Commodore 65 prototype, 80-column mode control characters

Base 128

Out of PETSCII's first 192 codes, 164 have visible representations : 5, 17–20 and 28–31, 32–90, 91–127, 129, 133–140, 144–159, and 160–192. This theoretically permits encodings, such as base128, in DATA statements, or perhaps between PETSCII-speaking machines; for example, 33–127, 160–192.