Display List Interrupts
by Bob Cockroft
by Bob Cockroft
Warning; It is recommended that reader should have a basic knowledge of display lists or have read the article in this magazine called 'DISPLAY LISTS' (see index).
Display list interrupts allows more colors to be presented on the screen. If you are a basic programmer, you have no doubt come across one of the main problems with graphics in basic, you cannot use more than four colors. But now with display list interrupts your problems are solved. By adding as many as 128 colors, your program displays can now be much more colorful.
As you already know, the display list is a program in the computer that is used by the Antic chip to display the screen. Although varying slightly with every graphic mode, the basic format remains constant. The display list's base address can be found by using location 560,561 :the display list pointers
The first 3 bytes set the display list in a readable location on the screen. The next 3 bytes are the LMS. These bytes give the beginning address of where the screen data will be located. The following string of bytes are the ones we are interested in. Known as the instruction register(IR) mode bytes, these locations control the type of graphic mode that will be displayed. By each controlling an individual line of graphics, starting from the top to bottom, they are the largest single item on the display list. It is important to remember that the (IR) mode bytes both change in number and in the value contained in them with each graphic mode. The table below gives the value in the (IR) mode bytes with each graphic mode.
|Graphic mode||Value in (IR) mode byte|
In this first article, in a series on display list interrupts, I will create a program using the Basic 'COLOR' command that will draw 3 colors on the screen. In addition, using display list interrupts, I will create one extra color by dividing the screen with color into 2 sections. Therefore I will have created different colors on the screen; one more than the maximum for this graphic mode.
There are four steps to do to create a display list interrupt. First we want to determine where on the vertical plane we want to divide the screen with color. Remembering that each (IR) mode byte represents one line of graphics from top to bottom, one is able to find his desired dividing point by counting down the (IR) list the number of graphic lines before the point where you want the division. After this, all we need to do is add 128 to this (IR) byte to tell the computer to interrupt. For example, if the dividing point was to be in the middle, the programmer would need to add 128 to the middle (IR) byte.
The second thing we need to do is make a subroutine that tells the computer what to do during the interrupt. The subroutine I will create will be in machine language and will start at 1536(DEC). But before we are able to create this subroutine there are a few thing you need to know about color registers.
There are two different types of registers for color creation in the Atari computer; Hardware registers and shadow registers. Hardware registers are 'write only' locations. In other words, if a command was given to read these locations, only zero's would be outputted. Hardware registers are updated by the value in there corresponding shadow register everytime the Antic draws a screen. Unlike the hardware registers the shadow registers can be both read from and writen to. Below is a table of the hardware registers and corresponding shadow registers.
The following machine language subroutine will change the color of the background before the end of the screen by modifing the background hardware register before the shadow register can update it. In other words, we have changed the background color before the Antic has completed drawing the screen.
Machine Language Subroutine
Mem. Loc Value Assembly ;Comment
1536 72 PHA ;PUSH 'A' ON THE STACK
1537 169 LDA ;LOAD 'A'
1538 1 #1 ;WITH ANY NO.
1539 141 STA ;AVOID CHANGE
1540 10 $0A ;IN MIDDLE OF
1541 212 $D4 ;LINE
1542 169 LDA ;LOAD 'A'
1543 50 #50 ;WITH NEW COLOR
1544 141 STA ;STORE NEW COL.
1545 26 $1A ;IN HARDWARE
1546 20 $D0 ;REGISTER
1547 104 PLA ;REPLACE 'A'
1548 64 RTS ;RETURN
The third thing we need to do is tell the computer where to jump after the interrupt. As you probably remember in step one we added 128 to one of the (IR) mode bytes of our choosing. Therefore forcing an interrupt when the Antic crossed this modified byte. Now we must tell the computer where to jump to in order to make the necessary changes in the color registers. The destination of our jump will be the machine language subroutine we created. Remembering that the beginning location of the subroutine is 1536 ($600 hex), we POKE this location into the address 512,513 dec. When an interrupt occurs, the computer looks at location 512,513 and jumps to that address they contain. It is important to note that the address stored in 512,513 is in LSB/MSB form, (Therefore 1536 decimal would be as '0' and '6). (see below)
POKE 512,0:POKE 513,6
The fourth and last step would be to enable a Non-maskable interrupt(NMI). This can simply be done by POKEing 54236 dec. with 192
The program below contains all the steps I have mentioned. It should help you in future programs of your own. It is important to note that only the bottom half of the screen is colored by Display List Interrupts. The blocks of color that will be seen have been created by the Basic's COLOR comand. By using a joystick, the number placed into the hardware register can be changed. Look at the bottom left corner of the screen for the value in the Hardware register.
2 REM **** DISPLAY LIST INTERRUPT ****
5 REM LOAD IN MACHINE SUBROUTINE
10 FOR X=1536 TO 1536+12
15 READ D
20 POKE X,D
30 NEXT X
35 REM LOAD LOCATION FOR THE INTERRUPTS JUMP
40 POKE 512,0: POKE 513,6
50 GRAPHICS 5
60 DL=PEEK (560)+256 *PEEK (561)
65 REM ADD 128 TO INTERRUPT BYTE
70 POKE DL+24,10+128
75 REM DRAW COLORED BLOCKS
80 COLOR 1
32 FOR C1=10 TO 20:FOR C 1 Y=10 TO 20
84 PLOT C 1,C 1 Y:NEXT C 1 Y:NEXT C 1
90 COLOR 2
92 FOR C2=40 TO 50:FOR C2Y=10 TO 20
94 PLOT C2,C2Y:NEXT C2Y:NEXT CZ2
100 COLOR 3
102 FOR C3=10 TO 20:FOR C3Y=30 TO 40
104 PLOT C3,C3Y:NEXT C3Y:NEXT C:
195 REM ENABLE (NMI)
200 POKE 542836,192
295 REM CHANGE VALUE PLACED IN HARDWARE REGISTER
300 IF STICK (0)=11 AND P<255 THEN P=P+1
310 IF STICK(0)=7 AND P>0 THEN P=P-1
320 POKE 1543,P
330 PRINT P
340 GOTO 300
500 DATA 72,169,1,141,10,212,169
510 DATA 6,141,26,208,104,64