← Back to The Vault

PETSCII Character Chart

Every character code the C64 knows about

PETSCII codes, screen codes, and control characters—the complete reference for displaying text and graphics on the Commodore 64.

C64 PETSCIICharacter setsScreen codesCHR$ 1982–1994

Overview

PETSCII (PET Standard Code of Information Interchange) is the Commodore 64’s character encoding system. Unlike ASCII, PETSCII includes built-in graphics characters, colour control codes, and cursor movement—everything needed for games and demos. But here’s the catch: PETSCII codes and screen codes are different numbers for the same character.

When you PRINT "A" or use CHR$(65), you’re using PETSCII. When you POKE 1024,1, you’re using screen codes. Same letter ‘A’, different numbers (65 vs 1). Master this distinction and you’ve unlocked direct hardware control.

The Critical Difference

PETSCII Codes

Used with:

  • PRINT "HELLO"
  • CHR$(147) — clear screen
  • ASC("A") — returns 65
  • GET A$ — keyboard input
  • INPUT statements

Screen Codes

Used with:

  • POKE 1024,1 — write directly to screen memory
  • PEEK(1024) — read screen memory
  • Assembly: STA $0400 (direct screen writes)

Quick example:

PRINT "A"       : REM Uses PETSCII 65
POKE 1024,1     : REM Uses screen code 1
REM Both display the letter A!

Memory Locations

MemoryAddressDecimalWhat It Does
Screen RAM$0400-$07E71024-2023Character positions (40×25)
Colour RAM$D800-$DBE755296-56295Colour for each character

Formula for any position:

Position = 1024 + (row * 40) + column
Colour = 55296 + (row * 40) + column

Row 0 is the top, column 0 is the left. Position (0,0) is address 1024.

Common Characters (Uppercase Mode)

CharacterPETSCIIScreen CodeNotes
Space3232Same in both
0-948-5748-57Same in both
@640Different!
A651Different!
B662Different!
C673Different!
Z9026Different!
[9127Different
£9228Pound sterling
]9329Different
9430Up arrow
9531Left arrow

Pattern: For letters A-Z, subtract 64 from PETSCII to get screen code.

Control Characters

These codes don’t display—they do things. Essential for clearing screens, moving cursors, and changing colours.

CodeCHR$()What It Does
13CHR$(13)Carriage return (ENTER key)
19CHR$(19)Home cursor (top-left)
147CHR$(147)Clear screen (most used!)
17CHR$(17)Cursor down one line
145CHR$(145)Cursor up one line
29CHR$(29)Cursor right one space
157CHR$(157)Cursor left one space
18CHR$(18)Reverse video on
146CHR$(146)Reverse video off
14CHR$(14)Switch to lowercase charset
142CHR$(142)Switch to uppercase charset

Game use: CHR$(147) clears the screen instantly. CHR$(19) resets cursor to home. Both faster than scrolling or manually clearing.

Colour Control Codes

Change text colour mid-PRINT with these PETSCII codes:

ColourPETSCIIExample
Black144PRINT CHR$(144);
White5PRINT CHR$(5);
Red28PRINT CHR$(28);
Cyan159PRINT CHR$(159);
Purple156PRINT CHR$(156);
Green30PRINT CHR$(30);
Blue31PRINT CHR$(31);
Yellow158PRINT CHR$(158);
Orange129PRINT CHR$(129);
Brown149PRINT CHR$(149);
Light Red150PRINT CHR$(150);
Dark Grey151PRINT CHR$(151);
Grey152PRINT CHR$(152);
Light Green153PRINT CHR$(153);
Light Blue154PRINT CHR$(154);
Light Grey155PRINT CHR$(155);

Example:

PRINT CHR$(147);CHR$(31);"SCORE: ";CHR$(158);"9999"

Clear screen, blue “SCORE:”, yellow number—all in one line.

Colour RAM Values (For POKEing)

When writing directly to colour RAM (55296+), use these values:

ColourValueHex
Black0$00
White1$01
Red2$02
Cyan3$03
Purple4$04
Green5$05
Blue6$06
Yellow7$07
Orange8$08
Brown9$09
Light Red10$0A
Dark Grey11$0B
Grey12$0C
Light Green13$0D
Light Blue14$0E
Light Grey15$0F

Note: Only the low 4 bits matter—POKE 55296,18 gives you red (18 AND 15 = 2).

Graphics Characters

PETSCII includes built-in line-drawing and symbol characters, perfect for game borders and UI:

DescriptionPETSCIIScreen CodeVisual
Horizontal line673
Vertical line662
Upper-left corner8521
Upper-right corner739
Lower-left corner7410
Lower-right corner7511
Cross7814
Heart ♥8319
Diamond ♦9026
Club ♣8824
Spade ♠651
Circle ●8117
Solid block █160160

Game use: Draw UI borders with line characters. Hearts for lives. Solid blocks for platforms or walls.

Conversion Rules

PETSCII → Screen Code

Letters A-Z (uppercase):

Screen = PETSCII - 64
Example: 'A' = 65 - 64 = 1

Numbers and symbols (32-63):

Screen = PETSCII (same)
Example: '0' = 48 (both)

Graphics/shifted (varies): Check the tables—no simple formula.

Screen Code → PETSCII

Quick approximation:

IF S<32 THEN P=S+64
IF S>=32 AND S<64 THEN P=S
IF S>=64 THEN P=S+64

Better: Use lookup tables for accuracy.

Practical Examples

Example 1: Clear Screen and Set Colours

10 PRINT CHR$(147);
20 PRINT CHR$(31);
30 PRINT CHR$(18);
40 PRINT "  GAME OVER  ";
50 PRINT CHR$(146)

Example 2: Draw a Simple Box

10 PRINT CHR$(147);CHR$(5)
20 PRINT CHR$(85);
30 FOR I=1 TO 18
40 PRINT CHR$(67);
50 NEXT I
60 PRINT CHR$(73)

Example 3: Write Text Directly to Screen

10 REM Display "HI" at position (5,10)
20 P=1024+(5*40)+10
30 POKE P,8
40 POKE P+1,9
50 C=55296+(5*40)+10
60 POKE C,7
70 POKE C+1,7

Example 4: Scroll Text Effect

10 T$="*** WELCOME TO THE GAME ***"
20 FOR I=1 TO LEN(T$)
30 PRINT CHR$(19);
40 PRINT MID$(T$,I,40)
50 FOR D=1 TO 50:NEXT D
60 NEXT I
70 GOTO 20

Historical Notes

PETSCII evolved from the PET computer’s character set (1977), which itself was influenced by ASCII but needed to fit Commodore’s hardware and business keyboard layout. The pound sterling symbol (£) at position 92 reflects Commodore’s UK market focus, while the built-in graphics characters made the C64 perfect for home computing when terminals and modems used plain ASCII.

Early games like Wizard of Wor and Boulder Dash relied heavily on PETSCII graphics for their visuals—no custom character sets needed. By the mid-1980s, most games switched to custom charsets and bitmaps, but PETSCII remained the standard for file listings, documentation, and BBS systems well into the 1990s.

See Also