Exploring the ATARI® Frontier

ANTIC and the Display List: Part 1 by Alan J. Zett


Note: It is not recommended that beginners attempt to read this article without first having a thorough understanding of BASIC programming. Some books to read that will give you sufficient background include: ATARI® BASIC Manual, Introduction to Programming (Schaum's Outline Series). It is also recommended that the following book should be read: 6502 Assembly Language Programming (McGraw-Hill).


The Shape of Things to Come


The aim of this series of tutorials is to cover all aspects of ATARI® graphics capabilities in minute detail so those with the inspiration can learn. Advanced graphics will be the central theme, with occasional excursions into the realm of Machine Language. As more of you learn the secrets, everyone will benefit from the improvements in the quality of ATARI® software.

If you have the knowledge, experience, and ability, the ATARI® will produce far superior games in BASIC than the TRS-80® or Apple. However, the ATARI® is a bit slow and the features that make it superior are, at best, well hidden. Making superior games will not be easy for beginners.

Generally speaking, the ATARI® is comparable to the TRS-80® and the Apple. I believe that the Apple has a distinct advantage in writing good games full of color and detail with simple BASIC coding techniques. The number of colors available in Hi-Res when teamed up with shape tables and the ampersand vector make for amazing displays. The TRS-80® is best for games not requiring sharp graphics and color. Big Five Software and Adventure International have had a lot of success with their lines of arcade and adventure games.

If I had to give a rating to all three computers, it would be as follows:

TRS-80®: Excellent for business. Good for games.

Apple: Very good for business. Very good for games.

ATARI®: Good for business. Potentially excellent for games.

If a programmer knows all of the features the ATARI® is capable of and how to use them, the ATARI® is an ideal game computer. But learning these "undocumented features" can be extremely difficult. Even the most concise manual can be confusing at times. Sometimes, the concepts get totally beyond me. That's usually when I decide to call Atari, Inc.

Atari has done more customer support for their computer than any other company in the business. By providing detailed manuals for users and having a toll-free technical hot line, anyone with the inspiration can become a master at the ATARI®.


ANTIC - What is it?


I will begin this month by introducing you to ANTIC: the ATARI®'s graphics nerve center. ANTIC is just one of the four special-purpose microprocessors contained within the ATARI®. A microprocessor is an integrated circuit that has the capability to make simple logical decisions. Almost all of the capabilities of the ATARI® are handled by custom made integrated circuits that control literally every aspect of its operation. Most of you are already familiar with the 6502 microprocessor. The 6502 is the Central Processing Unit (CPU) of the ATARI® computer. You can think of it as large time-sharing computer. It can do nothing useful by itself, but it can process and channel the flow of information to and from other computer circuits in many useful ways. One of the most common methods of communication to a microprocessor is by using a set of predefined instructions. Each instruction directs the CPU how to react in a given situation. In this way, groups of instructions (called a program) can be combined to perform a complicated (multistage) function called a task.

The BASIC language is an example of a large task. The instructions contained in BASIC explain to the CPU what BASIC is and describe how it works. The CPU follows these instructions and tells other circuits what to do and/ or listens to what they have to say.

The 6502 microprocessor has a hundred or so instructions it understands. In addition, some of these instructions require extra information to further explain to the CPU what is to be done. The reason for so many instructions is that the CPU is responsible for communicating to all other circuits in the computer. It must be able to talk to any circuit in the system, no matter how complicated. In this sense, the CPU is a universal translator between all of the components in a computer. But only under the direction of a program can it know how to translate.

When the CPU needs to communicate with the outside world, it contacts other circuitry in the computer that has been designed for that purpose. When the CPU is told via the program to get data from the operator, it requests information be input from the keyboard. When it is told to talk to the operator, it sends information in computer form to an area of memory called "screen memory". ANTIC's main responsibility is to translate and encode this CPU data to a form that can be understood by the video processing circuits.

In a less versatile computer, this information could only be displayed in a fixed, unchangeable manner. This is because most computers contain single-purpose circuits for converting screen data into letters and/or graphics on a video screen. In the ATARI®, the circuitry responsible for this type of work is a microprocessor called CTIA.

ANTIC, on the other hand, is a special-purpose processor for displaying visual information. Its duty is to act as a Graphics Processing Unit (GPU). ANTIC sends CTlA display information based on data in screen memory according to a short "program" written in ANTIC's own language called the "Display List" or the "DL." The GPU program must be able to tell ANTIC where screen memory is, and how to display it.

To further clarify the differences between the 6502, ANTIC, and CTIA, use this analogy. A company that designs buildings is going to build a house for a client. First the client talks to the owner of the company and comes to an agreement on what type of house should be built. The owner then tells the architect to design a house based on the client's description. The architect lays out the design of the house and hires some workers to build it. The workers know how to build, but without directions from the architect, what they build will have no relation to what the client wants. In this sense, the computer is the company which builds houses, the 6502 is the owner of the company, the display list is the client who wants a house to be built, ANTIC is the architect who designs houses, and CTIA is the group of workers who build the house according to ANTIC. The house is the video signal which is shown on the video display.

CTIA will be covered in more detail when the subject of Player /Missile graphics is discussed later in the series.

A TV displays a picture by forcing a beam of electrons in straight lines across a screen lined with phophor. Each horizontal line of phosphor glowing with electrons is known as a "scan line." A picture is formed by tracing many scan lines beneath one another to form a complete image. On the ATARI® video display, there are 192 scan lines. Note that there are many other scan lines above and below the visible video display. These are to make sure that the display information will not be written too high or too low on the picture tube to be seen.

ANTIC works with sets of scan lines called "mode lines." Mode lines can be any number of scan lines between one and 16. Any number of mode lines may be combined, as long as their total comes out to be 192.



ANTIC sends CTIA display
information based
on data in
screen memory.


BASIC already has a set of nine preprogrammed display lists available to the programmer. These are more commonly known as GRAPHICS 0 to 8. GRAPHICS 0 to 2 are text modes; 3 to 8 are color graphics modes. To better understand what a display list does, we will be dissecting the display list that BASIC generates when you type GRAPHICS 0.

ANTIC has only four types of instructions: graphics mode, character mode, blank mode line, and jump instructions.

Graphics mode instructions tell ANTIC to display a line of screen data as color graphics. Character mode instructions display single or multi-color text. Blank mode line instructions tell ANTIC to skip a number of lines on the screen without printing. Jump instructions are used to continue execution of a display list at the specified memory location.

In addition to these modes, there are four special options that may also be specified in any text or graphics mode: Display List Interrupts (DLI), Load Memory Scan (LMS), Vertical Scroll, and Horizontal Scroll. For the purpose of discussing the GRAPHICS 0 display list, the general use of the LMS option will need explanation. All of the options will be covered more extensively in future discussions of display lists, but for now we'll stick to basics.


A Sample Display


BASIC's GRAPHICS 0 consists of 24 screen lines of ANTIC mode 2. Each mode line consists of eight individual scan lines. If we multiply the number of scan lines by the number of screen lines, we come up with a total of 192 scan lines. Figure 1 is the list of all ANTIC text and graphics mode instructions with other relevant information. There are many other forms of these instructions that do not pertain to this month's column and have been left out. You may notice that there are certain ANTIC modes that have no corresponding BASIC GRAPHIC mode. This is because ANTIC has three text modes and two graphics modes which are unused in BASIC. However, this does not mean they cannot be used as we'll see in the future.


Figure 1: ANTIC Text and Graphics Mode Instructions

ANTIC DL
Mode No.
ATARI® BASIC
Graphics Mode
No. Scan Lines
Per Mode Line
Screen Bytes
Per Mode Line
No. Of
Colors
Type of
Mode Line

0(see Figure 3)Blank
1----Jump
208402Text
3n/a10402Text
4n/a8404Text
5n/a16404Text
618205Text
7216205Text
838104Graphics
944102Graphics
1054204Graphics
1162202Graphics
12n/a1202Graphics
1372404Graphics
14n/a1404Graphics
1581402Graphics

First of all, we have to know where to find the display list. This is conveniently provided in memory locations 560 and 561. Every time a GRAPHICS command is executed, the Operating System (OS) cartridge builds a display list in memory and puts its address in these locations. From then on, this is where ANTIC will look to find the display list. To find the actual memory location, use this formula: DL = PEEK(560) + PEEK(561) * 256. The variable DL will then hold the starting location.

Now that we know where to find the display list, let’s have a look at it. Figure 2 is a listing of a standard GRAPHICS 0 display list. Keep in mind that what you are looking at is actually a Machine program written in ANTIC Machine Language. Starting from the top of the display list and working down, we first see three bytes of 112. (A byte is roughly one number with a value in the range of 0 to 255.) Each of these bytes is of a special class known as blank mode lines. Figure 3 is a table of blank mode line codes.


Figure 2: A GRAPHICS Zero Display List

DL BYTE NO.BYTE VALUEMODE TYPE

1112Blank
2112Blank
3112Blank
466Text w/LMS option
5nnLeast significant byte of screen memory
6nnMost significant byte of screen memory
72Text
82Text
92Text
102Text
112Text
122Text
132Text
142Text
152Text
162Text
172Text
182Text
192Text
202Text
212Text
222Text
232Text
242Text
252Text
262Text
272Text
282Text
292Text
3065Jump w/WVB option
31nnLeast significant byte of DL
32nnMost significant byte of DL


Figure 3: ANTIC Blank Mode Instructions

ANTIC DL
Mode Byte
No. of Blank
Scan Lines

01
162
323
484
645
806
967
1128

This type of ANTIC instruction is responsible for skipping a number of scan lines on the video display. One of its main uses is in bringing the start of the video display down far enough so that the top is clearly visible on the video screen. The blank mode line's other main use is to separate sections of the display without using up screen data. That is, to insert blank lines without having to provide blank screen data. The blank mode instruction 112 causes eight scan lines to be skiped. Three 112 codes will cause the top of the video display to start 24 scan lines down from the top of the video screen. (The video screen starts at the top of the picture tube.) In almost every case, a display list should start with three 112 instructions .

After this, the fourth byte we find is a 66 instruction. This one is a little tricky. The byte we see is actually the ANTIC mode line 2 instruction (GRAPHICS 0 line) with 64 added to it. Whenever you take a text or graphics mode line value and add 64 to it, you are telling ANTIC that you are using the Load Memory Scan (LMS) option. What the 66 byte is actually telling ANTIC is this: The first line of the display is a GRAPHIC 0 text line and the two bytes which follow it are the memory location of the start of screen memory. ANTIC then uses this address as the start of computer data to be interpreted. The first text or graphics mode instruction should always contain the LMS option.

Bytes 5 and 6 are the screen memory address in Least Significant Byte (LSB) / Most Significant Byte (MSB) order. If either of these terms is unfamiliar to you, I suggest you visit your local computer store or library and pick up a book on the computer numbering system. But for now let it suffice that the MSB is the integer portion of any number in the range of 0 to 65535 which is divided by 256((MSB = INT(n/256)). The LSB is the remainder after the MSB * 256 is subtracted from the original number. I hope this explanation is helpful because the concepts of bytes and LSB/MSBs are essential to understanding any computer on its own level (the machine level) i.e., Machine Language.

Bytes 7 through 29 tell ANTIC that there are 23 more lines of mode 2 (GRAPHICS 0) to follow. These mode 2 bytes along with the first mode 2 byte (with the LMS option) combine to form the 24 text lines of GRAPHICS 0.

Byte 30 is a special form of the jump mode. Normally if a mode line 1 instruction is specified, ANTIC does the equivalent of a BASIC GOTO command. This is necessary because, like any other program, the last instruction in the display list must either jump somewhere to continue or end execution. Since the video display is in use almost constantly, the display list should form an endless loop. However, if the display list were to continue executing itself immediately after the last instruction, the first line of the next screen display would appear directly BELOW the last line of the previous display. When ANTIC tries to continue this program, CTIA will get confused and the video screen will begin to flip very fast. This would happen because the TV set or video monitor would be trying to write information out of synchronization with the standard video signal sequence. In other words, video data would be confused with positioning data in the composite video signal coming from CTIA. To make sure that the display starts at the top of the screen in the same place as before, the Wait for Vertical Blank (WVB) option for jump commands is used.

If you add 64 to a jump instruction (mode line 1), ANTIC will halt execution of the display list until the video has started a new picture. This type of instruction is always required at the very end of a display list.

The last two bytes, 31 and 32 are the LSB/ MSB of the start of the display list in memory. Well, that certainly was a workout, but from the ATARI®'s point of view, we've only just begun.

The real versatility of ANTIC starts to shine through when we combine different modes in the same display list. Take GRAPHICS 5, for example. There are 40 lines of graphics followed by 4 lines of text.


The Display Mix Twist


Figure 4 is a display list for GRAPHICS 5. As usual, there are three blank mode line instructions at the start for lowering the top of the video display. Following this is a graphics mode 10 byte with the LMS option specified (10 plus 64). The chart in Figure 1 shows that mode 10 is the same as GRAPHICS 5 so we're on the right track. Bytes 5 and 6 are the start of screen memory address that go with the LMS option of byte 4. Bytes 7 to 45 are the other 39 graphics mode lines we would expect to find.


Figure 4: A GRAPHICS 5 Display List

DL BYTE NO.BYTE VALUEMODE TYPE

1112Blank
2112Blank
3112Blank
474Graphics w/LMS option
5nnLeast significant byte of screen memory
6nnMost significant byte of screen memory
710Graphics
810Graphics
910Graphics
...
...
...
...
4310Graphics
4410Graphics
4510Graphics
4666Text w/LMS option
47nnLeast significant byte of screen memory
48nnMost significant byte of screen memory
492Text
502Text
512Text
5265Jump w/WVB option
53nnLeast significant byte of DL
54nnMost significant byte of DL

Now look at byte 46. If you remember, a 66 in the GRAPHICS 0 display list represented a mode 2 line with the LMS option. Here is where ANTIC splits the video display.

According to Figure 1, each line of GRAPHICS 5 takes up 20 bytes of screen memory. When ANTIC comes to byte 46, it reloads the screen memory pointer to start at the address contained in bytes 47 and 48. As long as the data here are text data, ANTIC will set up the next video mode line to be in GRAPHICS 0. The next 40 bytes of data at the location specified in bytes 47 and 48 will be displayed as one line of text.

Bytes 49 to 51 tell ANTIC that the next three lines are also GRAPHICS 0. No other LMS instruction was used since the last LMS option was specified, therefore ANTIC will continue to look at the data following' the first GRAPHICS 0 line.

Bytes 52 to 54 perform the same function as bytes 30 to 32 in Figure 2.

Now, you might be asking yourself why there are only four GRAPHICS 0 lines after the GRAPHICS 5 lines. If you recall, earlier I mentioned that each video display must be a maximum of 192 scan lines long. If you look at Figure 1, you will see that each GRAPHICS 5 mode line requires four scan lines while each GRAPHICS 0 requires eight. If you multiply 4 text lines times 8 scan lines, then add 40 graphics lines times 4 scan lines, the answer comes out to 192 scan lines and ANTIC is satisfied.


The Catch!


Well, as you might have figured, there is one small problem to be overcome when writing display lists. ANTIC can only look at consecutive screen memory as long as it is 4K bytes long or less. (Beginners skip this next sentence.) This is because ANTIC's program counter is only 12 bits wide, which means 4K is its incrementing limit. (Welcome back beginners.) However, the memory requirement for GRAPHICS 8 is 7.5K. So (the intrepid beginner asks), how then does ANTIC display 7.5K of data when 4K is its limit?

I'm glad you asked that! It shows you're thinking. Refer now to Figure 5 where you will find a GRAPHICS 8 display list. The bytes from 1 to 99 should be familiar to you by now. But look at bytes 100 through 102. Haven't we seen them somewhere before?


Figure 5: A GRAPHICS 8 Display List

DL BYTE NO.BYTE VALUEMODE TYPE

1112Blank
2112Blank
3112Blank
479Graphics w/LMS option
5nnLeast significant byte of screen memory
6nnMost significant byte of screen memory
715Graphics
815Graphics
915Graphics
...
...
...
9715Graphics
9815Graphics
9915Graphics
10079Graphics w/LMS option
101nnLeast significant byte of screen memory
102nnMost significant byte of screen memory
10315Graphics
10415Graphics
10515Graphics
...
...
...
16515Graphics
16615Graphics
16715Graphics
16866Text w/LMS option
169nnLeast significant byte of screen memory
170nnMost significant byte of screen memory
1712Text
1722Text
1732Text
17465Jump w/WVB option
175nnLeast significant byte of DL
176nnMost significant byte of DL

Look at bytes 3 to 5. They both start with the same mode byte. What bytes 100 to 102 do is tell ANTIC that in order to finish with the display, it must continue looking for screen data at the address contained in bytes 101 and 102. By literally hopping over the 4K boundary, ANTIC can display data as long as desired. Byte 100 is simply a GRAPHICS 8 mode line byte with the LMS option specified. All other bytes from 103 to 176 have been explained before.

Well, that covers most of the basics. In my next installment, I'll be covering the text and graphics mode line options in more detail as well as making a few custom display lists. In the meantime, experiment with the program in Figure 6. It will allow you to look at the display list of any BASIC GRAPHICS mode from 0 to 56. If you work at it, by the next column you should be able to recognize any NORMAL display list.

In the interest of aiding all ATARI® users, reader input will be passed on whenever possible. Any comments, ideas , corrections (knock on wood), or information that will help me to convey a correct and simple explanation of the ATARI® graphics features will be welcome.