6 Advanced Graphics Techniques

Part II:
Atari Video Graphics And The New GTIA

Craig Chamberlain


How to get 256 colors out of your Atari. The previous article in this three-part series opened with a discussion of Atari graphics. Part II examines techniques involving color indirection and looks at the new GTIA chip in detail.

Next, this series concludes with several programs which put GTIA through its paces.


Using Color Indirection

With color indirection, the number of different playfields is limited according to the number of bits per pixel, but the actual color/luminance of each playfield can be one of the 128 possibilities. The data bits are used as an index or offset into playfield color registers:


COLOR0 $02C4 708 
   playfield zero color register 
COLOR1 $02C5 709 
   playfield one 
COLOR2 $02C6 710 
   playfield two (used in modes 0 and 8) 
COLOR3 $02C7 711
   playfield three (used in color text modes) 
COLOR4 $02C8 712
   background color register 

These playfield color registers use seven bits to select the color and luminance, as follows:

D7,D6,05,D4
D3,D2,D1
D0
color
luminance
not used

BITS
0000
0001
0010
0011
0100
0101
0110
0111
1000
1001
1010
1011
1100
1101
1110
1111
VALUE
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
COLOR
gray (no color)
light orange
orange
red orange
pink
purple
purple blue
blue
blue
light blue
turquoise
blue green
green
yellow green
orange green
light orange

Atari BASIC allows you to select a playfield color to draw in by using the COLOR statement. The color register that corresponds to that playfield can be changed by using SETCOLOR.

Color indirection is a tool that should not be overlooked. It is possible to draw a detailed figure on the screen with one playfield, and then change the color of the entire figure with just one command. For example, a printed message can flash in colors to attract attention. A "glowing" effect can be created by rapidly changing the luminance of a playfield while maintaining the same color. Or, the playfield colors can all be set to the same color/luminance as the background. Figures drawn will not appear until the playfield color registers are changed. By changing the registers one at a time, an animation effect can be created. Color indirection may still not solve the problem of having many colors on the screen at the same time, but it does afford possibilities that otherwise would be difficult to achieve.

In special instances, playfield color registers can be changed during the horizontal blank, in which case all 128 color variations can be shown in one frame. This requires the use of machine language and still does not solve the problem of many colors on one scan line. Fortunately, experience has shown that, for many applications, three playfield colors will be sufficient.


Multiple Colors

Nevertheless, there are times when many colors would be desirable. This is where the GTIA steps in. It should now be apparent that 16 colors will require four bits per pixel. This is very expensive in terms of memory, so either pixel size or display memory will have to increase. Because ANTIC has a limit on how much memory it can access during one horizontal scan line, we have a limit on how much memory can be devoted to a screen. Therefore, resolution will have to suffer.

Before we see what the memory limit is, we should mention the two modes which are exceptions to the above rules. Three things distinguish modes zero and eight from the normal modes. Each pixel is a half color clock wide; a side effect of this is artifacting. The background color now becomes the border, and the main part of the screen is filled with playfield two. Finally, since the whole screen is now playfield two, the bit no longer tells which playfield to use, but which luminance to use.

MODE
0,8
0,8
BIT
1
2
LUMINANCE REGISTER
playfield one
playfield two (no image)

The color part of playfield one is ignored; only the luminance data is used. If the luminance values of playfields one and two are the same, the writing disappears. Modes zero and eight use this special "half color clock, one playfield color, two brightness" arrangement. Both modes have 320 distinct points of light horizontally and have single scan line resolution. The only difference between mode zero and mode eight is that the first is a text mode and the second is a direct mapping mode. Mode zero uses a character set and thereby saves memory; about 1K is required for this mode. Mode eight doesn't use a character set, and requires approximately 8K. That is our display memory limit. The Atari 400/800 is not capable of doing DMA to much more memory than the memory represented by one television frame.

Since the "half color clock, one color, two brightness" mode is used by graphics modes zero and eight, all the GTIA really does is provide three variations on this mode. They all use the maximum memory arrangement used by mode eight, so each of the three new modes requires 8K. All of the new modes use four-bit pixels, so the horizontal resolution goes from 320 (half color clock) to 80 (two color clock, as in modes four and five). Therefore, the resolution for all three new modes is 80 by 192, for a total of 15,360 points. One side effect of changing only the horizontal resolution is that the pixels are no longer square.

