User Rating 0.0
Total Usage 0 times
C64 Preview
PETSCII Codes
Byte Sequence
Is this tool helpful?

Your feedback helps us improve.

About

PETSCII (PET Standard Code of Information Interchange) is the character encoding system used by Commodore computers from 1977 onward, including the VIC-20, C64, and C128. It maps 256 code points across two modes: uppercase/graphics and lowercase/uppercase. Unlike standard ASCII where A occupies code point 65, PETSCII shifts printable letters and adds 64 unique block-graphic symbols with no direct ASCII equivalent. Confusing PETSCII screen codes with PETSCII keyboard codes is a common source of bugs in cross-development toolchains. This tool performs real mapping from 7-bit ASCII (0 - 127) into PETSCII code values, rendering each glyph through a pixel-accurate 8×8 bitmap font.

Incorrect encoding causes garbled output on real hardware and emulators. PRG files assembled with wrong mappings produce unreadable screens. This converter validates each input byte and flags unmappable characters rather than silently corrupting data. Note: control codes below 32 map to PETSCII control functions (cursor movement, color changes) and are shown as symbolic labels, not printable glyphs.

petscii ascii commodore 64 c64 character encoding retro computing converter

Formulas

PETSCII encoding applies a piecewise mapping function from ASCII code point a to PETSCII code point p. The primary transformation for printable letters in uppercase/graphics mode:

{
p = a if 32 a 63p = a if 65 a 90p = a 32 if 97 a 122 (fold to upper)p = lookup(a) otherwise

For the lowercase/uppercase mode, the mapping inverts: ASCII uppercase letters (65 - 90) map to PETSCII codes 193 - 218, and ASCII lowercase (97 - 122) maps to 65 - 90.

Where a = ASCII code point (decimal), p = resulting PETSCII code point (decimal), lookup = special-case table for symbols and control codes. Characters with no valid mapping produce a NULL result and are flagged in the output.

Reference Data

ASCII CharASCII DecPETSCII Dec (Upper Mode)PETSCII HexNotes
A6565$41Maps to uppercase A in upper/graphics mode
a9765$41Lowercase folds to uppercase in upper/gfx mode
Z9090$5ADirect mapping in upper range
04848$30Digits map identically
95757$39Digits map identically
Space3232$20Identical mapping
!3333$21Punctuation preserved
@640$00@ sign maps to PETSCII screen code 0
[9127$1BNo direct equivalent; mapped to closest
\92191$BFBackslash mapped to pound sign glyph area
]9329$1DMapped to closest bracket equivalent
^9430$1EUp-arrow in PETSCII
_95164$A4Underscore mapped to horizontal line
CR (Enter)1313$0DCarriage return - identical
LF1013$0DLine feed converted to CR
TAB9 - - No PETSCII equivalent; flagged unmappable
DEL12720$14Maps to PETSCII DELETE (INST/DEL)
`96 - - Backtick has no PETSCII mapping
~126222$DEMapped to pi symbol area
{123 - - No PETSCII equivalent; flagged
|124221$DDMapped to vertical bar graphic
}125 - - No PETSCII equivalent; flagged

Frequently Asked Questions

PETSCII character codes (also called CBM codes) are the values sent via keyboard or PRINT statements. Screen codes (poke codes) are different values written directly to video RAM at addresses $0400 - $07E7 on the C64. For example, uppercase A is character code 65 but screen code 1. This converter outputs PETSCII character codes by default. Screen codes require an additional transformation: for letters, subtract 64 from the character code.
Characters like backtick (96), curly braces (123, 125), and TAB (9) have no standard PETSCII mapping. The converter flags these as unmappable with a warning icon and outputs NULL in the code column. It does not silently substitute or drop them, preventing data corruption when transferring to real hardware.
The C64 boots into uppercase/graphics mode where only uppercase letters and block graphics are displayable. PETSCII codes 65 - 90 render as uppercase A - Z, while codes 97 - 122 render as graphic symbols, not lowercase letters. Sending an ASCII lowercase a (code 97) without folding would display a spade symbol, not the letter. Switching to lowercase/uppercase mode (PRINT CHR$(14)) resolves this but changes the entire character set.
Yes. The hex output values can be used directly as .byte directives in assemblers like ACME, KickAssembler, or ca65. Copy the hex sequence and paste it as comma-separated values: .byte $48,$45,$4C,$4C,$4F. Ensure your assembler expects PETSCII character codes, not screen codes. For BASIC DATA statements, use the decimal output instead.
The preview uses a programmatically defined 8×8 pixel bitmap font matching the Commodore 64 character ROM. Each glyph is rendered to a Canvas element at integer scaling to preserve sharp pixel edges. Anti-aliasing is disabled via image-rendering: pixelated. The result matches the output of a PAL C64 at zoom. Color approximates the default C64 light blue on dark blue, though actual CRT phosphor color varies by monitor.
Standard ASCII only defines 0 - 127. PETSCII defines all 256 code points, with codes 128 - 255 containing reversed (inverse) characters and additional control codes. This converter accepts 7-bit ASCII input (0 - 127) and maps into the PETSCII range. If you need to generate PETSCII codes above 127, use the graphic character palette provided in the tool.