An Introduction To Display List Interrupts

Alan Watson

Many startling effects are possible with display list interrupts. This tutorial will get you started.

Have you ever wondered how some commercial programs for your Atari display more than the four colors you can get from BASIC? It's done by using display list interrupts. In fact, it is possible to get all of Atari's 128 colors on the screen at the same time! While few programs ever call for all 128 colors, it is nice to see how it can be done.

Inside your Atari there is an integrated circuit which Atari calls ANTIC. This circuit takes care of the television screen display so the main processor can do other things in the program. ANTIC is a microprocessor and has its own program which it follows to display information on the screen. Its program is called the display list. The display list is different for each Graphics mode since each Graphics mode has different types and amounts of information which need to be displayed.

When a program encounters a Graphics command, the starting address for the display list is placed at decimal locations 560 (low byte of the address) and 561 (high byte). ANTIC looks at this address to find out what it needs to do. If no changes have been made in the display list, the first three instructions cause ANTIC to blank the first 24 lines. Since televisions overscan, this insures all our data will be in the visible area of the screen.

The next instruction (followed by an address) tells ANTIC where to find the display memory. Then comes instruction register (IR) mode bytes (see Table 1). The number of IR mode bytes depends on the Graphics mode that has been selected. Finally there is an instruction (followed by an address) to return to the start of the display list and start all over again.

Table 1

BASIC GRAPHICS MODE NUMBER IR MODEBYTE (DECIMAL)
02
16
27
38
49
510
611
714
816

The Three Necessary Steps

Creating a display list interrupt involves three steps. First, we must alter the IR mode byte for the line prior to the one we want to change. We do this by adding 128 (decimal) to it. Second, we must write a routine which tells the 6502 what we want to do during the interrupt. The third step is to allow the interrupt to happen by "enabling NMI" or POKEing decimal location 54286 with 192 (decimal).

When an interrupt occurs, the 6502 looks at decimal location 512 and 513 to find the address where interrupt instructions are located. The address is stored low byte then high byte. The examples for this article all use page six (starting at decimal location 1536) so each example POKEs 512 with zero and 513 with six.

Since we will interrupt the main processor to perform these instructions, we will have to save any registers we use and then restore them just before we return from the interrupt.

Here is how the interrupt display list program flows.

.
V
V
IR MODE BYTE
IR MODE BYTE + 128 > INTERRUPT VECTOR ADDRESS
                                   V
IR MODE BYTE          < INTERRUPT ROUTINE
IR MODE BYTE
    V
    V

Atari uses a number of registers (memory locations) to determine what colors and luminances should be used for background, plotted points, and characters. For each of these items there are a hardware register and a corresponding shadow register. Hardware registers are "write only" and cannot be read. They are updated from their respective shadow registers at the end of each frame (during the vertical blanking interval).

POKEing the shadow register is a quick alternative to the BASIC SETCOLOR command. You simply choose the color you want from the 16 colors listed on page 50 of Atari 400/800 Basic Reference Manual, multiply it by 16, and add the luminance value desired. Then POKE the result into the appropriate shadow register. (See Table 2.)

Table 2

TO SET THE COLOR OF …POKE DESIRED VALUE INTOCORRESPONDING HARDWARE REGISTER
Plotted Points70953271
Using COLOR 1
Plotted Points71053272
Using COLOR 2
Plotted Points71153723
Using COLOR 3
Background71253274

Note: This table is for Graphics modes 1 through 7.

If we place the change resulting from our display list interrupt in the appropriate hardware register, the part of the screen below the interrupt will change. The top of the screen remains as it was because the hardware register is updated from its shadow register at the end of the frame.

Now that you have the idea, type in Program 1 and RUN it.

Background Luminance, And More

All that changes is the background luminance. But you can do lots more with this example!

Let's examine the interrupt routine we used.

Memory Location Used in ExampleDecimal Value in Data Statement (Line 150)Assembly Language MnemonicComments
153672PHASave accumulator
1537169LDALoad accumulator
15386#6with new color
1539141STAWait for horizontal
154010$0Aso change doesn't
1541212$D4occur in mid line
1542141STAStore new color
154326$1Ain hardware
1544208$D0register
1545104PLARestore accumulator
154664RTIReturn from interrupt

You can choose any color you like for the bottom by determining its value (the same way as I mentioned above) and using it as the third number in the DATA statement (line 150). I've listed the memory locations above and left of a text window. I did this so you can type in POKE commands to make changes and watch to see what happens. To change the bottom color, POKE 1538 with the new color value you want.

You can choose any color you like for the top of the screen as well by POKEing the value into shadow register 712.

What's more, you can change the top and/or bottom color of any of the plotted rectangles. To change them in the direct mode (after the program has run and the "READY" prompt appears), POKE the appropriate shadow register with the desired color value for the top and POKE the corresponding hardware register with your color choice for the bottom.

See Table 2 to determine which registers to use for each of the rectangles. The left rectangle is plotted using COLOR 1, the center using COLOR 2, and the right using COLOR 3.

If you would rather make the changes in the program itself, change the eighth number in the DATA statement (line 150) to the low byte of the appropriate hardware register. For the rectangle using COLOR 1 use 22, for COLOR 2 use 23, and for COLOR 3 use 24.

To select a different vertical position for the color change to occur, add 128 to a different display list instruction. We've been using the instruction as START + 24 (line 240) which places the interrupt midway down the screen. Since there are 40 display blocks in BASIC Graphics mode 5, you can experiment anywhere from START + 6 to START + 44 without problems.

