Window on GTIA

Type
Graphics
Category
GTIA graphics demo / display-list interrupt technique
Author
David Sanders
Published in
Antic, April 1983 (Vol. 2, No. 1)
Year
1983
Language
Atari BASIC
Requirements
GTIA chip (any XL/XE, or a 400/800 built from 1982 on), Atari BASIC
Dozens of overlapping rectangle outlines in shades of blue in GRAPHICS 9, above a green text window reading MODE=9 #65, #66, #67

About the program

When Atari began fitting the GTIA chip, it brought three new graphics modes. GRAPHICS 9 has 16 shades of one hue, GRAPHICS 10 has nine colours of your choice, and GRAPHICS 11 has 15 hues at one brightness plus black. Atari BASIC and the OS supported them, with one irritation. They were full-screen modes only, with no four-line text window at the bottom. In the April 1983 Antic, David Sanders explained why and showed how to get the window back. This short demo shows the trick. It fills the screen with random rectangles in a GTIA mode and prints a running count in a perfectly normal text window underneath.

What you need

A computer with GTIA: every XL and XE, and most 400/800s built from 1982 onward. Use Altirra or atari800 set to GTIA if you are emulating. On an old CTIA machine you'll see GRAPHICS 8 patterns instead.

Typing it in

Plain ASCII, 24 lines. Lines 220–240 are the 23 bytes of the display-list interrupt routine, so check them carefully. Line 10 must come first, because it turns DLIs off while the display is being changed.

How to use it

RUN it and watch the rectangles pile up. The console keys control it:

  • OPTION clears the screen and moves on to the next mode (9 → 10 → 11 → 9).
  • SELECT clears the screen and resets the counter.
  • START freezes the drawing. Press START again to continue.

How it works

The GTIA modes are not separate ANTIC modes. ANTIC sends GTIA the same data as for GRAPHICS 8, and a GTIA mode is chosen by the top two bits of the priority register, PRIOR (shadow 623). Normally this setting covers the whole screen, text window included, which is why the OS didn't offer a window. Sanders' method:

  1. Line 10 opens an ordinary GRAPHICS 8 screen with its text window.
  2. Line 20 POKEs 143 into the last graphics instruction of the display list (offset 166). That is ANTIC mode 15 with the DLI bit set, so an interrupt happens just above the text window.
  3. Line 80 switches the top of the screen to GTIA mode 9, 10 or 11 with POKE 623,64*M. Line 50 sets location 87 (the OS's current graphics mode) to 9, so PLOT and COLOR follow GTIA rules.
  4. The DLI at page 6 (1768, $06E8) waits for the line to end, puts the player-0 colour (704) into the background register, with attract-mode handling, and writes 0 to PRIOR. GTIA is back in normal mode for the four text lines. On the next frame the OS copies 623 back into PRIOR and the GTIA mode returns at the top.

Variations to try

Change the colours POKEd into 704–712 in lines 60–70. In GRAPHICS 10 these are the nine colours you draw with.

Listing

10 POKE 54286,64:GRAPHICS 8
20 POKE PEEK(560)+256*PEEK(561)+166,143
30 FOR I=1768 TO 1791:READ A:POKE I,A:NEXT I
40 POKE 512,232:POKE 513,6
50 POKE 54286,192:POKE 87,9:M=1
60 POKE 704,0:POKE 705,26:POKE 706,54:POKE 707,84
70 POKE 708,104:POKE 709,130:POKE 710,184:POKE 711,218
80 POKE 712,6+122*(M=1)+6*(M=2):POKE 623,64*M:C=0
90 COLOR (8+6*(M<>2))*RND(0)+1
100 I=INT(72*RND(0))+4:J=INT(72*RND(0))+4
110 A=INT(144*RND(0))+8:B=INT(144*RND(0))+8
120 PLOT I,A+1:DRAWTO J,A+1:DRAWTO J,B+1:DRAWTO I,B+1
130 PLOT J,B:DRAWTO I,B:DRAWTO I,A:DRAWTO J,A
140 C=C+1:POKE 752,1:PRINT "  MODE=";M+8;"  #";C
150 A=PEEK(53279):IF A=7 THEN 90
160 POKE 77,0:IF A<4 THEN GOSUB 210:M=M+1-3*(M=3):GOTO 80
170 IF A<6 THEN GOSUB 210:C=0:GOTO 90
180 PRINT " **** FREEZE ****":FOR I=1 TO 200:NEXT I
190 IF PEEK(53279)<>6 THEN 190
200 POKE 77,0:FOR I=1 TO 50:NEXT I:GOTO 90
210 PRINT #6;CHR$(125):FOR I=1 TO 200:NEXT I:RETURN
220 DATA 72,141,15,212,141,10,212
230 DATA 173,192,2,69,79,37,78,141,26,208
240 DATA 169,0,141,27,208,104,64

Download

The original program from the Antic disk, to LOAD or ENTER instead of typing it: GTIAWIND.BAS.

Credits