The ANTIC instruction register mode number for the maximum memory mode (the number you will find in the display list) is $0F, or decimal 15. It is important to understand that this number indicates not only mode eight, but also nine, ten, and eleven as well. In fact, the display list for any one of these modes is identical to the display list for any of the others.


Selecting Modes With PRIOR

How then does ANTIC know which of the four is the desired mode? The answer is that ANTIC neither knows nor cares; no matter which mode is being used, ANTIC still has to do the same work of fetching memory. It's the GTIA that processes the video signal; somehow the chip must be told which of the four modes is wanted. The GTIA hardware register PRIOR does exactly that.

GPRIOR
PRIOR
$026F
$D01B
623
53275
 
shadow
hardware

The two most significant bits (bits six and seven) of this register are the GTIA special mode select bits. Here's how they are set.

MODE BITS HEX DECIMAL
8
9
10
11
00
01
10
11
00
40
80
CO
0
64
128
192

For example, it is possible to switch from any one of the four modes to another simply by changing the values of the two select bits.

Other bits in GPRIOR serve different functions, so care must be taken not to alter them. These other bits allow multicolor players (blending on overlap), set all missiles to the color of playfield three to form a fifth player, and establish player/missile and playfield priorities. See the Hardware Manualfor further information.

Now that we know how the three new modes are similar, let's find out how they are different.

Mode 11 is the one-luminance, 16-color mode. The overall luminance is set by the background color, which, for this mode, defaults to a luminance of six, rather than the usual zero. It is now easy to draw rather finely detailed shapes in several colors without having to fool around with the display list and machine code interrupt routines. The thing I am especially excited about is going to make Apple owners envious. The Apple has a 16-color mode with resolution of 40 by 48, called the "lo res" mode. The Atari now has a 16-color mode, but the resolution is eight times greater than the Apple's.

Sixteen colors do present a problem, though, since the GTIA has only four playfield color registers. Therefore, mode 11 does not allow color indirection. The color on the screen is determined directly by the bit data stored in memory, according to the chart given earlier in the section on color indirection. The values in the four color/luminance registers are ignored. Some may consider this a disadvantage, but there is a benefit too. Just as the playfield color registers are not used, neither are the player/missile color registers used, so by using players it is possible to have 21 colors on the screen at the same time, without using display list interrupts or other tricks.


Producing 256 Colors

Mode nine is the one color, 16-luminance mode. This mode will be used to create some excellent three-dimensional effects and digitized pictures. The 16 luminances, when stacked vertically by the scan line with each line having the next brightest luminance, blend so well that it is very difficult to see the division from one to the other. The main color is set by the background color. Weird things happen when you change the luminance of the background. Another nice fact is that having 16 main colors with 16 luminance variations means that the Atari is capable of producing 256 colors.

One advanced application for mode nine is the display of digitized pictures. Digitization is a process by which a normal television picture, such as from a station or video recorder, can be analyzed and divided into different luminances. That information can be sent to the computer and stored on disk for later display. Mode nine, with 16 luminances and rather high resolution, is able to reproduce such pictures with impressive quality. Thus far we have seen only four digitized pictures. They were apparently made by some people at Atari, and two of the pictures were, uh, for mature viewers only. Standing from a short distance, however, it is very difficult to tell if any of these pictures is computer generated or not. I have never seen such quality on any other computer in the 400/800 price range without expensive additional equipment.

Mode ten is a cross between the other two modes; it allows eight colors plus the background, each with its own luminance, as in the primary modes. Unlike the other two modes, this one allows color indirection, so it uses the playfield and player/missile registers for color/luminance information. This chart shows how data values correspond with playfield registers.

BITS
0000
0001
0010
0011
0100
0101
0110
0111
1000
1001
1010
1011
1100
1101
1110
1111
VALUE
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
REGISTER
704
705
706
707
708
709
710
711
712
712
712
712
708
709
710
711
PLAYFIELD
PCOLR0
PCOLR1
PCOLR2
PCOLR3
COLOR0
COLOR1
COLOR2
COLOR3
COLOR4
COLOR4
COLOR4
COLOR4
COLOR0
COLOR1
COLOR2
COLOR3

Only nine of the 16 possible data values correspond to different playfields. Data values greater than eight just repeat playfields. For some reason, the background color is no longer set by COLOR4, but instead by PCOLR0. The Atari BASIC statement SETCOLOR can't be used to change the player/missile color registers, so the equivalent POKE must be used. For any register, the data part of the POKE is the color choice number multiplied by 16, plus the luminance (refer to earlier chart).