Once you understand how to create and use display list interrupts, your programming capabilities are expanded. You can use them together with player-missile graphics to change player color, width, and/or horizontal position as the player passes through the interrupt line. With a slightly more complicated interrupt routine, a player can be drawn with the same or a different shape several times at different vertical positions on the screen.

A good example of this can be found in John Palevich's article "Shoot" in the September, 1981, issue of COMPUTE! Magazine (page 86). When programming with text modes, you can change character sets in mid screen. Atari's "Space Invaders" uses many display list interrupts. Many things are possible, and you'll discover more as you experiment.

All 128 Colors At Once

Atari is capable of showing all 128 colors at the same time. There are a number of ways this can be done. Program 2 shows one way. The two biggest changes compared to Program 1 are the interrupt routine and the custom display list.

The interrupt routine is written so that each time it's used, the color/luminance value is increased by two. By the end of the display, 128 colors appear.

A custom display list was created to get more than enough vertically displayed lines for the 128 colors and to be able to plot a design. BASIC Graphics 8 is essentially a one-color mode (one color/luminance and one luminance are available). Changes in the background show up in the plotted points as well. But, between BASIC Graphics 7 and Graphics 8, there is an ANTIC instruction register mode 14 (decimal) which has the same number of vertical positions as BASIC Graphics 8. It has only half as many horizontal positions. What you get instead is a four color mode. Program 2 uses only two of the four registers available!

In addition to the references cited at the end of this article, credit and thanks go to Judy Bogart at Atari, who explained how hardware registers are updated and helped with the interrupt routine in Program 1. It was my first attempt to use assembly language in a program.

References:

Atari 400/800 Basic Reference Manual. Atari, Inc., copyright 1980.

Atari Personal Computer System Hardware Manual. Atari, Inc., copyright 1980.

PROGRAM 1. An Introduction To Display List Interrupts.

10 REM *** An Introduction To Display List Interrupts
20 REM *** Listing #1
30 REM *** Alan Watson
40 REM *** Nov. 9, 1981
100 REM *** POKE CODE INTO PAGE 6
110 FOR I = 0 TO 10
120 READ C
130 POKE 1536 + I, C
140 NEXT I
150 DATA 72, 169, 6, 141, 10, 212, 141, 26, 208, 104, 64
160 REM *** POKE INTERRUPT VECTOR ADDRESS
170 POKE 512, 0 : POKE 513, 6
200 REM *** GRAPHICS CALL AND FIND DISPLAY LIST
210 GRAPHICS 5
220 START = PEEK(560) + 256 * PEEK(561)
230 REM *** MODIFY DISPLAY LIST IR MODE BYTE
240 POKE START + 24, 10 + 128
300 REM *** PLOT SOMETHING ON THE SCREEN
310 FOR X = 1 TO 3
320 COLOR X
330 PLOT 20 * X + 5, 30 : DRAWTO 20 * X + 5, 10
340 DRAWTO 20 * X - 5, 10 : POSITION 20 * X - 5, 30
350 POKE 765, X
360 X10 18, #6, 0, 0, "S : "
370 NEXT X
380 REM *** SHORT DELAY BEFORE COLOR CHANGE
390 FOR D = 1 TO 300 : NEXT D
400 REM *** ENABLE NMI
410 POKE 54286, 192

PROGRAM 2. An Introduction To Display List Interrupts.

10 REM *** An Introduction To Display List Interrupts
20 REM *** Listing #2
30 REM *** Alan Watson
40 REM *** Nov. 9, 1981
100 REM *** POKE CODE INTO PAGE 6
110 FOR I = 0 TO 17
120 READ B
130 POKE 1536 + I, B
140 NEXT I
150 REM *** POKE INTERRUPT VECTOR ADDRESS
160 POKE 512, 0 : POKE 513, 6
200 REM *** GRAPHICS CALL AND FIND DISPLAY LIST
210 GRAPHICS 8
220 START = PEEK(560) + 256 * PEEK(561)
230 COLOR 1
240 FOR I = 1 TO 5
250 READ X1, Y1, X2, Y2, X3, Y3, X4, Y4
260 PLOT X1, Y1 : DRAWTO X2, Y2 : DRAWTO X3, Y3 : POSITION X4, Y4
270 POKE 765, 1
280 X10 18, #6, 0, 0, "S : "
290 NEXT I
300 REM *** CREATE CUSTOM DISPLAY LIST(IR MODE 14)
310 POKE START + 3, 78
320 FOR I = 6 TO 33 : POKE START + I, 14 : NEXT I
330 FOR I = 34 TO 98 : POKE START + I, 14 + 128 : NEXT I
340 POKE START + 99, 78 + 128
350 FOR I = 102 TO 164 : POKE START + I, 14 + 128 : NEXT I
360 FOR I = 165 TO 198 : POKE START + I, 14 : NEXT I
370 POKE START + 199, 65
380 POKE START + 200, 80
390 POKE START + 201, 128
400 REM *** ENABLE NMI
410 POKE 54286, 192
800 REM *** CODE FOR INTERRUPT ROUTINE
810 DATA 72, 173, 198, 2, 24, 105, 2
820 DATA 141, 10, 212, 141, 198, 2, 141, 26, 208, 104, 64
830 REM *** PLOT POINTS
840 DATA 139, 155, 116, 27, 77, 27, 100, 155
850 DATA 219, 155, 242, 27, 203, 27, 179, 155
860 DATA 189, 99, 160, 35, 158, 35, 129, 99
870 DATA 140, 155, 159, 99, 130, 99, 139, 155
880 DATA 179, 155, 189, 99, 159, 99, 178, 155

Return to Table of Contents | Previous Section | Next Section