Classic Computer Magazine Archive COMPUTE! ISSUE 47 / APRIL 1984 / PAGE 161

Atari Display List Interrupts

Karl E. Wiegers

This tutorial explains how to use the Atari Display List Interrupt to create sophisticated graphics displays, with multicolored screens and special character sets.

The Display List Interrupt (DLI) is one of the most powerful graphics features of the Atari 400/800/1200 computers. DLIs can be used to create sophisticated displays, with elaborate vertical screen architecture and the simultaneous display of many colors. DLIs also permit the display of multiple character sets in different parts of the screen, and they can also be used to create sound effects. Creative use of DLIs is the reason for the complexity of many Atari games.

The Display List Interrupt takes advantage of the way the television display operates. After the TV's electron beam scans horizontally across the width of the screen, it is turned off very briefly while it returns to the opposite edge and moves down slightly to draw the next scan line. During the few microseconds that the electron beam is off, it is possible to execute a very short machine language program, a Display List Interrupt routine. In this brief time, such routines can do little more than change the value stored in a color or sound register, but this can create some exciting effects.


Atari computers control video output with a special microprocessor chip called ANTIC. ANTIC obtains its instructions from a small area in RAM containing the display list. The display list is simply a list of numbers which tells ANTIC what graphics mode to use for each of the 192 TV scan lines in the standard Atari display, where to find the information to be displayed, and so on.

As an example, the display list for graphics mode 0 contains 32 numbers, of which the seventh through twenty-ninth are instructions to display a mode 0 mode line, each of which consists of eight TV scan lines.

