Ring (GTIA Demo)

Type
Graphics
Category
GTIA graphics 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
Concentric ellipses glowing in bands of green and pink 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.

Ring draws 30 concentric ellipses. Their colours ramp up and down through the eight GRAPHICS 10 drawing colours, so the result looks like a glowing tube or a ripple in a pond. On its second pass the program fills the bands with the operating system's fill command. Then it settles into an endless loop that shifts the hue of every colour register, so the ring slowly changes colour.

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. Watch the double IF in line 3000 (IF T3=1 THEN IF ... THEN ...), which is legal Atari BASIC. Line 116 holds ten values, but line 115 only reads nine (registers 704–712), so the last value is never used. So the final 54 here (the printed book has 154) makes no difference.

How to use it

RUN it and watch. The outlines are drawn first. Then the program goes round again and fills them, which takes a while in BASIC. When it has finished, the colours cycle until you press BREAK.

How it works

  • Line 118 splits a circle into 22 steps. Lines 120 and 2500 store the sine and cosine of each step in the array C(), so the drawing loop never has to call SIN or COS again.
  • Subroutine 2000 turns a step number V and a ring number R into screen coordinates. Ring R has a horizontal radius of 30-R and a vertical radius of 60-R, which allows for the very wide GRAPHICS 10 pixels.
  • Lines 1010–1320 draw rings 1–30 with colours 1→8→1→8→1 (T6), which gives the banded glow.
  • On the second pass (T3=1), subroutine 3000 puts the fill colour in location 765 and calls XIO 18,#6,0,0,"S:". That is the OS fill command, the same as Atari BASIC's missing FILL statement. It paints to the right from each point until it hits a non-background pixel.
  • Lines 400–420 add 16 to each colour register, which moves it to the next hue at the same brightness. Values past 255 wrap round to 26. POKE 77,0 keeps the attract mode from dimming the screen.

Variations to try

  • Change LIM in line 118 to 12 for chunky polygons, or to 40 for smoother rings. The DIM C(22,2) in line 110 must be at least LIM.
  • Change line 116 to new starting colours.

Listing

100 REM GTIA TEST
110 DIM C(22,2)
115 GRAPHICS 10:FOR Z=704 TO 712:READ R:POKE Z,R:NEXT Z
116 DATA 0,26,42,58,74,90,106,122,138,54
118 LIM=22:T2=3.14159*2/LIM
120 GOSUB 2500:FOR V=1 TO LIM:T=T+T2:GOSUB 2500:NEXT V
200 GOTO 1000
400 FOR X=1 TO 8:Z=PEEK(704+X):Z=Z+16:IF Z>255 THEN Z=26
420 POKE 704+X,Z:NEXT X:POKE 77,0:GOTO 400
1000 REM
1010 FOR R=1 TO 8:T6=R
1020 GOSUB 1520:NEXT R
1110 FOR R=9 TO 15:T6=16-R
1120 GOSUB 1520:NEXT R
1210 FOR R=16 TO 23:T6=R-15
1220 GOSUB 1520:NEXT R
1310 FOR R=24 TO 30:T6=31-R
1320 GOSUB 1520:NEXT R
1400 IF T3=1 THEN GOTO 400
1410 T3=1:GOTO 1010
1520 COLOR T6:V=0:GOSUB 2000:PLOT X,Y:FOR V=1 TO LIM:T=T+T2:GOSUB 2000:GOSUB 3000:DRAWTO X,Y:NEXT V:RETURN
2000 X=(30-R)*C(V,1)+40:Y=(60-R)*C(V,2)+80:RETURN
2500 C(V,1)=SIN(T):C(V,2)=COS(T):RETURN
3000 IF T3=1 THEN IF (R=1 AND V>11) OR R>1 THEN POSITION X,Y:POKE 765,T6:XIO 18,#6,0,0,"S:"
3010 RETURN

Credits