Hypno (GTIA Demo)

Type
Graphics
Category
GTIA colour-cycling demo
Author
Unknown (an early Atari GTIA demo; the column's author asked the original programmer to come forward)
Published in
The Creative Atari (Creative Computing Press, 1983), "Design Philosophy and GTIA Demos"
Year
1983
Language
Atari BASIC
Requirements
Atari 400/800 with GTIA chip, or any XL/XE; 16K RAM; Atari BASIC
Hypno: a moire of diagonal lines in eight colours radiating from the screen centre in GRAPHICS 10

About the program

When Atari began fitting the GTIA graphics chip to every Atari 800 in January 1982, three new BASIC graphics modes became available: GRAPHICS 9, 10 and 11. Short demonstration programs for the new chip circulated, and The Creative Atari printed a set of them in its "Design Philosophy and GTIA Demos" chapter. The column's writer did not know who had written the programs. He guessed they came from inside Atari, from someone who had an early sample of the chip, and he invited the author to step forward for credit.

Hypno is the most hypnotic of the set, as the name suggests. It fills the 80×192 GRAPHICS 10 screen with two fans of diagonal lines, one from each pair of corners, stepping through eight colours as it goes. When the picture is complete, a tiny machine-language routine shifts the colour registers round and round, and the whole moiré pattern seems to swirl.

What you need

  • A machine with a GTIA chip. Every XL and XE has one, and so do Atari 800s built from 1982 on. Emulators such as Altirra emulate it too. On an old CTIA machine the program still runs, but the picture appears in the wrong colours.
  • 16K RAM and Atari BASIC.

Typing it in

The listing is plain ASCII. The DATA in lines 31000–31010 is the machine-language routine, so check every number. A wrong value there can lock up the computer when line 200 calls USR. The last few values in line 31010 (65 and 54) are only padding and are never executed. The book says to add lines 31000 and 31010 to the end of several of the demos, and the listing below already includes them. Atari BASIC accepts ? as shorthand for PRINT.

How to use it

Type RUN and wait while the lines are drawn (the drawing is slowish in BASIC). The colour animation then runs until you press BREAK. Press RESET to get back to a normal text screen.

How it works

  • GRAPHICS 10 is the GTIA mode with nine colour registers, 704–712. COLOR 0 uses register 704 (the background), and COLOR 1 to COLOR 8 use registers 705–712. Line 15 fills registers 705–712 with (I-1)*32+22, which gives every second hue (1, 3, 5 … 15), all at luminance 6.
  • Lines 30–80 draw lines from the left edge to the right edge. Each line's colour goes up by 0.4166 every time, so COLOR Q (which drops the fraction) changes colour every two or three lines. Lines 130–180 cross them with a second fan, drawn from the top edge to the bottom edge.
  • Lines 30000–30060 READ 27 bytes into A$. The first 21 bytes are a 6502 routine: PLA, LDX #0, LDY 705, then a loop of LDA 706,X / STA 705,X / INX / CPX #8 / BCC, then STY 712 and RTS. In other words it moves registers 706–712 down one place and wraps 705 round to 712. Each X=USR(ADR(A$)) moves every colour one step along.
  • Line 210 is a short delay that sets the speed of the spin.

Variations to try

  • Make the empty loop in line 210 longer or shorter.
  • Change line 15 to POKE 704+I,I*16+6 for a smooth rainbow.
  • Delete the REM at the start of line 190 to draw a big background-coloured X over the pattern.

Listing

2 DIM A$(30)
3 GOSUB 30000
10 GRAPHICS 10
15 FOR I=1 TO 8:POKE 704+I,(I-1)*32+22:NEXT I
20 Q=1
30 FOR Y=0 TO 191
40 COLOR Q
50 PLOT 0,Y
60 DRAWTO 79,191-Y
70 Q=Q+0.416666666:IF Q>8 THEN Q=1
75 REM FOR T=1 TO 100:NEXT T
80 NEXT Y
120 Q=1
130 FOR X=79 TO 0 STEP -1
140 COLOR Q
150 PLOT X,0
160 DRAWTO 79-X,191
170 Q=Q+1:IF Q>8 THEN Q=1
180 NEXT X
190 REM COLOR 0:PLOT 0,0:DRAWTO 79,191:PLOT 79,0:DRAWTO 0,191
200 X=USR(ADR(A$))
210 FOR J=1 TO 4:NEXT J
220 GOTO 200
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,54,65

Credits