Text - Graphics 8 (G: Text Handler)
- Type
- Utility
- Category
- CIO device handler / hi-res text
- Author
- Dittrich Clausdorff
- Published in
- Tips & Tricks für ATARI (1987); reprinted on the Czech disk magazine Flop, issue 3
- Year
- 1987
- Language
- Atari BASIC (with machine-language DATA)
- Requirements
- Any 8-bit Atari, 16K RAM, Atari BASIC; uses page 6 ($0600–$066A)
- Tags
- graphics-8, cio, device-handler, hatabs, machine-language, flop, german, atari-basic
About the program
You can't simply PRINT to a GRAPHICS 8 screen in Atari BASIC: the S: device only draws pixels. This 20-line program, credited in its REMs to Dittrich Clausdorff and the 1987 book Tips & Tricks für ATARI, gets round that by adding a new device, G:, to the operating system. Whatever you PRINT # to G: appears on the hi-res screen in the normal Atari font, starting wherever you last plotted. The program was reissued on the Czech disk magazine Flop 3. That is where the Czech REMs come from: pro vsechna ATARI XL/XE means "for all Atari XL/XE", and the demo prints TEXT V GRAFICE 8, "text in graphics 8".
Typing it in
The listing is plain ASCII. The machine code sits in lines 1020–1060 as 107 DATA values, which are POKEd into 1536–1642 ($0600–$066A). A single wrong number will usually crash the machine when line 1010 calls the code. SAVE the program before the first RUN, and check the DATA carefully.
How to use it
The demo draws a box and writes a caption inside it. In your own programs, keep lines 1000–1060 and start with something like this:
10 GOSUB 1000:REM install G: once
20 GRAPHICS 8+16:COLOR 1
30 OPEN #1,8,0,"G:"
40 PLOT 100,90:PRINT #1;"HELLO"
50 GOTO 50
The text starts at the byte that holds the plotted pixel and runs to the right, one character per byte (8 pixels). Only character codes 32–95 (space, digits, punctuation and capitals) give the right shapes. Lower-case letters come out as graphics symbols.
How it works
- Install routine ($0600): searches the handler address table HATABS (794 = $031A) for the first empty slot. It writes the letter
G(71) there, followed by the address $061C of a new handler vector table. - Vector table ($061C): OPEN, CLOSE, GET, STATUS and SPECIAL all point at a tiny "return success" stub at $0668 (
LDY #1:RTS). Only PUT points at real code ($0628). - PUT routine: does nothing for RETURN (155), just branching to the success stub. For any other character it subtracts 32, multiplies by 8 and adds $E000. That gives the address of the glyph in the ROM character set. It copies the 8 bytes down the screen, 40 bytes apart, starting at the address in locations 100/101. Mapping the Atari calls this location ADRESS, the display handler's scratch pointer. After a
PLOTit is left holding the screen address of the plotted byte, and the routine relies on that. Then it moves that pointer on by one byte and returns status 1 (success).
Gotchas
- Line 110 checks
PEEK(1536)<>62to see whether the handler is already installed. But the first byte of the code is 162, so the test always succeeds and every RUN adds another G: entry to HATABS. After a few runs, press RESET to get a clean table (the OS rebuilds HATABS on a warm start) and RUN again. Note that RESET also removes G:, so reinstall it afterwards. - Page 6 is shared with many other utilities. Don't combine this with code that lives at $0600.
- The routine depends on an undocumented detail of the original Atari OS (what ADRESS holds after
PLOT). Under a replacement OS, such as the AltirraOS ROM that emulators use when no Atari ROM image is installed, the box is drawn but the text may not appear. Use a genuine Atari OS ROM. - Characters don't wrap: printing past the right edge carries on into the next pixel row.
Listing
10 REM TEXT - GRAPHICS 8
20 REM pro vsechna ATARI XL/XE
30 REM demo program 110-160
40 REM main program 1000-1060
50 REM 1987 by Dittrich Clausdorff
60 REM Tips & Tricks fuer ATARI
100 REM demo
110 IF PEEK(1536)<>62 THEN GOSUB 1000
120 GRAPHICS 8+16:COLOR 1
130 OPEN #1,8,0,"G:"
140 PLOT 90,80:DRAWTO 230,80:DRAWTO 230,110:DRAWTO 90,110:DRAWTO 90,80
150 PLOT 100,90:? #1;"TEXT V GRAFICE 8"
160 GOTO 160
1000 REM Main routine
1010 FOR I=1536 TO 1642:READ A:POKE I,A:NEXT I:POKE 1535,104:X=USR(1535):RETURN
1020 DATA 162,0,189,26,3,240,5,232,232,232,208,246,169,71,157,26,3,169,28,157,27,3,169,6,157,28
1030 DATA 3,96,103,6,103,6,103,6,39,6,103,6,103,6,201,155,240,60,56,233,32,133,216,169,0,6
1040 DATA 216,42,6,216,42,6,216,42,9,224,133,217,165,100,133,218,165,101,133,219,162,0,160,0,177,216
1050 DATA 129,218,165,218,24,105,40,133,218,165,219,105,0,133,219,200,192,8,208,234,230,100,208,2,230,101
1060 DATA 160,1,96
Credits
- Program listing: Text - Graphics 8 (G: Text Handler) — program listing (Tips & Tricks für ATARI (1987); reprinted on the Czech disk magazine Flop, issue 3) — Dittrich Clausdorff
- Gury's Atari 8-bit Forever — Text - Graphics 8 — Dittrich Clausdorff
- Mapping the Atari (Ian Chadwick) — locations 100,101 ADRESS and 794 HATABS (text copy) — Ian Chadwick
