Classic Computer Magazine Archive COMPUTE! ISSUE 51 / AUGUST 1984 / PAGE 10

New Atari Graphics Mode?

I wrote a program that puzzles me:

10 GRAPHICS 9016 : POKE 710,0
20X = INT (RND(0) * 318) : Y = INT (RND(0) * 191)
30 PLOT 159, 95
40 COLOR Y : DRAW TO X, Y
50 GOTO 20

What is graphics mode 9016? When I break in and rerun the program, the previous picture is not erased! Also, sometimes it would suddenly clear the screen. Why? Is there something wrong with my computer?

Gordon E. Gizowski II

No, your computer is fine. You've just revealed some of the peculiarities of BASIC and the operating system. First, graphics modes are specified with a number from 0 to 15. If you add 16 to the number, the split screen will be disabled. If you add 32 to the number, the screen will not be cleared when the graphics mode is entered. But anything above 15 + 16 + 32 is just chopped off. In binary terms, only the lower six bits of the mode number are used. So GRAPHICS 71 is the same as GRAPHICS 7+64. Since 64 (bit 6) is not used, GRAPHICS 71 is the same as GRAPHICS 7. GRAPHICS 9016 is the same as 8 + 32 + 16 + 8960. Since 8960 is outside the range, it is ignored, and you get 8 + 32 + 16 (56), which is GRAPHICS 8 with no split screen. The 32, as mentioned, prevents the screen from being cleared when GRAPHICS 8 is set up. A portion of the previous picture may have been destroyed, though, if you have changed modes (such as from GRAPHICS 8 to GRAPHICS 0).

The reason the screen was sometimes cleared is in line 40. You PLOT and DRAWTO random X, Y coordinates, but also use the Y coordinate for the color number. COLOR also chops off the part of a number that is not used. In GRAPHICS 8, only COLOR 1 and COLOR 0 are valid, so that odd numbers, count as COLOR 1, and even numbers work as COLOR 0. PLOT is the same as PRINTing the CHR$ value of the color at the screen X, Y position (try using COLOR and PLOT with GRAPH­ICS 0, 1, and 2 to see the effect). If, however, the color number is 125, it is interpreted as CHR$(125), which is the same as the code for clear screen (CTRL-CLEAR). So COLOR 125-.PLOT x, y will clear the screen. Your program is interesting, but to get the intended effect, you should use a different variable for the color. For example:

25 C = INT (2 * RND(0)).
40 COLOR C : DRAW TO X, Y