Text on Graphics Screens: Labels in GRAPHICS 8 and 80-Column Software Text

Black GRAPHICS 8 screen with a heading in normal Atari letters, a plotted sine wave with axes and the label SIN(X), and a line of narrow 80-column text at the bottom

GRAPHICS 8 gives you 320 × 192 pixels, but no way to PRINT on them. PRINT #6 only works in the character modes, GRAPHICS 1 and 2, and in GRAPHICS 8 the text window is limited to four lines at the bottom. Graphs need labels, drawing programs need menus, and a word processor or terminal may want 80 columns on a 40-column machine. The answer in every case is the same: draw the letters into the bitmap yourself. This guide shows how, in Atari BASIC, and then how the same idea gave the Atari its software 80-column displays.

What you'll learn: where the character shapes live, how to copy them into GRAPHICS 8 memory at any row, how to convert ATASCII to the font's order, how to squeeze characters to four pixels for 80 columns, and the trade-offs that commercial 80-column drivers made.

What you need: Atari BASIC. The program was run in atari800, as in the screenshot.

1. Why copying works

In GRAPHICS 8 (ANTIC mode F), every byte of screen memory is 8 pixels in a row, and each of the 192 lines is 40 bytes. A character in the ROM font is 8 bytes, one per row of 8 pixels. So a character is drawn by copying its 8 bytes to 8 consecutive screen lines, 40 bytes apart. No bit-shuffling is needed as long as the character starts on a byte boundary, which gives 40 character columns, exactly like the text screen. Vertically, text can start on any of the 192 pixel rows.

The ROM character set is at 57344 ($E000). Its order is the internal code, not ATASCII, so convert first (see ATASCII and Keyboard Codes): ATASCII 0–31 become 64–95, 32–95 become 0–63, and 96–127 stay the same. Character c starts at 57344 + 8 × c.

2. The program

10 REM TEXT ON A GRAPHICS 8 SCREEN
20 GRAPHICS 8+16:SETCOLOR 2,0,0:SETCOLOR 1,0,14:COLOR 1
30 SC=PEEK(88)+256*PEEK(89):DIM T$(80),SQ(255)
40 T$="40 COLUMNS: ROM FONT COPIED INTO GR.8":X=1:Y=4:GOSUB 1000
50 PLOT 8,40:DRAWTO 311,40:PLOT 8,40:DRAWTO 8,150
60 DEG :FOR I=0 TO 300 STEP 3:PLOT 8+I,95-50*SIN(I*1.2):NEXT I
70 T$="SIN(X)":X=34:Y=50:GOSUB 1000
80 REM BUILD A TABLE THAT SQUEEZES 8 PIXELS INTO 4
90 FOR B=0 TO 255:V=0:W=B:FOR K=0 TO 3:P=INT(W/4):Q=W-P*4:IF Q THEN V=V+2^K
100 W=P:NEXT K:SQ(B)=V:NEXT B
110 T$="80 COLUMNS: EACH CHARACTER IS ONLY FOUR PIXELS WIDE, TWO PER BYTE OF SCREEN!"
120 X=0:Y=170:GOSUB 2000
130 POKE 77,0:GOTO 130
1000 REM DRAW T$ AT BYTE COLUMN X (0-39), PIXEL ROW Y
1010 FOR I=1 TO LEN(T$):A=ASC(T$(I)):C=A-32:IF A<32 THEN C=A+64
1020 IF A>95 THEN C=A
1030 F=57344+C*8:P=SC+Y*40+X+I-1
1040 FOR R=0 TO 7:POKE P+R*40,PEEK(F+R):NEXT R:NEXT I:RETURN
2000 REM SAME, BUT HALF-WIDTH: TWO CHARACTERS SHARE ONE BYTE
2010 FOR I=1 TO LEN(T$) STEP 2:P=SC+Y*40+X+INT(I/2)
2020 A=ASC(T$(I)):GOSUB 2100:F1=F:A=32:IF I<LEN(T$) THEN A=ASC(T$(I+1))
2030 GOSUB 2100
2040 FOR R=0 TO 7:POKE P+R*40,SQ(PEEK(F1+R))*16+SQ(PEEK(F+R)):NEXT R:NEXT I:RETURN
2100 C=A-32:IF A<32 THEN C=A+64
2110 IF A>95 THEN C=A
2120 F=57344+C*8:RETURN

