In my continuing efforts to learn how to program the Atari 8-bit line decided I needed to step back when I started looking at display lists interrupts. I want to, eventually, learn to program this machine using assembler, but it became clear to me I needed to understand more about the concepts surrounding how the Atari draws to the screen, handles colors, and standard graphics modes. I pulled out my copy of Compute! ‘s First Book on Atari Graphics and my Atari Basic Reference Manual and set out to understand these topics.

This article is going to be my first foray into documenting my understanding of these so far. This article may not contain the correct information, but if it doesn’t, I will endeavor to come back to this article and post an addendum or follow up reference to a new corrected article when I learn more.

Text Modes

Firstly the 8-bit Atari (XL/XE lines at least) have 16 graphics modes. The modes include Text modes and Graphics modes. The text modes:

Mode 0Regular Text40 Columns x 24 Rows
Mode 1Text – Double Wide Characters20 Columns x 24 Rows (20 in split mode)
Mode 2Text – Double Wide and Double Height Characters20 Columns x 12 Rows (10 in split mode)

In these text modes (Modes 1 & 2 – we will not discuss Mode 0 here yet), the COLOR command doesn’t appear to be used. Colors are displayed with a combination of the choice of characters printed and the SETCOLOR command. The choice of upper case or lower case and the inverse status being used to define what color will be displayed. It is worth noting that: everything displayed is upper case, nothing is displayed in inverse, and the numeric characters as well as symbols like * or () and others are displayed in the same color as the uppercase text.

The registers are as follows:

0Uppercase Text, Symbols & Numbers
1Lowercase Text
2Inverted Uppercase Text, Symbols & Numbers
3Inverted Lowercase Text

So, for instance, to display a three color title for a game you might do something like this:

In this code we are setting the Graphics mode to 1 with a modifier of 16. This modifier removes four lines of Graphics 0 split screen at the bottom of the monitor.

In the next four lines we set the colors using the BASIC SETCOLOR command.

  • Line 20 sets the color of upper case non inverted characters to green with a luminance of 5 (In this case the word “PRESENTS”)
  • Line 25 sets the color of the lower case non inverted characters (“AN EIGHT BIT”, “PRODUCTION”) to blue with a luminance of 5.
  • Line 30 sets the color of inverted upper case (numbers & symbols as well — though none are present here) to red/orange with a luminance of 15. (In this case the text “CODEWRENCH.COM”)
  • Line 40 sets the color of inverted lower case (“JOURNEY TO THE CODE”) light orange with a luminance of 15.
  • Line 45 sets the color of the background to grey with a luminance of 2 (very dark).

Lined 50-90 position the cursor and print the message to the screen. Note the use of #6 in the PRINT statements. The #6 token is a special handle that BASIC opens for us when we invoke an appropriate graphics mode to allow PRINT statements to be displayed.

Finally line 100 enters an infinite loop – as exiting the program will cause the graphics mode to get changed, automatically back to 0 and clear the screen.

The results are:

As of right now, and as far as I can tell, with BASIC there isn’t a good way to display lowercase letters, inverted text or any other kinds of data than upper case letters, numbers and basic symbols in GRAPHICS mode 1 or 2. That said, I still need to do more studying, research and experimentation here.

Graphics Modes

Graphics modes appear to work similarly to text modes with the exception that you can’t print directly to them, They can be much higher resolution and In order to use specific colors you must use SETCOLOR and COLOR in conjunction with one another

To use graphics modes, you need to specify the color using the COLOR command before drawing operations (there are other ways to use strings to do plotting, but this article won’t cover that aspect of the language). The COLOR command takes an argument that is related to the register number associated with a SETCOLOR command (COLOR register is SETCOLOR register + 1). Unless you are happy with the default colors, therefore, you must also provide a SETCOLOR command to change the actual color that the COLOR argument represents.

For an example I will write some code that uses Graphics Mode 15. This mode is 160 columns x 192 rows (160 if the Graphics 0 text area is left) and has three possible colors, plus the background color for a total of four colors.

I start this program by selecting Graphics 15 with a modifier of 16 to remove the GR. 0 window. Then I choose some colors using the SECTOLOR commands in lines 20-35. Register 0 is loaded with a color that approximates the color red (but it looks brown on my monitors). Register 1 is loaded with the color gray, but with a luminance of 15, it really gives it the appearance of white. Register 2 is loaded with blue, and finally, the background is loaded with that same gray color but this time with a luminance of 0, which yields black (which I believe would be the default if unset anyway).

Line 50 sets the starting color register to be 1. This setting brings up an important point about the color register argument in the COLOR statement vs. the color register argument in the SETCOLOR statement. It appears the COLOR argument is ones based (or at least starts with 1) where the SETCOLOR statements colors are 0 based. So we need to add one to the SETCOLOR argument we are using to get the correct color. For instance, if we want red (or brown), it would be COLOR 1, for white COLOR 2, blue COLOR 3, and BLACK COLOR 4.

Lines 60 and 70 setup loops to go through the rows and the columns of the graphics mode. This graphics mode allows 192 rows and 160 columns. The indexing is zero based so we loop from 0 to 191 rows and 0 to 159 columns.

Line 80 changes the color to the currently assigned value in C. Remember we initially start off C with the value of 1 representing RED.

Line 90 plots a point with the PLOT command at position X,Y (the current row & column)

Line 100 Increments C

Line 110 check to C to determine if it has gone out of bounds after the increment and sets it back to one if that is case.

Lines 120 and 130 increment our loops

Line 140 starts our infinite loop to keep the graphics on the screen when the work is done.

The result is below:

Conclusion so Far

This content is obviously very basic (pun intended) stuff. I expect most people who have done much at all with Atari programming already know all of this. That said, I found the references to be a bit hard to understand in comprehending the relationships between these two commands. It took digging in and experimenting to figure this out for me. The next steps for me are to continue working through the Compute!’s First Book of Atari Graphics book (this first references to COLOR and SETCOLOR there are what kind of stumped me and sent me down this rabbit hole) now that I have a beginners grasp on these concepts. Finally, I know there are many other ways to manipulate color in Atari Graphics (e.g., POKE statements, assembler, etc…), so there is more to learn. My intention with writing this (along with nearly everything else I write here) is primarily to force me to memorialize the learning or whatever the topic is to help solidify it in my mind. As a secondary benefit, I hope that someone stumbles across it when they are similarly confused, and this article is helpful.