Allmodes: Unlocking the 56 Graphics Modes

Type
Graphics
Category
Graphics-mode explorer / display-list tutorial
Author
Paul Chabot
Published in
Antic, September 1984 (Vol. 3, No. 5), "Starting Out: Unlocking the 56 Graphic Modes"
Year
1984
Language
Atari BASIC
Requirements
Any Atari 8-bit, Atari BASIC; GTIA for the G key states
A red GRAPHICS 2 title box reading ALLMODES BY PAUL CHABOT 1983 with borders of letters, and a text-window menu: 0 GR.0, 1 GR.1, 2 GR.2, A Antic3, B Antic4, C Antic5, D GR.6+, E GR.7+, G GTIA, S Screen Area, R Restore

About the program

ANTIC can show screen memory in 14 different ways, its "modes" (the text and graphics modes BASIC calls GRAPHICS 0 to 8, plus several that BASIC on a 400/800 can't select directly). GTIA can then reinterpret the result in four states, set by the top bits of location 623. Paul Chabot's point in this September 1984 "Starting Out" article was that 14 × 4 gives 56 modes, "some ugly, some simply useless", but many valuable. His program lets you see them all instantly. It builds one sample screen, then shows that same memory in whatever mode you choose. The display won't always be recognisable, but that's the lesson: the data stays the same and only the interpretation changes.

What you need

Any Atari with Atari BASIC. The G key needs a GTIA machine to show GRAPHICS 9–11 effects.

Typing it in

The title box in lines 210–228 mixes upper case, lower case and inverse letters ({inv}…{/inv}, Atari key). In GRAPHICS 2 these select different colours, so type them exactly. The menu lines 254–260 also use inverse video. Antic asked readers to check the listing with TYPO.

How to use it

RUN it, and you get a GRAPHICS 2 screen with a menu in the text window.

  • 0–8 switch the display to ANTIC's equivalents of GRAPHICS 0 to 8.
  • A–E select the extra modes: ANTIC modes 3, 4 and 5 (the lower-case-descender and four-colour character modes), plus the "GRAPHICS 6+" and "7+" one-line modes. XL machines support these directly, but a 400/800 needs special programming.
  • G steps GTIA through its four states (adding 64 to location 623 each time).
  • S asks for a new start address for the screen, so you can look at any memory. Chabot suggested 1536, 53760, 53960, 0 and 40520. R restores the normal screen.

You can press BREAK at any time, try POKEs to the colour registers 704–712, then type CONT.

How it works

  • Changing mode takes a few POKEs. Line 102 POKEs the first display-list instruction with 64+M (the mode plus the LMS bit), and lines 104–108 write M into the following nine instructions. The text window is left alone. Modes use different numbers of scan lines per row, so the picture grows or shrinks as you switch, which the article explains in detail.
  • Moving the window into memory (lines 120–134) writes a new address into the LMS operand at DL+4 and DL+5.
  • Lines 230–238 POKE rows of the values 0–15 and 17×0 to 17×15 into page 6, colour test patterns for the GTIA modes. While waiting for a key, lines 30–32 fill 1536–1575 with random bytes, so pointing the screen at 1536 shows something always moving.
  • Keys are read from location 764 by key code (50 is 0, 31 is 1 and so on), with no RETURN needed.

Listing

5 REM ALLMODES
6 REM BY PAUL CHABOT
7 REM ANTIC MAGAZINE
10 GOSUB 200
20 K=PEEK(764):IF K<64 THEN 40
30 FOR I=1536 TO 1575
32 POKE I,PEEK(53770):NEXT I
34 GOTO 20
40 POKE 764,255
50 REM LINKAGE
52 IF K=50 THEN M=2:GOSUB 100:REM ..0
54 IF K=31 THEN M=6:GOSUB 100:REM ..1
56 IF K=30 THEN M=7:GOSUB 100:REM ..2
58 IF K=26 THEN M=8:GOSUB 100:REM ..3
60 IF K=24 THEN M=9:GOSUB 100:REM ..4
62 IF K=29 THEN M=10:GOSUB 100:REM .5
64 IF K=27 THEN M=11:GOSUB 100:REM .6
66 IF K=51 THEN M=13:GOSUB 100:REM .7
68 IF K=53 THEN M=15:GOSUB 100:REM .8
70 IF K=63 THEN M=3:GOSUB 100:REM ..A
72 IF K=21 THEN M=4:GOSUB 100:REM ..B
74 IF K=18 THEN M=5:GOSUB 100:REM ..C
76 IF K=58 THEN M=12:GOSUB 100:REM .D
78 IF K=42 THEN M=14:GOSUB 100:REM .E
80 IF K=62 THEN GOSUB 120:REM ......S
82 IF K=40 THEN GOSUB 140:REM ......R
84 IF K=61 THEN GOSUB 150:REM ......G
90 GOTO 20
100 REM MODE CHANGE
102 POKE DL+3,64+M
104 FOR I=DL+6 TO DL+14
106 FOR W=0 TO 20:NEXT W
108 POKE I,M:NEXT I
110 RETURN
120 REM SCREEN AREA CHANGE
122 ? :? :? :? :POKE 656,0
124 ? "SCREEN AREA NOW BEGINS AT ";SA
126 ? :? "INPUT A NEW BEGIN ADDRESS"
128 INPUT SA
130 SH=INT(SA/256):SL=SA-256*SH
132 POKE DL+4,SL:POKE DL+5,SH
134 GOSUB 250:RETURN
140 REM RESTORE SCREEN
142 SL=PEEK(88):SH=PEEK(89)
143 POKE 623,0
144 SA=SL+256*SH
146 POKE DL+4,SL:POKE DL+5,SH
147 GOSUB 250
148 M=7:GOSUB 100:RETURN
150 REM GTIA MODES
152 I=PEEK(623)+64:POKE 712,48
154 IF I>255 THEN I=I-256
156 IF I>191 THEN POKE 712,8
158 POKE 623,I:RETURN
200 REM INITIALIZE
202 GRAPHICS 2
204 DL=PEEK(560)+256*PEEK(561)
206 SA=PEEK(88)+256*PEEK(89)
210 ? #6;" {inv}AAAAAAAAAAAAAAAAAA{/inv}"
212 ? #6;" l      ****      {inv}r{/inv}"
214 ? #6;" l  ++++++++++++  {inv}r{/inv}"
216 ? #6;" l    {inv}a{/inv}l{inv}l{/inv}m{inv}o{/inv}d{inv}e{/inv}s    {inv}r{/inv}"
218 ? #6;" l  ++++++++++++  {inv}r{/inv}"
220 ? #6;" l      ****      {inv}r{/inv}"
222 ? #6;" l       BY       {inv}r{/inv}"
224 ? #6;" l  {inv}PAUL  CHABOT{/inv}  {inv}r{/inv}"
226 ? #6;" l      1983      {inv}r{/inv}"
228 ? #6;" BBBBBBBBBBBBBBBBBB"
230 FOR I=0 TO 15:POKE 1616+I,I
232 POKE 1636+I,I:POKE 1656+I,I
234 POKE 1676+I,I:POKE 1696+I,17*I
236 POKE 1736+I,17*I:POKE 1756+I,I
238 NEXT I
240 POKE 712,48:POKE 704,12*16
242 POKE 705,6*16+6:POKE 706,15*16+4
244 POKE 707,166
250 REM MAIN MENU
252 ? :? :? :? :POKE 656,0:POKE 752,1
254 ? "{inv} 0 {/inv} GR.0  {inv} A {/inv} Antic3  {inv} E {/inv} GR.7+"
256 ? "{inv} 1 {/inv} GR.1  {inv} B {/inv} Antic4  {inv} G {/inv} GTIA"
258 ? "{inv} 2 {/inv} GR.2  {inv} C {/inv} Antic5  {inv} S {/inv} Screen Area"
260 ? "{inv}...{/inv} etc.  {inv} D {/inv} GR.6+   {inv} R {/inv} Restore";
270 RETURN

Download

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

Credits