SAS (GTIA Demo)

Type
Graphics
Category
GTIA colour-cycling demo
Author
Unknown (early GTIA demonstration program, author not identified in the book)
Published in
The Creative Atari (Creative Computing Press, 1983), "Design Philosophy and GTIA Demos"
Year
1983
Language
Atari BASIC
Requirements
GTIA chip (any XL/XE or later 400/800); 16K RAM; Atari BASIC
An oval fan of golden rays converging on a point at the right, in GRAPHICS 10

About the program

The demos come from the "Design Philosophy and GTIA Demos" chapter of The Creative Atari. The column's writer explained that Atari had started fitting the new GTIA chip to all Atari 800s in January 1982, and that the chip added three graphics modes. He didn't know who had written these little demonstration programs. He guessed they came from somebody at Atari with an early sample of the chip, and he asked the author to get in touch so that he could give credit.

SAS (the book doesn't explain the name) draws a full circle of thick rays from a point near the right-hand side of the screen out to an ellipse. It cycles the colour registers after every ray, so the picture shimmers while it is still being built. When the fan is finished, the colours keep running, like a glowing searchlight or an eye.

What you need

  • A GTIA machine: any XL/XE, a 400/800 built from 1982 on, or an emulator such as Altirra. CTIA machines run the program but show the wrong colours.
  • 16K RAM, Atari BASIC.

Typing it in

The listing is plain ASCII. Lines 15 and 910 end with NEXT I. The original printed page shows a bare NEXT there, which Atari BASIC rejects, so type the version below. Check the machine-language DATA in lines 31000–31010 carefully.

How to use it

RUN it. "STAND BY" appears and the numbers 0–90 scroll past while the sine table is built. Then the drawing starts. Press BREAK to stop.

How it works

  • Line 9 builds a table of sines in degrees, so that SINE(ANG+90) can stand in for a cosine.
  • Each pass of the loop at line 20 works out a point on an ellipse centred at (40,96), with a horizontal radius of 30 pixels and a vertical radius of 80. Lines 60–79 then draw three parallel lines to it from (65,94)–(65,96), which makes each ray thick.
  • C goes up by 0.5 for each degree and wraps from 9 back to 1, so the eight drawing colours take turns two degrees at a time.
  • Line 15 sets the registers to hue 14 (A+224) with luminances from line 1000 (2,4,6,8,6,4,2,2), so the colours ripple from dark to bright and back.
  • Lines 30000–30060 READ 27 bytes from lines 31000–31010 into A$. The first 21 bytes are a small 6502 routine (PLA, LDX #0, LDY 705, a loop of LDA 706,X / STA 705,X / INX / CPX #8 / BCC, STY 712, RTS). It moves colour registers 706–712 down one place and wraps 705 round to 712, so each USR(ADR(A$)) call moves every colour one step along. Any values after the 96 (RTS) are padding. Line 80 calls the routine inside the drawing loop, and lines 900–920 keep calling it once drawing is done.

Variations to try

  • Move the centre point in lines 60–78 (65,96) to change the viewpoint.
  • Change +224 in line 15 to another multiple of 16 for a different hue.
  • Lengthen the delay in line 910 to slow the shimmer.

Listing

2 DIM A$(30),SINE(450)
3 GOSUB 30000
4 DEG
8 ? "STAND BY"
9 FOR I=0 TO 90:? I:A=SIN(I):SINE(I)=A:SINE(180-I)=A:SINE(I+180)=-A:SINE(360-I)=-A:SINE(I+360)=A:NEXT I
10 GRAPHICS 10
15 RESTORE :FOR I=1 TO 8:READ A:POKE 704+I,A+224:NEXT I
19 C=1
20 FOR ANG=0 TO 359
30 X=40+30*SINE(ANG+90)
40 Y=96+80*SINE(ANG)
50 COLOR INT(C)
60 PLOT 65,96
70 DRAWTO X,Y
75 PLOT 65,95
77 DRAWTO X,Y-1
78 PLOT 65,94
79 DRAWTO X,Y-2
80 Q=USR(ADR(A$))
85 C=C+0.5:IF C>=9 THEN C=1
90 NEXT ANG
900 Q=USR(ADR(A$))
910 FOR I=1 TO 14:NEXT I
920 GOTO 900
1000 DATA 2,4,6,8,6,4,2,2
30000 REM *** SET UP ASSY PROGRAM
30010 RESTORE 31000
30020 FOR Z=1 TO 27
30030 READ X:A$(Z)=CHR$(X)
30040 NEXT Z
30050 RESTORE
30060 RETURN
31000 DATA 104,162,0,172,193,2,189,194,2,157,193,2,232,224,8,144,245,140,200
31010 DATA 2,96,65,65,65,65,65,65

Credits