NEWS, EDITORIALS, REFERENCE

Subscribe to C64OS.com with your favorite RSS Reader
January 19, 2018#52 Reference

VIC-20 / Commodore 64 SuperChart

Post Archive Icon

This table appears in The Complete Commodore Inner Space Anthology, pages 37 and 38. The data are rearranged here to best suit the format of a webpage, and a couple of pretty big errors in the Inner Space Anthology listing have been corrected. Corrections are noted below each block.

It is called a SuperChart because it lists the PETSCII, ScreenCode (both character sets), BASIC character/token, and 6502 operation for every value in the 8-bit range. The numeric values are conveniently given in both decimal and hexadecimal. I'm digitizing it so I can have access to it without having the reference text open on the desk in front of me, and tagging it here as Programming Reference for others to find. Hopefully someone out there will find this chart as useful as I do.


PETSCII, ScreenCodes and BASIC codes are roughly divided into 8 blocks of 32 characters each. For this reason, the chart is presented below as eight 32-row tables. See the end discussion for an explanation of PETSCII's block structure.

SuperChart

Bit 7 Low: %0xxx xxxx

Bit 7 High: %1xxx xxxx

Block 1

DEC HEX PETSCII SCREEN
(up/gfx, lo/up)
BASIC 6502
0 00   @ end-line BRK
1 01   A a   ORA(I,X)
2 02   B b    
3 03 stop C c    
4 04   D d    
5 05 white E e   ORA Z
6 06   F f   ASL Z
7 07   G g    
8 08 lock H h   PHP
9 09 unlock I i   ORA #
10 0A   J j   ASL A
11 0B   K k    
12 0C   L l    
13 0D car ret M m   ORA
14 0E text N n   ASL
15 0F   O o    
16 10   P p   BPL
17 11 cur down Q q   ORA(I),Y
18 12 reverse R r    
19 13 cur home S s    
20 14 delete T t    
21 15   U u   ORA Z,X
22 16   V v   ASL Z,X
23 17   W w    
24 18   X x   CLC
25 19   Y y   ORA Y
26 1A   Z z    
27 1B   [    
28 1C red £    
29 1D cur right ]   ORA X
30 1E green Up Arrow   ASL X
31 1F blue Left Arrow    

Corrections: Inner Space Anthology lists the block-1 alphabetic SCREEN CODES as only uppercase. They should be uppercase in the upper/graphics character set, and lowercase in the lower/upper character set, as shown above.

Corrections: Inner Space Anthology lists the SCREEN CODE $1C as a backslash. It should be the british pound symbol (£) as shown above.

 

Block 2

DEC HEX PETSCII SCREEN
(up/gfx, lo/up)
BASIC 6502
32 20 space space space JSR
33 21 ! ! ! AND(I,X)
34 22 " double quote "  
35 23 # # #  
36 24 $ $ $ BIT Z
37 25 % % % AND Z
38 26 & & & ROL Z
39 27 ' apostrophe '  
40 28 ( ( ( PLP
41 29 ) ) ) AND #
42 2A * * * ROL A
43 2B + + +  
44 2C , , , BIT
45 2D - - - AND
46 2E . . . ROL
47 2F / / /  
48 30 0 0 0 BMI
49 31 1 1 1 AND(I),Y
50 32 2 2 2  
51 33 3 3 3  
52 34 4 4 4  
53 35 5 5 5 AND Z,X
54 36 6 6 6 ROL Z,X
55 37 7 7 7  
56 38 8 8 8 SEC
57 39 9 9 9 AND Y
58 3A : : :  
59 3B ; ; ;  
60 3C < less than <  
61 3D = = = AND X
62 3E > greater than > ROL X
63 3F ? ? ?  

Block 3

