Roll (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
Four blue cylinders in a row, each with one bright highlighted segment

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.

Roll is a lesson in how far colour-register animation can go. It draws four upright cylinders. Each one is built from short vertical lines placed round a circle, and the colour number goes up step by step round the circle. Then only one of the eight drawing colours is set bright, and the program keeps passing that bright value from register to register. A highlight runs round each cylinder, and because neighbouring cylinders were drawn with their colours in opposite orders, they seem to turn against each other like a row of rollers.

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, with no machine code. Lines 420–490 draw a fifth cylinder, but line 410 jumps straight past them, in the printed book too. Type them anyway if you want to experiment (see below).

How to use it

RUN it and wait for the four cylinders. The rolling starts at once and carries on until you press BREAK.

How it works

  • DEG puts SIN/COS into degrees. Each block (lines 20–90, 120–190, 220–290, 320–390) steps round a circle of radius 8 in 6-degree steps, and draws a vertical line 50 pixels long down from each point. That gives a solid-looking cylinder.
  • The colour is (ANG-180)/45+1 on cylinders 1 and 3, and 9-(ANG-180)/45 on cylinders 2 and 4, so the colour numbers run round them in opposite directions.
  • COLOR 0:PLOT X,Y after each line erases its top pixel. That keeps the upper rim neat.
  • Line 15 sets all of registers 705–712 to a dark shade of hue 8 (130), and line 17 makes register 705 bright (136). Lines 500–550 rotate the registers: save 705, copy each of 706–712 down one place, put the saved value in 712. The one bright stripe moves round each cylinder.

Variations to try

  • Delete line 410 to add the fifth cylinder at X=50. It overlaps its neighbours, which makes an interesting tangle.
  • Set two registers bright in line 17 for a double highlight.
  • Change 130/136 to another hue, for example 66/72.

Listing

5 DEG
10 GRAPHICS 10
15 FOR I=0 TO 7:POKE 705+I,128+2:NEXT I
17 POKE 705,136
20 FOR ANG=180 TO 360+180 STEP 6
30 X=8+8*COS(ANG)
40 Y=16+8*SIN(ANG)
50 COLOR (ANG-180)/45+1:PLOT X,Y
60 DRAWTO X,50+Y
70 COLOR 0:PLOT X,Y
90 NEXT ANG
120 FOR ANG=180 TO 360+180 STEP 6
130 X=26+8*COS(ANG)
140 Y=16+8*SIN(ANG)
150 COLOR 9-(ANG-180)/45:PLOT X,Y
160 DRAWTO X,50+Y
170 COLOR 0:PLOT X,Y
190 NEXT ANG
220 FOR ANG=180 TO 360+180 STEP 6
230 X=44+8*COS(ANG)
240 Y=16+8*SIN(ANG)
250 COLOR (ANG-180)/45+1:PLOT X,Y
260 DRAWTO X,50+Y
270 COLOR 0:PLOT X,Y
290 NEXT ANG
320 FOR ANG=180 TO 360+180 STEP 6
330 X=62+8*COS(ANG)
340 Y=16+8*SIN(ANG)
350 COLOR 9-(ANG-180)/45:PLOT X,Y
360 DRAWTO X,50+Y
370 COLOR 0:PLOT X,Y
390 NEXT ANG
410 GOTO 500
420 FOR ANG=180 TO 360+180 STEP 6
430 X=50+8*COS(ANG)
440 Y=16+8*SIN(ANG)
450 COLOR (ANG-180)/45+1:PLOT X,Y
460 DRAWTO X,50+Y
470 COLOR 0:PLOT X,Y
490 NEXT ANG
500 A=PEEK(705)
510 FOR I=705 TO 711
520 POKE I,PEEK(I+1)
530 NEXT I
540 POKE 712,A
550 GOTO 500

Credits