Graphics 7 Plus Spiral (Program 3)

Type
Graphics
Category
Display-list demo
Author
Dave Small
Published in
The Creative Atari (Creative Computing Press, 1983), "Graphics Seven Plus", Program 3
Year
1983
Language
Atari BASIC
Requirements
Any Atari 8-bit, 16K RAM, Atari BASIC
A fine-lined multicoloured spiral squeezed into the top half of the screen, with the text window directly beneath it

About the program

The ANTIC chip can draw 14 kinds of screen line, but Atari BASIC's GRAPHICS statement offers only some of them. One that was left out is a four-colour bitmap with GRAPHICS 7's horizontal resolution (160 pixels) and GRAPHICS 8's vertical resolution (192 lines). Dave Small called it "Graphics 7+". It is ANTIC mode E, the mode that many commercial games went on to use. He first described it in Creative Computing in July 1981, and The Creative Atari reprinted the full article.

Program 3 is the eye-opener of the article. It draws a multicoloured spiral in ordinary GRAPHICS 7, and then changes a few bytes of the display list. The picture instantly shrinks into the top half of the screen. The same data is now drawn one scan line per row instead of two, so every line is half as thick and the drawing looks twice as sharp.

What you need

Any Atari 8-bit computer with Atari BASIC. The program is short and runs in 16K.

Typing it in

Plain ASCII with no special characters. Lines 10–530 are REMs and can be left out, apart from any line numbers that you want to keep for your own reference. Line 610 (C(K)=K+1*2) fills an array that the program never uses. It is printed that way in the book and does no harm.

How to use it

RUN it. "CREATING IMAGE." appears while the spiral is drawn in GRAPHICS 7. Then "MODIFYING DL." appears, the picture jumps into Graphics 7+, and the program stops at line 1060. The text window jumps up too: it now sits just below the half-height picture, because ANTIC reaches the window's instructions after only 96 scan lines. To see both modes alternate for ever, as the REM in line 1059 suggests, delete line 1060. The program then flips the display list back and forth between the two modes.

How it works

  • Locations 560/561 (SDLSTL/SDLSTH) hold the address of the display list, ANTIC's own program. Line 1010 reads it into START.
  • A GRAPHICS 7 display list contains 96 instructions with code 13 (ANTIC mode D: two scan lines per row). Line 1020 changes the first one, which has the Load Memory Scan bit added (13+64), to 14+64. Lines 1030–1050 change every following 13 to a 14 (mode E: one scan line per row).
  • Screen memory itself is untouched. ANTIC just reads the same 3840 bytes faster, so 96 rows of data fill only 96 scan lines.
  • Lines 1100–1160 reverse the process.

The rest of the article explains why you can't simply stretch this to a full screen from BASIC. If you set up GRAPHICS 8 and convert its display list, the operating system still thinks it is in GRAPHICS 7 (location 87, DINDEX) and gives error 141 below row 95. Small's answer was to copy the OS line-draw routine into RAM and patch out the bounds check with machine code.

Variations to try

  • Delete line 1060 and add a delay before line 1160 to make a slow "breathing" effect.
  • Draw your own picture in lines 550–690 to compare the two modes.
  • For a full-screen Graphics 7+ from BASIC, change GRAPHICS 8's display list (codes 15 → 14, LMS 79 → 78), then POKE 87,7, and draw only in the top 96 rows. That is the experiment in Program 4 of the article, and it shows the bounds-check problem for yourself.

Listing

10 REM PROGRAM 3
20 REM
30 REM CONVERT GR.7 TO GR.7+
40 REM DAVE SMALL
50 REM 8K BASIC VERSION
60 REM
70 REM CREATE IMAGE
530 REM ***********************
540 REM ** FROM CREATIVE COMPUTING..
545 REM **GENERATES MULTICOLOR SPIRAL
550 GRAPHICS 7:DEG :DIM C(3)
555 PRINT "CREATING IMAGE."
590 R=20:COLOR 1:C=1
600 X0=79:Y0=47
610 FOR K=0 TO 3:C(K)=K+1*2:NEXT K
620 FOR K=1 TO 3
630 X=X0+R*COS(360):Y=Y0:PLOT X,Y
640 FOR I=0 TO 5*360 STEP 75
650 X=X0+R*COS(I):Y=Y0+R*SIN(I)
660 DRAWTO X,Y
665 C=C+1:IF C>3 THEN C=1
667 COLOR C
670 NEXT I:R=R+12
680 NEXT K
690 Z8=1
700 PRINT "MODIFYING DL."
1000 REM GR.7 TO GR.7+
1010 START=PEEK(560)+256*PEEK(561)
1020 POKE START+3,14+64:REM LMS
1030 FOR Z=START+6 TO START+6+96
1040 IF PEEK(Z)=13 THEN POKE Z,14
1050 NEXT Z
1059 REM REMOVE THIS STOP FOR LOOP..
1060 STOP
1100 REM GR.7+ TO GR.7
1110 FOR Z=START+6+96 TO START+6 STEP -1
1140 IF PEEK(Z)=14 THEN POKE Z,13
1150 NEXT Z
1155 POKE START+3,13+64:REM LMS
1160 GOTO 1020

Credits