ATASCII and the Atari Character Set

Year
1979
Type
Component
Category
Technical reference — character encoding, screen codes and control codes
Manufacturer
Atari, Inc.

Overview

The 8-bit Atari uses its own variant of ASCII called ATASCII (Atari ASCII). Letters, digits and most punctuation have their standard ASCII codes, so plain text moves easily between an Atari and other computers — but the control codes, the line ending and the graphics characters are all Atari's own. Underneath ATASCII sit two further numbering schemes that programmers meet sooner or later: the internal (screen) codes that ANTIC actually displays, and the scan codes that POKEY reports from the keyboard.

What is in ATASCII

  • 256 printable characters, each an 8×8 pixel matrix stored in the OS ROM. Codes 32–127 broadly follow ASCII; codes 0–31 are graphics characters (line-drawing pieces and other symbols) where ASCII has invisible controls.
  • 128 inverse-video characters. Codes 128–255 repeat 0–127 with bit 7 set, which in the text modes displays the same glyph in reverse video (the Atari-logo / "Inverse" key toggles this while typing).
  • Missing ASCII characters. ATASCII has no left or right curly brace, tilde or grave accent; those positions hold graphics symbols or control functions instead.
  • End of line = 155 ($9B). This is the single biggest difference from other systems, which use carriage return (13) and/or line feed (10). Every Atari text file, BASIC LIST and CIO record ends lines with 155.

Screen Editor control codes

Sixteen ATASCII codes act as controls when printed to the screen editor (E:):

Code Function Code Function
27 ($1B) ESC — show the next character literally 155 ($9B) End of line
28 ($1C) Cursor up 156 ($9C) Delete line
29 ($1D) Cursor down 157 ($9D) Insert line
30 ($1E) Cursor left 158 ($9E) Clear tab stop
31 ($1F) Cursor right 159 ($9F) Set tab stop
125 ($7D) Clear screen 253 ($FD) Bell (buzzer)
126 ($7E) Backspace 254 ($FE) Delete character
127 ($7F) Tab 255 ($FF) Insert character

ESC before a control code displays its graphic instead of performing it (ESC ESC shows the ESC symbol); only EOL can never be escaped. Setting the flag DSPFLG (location 766, $2FE) to a non-zero value makes the editor display all control codes except EOL. This is why magazine listings print special symbols for "clear screen" or cursor moves inside quoted strings: they are ATASCII control characters typed with ESC.

10 PRINT CHR$(125):REM CLEAR THE SCREEN
20 PRINT CHR$(27);CHR$(125):REM SHOW THE CLEAR-SCREEN SYMBOL INSTEAD
30 PRINT CHR$(253):REM SOUND THE BUZZER

Internal (screen) codes

ANTIC does not display ATASCII directly. The character set in ROM — at $E000–$E3FF, selected through CHBAS (location 756) — is arranged in internal code order, and the OS converts every character as it writes to or reads from the screen:

ATASCII Internal
0–31 ($00–$1F) 64–95 ($40–$5F)
32–63 ($20–$3F) 0–31 ($00–$1F)
64–95 ($40–$5F) 32–63 ($20–$3F)
96–127 ($60–$7F) unchanged
128–255 the same mapping, with bit 7 kept for inverse video

So a space is ATASCII 32 but screen code 0, and "A" is ATASCII 65 but screen code 33. Programs that POKE directly into screen memory, and anyone designing a custom font, must use internal codes. In the 20-column text modes (BASIC GRAPHICS 1 and 2, ANTIC modes 6 and 7) the top two bits of each code select one of four colours instead, which limits those modes to 64 different characters.

Keyboard scan codes

The keyboard produces neither ATASCII nor internal codes: POKEY reports a 6-bit scan code (plus SHIFT and CONTROL bits) in KBCODE, and the OS translates it through a table into ATASCII. The OS's last-key location 764 (CH) also holds the raw scan code, which is why PEEK(764) returns numbers that look unrelated to the key's character.

The International Character Set

The XL operating system contains a second font, the International Character Set, in which 29 of the ATASCII graphics characters are replaced mostly by accented European letters. It can be selected with POKE 756,204 from BASIC (or CONTROL+F4 on the 1200XL), and the XL owner's guides show which CONTROL-key combinations type the extra characters. The 400/800 OS does not include it.

Exchanging text with other computers

Because of the different line ending, Atari text files need conversion when moving to or from a PC or Mac: 155 must become CR/LF (or LF) and vice versa, and tab (127) and other control codes may need attention. Left unconverted, an Atari text file appears on a PC as one long line, and PC text loaded on an Atari has no line breaks the Atari recognises.

Credits