Colour-Cycling Stripes (De Re Atari)
- Type
- Graphics
- Category
- Colour register animation demo
- Author
- Chris Crawford (Section 3 of De Re Atari)
- Published in
- De Re Atari: A Guide to Effective Programming (Atari Program Exchange, APX-90008, 1982), Section 3, "Graphics Indirection"
- Year
- 1982
- Language
- Atari BASIC
- Requirements
- Any Atari 8-bit, 16K RAM, Atari BASIC
About the program
De Re Atari was Atari's own programming guide, written by its Software Development Support Group for professional developers. Early versions circulated in 1981, and the 1982 edition was sold through the Atari Program Exchange as APX-90008. Chris Crawford's section on "graphics indirection" explains why the Atari's colour registers are so powerful. The screen stores only a register number for each pixel, so changing one register recolours every pixel that uses it, instantly. His example of "simple cyclic animation" is this little program. It draws a pattern once and then animates it without touching screen memory again.
What you need
Any Atari 8-bit with Atari BASIC.
Typing it in
Just 14 lines of plain ASCII. Watch the order of the POKEs in lines 90–130. It matters, because each one copies the register before it.
How to use it
RUN it. The screen fills with vertical stripes of four colours (one of them the background), and then the stripes appear to slide sideways continuously, like a barber's pole or a cinema marquee. Press BREAK to stop.
How it works
GRAPHICS 23is GRAPHICS 7 without a text window: 160×96 pixels in four colours.- Lines 20–80 draw 160 one-pixel-wide vertical lines, cycling through
COLOR 0toCOLOR 3. This is the only drawing the program ever does. - In GRAPHICS 7, colours 0–3 come from registers 712 (background), 708, 709 and 710. Lines 90–130 rotate the contents of those four registers: save 712, copy 710 into 712, 709 into 710, 708 into 709, and the saved value into 708. Each pass, every stripe takes on its neighbour's colour, so the pattern seems to move by one pixel.
- Crawford's text points out the simplest version of the idea:
FOR I=0 TO 254 STEP 2:POKE 712,I:NEXT Icycles the border through every colour.
Variations to try
- Rotate in the other direction to reverse the motion.
- Draw diagonal or circular bands instead of vertical lines, for spirals and ripples.
- Put a short delay loop before line 140 to slow it down, or use different starting colours with SETCOLOR.
Listing
10 GRAPHICS 23
20 FOR X=0 TO 39
30 FOR I=0 TO 3
40 COLOR I
50 PLOT 4*X+I,0
60 DRAWTO 4*X+I,95
70 NEXT I
80 NEXT X
90 A=PEEK(712)
100 POKE 712,PEEK(710)
110 POKE 710,PEEK(709)
120 POKE 709,PEEK(708)
130 POKE 708,A
140 GOTO 90
Credits
- Program listing: Colour-Cycling Stripes (De Re Atari) — program listing (De Re Atari: A Guide to Effective Programming (Atari Program Exchange, APX-90008, 1982), Section 3, "Graphics Indirection") — Chris Crawford (Section 3 of De Re Atari)
- Picture: The stripes appear to march sideways as the four colour registers rotate. — Chris Crawford (Section 3 of De Re Atari) (program); screenshot by the site
- De Re Atari — Section 3: Graphics Indirection (atariarchives.org) — Chris Crawford (Section 3 of De Re Atari)
- De Re Atari — preface (section authors) — AtariArchives.org
- comp.sys.atari.8bit FAQ (De Re Atari editions) — Michael Current (comp.sys.atari.8bit FAQ)
