PETSCII

From Wikipedia, the free encyclopedia
Jump to: navigation, search

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[edit]

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[edit]

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, like for 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[edit]

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 the glyphs for PETSCII graphic characters where there is a corresponding Unicode glyph, and the Unicode replacement character U+FFFD (�) otherwise. Control characters and other non-printing characters are represented by abbreviations for 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. 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 POKEing 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_
 


0


1


2
RUN/
STOP


3


4
WHT

5


6


7
SHIFT
DISABLE


8
SHIFT
ENABLE


9


10


11


12
CR
000D
13
TEXT
MODE


14


15
 
1_
 


16
DOWN

17
RVS ON

18
HOME

19
DEL
007F
20


21


22


23


24


25


26


27
RED

28
RIGHT

29
GRN

30
BLU

31
 
2_
 
SP
0020
32
!
0021
33
"
0022
34
#
0023
35
$
0024
36
%
0025
37
&
0026
38
'
0027
39
(
0028
40
)
0029
41
*
002A
42
+
002B
43
,
002C
44
-
002D
45
.
002E
46
/
002F
47
 
3_
 
0
0030
48
1
0031
49
2
0032
50
3
0033
51
4
0034
52
5
0035
53
6
0036
54
7
0037
55
8
0038
56
9
0039
57
:
003A
58
;
003B
59
<
003C
60
=
003D
61
>
003E
62
?
003F
63
 
4_
 
@
0040
64
A a
0041
65
B b
0042
66
C c
0043
67
D d
0044
68
E e
0045
69
F f
0046
70
G g
0047
71
H h
0048
72
I i
0049
73
J j
004A
74
K k
004B
75
L l
004C
76
M m
004D
77
N n
004E
78
O o
004F
79
 
5_
 
P p
0050
80
Q q
0051
81
R r
0052
82
S s
0053
83
T t
0054
84
U u
0055
85
V v
0056
86
W w
0057
87
X x
0058
88
Y y
0059
89
Z z
005A
90
[
005B
91
£
005C
92
]
005D
93

005E
94

005F
95
 
6_
 

0060
96
A
0061
97
B
0062
98
C
0063
99
D
0064
100
E
0065
101
F
0066
102
G
0067
103
H
0068
104
I
0069
105
J
006A
106
K
006B
107
L
006C
108
M
006D
109
N
006E
110
O
006F
111
 
7_
 
P
0070
112
Q
0071
113
R
0072
114
S
0073
115
T
0074
116
U
0075
117
V
0076
118
W
0077
119
X
0078
120
Y
0079
121
Z
007A
122

007B
123

007C
124

007D
125
π
007E
126
◥ �
007E
127
 
8_
 


128
ORG

129


130


131


132
F1

133
F3

134
F5

135
F7

136
F2

137
F4

138
F6

139
F8

140
LF
000A
141
GRAPHICS

142


143
 
9_
 
BLK

144
UP

145
RVS OFF

146
CLR

147
INS

148
BRN

149
LT RED

150
GRAY1

151
GRAY2

152
LT GRN

153
LT BLU

154
GRAY3

155
PUR

156
LEFT

157
YEL

158
CYN

159
 
A_
 
SHIFT SP

160


161


162


163


164


165


166


167


168
◤ �

169


170


171


172


173


174


175
 
B_
 


176


177


178


179


180


181


182


183


184


185
� ✓

186


187


188


189


190


191
 
C_
 

0060
192
A
0061
193
B
0062
194
C
0063
195
D
0064
196
E
0065
197
F
0066
198
G
0067
199
H
0068
200
I
0069
201
J
006A
202
K
006B
203
L
006C
204
M
006D
205
N
006E
206
O
006F
207
 
D_
 
P
0070
208
Q
0071
209
R
0072
210
S
0073
211
T
0074
212
U
0075
213
V
0076
214
W
0077
215
X
0078
216
Y
0079
217
Z
007A
218

007B
219

007C
220

007D
221
π
007E
222
◥ �
007E
223
 
E_
 
CMDR SP

224


225


226


227


228


229


230


231


232
◤ �

233


234


235


236


237


238


239
 
F_
 


240


241


242


243


244


245


246


247


248


249
� �

250


251


252


253


254
π ▒

255

Some PETSCII Codes can't be printed and are only used for Keyboard input (e.g. F1, RUN/STOP).

PET 2001 keyboard layout, illustrating PETSCII graphics characters

See also[edit]

Notes[edit]

  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[edit]

External links[edit]