
       Display List Interrupts
      --------------------------
            by NIR DAREY


Before you go on reading about DLI's, you must know all about the DISPLAY LIST of the ATARI 8-bit computer.
There is a good article about this subject in the "NEW ATARI USER" mag. ISSUE #51 from Ian Finlayson.

Now let's start explaining what DLI is.
The television draws the screen image in 20 miliseconds, at this speed the computer has plenty of time to change parameters while the display is being drawn,
the computer responds to the request interrupt that you put in the Display List, changes parameters and returns to it's normal buisness.
Of curse you shouldn't do to many things becuse it's effect the time the screen is drawn.

Enough theory let's talk buisness,
The registers for the Display List Interrupt is 512,513
you should insert in them the address of your routine.
Allways remember to enable the DLI, by setting the NMEIN register (54286) to 192. otherwize your routine wouldn't be executed!.
Now tell the ANTIC chip at what line it should execute your DLI routine, by setting bit 7 at the desired line on the DISPLAY LIST.

There are few thing you must allways remember when writing a DLI routine:
1) Make sure you restore the Accumulator and the X and Y registers in the stack if you use them. and at the end of the routine restore them back.
2) End your routine with RTI (Return From Interrupt) instruction.
3) When using graphics registers (colors,scroll,charecter sets etc...) store the value allso in the WSYNC (Wait For Horizontal Sync) register,so the next command won't be executed untill ANTIC finished drawing the current scan line. by doing this you prevent any flickering on the screen.
4)Make sure you change the hardware registers, not the shadow registers.

Now let's look at a small DLI routine, the following sourcecode was written in MAC65.

10       *=1536
20       PLA
30       LDA 560  ;those 4 lines
40       STA 203  ;finds the address
50       LDA 561  ;of the
60       STA 204  ;DISPLAY LIST
70       LDA #<DLI
80       STA 512
90       LDA #>DLI
100      STA 513
110      LDA #192
120      STA 54286     ;enable DLI
130      LDY #15       ;lines 130-170
140      CLC           ;sets bit-7   
150      LDA (203),Y   ;at line 15 of
160      ADC #128      ;the 
170      STA (203),Y   ;DISPLAY LIST.
180      RTS
190 DLI  PHA
200      LDA #40
210      STA 53272   ;COLPF1
220      STA 54282   ;WSYNC
230      PLA
240      RTI


The next program is for the basic user.

10 ADDR=1536
20 READ DAT:IF DAT=-1 THEN 50
30 POKE ADDR,DAT:ADDR=ADDR+1
40 GOTO 20
50 X=USR(1536):END
70 DATA 104,173,48,2,133,203,173,49,2
80 DATA 133,204,169,36,141,0,2,169,6
90 DATA 141,1,2,169,192,141,14,212,160
100 DATA 15,24,177,203,205,128,145,203
110 DATA 105,128,145,203,96,72,169,40
120 DATA 141,24,208,141,10,212,104,64


If you want to use more than one DLI in the same program, (let's say 2 DLI'S) you must set in the first DLI, the second DLI address in the DLI registers (512,513) just before you restore the processor registers. and at the second DLI routine you must point back to the first.
Make sure when using more than one DLI, you enable them (remember storing 192 at 54286) during VBI, otherwize they wont executed in the right order.
Don't forget to set more than one DLI request at the DISPLAY LIST.
for more information about multiply DLI's read Eisbaer Corp. artical at "MEGA MAGAZINE 4", and more technical information you can find at "DE-RE ATARI" book.

Next time i will write about the SOFTWARE TIMERS and how to use them.
