Why does PETSCII have upper case and lower case reversed?

The PETSCII character encoding that is used on the Commodore 64 (and all other Commodore 8 bit computers) is similar to ASCII, but different: Uppercase and lowercase are swapped! Why is this?

The "PET 2001" from 1977 had a built-in character set of 128 characters. This would have been enough for the 96 printable ASCII characters, and an extra 32 graphical characters. But Commodore decided to replace the 26 lowercase characters with even more graphical characters. After all, the PET did not support a bitmapped display, so the only way to display graphics was using the graphical characters built into the character set. These consisted of symbols useful for box drawing as well as miscellaneous symbols (including the french deck suits).

So the first PET was basically using ASCII, but with missing lower case. This had an influence on the character codes produced by the keyboard:

Key ASCII keyboard PET keyboard
A a ($61) A ($41)
Shift + A A ($41) ♠ ($C1)

On a standard ASCII system, pressing "A" unshifted produces a lower case "a", and together with shift, it produces an uppercase "A". On a PET, because there is no lower case, pressing "A" unshifted produces an uppercase "A", and together with shift produces the "spade" symbol ("♠") from the PET-specific graphical characters.

Later Commodore 8 bit computers added a second character set that supported uppercase and lowercase. Commodore decided to allow the user to switch between the two character sets at any time (by pressing the "Commodore" and "Shift" keys together), so applications generally didn't know which character set was active. Therefore, the keyboard had to produce the same character code independent of the current character set:

key ASCII keyboard PET keyboard (upper/graph) PET keyboard (upper/lower)
A a ($61) A ($41) a ($41)
Shift + A A ($41) ♠ ($C1) A ($C1)

An unshifted "A" still produces a code of $41, but it has to be displayed as a lower case "a" if the upper/lower character set is enabled, so Commodore had to put lower case characters at the $40-$5F area – which in ASCII are occupied by the uppercase characters. A shifted "A" still produces a code of $C1, so Commodore put the uppercase characters into the $C0-$DF area.

Now that both upper case and lower case were supported, Commodore decided to map the previously undefined $60-$7F area to upper case as well:

range ASCII upper case PETSCII lower case PETSCII lower case PETSCII with fallback
$40-$5F upper case upper case lower case lower case
$60-$7F lower case undefined undefined upper case
$C0-$DF undefined graphical upper case upper case

If you only look at the area between $00 and $7F, you can see that PETSCII reverses upper and lower case compared to ASCII, but the $60-$7F area is only a compatibility fallback; upper case is actually in the $C0-$DF area – it's what the keyboard driver produces.

2 thoughts on “Why does PETSCII have upper case and lower case reversed?”

  1. Actually, the PET already supported lowercase just fine! You could enable it with poke 59468,14. This changed which half of the character generator ROM was active.

    Remember that PETSCII worked such, that typing a key together with shift added 128 to the PETSCII code (on the original non-business variants of the PET keyboard). The valid visible characters are therefore $20-$5F and $A0-$DF. $00-$1F and $80-$9F are control codes, and $60-$7F and $E0-$FE are undefined ($FF was some sort of exception and depicted pi). The undefined characters get mapped to printables in some undefined way, that I think even changed in various later computer versions. So your table is incorrect; note that the results of GET A$; PRINT ASC(A$) is leading, not what PRINT produces. PETSCII doesn’t have upped and lower case “reversed”, it has it in completely different ranges than ASCII. The Wikipedia article on PETSCII is wrong, but the Talk page discusses fixes which nobody apparently applied.

    In the first version, if you enabled lower case, the graphics characters that are available on the shifted letters would be replaced by lower case letters.

    Apparently somebody thought that having to press shift to get lower case characters was too weid, and they swapped the letters (but nothing else) in the lowercase ROM. And that version has been carried over to the VIC-20 and later.

  2. Yes. So if you create a program that displays mixed-case text correctly on all Commodore 8-bit computers from the second version of the PET (3000 series) onward, it will display with upper- and lower-case reversed on the original PET 2001.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.