The power of indirection is magnified when eight main drawing colors can be used. This mode is very useful for creating motion effects. With nine color/luminances and color indirection, mode ten may prove to be the most versatile of the three new modes.


Compatibility Between CTIA And GTIA

Remember that the GTIA only controls how the display is generated, so all programs written for the CTIA should run on a GTIA machine in the same way. There can be no such thing as incompatibility. We have, however, come across one discrepancy between the CTIA and GTIA. The video signal generated by the GTIA is shifted one half color clock, so colors produced by artifacting, such as in POOL 1.5or Jawbreakers,will be different. That is just a minor visual difference; the important thing is that all software should be entirely compatible. Of course, you cannot expect a CTIA to generate these three new modes, but again the conflict is the display, not the program.

Because of the half color clock shift, it is now possible for players and playfields to overlap perfectly, whereas with the CTIA they didn't.

There are some cases where software will not run on GTIA machines. This is due to the fact that some of the new computers with the GTIA also have a revised (no bugs) operating system in them. Atari has made very clear which memory locations and vectors are permanent and protected from any revisions. If a program does not run on a GTIA machine, it is the software's fault because illegal entry points were used.

One other conflict has appeared which really surprised me. We have discovered that a few programs written on CTIA machines carelessly set the GTIA special mode select bits of GPRIOR for no purpose. Since these two bits do nothing on the CTIA, there was no problem. But there was also no reason to involve them. When the same programs are run on GTIA, the accidental bit settings affect the display, even though modes nine, ten, and eleven are not used. The function of those two bits has not been a secret. I figured out their function in July 1981, when I read the OS source listing before I bought my Atari 800. The Hardware Manualhas described the three "new" modes in Appendix H ever since the manual was released.


No Text Window

There is a difference between the normal modes and the three new modes--the three new ones do not allow split screen (text window at bottom) configurations. If you remember how modes eight and zero are related, you should understand why. The mode used in the text windows is mode zero, which follows the special "half color clock, one color, two luminances" arrangement. As stated above, having the mode select bits in GPRIOR set for a mode greater than eight causes mode zero to act funny. A split screen would be possible only if a display list interrupt were inserted just before the text window area. The interrupt routine would have to reset to zero the mode select bits in the hardware register PRIOR, not the shadow register. The hardware register will then be reset to the value of GPRIOR during the vertical blank service routine.

The three new modes seem to handle player/missile to playfield collisions a little differently. In modes zero and eight, a playfield two collision is flagged when a player or missile hits a pixel whose luminance is controlled by COLOR1 rather than the COLOR2 for the main playfield. From what I have been able to tell thus far, there is no kind of playfield collision at all in modes nine and eleven. Mode ten collisions work only for playfield colors that correspond to the usual playfield registers (COLOR1 through COLOR3). Also, the fact that the background in this mode is set by PCOLR0 affects the priority of players and playfields in some cases. In priority, mode ten playfield colors PCOLR0 through PCOLR3 behave like players.

The GTIA still allows only eight luminances on the normal modes.

All new Atari computers are being shipped with the GTIA at no extra cost. The CTIA is no longer being produced. The new machines with the GTIA have little yellow or white stickers that have the letter "G" on them. Those of us who have older machines with the CTIA can replace it with a GTIA. The part number is C014805.

If you want to do it yourself, it will be a simple matter to replace the CTIA. The CTIA is on the CPU card that plugs into the motherboard inside the Atari case. It's not soldered in, so the replacement operation should take only 30 minutes if you have taken your computer apart before. Instructions are supplied with the chip. In the meantime, if you don't have the GTIA, don't fret. It will be a while before much software requiring the chip is available.


Do You Already Have The GTIA?

If you want to quickly see if your computer has a GTIA, try this: POKE 623,64 (while in the default mode, zero).

If you have the GTIA, the screen will go black. Otherwise, there will be no change and you'll know you've got the CTIA. If you have the GTIA and want to see 16 colors, try this:

10 GRAPHICS 11
20 FOR K= 0 TO 79
30 COLOR K
40 PLOT K,0
50 DRAWTO K,191
60 NEXT K
70 GOTO 70


Return to Table of Contents | Previous Section | Next Section