Jump to content

PETSCII

From Wikipedia, the free encyclopedia

This is an old revision of this page, as edited by Frietjes (talk | contribs) at 16:05, 22 August 2016 (→‎Codepage layout: more excess br). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

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

History

The character set was largely designed by Leonard Tramiel (the son of Commodore CEO Jack 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.[1] 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 (released several years earlier).

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 (as part of the specification list he received).[2]

Specifications

C64 startup screen with shifted and unshifted modes of PETSCII, and the two characters from ASCII-1963.
PETSCII Chart as displayed on the C64 in shifted and unshifted modes. (Not shown are control codes, as well as characters in the $C0-$FF range, which are the standard uppercase keycodes returned from the keyboard, and which are mirrored to the range $60-7F)

PETSCII is based on the 1963 version of ASCII (rather than the 1967 version, which most if not all other computer character sets based on ASCII use). 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. 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 (horizontal and vertical lines, hatches, shades, triangles, circles and card suits). 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 (see below) 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 text mode is not available at powerup, but must be actuated by holding one of the SHIFT keys and then press and release 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 letters — i.e. the grave accent, curly braces, vertical bar, and tilde — do not exist in PETSCII.

Included in PETSCII are cursor and screen control codes, such as {HOME}, {CLR}, {RVS ON}, and {RVS OFF} (the latter two activating/deactivating reverse-video character display). 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 (unshifted) uppercase+graphics character set and the alternative (shifted) lower+uppercase set (where the shifted set contains a subset of the block graphic characters of the unshifted 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$(14) 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.[2] Thus, screen editor state changes, rather than the employment of separate ASCII codes, are used to choose between single-case (all capitals) and dual case. In the VIC-20, C64, and later machines (not including the CBM business computers), color codes supplement the other screen control codes. (The colors of the VIC-20 and C64/128 are listed in the VIC-II article.)

Codepage layout

Since not all of the characters encoded by PETSCII are 'graphic' (i.e., control codes) and not all of them have a corresponding Unicode representation, they cannot be portably displayed in a web browser. The following table shows for PETSCII characters the corresponding Unicode glyph and code point, if there is any; otherwise the Unicode replacement character U+FFFD (�) and a hyphen for the 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/code points/glyphs are shown, with the unshifted character/glyph on the left and the unshifted code point at the bottom. 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. Other Commodore machines used slightly different versions of PETSCII, which used different control characters and in some cases different graphic characters. For example, on the Commodore 128, $07 was the bell control character, and on CBM machines prior to the VIC-20, characters $2C and $6C both produced a comma character, albeit with slightly different semantics.[3]

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.

PETSCII (Commodore 64)
_0 _1 _2 _3 _4 _5 _6 _7 _8 _9 _A _B _C _D _E _F
0_ Template:Chset-color-undef| 
-
0
Template:Chset-color-undef| 
-
1
Template:Chset-color-undef| 
-
2
Template:Chset-color-ctrl|RUN/ STOP
0003
3
Template:Chset-color-undef| 
-
4
Template:Chset-color-ctrl|WHITE
-
5
Template:Chset-color-undef| 
-
6
Template:Chset-color-undef| 
-
7
Template:Chset-color-ctrl|SHIFT DISABLE
-
8
Template:Chset-color-ctrl|SHIFT ENABLE
-
9
Template:Chset-color-undef| 
-
10
Template:Chset-color-undef| 
-
11
Template:Chset-color-undef| 
-
12
Template:Chset-color-ctrl|CR
000D
13
Template:Chset-color-ctrl|TEXT MODE
-
14
Template:Chset-color-undef| 
-
15
1_ Template:Chset-color-undef| 
-
16
Template:Chset-color-ctrl|DOWN
-
17
Template:Chset-color-ctrl|REVERSE ON
-
18
Template:Chset-color-ctrl|HOME
-
19
Template:Chset-color-ctrl|DEL
007F
20
Template:Chset-color-undef| 
-
21
Template:Chset-color-undef| 
-
22
Template:Chset-color-undef| 
-
23
Template:Chset-color-undef| 
-
24
Template:Chset-color-undef| 
-
25
Template:Chset-color-undef| 
-
26
Template:Chset-color-undef| 
-
27
Template:Chset-color-ctrl|RED
-
28
Template:Chset-color-ctrl|RIGHT
-
29
Template:Chset-color-ctrl|GREEN
-
30
Template:Chset-color-ctrl|BLUE
-
31
2_ Template:Chset-color-punct|SP
0020
32
Template:Chset-color-punct|!
0021
33
Template:Chset-color-punct|"
0022
34
Template:Chset-color-punct|#
0023
35
Template:Chset-color-punct|$
0024
36
Template:Chset-color-punct|%
0025
37
Template:Chset-color-punct|&
0026
38
Template:Chset-color-punct|'
0027
39
Template:Chset-color-punct|(
0028
40
Template:Chset-color-punct|)
0029
41
Template:Chset-color-punct|*
002A
42
Template:Chset-color-punct|+
002B
43
Template:Chset-color-punct|,
002C
44
Template:Chset-color-punct|-
002D
45
Template:Chset-color-punct|.
002E
46
Template:Chset-color-punct|/
002F
47
3_ Template:Chset-color-digit|0
0030
48
Template:Chset-color-digit|1
0031
49
Template:Chset-color-digit|2
0032
50
Template:Chset-color-digit|3
0033
51
Template:Chset-color-digit|4
0034
52
Template:Chset-color-digit|5
0035
53
Template:Chset-color-digit|6
0036
54
Template:Chset-color-digit|7
0037
55
Template:Chset-color-digit|8
0038
56
Template:Chset-color-digit|9
0039
57
Template:Chset-color-punct|:
003A
58
Template:Chset-color-punct|;
003B
59
Template:Chset-color-punct|<
003C
60
Template:Chset-color-punct|=
003D
61
Template:Chset-color-punct|>
003E
62
Template:Chset-color-punct|?
003F
63
4_ Template:Chset-color-punct|@
0040
64
Template:Chset-color-alpha|A a
0041 0061
65
Template:Chset-color-alpha|B b
0042 0062
66
Template:Chset-color-alpha|C c
0043 0063
67
Template:Chset-color-alpha|D d
0044 0064
68
Template:Chset-color-alpha|E e
0045 0065
69
Template:Chset-color-alpha|F f
0046 0066
70
Template:Chset-color-alpha|G g
0047 0067
71
Template:Chset-color-alpha|H h
0048 0068
72
Template:Chset-color-alpha|I i
0049 0069
73
Template:Chset-color-alpha|J j
004A 006A
74
Template:Chset-color-alpha|K k
004B 006B
75
Template:Chset-color-alpha|L l
004C 006C
76
Template:Chset-color-alpha|M m
004D 006D
77
Template:Chset-color-alpha|N n
004E 006E
78
Template:Chset-color-alpha|O o
004F 006F
79
5_ Template:Chset-color-alpha|P p
0050 0070
80
Template:Chset-color-alpha|Q q
0051 0071
81
Template:Chset-color-alpha|R r
0052 0072
82
Template:Chset-color-alpha|S s
0053 0073
83
Template:Chset-color-alpha|T t
0054 0074
84
Template:Chset-color-alpha|U u
0055 0075
85
Template:Chset-color-alpha|V v
0056 0076
86
Template:Chset-color-alpha|W w
0057 0077
87
Template:Chset-color-alpha|X x
0058 0078
88
Template:Chset-color-alpha|Y y
0059 0079
89
Template:Chset-color-alpha|Z z
005A 007A
90
Template:Chset-color-punct|[
005B
91
Template:Chset-color-punct|£
00A3
92
Template:Chset-color-punct|]
005D
93
Template:Chset-color-punct|
2191
94
Template:Chset-color-punct|
2190
95
6_ Template:Chset-color-graph|
2500
96
Template:Chset-color-alpha|A
2660 0041
97
Template:Chset-color-alpha|B
2502 0042
98
Template:Chset-color-alpha|C
2500 0043
99
Template:Chset-color-alpha|D
- 0044
100
Template:Chset-color-alpha|E
- 0045
101
Template:Chset-color-alpha|F
- 0046
102
Template:Chset-color-alpha|G
- 0047
103
Template:Chset-color-alpha|H
- 0048
104
Template:Chset-color-alpha|I
256E 0049
105
Template:Chset-color-alpha|J
2570 004A
106
Template:Chset-color-alpha|K
256F 004B
107
Template:Chset-color-alpha|L
- 004C
108
Template:Chset-color-alpha|M
2572 004D
109
Template:Chset-color-alpha|N
2571 004E
110
Template:Chset-color-alpha|O
- 004F
111
7_ Template:Chset-color-alpha|P
- 0050
112
Template:Chset-color-alpha|Q
25CF 0051
113
Template:Chset-color-alpha|R
- 0052
114
Template:Chset-color-alpha|S
2665 0053
115
Template:Chset-color-alpha|T
- 0054
116
Template:Chset-color-alpha|U
256D 0055
117
Template:Chset-color-alpha|V
2573 0056
118
Template:Chset-color-alpha|W
25CB 0057
119
Template:Chset-color-alpha|X
2663 0058
120
Template:Chset-color-alpha|Y
- 0059
121
Template:Chset-color-alpha|Z
2666 005A
122
Template:Chset-color-graph|
253C
123
Template:Chset-color-graph|
-
124
Template:Chset-color-graph|
2502
125
Template:Chset-color-punct|π
03C0 2592
126
Template:Chset-color-graph|◥ �
25E5 -
127
8_ Template:Chset-color-undef| 
-
128
Template:Chset-color-ctrl|ORANGE
-
129
Template:Chset-color-undef| 
-
130
Template:Chset-color-undef| 
-
131
Template:Chset-color-undef| 
-
132
Template:Chset-color-ctrl|F1
-
133
Template:Chset-color-ctrl|F3
-
134
Template:Chset-color-ctrl|F5
-
135
Template:Chset-color-ctrl|F7
-
136
Template:Chset-color-ctrl|F2
-
137
Template:Chset-color-ctrl|F4
-
138
Template:Chset-color-ctrl|F6
-
139
Template:Chset-color-ctrl|F8
-
140
Template:Chset-color-ctrl|LF
000A
141
Template:Chset-color-ctrl|GRAPHICS
-
142
Template:Chset-color-undef| 
-
143
9_ Template:Chset-color-ctrl|BLACK
-
144
Template:Chset-color-ctrl|UP
-
145
Template:Chset-color-ctrl|REVERSE OFF
-
146
Template:Chset-color-ctrl|CLR
-
147
Template:Chset-color-ctrl|INSERT
-
148
Template:Chset-color-ctrl|BROWN
-
149
Template:Chset-color-ctrl|LIGHT RED
-
150
Template:Chset-color-ctrl|DARK GRAY
-
151
Template:Chset-color-ctrl|MIDDLE GRAY
-
152
Template:Chset-color-ctrl|LIGHT GREEN
-
153
Template:Chset-color-ctrl|LIGHT BLUE
-
154
Template:Chset-color-ctrl|LIGHT GRAY
-
155
Template:Chset-color-ctrl|PURPLE
-
156
Template:Chset-color-ctrl|LEFT
-
157
Template:Chset-color-ctrl|YELLOW
-
158
Template:Chset-color-ctrl|CYAN
-
159
A_ Template:Chset-color-graph|SHIFT- SPACE
00A0
160
Template:Chset-color-graph|
258C
161
Template:Chset-color-graph|
2584
162
Template:Chset-color-graph|
2594
163
Template:Chset-color-graph|
2581
164
Template:Chset-color-graph|
258F
165
Template:Chset-color-graph|
2592
166
Template:Chset-color-graph|
2595
167
Template:Chset-color-graph|
-
168
Template:Chset-color-graph|◤ �
25E4 -
169
Template:Chset-color-graph|
-
170
Template:Chset-color-graph|
251C
171
Template:Chset-color-graph|
2597
172
Template:Chset-color-graph|
2514
173
Template:Chset-color-graph|
2510
174
Template:Chset-color-graph|
2582
175
B_ Template:Chset-color-graph|
250C
176
Template:Chset-color-graph|
2534
177
Template:Chset-color-graph|
252C
178
Template:Chset-color-graph|
2524
179
Template:Chset-color-graph|
258E
180
Template:Chset-color-graph|
258D
181
Template:Chset-color-graph|
-
182
Template:Chset-color-graph|
-
183
Template:Chset-color-graph|
-
184
Template:Chset-color-graph|
2583
185
Template:Chset-color-graph|� ✓
- 2713
186
Template:Chset-color-graph|
2596
187
Template:Chset-color-graph|
259D
188
Template:Chset-color-graph|
2518
189
Template:Chset-color-graph|
2598
190
Template:Chset-color-graph|
259A
191
C_ Template:Chset-color-graph|
2500
192
Template:Chset-color-alpha|A
2660 0041
193
Template:Chset-color-alpha|B
2502 0042
194
Template:Chset-color-alpha|C
2500 0043
195
Template:Chset-color-alpha|D
- 0044
196
Template:Chset-color-alpha|E
- 0045
197
Template:Chset-color-alpha|F
- 0046
198
Template:Chset-color-alpha|G
- 0047
199
Template:Chset-color-alpha|H
- 0048
200
Template:Chset-color-alpha|I
256E 0049
201
Template:Chset-color-alpha|J
2570 004A
202
Template:Chset-color-alpha|K
256F 004B
203
Template:Chset-color-alpha|L
- 004C
204
Template:Chset-color-alpha|M
2572 004D
205
Template:Chset-color-alpha|N
2571 004E
206
Template:Chset-color-alpha|O
- 004F
207
D_ Template:Chset-color-alpha|P
- 0050
208
Template:Chset-color-alpha|Q
25CF 0051
209
Template:Chset-color-alpha|R
- 0052
210
Template:Chset-color-alpha|S
2665 0053
211
Template:Chset-color-alpha|T
- 0054
212
Template:Chset-color-alpha|U
256D 0055
213
Template:Chset-color-alpha|V
2573 0056
214
Template:Chset-color-alpha|W
25CB 0057
215
Template:Chset-color-alpha|X
2663 0058
216
Template:Chset-color-alpha|Y
- 0059
217
Template:Chset-color-alpha|Z
2666 005A
218
Template:Chset-color-graph|
253C
219
Template:Chset-color-graph|
-
220
Template:Chset-color-graph|
2502
221
Template:Chset-color-punct|π
03C0 2592
222
Template:Chset-color-graph|◥ �
25E5 -
223
E_ Template:Chset-color-graph|SHIFT- SPACE
00A0
224
Template:Chset-color-graph|
258C
225
Template:Chset-color-graph|
2584
226
Template:Chset-color-graph|
2594
227
Template:Chset-color-graph|
2581
228
Template:Chset-color-graph|
258F
229
Template:Chset-color-graph|
2592
230
Template:Chset-color-graph|
2595
231
Template:Chset-color-graph|
-
232
Template:Chset-color-graph|◤ �
25E4 -
233
Template:Chset-color-graph|
-
234
Template:Chset-color-graph|
251C
235
Template:Chset-color-graph|
2597
236
Template:Chset-color-graph|
2514
237
Template:Chset-color-graph|
2510
238
Template:Chset-color-graph|
2582
239
F_ Template:Chset-color-graph|
250C
240
Template:Chset-color-graph|
2534
241
Template:Chset-color-graph|
252C
242
Template:Chset-color-graph|
2524
243
Template:Chset-color-graph|
258E
244
Template:Chset-color-graph|
258D
245
Template:Chset-color-graph|
-
246
Template:Chset-color-graph|
-
247
Template:Chset-color-graph|
-
248
Template:Chset-color-graph|
2583
249
Template:Chset-color-graph|� ✓
- 2713
250
Template:Chset-color-graph|
2596
251
Template:Chset-color-graph|
259D
252
Template:Chset-color-graph|
2518
253
Template:Chset-color-graph|
2598
254
Template:Chset-color-graph|π ▒
03C0 2592
255
_0 _1 _2 _3 _4 _5 _6 _7 _8 _9 _A _B _C _D _E _F

Some PETSCII codes cannot be printed and are only used for keyboard input (e.g. F1, RUN/STOP).

PET 2001 keyboard layout, illustrating PETSCII graphics characters

Base 128

Out of PETSCII's first 192 codes, 164 have visible representations (for the control codes, these are visible when quoted): 5 (white), 17-20 and 28-31 (colors and cursor controls), 32-90 (ASCII equivalent), 91-127 (graphics), 129 (orange), 133-140 (function keys), 144-159 (colors and cursor controls), and 160-192 (graphics). This theoretically permits encodings, such as base128, between PETSCII-speaking machines; for example, 33-127, 160-192.

See also

Notes

  1. ^ The Amiga home/personal computer family uses standard ISO-8859-1.
  2. ^ see On The Edge by Brian Bagnall, ISBN 0-9738649-0-7, page 43, 54-55.

References

External links