More Interrupting: Three DLI Demos
- Type
- Graphics
- Category
- Display-list interrupt tutorial programs
- Author
- Allan Moose and Marian Lorenz
- Published in
- Antic, December 1983 (Vol. 2, No. 9), "More Interrupting: Deeper into display lists"
- Year
- 1983
- Language
- Atari BASIC
- Requirements
- Any Atari 8-bit, Atari BASIC
About the program
Allan Moose, a maths and physics professor at Southampton College, and Marian Lorenz, a special-education teacher, wrote a run of display-list articles for Antic. In June 1983 they had shown one display-list interrupt (DLI) changing colours partway down the screen. In this December 1983 follow-up they tackled using several DLIs at once. ANTIC can request an interrupt on any mode line, but the CPU looks in only one place, locations 512–513, for the address of the routine to run. The article offers two answers, and the three programs demonstrate them.
What you need
Any Atari with Atari BASIC. Each program puts its machine code in page 6 (from 1536), so run them one at a time.
Typing it in
All three are plain ASCII. The machine code is the DATA, so check every number. A wrong byte in a DLI routine usually locks up the machine the moment line 230 (Program 1), 90 (Program 2) or 150 (Program 3) enables interrupts with POKE 54286,192. Programs 2 and 3 end in an endless GOTO loop. Press BREAK, then RESET, to get out. The space inside DATA numbers in Program 3 (169, 82) is harmless.
The three programs
Program 1: a colour table. Six DLIs are set on GRAPHICS 7 lines (line 100 POKEs 141, mode 13 with the DLI bit, every sixth line). One routine serves them all. It steps a counter at 1567 and loads the next colour from a table at 1568–1573 into colour register 0 (53270), so the filled box is painted in six bands. This is the "table-driven" method, good when every interrupt does the same job with different values.
Program 2: chained routines. When each interrupt has a different job, each routine ends by storing the address of the next routine in location 512. The first DLI (on the line set by POKE DL+7,135) sets colour register 0 and points 512 at the second routine at 1552. The second sets another colour and points back to 1536 for the next frame. The column of "ANTIC" words changes colour at both points.
Program 3: a boat and its reflection. Lines 230–370 copy the font to RAM and redefine @ to F as pieces of a sailboat. The first DLI changes colour register 0 partway down the boat. The second sets the background to sea blue, gives register 0 another colour and writes 4 to CHACTL (54273), which turns characters upside down. The two lowest rows of the boat (both printed with DEF) appear as a reflection in the water.
How it works
A DLI routine runs during the horizontal blank, while the beam returns to the left edge. Each routine saves the registers it uses, stores to WSYNC (54282) to wait for the end of the line, writes the new values directly to the hardware registers, then restores the registers and ends with RTI (64). It must write to the hardware addresses (53270 and so on), not the OS shadows (708 and so on). The OS copies the shadows into the hardware at every vertical blank, which is why the top of each screen always starts with the normal colours.
Listings
Program 1: colour table
1 REM *** PROGRAM 1 ***
5 REM *** SET UP COLOR TABLE ***
10 FOR CT=0 TO 5
20 READ D:POKE 1568+CT,D
30 NEXT CT
40 DATA 200,90,56,152,88,120
50 POKE 1536+31,31:REM INITIALIZE COUNTERS
60 REM *** PUT SIX INTERRUPTS INTO THE DISPLAY LIST ***
70 GRAPHICS 7:COLOR 1
80 DL=PEEK(560)+PEEK(561)*256
90 FOR C=18 TO 48 STEP 6
100 POKE DL+C,141:NEXT C
110 REM *** CREATE DISPLAY ***
120 POKE 752,1:? "DLI COLOR TABLE EXAMPLE"
130 PLOT 112,49
140 DRAWTO 112,14:DRAWTO 48,14
150 POSITION 48,49
160 POKE 765,1
170 XIO 18,#6,0,0,"S:"
180 REM *** SET UP DLI SERVICE ROUTINE ***
190 FOR J=0 TO 30:READ B:POKE 1536+J,B:NEXT J
200 DATA 72,138,72,238,31,6,174,31,6,189,0,6,141,10,212
210 DATA 141,22,208,224,37,208,5,169,31,141,31,6,104,170,104,64
220 POKE 512,0:POKE 513,6
230 POKE 54286,192
Program 2: two chained DLIs
10 REM *** PROGRAM 2 ***
20 GRAPHICS 2+16
30 DL=PEEK(560)+PEEK(561)*256
40 POKE DL+7,135:POKE DL+10,135
50 FOR J=0 TO 31:READ B:POKE 1536+J,B:NEXT J
60 DATA 72,169,92,141,10,212,141,22,208,169,16,141,00,02,104,64
70 DATA 72,169,136,141,10,212,141,22,208,169,00,141,00,02,104,64
80 POKE 512,0:POKE 513,6:REM SET ADDRESS OF FIRST ROUTINE
90 POKE 54286,192:REM ENABLE DLI
100 FOR J=0 TO 8
110 POSITION 4,J:? #6;"ANTIC"
120 NEXT J
130 GOTO 130
Program 3: sailboat
1 REM PROGRAM 3
10 REM ** SET UP DLI ROUTINES **
20 GRAPHICS 2:POKE 752,1:POKE 712,138
30 POKE 708,60
40 ? "PLEASE WAIT, LIFTING ANCHOR.."
50 DL=PEEK(560)+PEEK(561)*256
60 POKE DL+10,135:POKE DL+11,135
70 REM ** READ IN DLI ROUTINE **
80 FOR J=0 TO 49:READ B:POKE 1536+J,B:NEXT J
90 DATA 72,169, 82,141,10,212,141,22,208,169,16,141,00,02,104,64
100 DATA 72,138,72,152,72,169,132,162, 84,160,04,141,10,212
110 DATA 141,26,208,142,22,208,140,01,212,169,00,141,00,02
120 DATA 104,168,104,170,104,64
130 GOSUB 230
135 REM ** ENABLE INTERRUPTS PRINT DISPLAY **
140 POKE 512,0:POKE 513,6
150 POKE 54286,192
160 ? CHR$(125)
170 POSITION 9,4:? #6;"@A"
180 POSITION 9,5:? #6;"BC"
190 POSITION 8,6:? #6;"DEF"
200 POSITION 8,7:? #6;"DEF"
210 GOTO 210
220 REM *** REDEFINE CHARACTER SET **
230 POKE 106,PEEK(106)-8
240 START=(PEEK(106))*256
250 POKE 756,START/256:POKE 752,1
260 FOR R=0 TO 1023
270 POKE START+R,PEEK(57344+R):NEXT R
280 FOR X=0 TO 55
290 READ D:POKE START+32*8+X,D:NEXT X
300 DATA 0,0,1,1,3,7,7,15
310 DATA 192,248,224,128,128,192,192,224
320 DATA 15,31,63,63,127,255,1,1
330 DATA 224,240,248,248,252,128,128,128
340 DATA 0,1,255,255,255,127,95,95
350 DATA 255,255,255,255,255,255,255,255
360 DATA 240,240,255,254,252,248,240,224
370 RETURN
Download
The original program from the Antic disk, to LOAD or ENTER instead of typing it: DLI1.BAS, DLI2.BAS, DLI3.BAS.
Credits
- Program listing: More Interrupting: Three DLI Demos — program listing (Antic, December 1983 (Vol. 2, No. 9), "More Interrupting: Deeper into display lists") — Allan Moose and Marian Lorenz
- Picture: Program 3: the second interrupt turns the sea blue and flips the characters upside down to draw the reflection. — Allan Moose and Marian Lorenz (program); screenshot by the site
- Antic Software Archive — disk files (December 1983 - Vol. 2 No. 9): DLI1.BAS, DLI2.BAS, DLI3.BAS — Nina R. Franco, 1983
- Antic magazine scan (OCR text layer): Antic_Vol_2-09_1983-12_Buyers_Guide_text.pdf — Internet Archive
