Classic Computer Magazine Archive COMPUTE! ISSUE 21 / FEBRUARY 1982 / PAGE 114

Put A Rainbow In Your Atari

Fred and Doug Tedsen
Sonoma, CA

You've probably seen programs that display 128 colors on the Atari. They are usually interesting to look at, but what do you do with them after you have run them two or three times? Well here is a program that displays a moving rainbow of all 128 colors, and the techniques could easily be used for dramatic title screens in your own programs.

The program begins by drawing the word COLOR in large block letters on the GRAPHICS 7 screen. This is performed by the subroutine at lines 1000 to 1200. While the letters are being drawn, the program is doing a graphics fill. The letter outline is drawn with color register 1 (controlled by SETCOLOR 1) and the inside area of the letters is filled with color register 0 (COLOR 1, SETCOLOR 0). Lines 2000 through 2500 contain the data points for drawing the letters.

The program now goes through a color changing sequence (lines 110-190). This section was included to demonstrate how colors can be controlled inside and outside of the fill areas and also to heighten anticipation for the part that follows. First we randomly change the colors inside the letters, leaving the background black. Next the background colors is changed while the letters remain black. And, finally, we change both the letter and background colors independently. Notice that the letter outlines remain white throughout.

Now The Fun Part

Now we come to the fun part. At the beginning of the program, the subroutine at lines 3000 to 3040 was run to load the machine language color rainbow generator into the strings CUP$ and CDOWN$. These are now used to produce the rainbow pattern. The pattern is first set moving up the screen within the letters, with a black background. The pattern is then put on the background with solid color letters. These steps are then repeated with movement down the screen, just to show that we can go both ways.

So how does it work? Briefly, the POTO register is read and the value obtained placed in one of the playfield color registers. Since the pots are continually counting down to zero, this value changes every scan line. A write to WSYNC makes the change occur at the end of a scan line, resulting in solid lines across the screen. Movement is accomplished by adding or subtracting the value of the 1/60th of a second frame counter to the POTO value before writing it to the color register. The write is directly to the registers in CTIA because the OS shadow registers are not copied until vertical blank and therefore would do nothing. The assembler source listing is included for reference. Notice that there is a direct correspondence between the source listing and the BASIC data statements at lines 3100 to 3280.

Modifications

There are several things which you can do with this routine to change the display:

  1. Parameter two in the USR statement is the time in seconds that the routine is to be run. Thus X = USR(ADR(CUP$), 4) will display the pattern moving up the screen for about four seconds.
  2. You can affect any of the five playfield color registers. To do this you can change either the DATA statement at line 3180 or the machine language string. The values to use are 22, 23, 24, 25, and 26 for color registers 0, 1, 2, 3, and the background, respectively. For example, changing line 3180 to DATA 141,26,208 will affect the background. Line 240 demonstrates how the string may be changed to give the same result.
  3. You can obtain a stationary rainbow pattern by changing line 3170 to DATA 234,234 (NOP's). Don't try to use CDOWN$ if you do this, however. A better way would be to change elements 12 and 13 of the string.
  4. For those of you with Assembler, there is a myraid of patterns which can be generated by using AND and ORA before writing to the color register. You can create patterns with large bars of color, with small bars of different shades of the same color, or with some combinations—a rainbow of pastels.
  5. While the machine language routine is running, your program can't do anything else. Though we haven't tried it yet, it should be possible to incorporate the logic in a display list interrupt routine. This would allow you to do things such as having the pattern roll down the screen with a curtain effect.

There are a couple of things to watch out for when running the program. A time value of zero will run the rainbow routine for about four minutes. If you accidently do this, you will have to press SYSTEM RESET to get out. Also, unplug your paddles from game port 1 to get the proper rainbow effect. You might want to plug a paddle in later to see the effect. It's kind of interesting.