The display list instructions are not the same as the BASIC graphics mode numbers; for BASIC mode 0, the display list instruction is a "2". The display list is different for each graphics mode, and unique display lists can be designed to combine graphics modes in a single display (see "How to Design Custom Graphics Modes," COMPUTE!'s First Book of Atari Graphics). The address of the beginning of the display list in RAM is located by:

DL = PEEK(560) + 256*PEEK(561)

Setting Up The Interrupt

To tell ANTIC that a Display List Interrupt is to be performed, several things must be done.

  1. Select the vertical screen position where you want the interrupt to take place, for example, where you want the background color to change. Setting bit 7 of a number in the display list tells ANTIC to perform a DLI following the display of that mode line. Setting bit 7 can be done by simply adding 128 to the value in any memory location. Suppose you wish to have a DLI take place at line 10 of a graphics mode 0 display. You need to add 128 to the display list instruction for line 9, which happens to be in the memory location 13 bytes past the beginning of the display list:
    POKE DL + 13,PEEK(DL + 13) + 128
    Do not add 128 to any number in the display list before DL + 6, which corresponds to the second mode line.
  2. Write your DLI routine and store it someplace safe in memory. The familiar READ/DATA/POKE combination works well for storing ML routines from within a BASIC program. I like to use Page 6 of RAM (locations 1536–1791) for the DLI, although other RAM locations or character strings can also be used.
  3. Load the starting address of the DLI routine into locations 512 (low-byte) and 513 (high-byte). For a routine at the beginning of Page 6 this is accomplished with POKE 512,0 and POKE 513,6.
  4. POKE 54286, 192 to enable the DLI.

Writing The DLI Routine

There are several rules to be followed when writing the DLI routine.

First, it must be short. Only 14 to 61 machine cycles are available for execution, depending on the graphics mode, so keep your total routine down to about 25–30 cycles.

The first operation in your routine must be to save on the stack any of the 6502 registers (accumulator, X, and/or Y) which you use in the DLI. You must also restore these registers by pulling them off the stack at the end of the routine. In between, they can be used for executing the DLI instructions. Also, the final machine language instruction must be a ReTurn from Interrupt (RTI).

You will want to insure that any changes your DLI makes in the video display are properly synchronized with the TV electron gun's operation. A register is provided for this purpose at location 54282 ($D40A). Addressing this location, called WSYNC (Wait for horizontal SYNChronization), will provide a sharp separation between pre- and post-interrupt regions on the screen. So, early in your DLI routine, you should store some number in WSYNC (any number will do).

Use ROM For Changes

Another point is that changes in color registers, audio registers, and the like should be made directly into the hardware locations in ROM, rather than into the corresponding shadow locations in RAM. For example, the five playfield color registers are at locations 53270 through 53274 ($D016–$D01A) in ROM, and their shadows are at locations 708 through 712 in RAM. Your DLI should store values only in locations 53270–53274.

A Simple Color Change

Program 1, in BASIC, calls a DLI to change the screen background color from blue to red after six mode lines have been displayed. The POKE 512,0 and POKE 513,6 in line 70 load the DLI into the beginning of Page 6 of RAM. The DLI routine is stored as decimal numbers in the DATA statement. You can change the third number in this DATA statement to any number less than 256, to change the color displayed in the bottom portion of the screen. This color number is the same value you would POKE into location 710, the color register 2 shadow location, to change the background color. It is computed by taking 16* HUE + LUMINANCE. To return to the normal background from this modified display, simply type GRAPHICS 0.

A Two-Tone Text Window

Graphics modes 1 through 8 are really mixed mode displays, with a mode 0 text window of four lines at the bottom of the screen.

Program 2 shows a way to get three background colors on the screen. The default black for mode 2 is displayed at the top, green goes into the top two lines of the text window, and the bottom half of the text window is yet a different color (pink). In addition, the DLI sets color register 1, which controls the luminance of characters in mode 0, to zero, so the characters are now black.

These techniques will work with any custom-mixed mode display list, allowing almost unlimited variation in graphics displays.

All This And Sound, Too

DLIs need not be used only to brighten up your TV screen. Program 3 shows a way to get a repeating sound using a DLI and audio channel 1. (See Mapping the Atari[COMPUTE! Books] by Ian Chadwick, p. 121, for more information about directly addressing the audio registers.) In this program, the loop in line 50 sets the DLI instruction on several lines in the mode 0 display list; the exact number depends on the STEP size. A smaller step size gives a higher rate of sound repetition because the DLI is called more often.

The DLI routine in this example uses an additional RAM byte at location 1600 ($0640) to store a value which governs the pitch of the sound being generated. This location is initially set to 121 (middle C) by line 60.

The DLI decrements this value, then stores it in location 53760 ($D200) to produce a sound on audio channel 1. This value is then compared to a preset limiting pitch value, decimal 60 ($3C) in this example, corresponding to one octave above middle C. If not equal, then the routine terminates. If equal, then 121 ($79) is loaded back into location 1600 to restart the cycle the next time the DLI is called. This routine can be changed, as shown in the REM statements, to give increasing or decreasing pitch, fast or slow repeat rate, and any desired starting and ending pitches.

DLI For Special Characters

Many programs use specially designed character sets in place of the standard Atari characters. A DLI can be used to simultaneously display characters from more than one set on different lines of the screen.

This technique is used in some character set generation programs, such as "SuperFont" (COMPUTE!, January 1982). Program 4 shows how it works, without getting into the details of alternate character set creation (see COMPUTE!'s First Book of Atari Graphics, Chapter 3, for more information).

First, 1084 bytes are reserved for the redefined characters, and a DLI is set on line 10 of the graphics mode 0 display. The first five DATA statements contain redefined values of capital letters A, B, C, D, and E, which are loaded into the correct locations in the reserved RAM space. The DLI routine loads the most significant byte of the starting address of the new character set (156, $9C) into both WSYNC and location 54281 ($D409), the hardware character base address (RAM shadow is 756, which would be used by BASIC).

The routine also changes the color of the lower part of the screen. You will see both the regular ABCDE and the redefined ABCDE on the screen simultaneously.

Moving The Invisible Cursor

If you delete the last line in Program 4, you can move the invisible cursor and print in immediate mode in either the top (regular) or bottom (redefined) part of the screen. With this limited sample, only the letters A–E will be shown as nonblanks in the redefined screen area. However, this concept obviously allows great flexibility for creating elaborate screen displays with multiple character sets.

A Demonstration Of Multiple DLIs

So far, our examples have used one DLI routine per BASIC program. But you can also show several colors at once, or change both character sets and colors in separate operations. Obviously, multiple DLIs are needed in such cases. A problem arises, because you can only tell the operating system about one DLI at a time using locations 512 and 513.

There are several possible solutions to this problem. Perhaps the simplest is to load several DLIs into memory, and have each routine load the starting address of the next one to be called into locations 512 and 513. This chaining of DLIs is illustrated in Program 5.

This program will place five bands of color in a mode 1 screen, together with different-colored characters. The same basic DLI is used four times, stored 32 bytes apart in Page 6. The only changes are to the actual color value stored in the background color register 53274 ($D01A) and to the low byte of the Page 6 address of the next DLI to use, which gets stored in location 512 ($0200).

Avoiding Screen Flicker

DLI instructions are placed on four mode lines (line 40). The BASIC program contains a POKE 559,0 in line 30 and a POKE 559,34 in line 230. These statements simply turn off the TV display briefly while the DLI routines are stored and changed, to avoid screen flicker. You can remove these statements and watch the action, if you like.

By experimenting with the BASIC programs and DLI routines in these five programs, you can better understand the principles involved and the ease of using DLIs in your own programs. The book Mapping the Atari contains the most detailed available memory map of the Atari, and is an in valuable reference for the programmer wishing to use DLIs effectively.