COLOR, and POKE
to Color Your Screen
The SETCOLOR and COLOR statements are important to Atari graphics, but are often misunderstood by beginners. Here are simple examples to help newcomers get the most from their Ataris.
One confusing aspect of Atari graphics for the beginner is the relationship between the COLOR and SETCOLOR statements. Once the relationship between these statements is understood, the beginner can control the color patterns he or she wishes to create.
SETCOLOR in Mode 0
The SETCOLOR statement is used to define the colors which will appear on the screen. In mode 0 the statement will function alone. Try entering the following without a line number:
The screen should have turned white. But characters on a white screen are difficult to read. To remedy this situation, enter the following line:
The print on the screen is now dark enough to read easily. To try one more color change, enter this line exactly as it's printed:
SE. is the abbreviation for SETCOLOR and may be used to enter the statement, even within a program line. As an example, try entering this line using the SETCOLOR and GRAPHICS abbreviations as follows:
100 GR. 0:SE.2,8,6
Now list the line by typing L. (RETURN) (L. is the same as LIST). Notice that the computer has printed the entire word for SETCOLOR and GRAPHICS.
Take a closer look at the SETCOLOR statement. The first number is the color register, the second number is the hue, and the last number is the luminance. There are 16 hues to choose from and 8 luminances for each hue. Table 1 summarizes the hues.
|Table 1. Color Numbers|
|*Colors may vary on different color TVs.|
The simple examples of the SETCOLOR statement given previously used registers 1, 2, and 4. The use of these registers varies for the different modes. In mode 0, SETCOLOR 1 controls the print color and should have the same hue as register 2, which controls the screen color. Register 4 controls the border color for mode 0. Table 2 summarizes which color registers are used in which modes. It is important to remember that the term colorregister refers to the first number in the SETCOLOR statement, not to the first number in the COLOR statement, which is discussed below.
SETCOLOR and COLOR in Modes 3, 5, and 7
Look at Program 1. Lines 20, 30, and 40 set the color registers 0, 1, and 2. But just setting the registers does nothing to put color on the screen. A COLOR statement is needed to tell the computer which of the colors you wish to use, and something must be PLOTted or drawn.
The numbering can be a bit confusing. Refer to the first two columns of Table 2. Notice that to get the color established by the SETCOLOR 0,4,6 statement, you must issue the command COLOR 1. The COLOR statement number is always one more than the first number in the SETCOLOR statement, except for SETCOLOR 4, when COLOR 0 would be used.
If you haven't already typed in Program 1, do so now. Line 50 is the COLOR statement that decides which of the three SETCOLOR statements will be used when the box is drawn. This program will continue to rotate through the three colors endlessly until the BREAK key is pressed. Experiment with the program, change the colors, and see what happens.
Changing the Background Color
Program 2 illustrates how to change the background color in modes 3, 5, and 7. SETCOLOR 4 has just been hinted at so far. It is the color register that controls the background color in each of the four-color modes (3, 5, and 7).
Line 50 sets the background color. Lines 20, 30, and 40 set the colors for the rectangles. The text window keeps you informed about the colors. Again, the best way to learn about these colors is to experiment.
POKE Instead of SETCOLOR
Replace lines 20, 30, 40, and 50 of Program 2 with those lines from Program 3. Once this is done, run the program. All that was done was to replace each of the SETCOLOR statements with a POKE statement. The new lines act exactly the same as the originals.
Here's how to figure the second number in the POKE statement: multiply the hue by 16 and add the luminance. For example, SETCOLOR 0, 3, 10 would become 3 times 16 (48) plus 10, for a total of 58--POKE 708, 58. Table 2 shows which POKE location to use for each color register.
|Table 2. SETCOLOR, COLOR, and POKE|
1 and 2
*a = any number from 0 to 15.
b = zero or any even number from 2 to 14.
t c = a x 16 + b (a times 16 plus b).
Selecting the Right Colors
One problem that many new programmers have is selecting the best combination of colors. Each time a color is added or changed on the screen, it affects the other colors on the screen. Program 4, a simple color editor, is intended to help with this problem. It will tell you the number to POKE to get the color you have selected. It will also tell you which color number to use in the COLOR statement.
Once the program is typed in and run, you will see one number flashing. That is the current register that will be affected by the joystick plugged into port one. Moving the joystick forward advances the numbers, and pulling back makes the numbers decrease. Pressing the fire button will change the register that is affected by the joystick. Trial and error will be the best teacher here. When you discover a combination of colors you believe would fit your application, make a note of it so you can use that combination in your own program.
Only the Beginning
This article is just an introduction to the world of Atari graphics. There is much more to be learned, but with the simple techniques shown here, you should be able to make some very impressive displays.
Program 1. SETCOLOR ExampleDownload P032L1.BAS (Saved BASIC)
Download / View P032L1.LST (Listed BASIC)
Program 2. Background ColorsDownload P032L2.BAS (Saved BASIC)
Download / View P032L2.LST (Listed BASIC)
Program 3. POKE Instead of SETCOLORDownload P032L3.BAS (Saved BASIC)
Download / View P032L3.LST (Listed BASIC)
Program 4. Color EditorDownload P032L4.BAS (Saved BASIC)
Download / View P032L4.LST (Listed BASIC)
Return to Table of Contents | Previous Section | Next Section