The two drawing routines:

  • Lines 1000–1040 draw T$ at byte column X (0–39) and pixel row Y (0–191). Each character is converted to internal code (lines 1010–1020), then its eight font bytes are POKEd 40 bytes apart (line 1040).
  • Lines 2000–2120 draw at half width: two characters share each screen byte, left one in the top four bits and right one in the bottom four. The table SQ() built in lines 90–100 turns each 8-pixel font row into 4 pixels, by setting each output pixel if either of the two input pixels it replaces is set. That keeps thin strokes from vanishing.

Line 20 uses GRAPHICS 8+16 for a full screen with no text window, black background (SETCOLOR 2,0,0) and bright pixels (SETCOLOR 1,0,14). Lines 50–70 draw a pair of axes, plot a sine curve and label it at column 34, row 50. That label sits in the middle of the graph, where the text window couldn't reach.

Mixing text and PLOT is easy in this direction: drawn text is just pixels, so you can PLOT over it or erase it with COLOR 0. To clear a text area, POKE zeros into its bytes.

3. How fast is it?

Not very, in BASIC. Each character costs eight PEEKs and eight POKEs plus the address arithmetic. A heading appears in a moment, but a screenful of 960 characters takes a long time. Building the 256-entry squeeze table also takes a few seconds at start-up. Two remedies:

  • Do the copy in machine language through USR. It is the same loop, but runs hundreds of times faster.
  • Precompute what you can. Store the internal-code font addresses for a fixed message, or keep screen-row start addresses in an array instead of multiplying by 40 each time.

For bigger lettering, plot each font bit as a block of pixels (a 2×2 or 4×4 square per bit), or use a coarser mode such as GRAPHICS 7. That is how BASIC title-screen routines draw giant text, at the cost of even more time per letter. Jerry White's DRAWTEXT, published in Antic (November 1983), drew the ROM letters enlarged in a mixed display for programs using the S.A.M. speech synthesizer, which couldn't tolerate text modes while it was speaking.

4. Eighty columns in software

Half-width characters are exactly how software 80-column displays worked before the XEP80 and on machines without one. The 40-column screen can't show 80 characters, but GRAPHICS 8 has 320 pixels across, so 80 characters of 4 pixels each fit precisely. The squeezed ROM font in our example shows the problem: shrinking 8 pixels to 4 makes letters blotchy and hard to tell apart. Serious drivers therefore used fonts designed for the narrow cell. Among them:

  • Omniview (CDY Consulting, 1984): an OS add-on (on the 400/800 it installs in the 4K block at $C000) providing 80-column E: and S: drivers with 3-pixel-wide characters in ANTIC mode F, leaving a pixel of space between letters.
  • ACE-80 (Claus Buchholz, for Amiable Computer Enhancements, 1985): a cartridge giving a software-generated 80-column display compatible with Atari BASIC.
  • 80 Column Pack! and XOS/80 Column Pack! (Computer Support, 1985–86): 80-column text using a Graphics 8 screen.
  • Terminal programs such as VT-10-Squared, OmniCom and later BBS software, which all had their own 80-column GR.8 handlers for VT100-style screens.

Because they work through the E: and S: handlers, the OS-level drivers let ordinary programs, BASIC included, print in 80 columns without changes. The costs are 7,680 bytes of screen memory instead of 960, slower printing (every character is drawn, and scrolling moves 7,680 bytes), and a picture whose fine detail suffers on a colour TV. They really need a monochrome monitor. The XEP80 (1986) solved this in hardware with its own 80 × 25 character display on a separate monitor output.

Troubleshooting

  • Letters come out as the wrong symbols: the ATASCII-to-internal conversion is missing or wrong.
  • Text appears in the wrong place: remember that X counts bytes (8 pixels) and Y counts pixel rows. Row Y starts at screen address + 40 × Y.
  • ERROR 141 or garbage after GRAPHICS: SC must be read after the GRAPHICS statement, because the screen moves.
  • Text in the text window instead: you used PRINT. Draw into the bitmap as above, or use GRAPHICS 8+16 for a full screen.
  • Colour fringes on letters: that's NTSC artifacting of the 320-pixel mode (see NTSC Artifacting). Use a monochrome monitor or a greyscale palette for 80-column text.

Further reading

  • Michael Current, comp.sys.atari.8bit FAQ: Omniview, 80 Column Pack!, ACE-80, XEP80 and terminal programs with 80-column handlers.
  • Jerry White, "Here's Looking at You, S.A.M.!", Antic, November 1983 (DRAWTEXT).
  • On this site: ATASCII and Keyboard Codes, Redefined Character Sets, Graphics in Atari BASIC.

Credits