DEC HEX PETSCII SCREEN
(up/gfx, lo/up)
BASIC 6502
64 40 @ @ RTI
65 41 a A A EOR(I,X)
66 42 b B B  
67 43 c C C  
68 44 d D D  
69 45 e E E EOR Z
70 46 f F F LSR Z
71 47 g G G  
72 48 h H H PHA
73 49 i I I EOR #
74 4A j J J LSR A
75 4B k K K  
76 4C l L L JMP
77 4D m M M EOR
78 4E n N N LSR
79 4F o O O  
80 50 p P P BVC
81 51 q Q Q EOR(I),Y
82 52 r R R  
83 53 s S S  
84 54 t T T  
85 55 u U U EOR Z,X
86 56 v V V LSR Z,X
87 57 w W W  
88 58 x X X CLI
89 59 y Y Y EOR Y
90 5A z Z Z  
91 5B [ [  
92 5C £ £  
93 5D ] ] EOR X
94 5E LSR X
95 5F  

Corrections: Inner Space Anthology lists the block-3 PETSCII alphabetic characters as uppercase. They should be lowercase as shown above.

Corrections: Inner Space Anthology lists the block-3 SCREEN CODES lower/upper alphabetic characters as lowercase. They should be uppercase as shown above.

Block 4

DEC HEX PETSCII SCREEN
(up/gfx, lo/up)
BASIC 6502
96 60     RTS
97 61     ADC(I,X)
98 62      
99 63      
100 64      
101 65     ADC Z
102 66     ROR Z
103 67      
104 68     PLA
105 69     ADC #
106 6A     ROR A
107 6B      
108 6C     JMP(I)
109 6D     ADC
110 6E     ROR
111 6F      
112 70     BVS
113 71     ADC(I),Y
114 72      
115 73      
116 74      
117 75     ADC Z,X
118 76     ROR Z,X
119 77      
120 78     SEI
121 79     ADC Y
122 7A      
123 7B      
124 7C      
125 7D     ADC X
126 7E     ROR X
127 7F      

Block 5

DEC HEX PETSCII SCREEN
(up/gfx, lo/up)
BASIC 6502
128 80   @ reversed END  
129 81 orange A reversed a reversed FOR STA(I,X)
130 82   B reversed b reversed NEXT  
131 83 load & run C reversed c reversed DATA  
132 84   D reversed d reversed INPUT# STY Z
133 85 F1 E reversed e reversed INPUT STA Z
134 86 F3 F reversed f reversed DIM STX Z
135 87 F5 G reversed g reversed READ  
136 88 F7 H reversed h reversed LET DEY
137 89 F2 I reversed i reversed GOTO  
138 8A F4 J reversed j reversed RUN TXA
139 8B F6 K reversed k reversed IF  
140 8C F8 L reversed l reversed RESTORE STY
141 8D car ret M reversed m reversed GOSUB STA
142 8E graphics N reversed n reversed RETURN STX
143 8F   O reversed o reversed REM  
144 90 black P reversed p reversed STOP BCC
145 91 cur up Q reversed q reversed ON STA(I),Y
146 92 rvs off R reversed r reversed WAIT  
147 93 clear S reversed s reversed LOAD  
148 94 insert T reversed t reversed SAVE STY Z,X
149 95 brown U reversed u reversed VERIFY STA Z,X
150 96 lt. red V reversed v reversed DEF STX Z,X
151 97 dk. grey W reversed w reversed POKE  
152 98 md. grey X reversed x reversed PRINT# TYA
153 99 lt. green Y reversed y reversed PRINT STA Y
154 9A lt. blue Z reversed z reversed CONT TXS
155 9B lt. grey [ reversed LIST  
156 9C purple £ reversed CLR  
157 9D cur left ] reversed CMD STA X
158 9E yellow Up Arrow reversed SYS  
159 9F cyan Left Arrow reversed OPEN  

Corrections: Inner Space Anthology lists the block-5 reversed alphabetic SCREEN CODES as only uppercase. They should be uppercase in the upper/graphics character set, and lowercase in the lower/upper character set, as shown above.

Block 6

