# C64/PETSCII block graphic symbol: was there ever a logical reason for their "ASCII" codes?

You know those block graphic symbols that allows you to draw lines, corners, intersections, fine bar charts, etc. they are useful and one can do a lot of stuff, but their code arrangements always struck me as arbitrary / random. But then maybe I just haven’t figured out the logic. Does anybody know why they ended up with the codes they got?

For what it's worth, I did a quick photo of my C-64 and VIC-20 keyboards, so it's very easy to see the physical grouping of the various graphics/symbols.

Commodore C-64 Keyboard:

Commodore VIC-20 Keyboard:

Answered by Geo... on August 20, 2020

The "PETSCII" encoding is based on keyboard positions of the original PET chicklet keyboard (*1):

(Taken from Wikipedia)

The keyboard is made similar to basic typewriter keyboards, but ordered in a square fashion, including a top row of symbols but not numbers and a separate numeric keyboard. By every key holding only a single ASCII equivalent symbol (*2), it leads to a direct encoding of ASCII as key position.

As a side effect the whole shift level could be used for graphics, as they did. All symols are ordered in a (mostly) useful pattern, like having UIJK forming the 4 sections of a circle, OPL: doing the same for the corners of a large square and 0.-=the same for a small square.

It not only looks neat on the keyboard but also makes a good UI as far as ordering of symbols can get.

The downside is that graphic symbols are encoded according to the (unsifted) character code. And here combinations like UIJK are simply non-continuous. As listing the PETSCII assignment shows:

(Taken from Wikipedia)

From a programmers perspective this is less than perfect. A logical sequence for related items (*3) could have been more helpful. This is especially true for the 16 codes that form a 2x2 division of a character cell would allow an easy 'bitmap' mode for 80x48 pixel (*4). Much like contemporary TRS-80 and Sinclair's ZX80/81 some years later.

An additionally sad part is that PETSCII itself isn't direct used for display, but translated into screencodes beforehand. If not right ahead, this would have been a good point to reorder.

... and so it became history :)

*1 - The Wikipedia entry for 'Chicklet Keyboard' is a nice example for a retrograde explanation.

*2 - Almost as if the first version was not meant to use shift.

*3 - Much like ASCII offers a monotone sequence for numbers ($30..$39) and letters ($41..$5A). The later according to the usual lexical sequence, as made popular by Bartholomeus Anglicus.

*4 - As usual the have been used anyway, but with a translation layer. Some of them, written in BASIC, look more like on purpose obfuscation.

Answered by Raffzahn on August 20, 2020

I think the codes were laid out so that when laid out sensibly on the PET keyboard, the shifted and unshifted forms of each key would have a consistent relationship. When the VIC-20 reduced the number of keys but added the Commodore key, this made it necessary to rearrange the placement of graphics on the keys; since Commodore kept the same arrangement of character codes, however, this meant that the arrangement no longer seemed to make as much sense.

One can see a similar effect in the design of ASCII. Many typewriters used to use a shifted 2 for a quotation mark, early teletypes did likewise, and thus the ASCII code for the quote mark is one bit different from that of the digit 2, even though modern keyboards use a shifted apostrophe as the quote mark.

Answered by supercat on August 20, 2020

## Related Questions

### Commercial C64 software implemented in Forth?

3  Asked on January 5, 2022

### Execution time for conditional jumps on the Intel 8080

1  Asked on January 3, 2022

### C64 cartridge emulation with ATmega

5  Asked on December 25, 2021 by masteraldo

### How does DMACON/R registers on Commodore Amiga platform work?

1  Asked on December 25, 2021 by marko-l

### DRAW instruction timing

1  Asked on December 25, 2021

### Were any M68000 systems capable of generating a “spurious interrupt”?

2  Asked on December 23, 2021

### Change color of the text written in PPU memory (NES-Super Mario Bros)

2  Asked on December 23, 2021 by kbc

### Which computers had redefinable character sets?

23  Asked on December 9, 2021 by richf

2  Asked on December 9, 2021 by fancypants

### Did OSes write the floppy’s logical sector number resulting from sector interleave/skew in the IDAM sector ID, or was it up to the OS?

1  Asked on November 24, 2021

### Does the 6502’s TXS and TSX affect flags or not?

1  Asked on November 12, 2021

### (Lack of) identifying IRQ sources in C64 interrupt handlers

2  Asked on November 12, 2021

### Sources for some old BASIC games

4  Asked on November 10, 2021

### Was the Ram Turbo the only 3rd party Interface 2 ROM cartridge interface for the ZX Spectrum or were there others?

1  Asked on November 7, 2021

### Why were computer customers called “Users”?

19  Asked on August 25, 2021 by brian-h

### Did many programs really store years as two characters (Y2K bug)?

14  Asked on August 25, 2021 by mr-chem-question

### Why were “data modems” so much more expensive compared to “fax modems” back in the day?

7  Asked on August 25, 2021 by b-yath

### Was it possible to write a novel on a BBC Micro 16kb/32kb memory era computer without expansions?

11  Asked on August 25, 2021 by nibblypig

### What’s the terminal/home computer used as a prop in the computer school in Superman 3?

4  Asked on August 25, 2021 by jdebp

### Did any computer use a 7-bit byte?

7  Asked on August 25, 2021