Rainbow (scan-line colour fan)

Type
Graphics
Category
Raster colour demo
Author
Salt Lake City Atari Computer Enthusiasts (ACE)
Published in
Antic, October 1986 (Vol. 5, No. 6), Tech Tips
Year
1986
Language
Atari BASIC (with a 22-byte machine-language routine)
Requirements
Any Atari 8-bit computer, Atari BASIC (XL/XE owners can use the GRAPHICS 15 variant in the REMs). Press RESET to stop.
A fan of lines radiating from the top left corner of a GRAPHICS 7 screen, coloured in horizontal rainbow bands that change hue every scan line

About the program

Antic's Tech Tips page for October 1986 offered "two pleasing graphics demonstrations". One was Visions by 17-year-old Michael Metz of St. Clair, Michigan. The other was this one, which the magazine had found in the newsletter of the Salt Lake City Atari Computer Enthusiasts (ACE). The REM credits it to "ACE of Salt Lake".

The BASIC part only draws a fan of straight lines from the top left corner of a GRAPHICS 7 screen, and all the lines are the same colour. A tiny machine-language routine then gives that one colour a different hue and brightness on every scan line, so the whole fan glows in rainbow bands.

Typing it in

The listing is plain Atari BASIC with no special characters. Check the 22 numbers in lines 120–130 carefully. They are the machine code, and an error will lock up the computer. Lines 200–230 are only REMs. As the magazine explained, they show the changes for XL/XE owners, who can use the higher-resolution GRAPHICS 15 (not available from BASIC on the older 400/800): replace lines 30, 50 and 70 with the versions given there.

How to use it

RUN it. The fan is drawn and the colours appear at once. The routine never returns to BASIC, so line 140 is never reached. Press RESET to get the computer back.

How it works

Line 100 POKEs the routine into page 6, and line 110 calls it. Taken apart, the 22 bytes do this:

  1. LDA 54283 / CMP #32 / BNE waits until VCOUNT, ANTIC's scan-line counter, reaches 32 (a little way down the screen).
  2. Then, in a loop: STA WSYNC (54282) waits for the start of the next scan line, and STX 53272 writes X into the hardware register for playfield colour 2. INX / INX steps X through all 128 even colour values.
  3. When X wraps round to 0, it writes 0 to the register and jumps back to wait for line 32 in the next frame.

COLOR 3 in GRAPHICS 7 is drawn with playfield colour 2, so only the lines change colour and the background stays black. Because the routine writes the hardware register directly, the normal OS colour shadow (710) is ignored while it runs. A loop like this takes over the CPU completely, which is why programs that need to keep running use display list interrupts instead.

Variations to try

Change the 32 in line 120 to start the bands higher or lower. You can also draw something else in lines 30–90: anything drawn with COLOR 3 picks up the rainbow.

Listing

10 REM RAINBOW
20 REM ACE OF SALT LAKE
30 GRAPHICS 7+16:COLOR 3
40 FOR X=0 TO 159 STEP 8
50 PLOT 0,0:DRAWTO X,95
60 NEXT X
70 FOR Y=95 TO 0 STEP -8
80 PLOT 0,0:DRAWTO 159,Y
90 NEXT Y
100 FOR I=0 TO 21:READ A:POKE 1536+I,A:NEXT I
110 A=USR(1536)
120 DATA 173,11,212,201,32,208,249,141,10,212,142,24,208,232,232,208,246,142
130 DATA 24,208,240,232
140 END
200 REM CHANGE LINES 30, 50 AND 70 TO THE FOLLOWING IF YOU HAVE AN XL OR XE.
210 REM 30 GRAPHICS 15+16:COLOR 3
220 REM 50 PLOT 0,0:DRAWTO X, 191
230 REM 70 FOR Y=191 TO 0 STEP -8

Download

The original program from the Antic disk, to LOAD or ENTER instead of typing it: RAINBOW.BAS.

Credits