DEC HEX PETSCII SCREEN
(up/gfx, lo/up)
BASIC 6502
160 A0 space CLOSE LDY #
161 A1 ! GET LDA(I,X)
162 A2 double quote NEW LDX #
163 A3 # TAB(  
164 A4 $ TO LDY Z
165 A5 % FN LDA Z
166 A6 & SPC( LDX Z
167 A7 apostrophe THEN  
168 A8 ( NOT TAY
169 A9 ) STEP LDA #
170 AA * + TAX
171 AB + -  
172 AC , * LDY
173 AD - / LDA
174 AE . LDX
175 AF / AND  
176 B0 0 OR BCS
177 B1 1 > LDA(I),Y
178 B2 2 =  
179 B3 3 <  
180 B4 4 SGN LDY Z,X
181 B5 5 INT LDA Z,X
182 B6 6 ABS LDX Z,X
183 B7 7 USR  
184 B8 8 FRE CLV
185 B9 9 POS LDA Y
186 BA : SQR TSX
187 BB ; RND  
188 BC less than LOG LDY X
189 BD = EXP LDA X
190 BE greater than COS LDX Y
191 BF ? SIN  

Note: Inner Space Anthology lists two PETSCII values at $A9 and $BA in the block-6 range. See end discussion on the changes I've made above.

Block 7

DEC HEX PETSCII SCREEN
(up/gfx, lo/up)
BASIC 6502
192 C0 TAN CPY #
193 C1 A A ATN CMP(I),X
194 C2 B B PEEK  
195 C3 C C LEN  
196 C4 D D STR$ CPY Z
197 C5 E E VAL CMP Z
198 C6 F F ASC DEC Z
199 C7 G G CHR$  
200 C8 H H LEFT$ INY
201 C9 I I RIGHT$ CMP #
202 CA J J MID$ DEX
203 CB K K GO  
204 CC L L   CPY
205 CD M M   CMP
206 CE N N   DEC
207 CF O O    
208 D0 P P   BNE
209 D1 Q Q   CMP(I),Y
210 D2 R R    
211 D3 S S    
212 D4 T T    
213 D5 U U   CMP Z,X
214 D6 V V   DEC Z,X
215 D7 W W    
216 D8 X X   CLD
217 D9 Y Y   CMP Y
218 DA Z Z    
219 DB    
220 DC    
221 DD   CMP X
222 DE   DEC X
223 DF    

Corrections: Inner Space Anthology lists the block-7 PETSCII alphabetic characters as lowercase. They should be uppercase as shown above.

Note: Inner Space Anthology lists two PETSCII values from $C1 to $DA, $DE and $DF in the block-7 range. See end discussion on the changes I've made above.

Block 8

DEC HEX PETSCII SCREEN
(up/gfx, lo/up)
BASIC 6502
224 E0     CPX #
225 E1     SBC(I),X
226 E2      
227 E3      
228 E4     CPX Z
229 E5     SBC Z
230 E6     INC Z
231 E7      
232 E8     INX
233 E9     SBC #
234 EA     NOP
235 EB      
236 EC     CPX
237 ED     SBC
238 EE     INC
239 EF      
240 F0     BEQ
241 F1     SBC(I),Y
242 F2      
243 F3      
244 F4      
245 F5     SBC Z,X
246 F6     INC Z,X
247 F7      
248 F8     SED
249 F9     SBC Y
250 FA      
251 FB      
252 FC      
253 FD     SBC X
254 FE     INC X
255 FF   π  

Corrections: Inner Space Anthology lists the block-8 reversed SCREEN CODES at $F7, $F8, and $F9 as their non-reversed counterparts at $77, $78 and $79. They should be reversed as shown above.

UPDATE: February 20, 2018

Here are scans I found online of the SuperChart from pages 37 and 38 of the Complete Commodore Inner Space Anthology. The above chart is my own version / arrangement of this data. And the Inner Space Anthology version has errors as noted in my version.

Page 37 of Inner Space Anthology Page 38 of Inner Space Anthology

Discussion

Understanding the difference between PETSCII values and Screen Codes can be confusing. The lists you will find if you search the internet for PETSCII Table do not all agree with one another, nor do they all agree with older listings found in books such as The Complete Commodore Inner Space Anthology. My SuperChart listing above is derived from Inner Space Anthology. I have made some corrections, as noted above, but I've also made some changes. I want to explain my reasons for the changes, even if others would not agree with me.

Screen Codes

Screen Codes are easy to understand when divorced from their conversion from PETSCII values. There are 256 Screen Codes. Any screen code value from 0 to 255, which occurs in a screen memory location, will be rendered by the VIC-II chip with a unique visual appearence. (When the VIC-II is in its standard text mode.)

The appearence of that character depends on the character set that is used. A character set is a 2 kilobyte bitmap. The screen code value is an index into that character set bitmap. The C64 and VIC-20 come with a character ROM, which is 4 kilobytes and contains 2 complete character sets. Additionally, custom character sets can be defined in RAM. Therefore, what actually gets displayed on screen is determined by the contents of the character set.

In the two built-in character sets, the bottom half, 0 to 127, are all unique. But the upper half, 128 to 255, are the reverse of the bottom half. Conveniently, this means that toggling bit 7 of any screen code will exchange that character with the inverse version of itself. Custom character sets do not need to adhere to this standard, but the fact that the two built-in sets work this way was a very clever design decision. In order to make the cursor blink, the KERNAL need only toggle bit 7 on and off. A nice side effect is that it allows text to be written in reverse characters for titles that stand out, and doubles the available graphics characters for drawing PETSCII-based images.

PETSCII Values

What the PETSCII values actually are is more contentious. Obviously, it cannot be the case that there is a one-to-one relationship between PETSCII values and Screen Codes. If there were, then every PETSCII value would have a visual representation, and there would be no room in the 8-bit space for control codes.

The tables above are divided into 8 blocks of 32 characters, because PETSCII itself is divided into 8 blocks. And it is easiest to understand PETSCII by comparing those blocks with each other. The 8 blocks are further subdivided into the low 4 blocks, and the high 4 blocks, as indicated in the table of contents links at the top of the SuperChart. The high 4 blocks are like a shifted version of the low 4 blocks.

  • Block 1 → shifted → Block 5
  • Block 2 → shifted → Block 6
  • Block 3 → shifted → Block 7
  • Block 4 → shifted → Block 8

PETSCII uses blocks 1, 2 and 3, and their shifted equivalents, 5, 6 and 7. PETSCII leaves block 4, and its shifted equivalent block 8, undefined. This provides a space of 192 values, however, in practice 22 of even those values are not defined.

The general scheme, with minor exceptions, is as follows:

  • Block 1: Control Codes
  • Block 2: Symbolic / Numeric
  • Block 3: Alphabetic (Lowercase)
  • Block 4: Unused

The shifted corresponding blocks are as follows:

  • Block 5: Control Codes (Often with inverse role)
  • Block 6: Symbolic (Graphical)
  • Block 7: Alphabetic (Uppercase)
  • Block 8: Unused

If you look at the two blocks of control codes, the unshifted block 1 is almost always inverted by the same code in the shifted block 5, (if that control code is dual in nature at all.) For example:

  • Stop → Run
  • Text → Graphics
  • Cursor Down → Cursor Up
  • Reverse On → Reverse Off
  • Home → Clear
  • Delete → Insert
  • Cursor Right → Cursor Left

The alphabetic block 3 values are therefore the lowercase letters, which become their uppercase equivalents in the shifted block 7.

And the symbolic / numeric block 2 becomes a set of 32 graphical symbols in the shifted block 6. The set of symbols don't have conceptual shifted alternatives, that's why the shifted block 6 is the block used for graphic symbols.

Strings of PETSCII that are output through the KERNAL's Screen Editor are interpreted and mapped into Screen Codes, which are put in memory to be displayed. For example, there is no PETSCII code that represents "reversed lowercase a". However, the following PETSCII sequence: $0E, $12, $41, (that is "the control code for Lowercase/Uppercase character set", "the control code for Reverse On", and the PETSCII value for "a") will cause a reversed lowercase "a" to appear on the screen wherever the cursor currently is, and then the cursor will be advanced. That sequence of PETSCII is interpreted by the KERNAL, but it results in the Screen Code $81 being put into screen memory, and the Lowercase/Uppercase character set being selected.

Confusion from Character Sets and Conversions

The above description of PETSCII is hard to uncover, because of how the alternative character set is laid out, and how PETSCII values are interpreted by the KERNAL's Screen Editor and converted to Screen Codes for display.

When a Commodore 64 is first turned on it is using the Uppercase/Graphics character set, rather than the Lowercase/Uppercase character set. It may simply be that Commodore thought having more graphics characters to work with in exchange for having only one case of alphabetic characters seemed like a good trade off.

Now, if you're going to provide only one case of letters in a character set it will be uppercase not lowercase. Why is that? Well, many things are written in all-caps, but very few things are ever written in all lowercase. Hence the existence of the term all-caps, and the existence of all-caps fonts. Many words, such as the pronoun I and most proper names cannot be correctly rendered in small letters alone. In fact, in ancient writing, Latin, Greek, and Hebrew, there were no small letters, that is, no miniscules only majuscules. So it makes sense that the alternative character set is Uppercase/Graphics and not Lowercase/Graphics.

However, it also makes sense that in the Uppercase/Graphics character set, it is the lowercase PETSCII values that are replaced by uppercase glyphs. Otherwise, when in Uppercase/Graphics mode you would have to constantly hold down shift in order to get letters instead of graphic symbols. But on the other hand, when you do switch character sets, it has to be that whatever you've typed without the shift key will appear as lowercase characters, otherwise, in the Lowercase/Uppercase character set, you'd be getting uppercase characters without the shift key, and you'd have to press the shift key to get a lowercase character. That just doesn't make any sense.

And so, all this taken into consideration, one should not be confused about the PETSCII values on account of the existence, availability and even default-status of the Uppercase/Graphics character set. It is merely a character set, an alternative on-screen representation, that renders lowercase PETSCII values using a set of uppercase glyphs, and renders uppercase PETSCII values with an extended set of graphical glyphs. In a conversion from ASCII to PETSCII, though, ASCII's uppercase characters map to PETSCII's block 7, and ASCII's lowercase characters map to PETSCII's block 3.

In my opinion, a "standard code of information interchange," which is what the SCII in PETSCII stands for, cannot have multiple meanings for the same value. Given that I feel there are good arguments that the lowercase alphabetic characters are in block 3, and the uppercase equivalents are in block 7, then the Lowercase/Uppercase character set should be used for deriving the canonical PETSCII values in block 6 and 7 where there are alternatives.

Specifically, $A9 and $BA. These are mapped by the KERNAL to the Screen Codes $69 and $7A respectively. In this entire block (block 6), both character sets are identical, except for these two values. My listing indicates that the canonical PETSCII value is the character that appears in the Lowercase/Uppercase set, and that the other glyph is merely a result of swapping in an alternative character set.

The only other contentious spot is $DE and $DF in block 7. These get mapped by the KERNAL to the Screen Codes $5E and $5F, where there is an alternative appearence in the Uppercase/Graphics set. This ambiguity is not there when you type the unshifted ↑ (PETSCII $5E, mapped to Screen Code $1E), because $1E is identical in both character sets.

The Character Sets

Here are the character set images, to help clarify how the Screen Codes work and differ between them.

Lowercase Uppercase Character Set @2X Uppercase Graphics Character Set @2X

Lowercase/Uppercase Character Set, and Uppercase/Graphics Character Set.

Do you like what you see?

You've just read one of my high-quality, long-form, weblog posts, for free! First, thank you for your interest, it makes producing this content feel worthwhile. I love to hear your input and feedback in the forums below. And I do my best to answer every question.

I'm creating C64 OS and documenting my progress along the way, to give something to you and contribute to the Commodore community. Please consider purchasing one of the items I am currently offering or making a small donation, to help me continue to bring you updates, in-depth technical discussions and programming reference. Your generous support is greatly appreciated.

Greg Naçu — C64OS.com

Want to support my hard work? Here's how!