Jump to content
Sign in to follow this  
scitari

DLI Help - Thanks!

Recommended Posts

I have been working with some DLI code and can't figure out why the first two lines of Graphics 0 don't draw correctly. What am I doing wrong? I have tried a number of different variations. Here is the text file. The code and a screenshot from Altirra is below. Many thanks!!!

10 REM assembly code from https://www.atariarchives.org/alp/chapter_8.php
15 REM see listing 8.2
20 GRAPHICS 0:POKE 752,1
30 SETCOLOR 1,0,0
40 DL=PEEK(560)+PEEK(561)*256
45 REM read in assembly code
50 FOR I=0 TO 34:READ B:POKE 1536+I,B:NEXT I
60 DATA 72,152,72,172,0,4,185,2,4,141
70 DATA 10,212,141,24,208,238,0,4,173,0
80 DATA 4,205,1,4,144,5,169,0,141,0
90 DATA 4,104,168,104,64
95 REM modify diplay list for interrupt
100 FOR I=6 TO 29:POKE DL+I,PEEK(DL+I)+128:NEXT I
195 REM read in background color data
200 POKE 1024,0:POKE 1025,24
210 FOR I=0 TO 23:READ B:POKE 1026+I,B:NEXT I
220 DATA 25,20,25,20,25,20,25,20,25,20,25,20
230 DATA 25,20,25,20,25,20,25,20,25,20,25,20
235 REM point to DLI on page 6 and enable interrupt
240 POKE 512,0:POKE 513,6:POKE 54286,192
250 GOTO 250

DLI.jpg

Share this post


Link to post
Share on other sites

Here's one way to fix it:

 

10 REM ASSEMBLY CODE FROM HTTPS://WWW.ATARIARCHIVES.ORG/ALP/CHAPTER_8.PHP
15 REM SEE LISTING 8.2
20 GRAPHICS 0:POKE 752,1
30 SETCOLOR 1,0,0
40 DL=PEEK(560)+PEEK(561)*256
45 REM READ IN ASSEMBLY CODE
50 FOR I=0 TO 49:READ B:POKE 1536+I,B:NEXT I
60 DATA 72,152,72,172,0,4,185,2,4,141
70 DATA 10,212,141,24,208,238,0,4,173,0
80 DATA 4,205,1,4,144,5,169,0,141,0
90 DATA 4,104,168,104,64
91 DATA 165,20,197,20,240,252,169,192,141,14,212,104,104,104,96
95 REM MODIFY DIPLAY LIST FOR INTERRUPT
100 FOR I=6 TO 27:POKE DL+I,PEEK(DL+I)+128:NEXT I
110 FOR I=2 TO 3:POKE DL+I,PEEK(DL+I)+128:NEXT I
195 REM READ IN BACKGROUND COLOR DATA
200 POKE 1024,0:POKE 1025,24
210 FOR I=0 TO 23:READ B:POKE 1026+I,B:NEXT I
220 DATA 25,20,25,20,25,20,25,20,25,20,25,20
230 DATA 25,20,25,20,25,20,25,20,25,20,25,15
235 REM POINT TO DLI ON PAGE 6 AND ENABLE INTERRUPT
240 POKE 512,0:POKE 513,6
245 X=USR(1571)
250 GOTO 250
 
Result:

 

post-21021-0-12224600-1542951849.png

 

Line 91 adds a new assembly routine to set NMIEN to $C0 right after a vertical blank. This insures that the first DLI fires at the top of the screen instead of some random line.

 

Line 50 adds 15 to the loop to account for the extra assembly code.

 

Line 100 subtracts 2 from the loop to avoid setting the DLI flag on the Jump and Wait for Veritical Blank instruction.

 

Line 110 adds another loop to set the DLI flag on the last blank line in the top margin and the LMS mode 2 instruction. The final display list looks like this:

 

Altirra> .dumpdlist
  9C20: x2   blank 8
  9C22:      blank.i 8
  9C23:      mode.i 2 @ 9C40
  9C26: x22  mode.i 2
  9C3C:      mode 2
  9C3D:      waitvbl 9C20
Note that the DLI fires on the last line of the lines implied by the modeline. That's why you want to put the first DLI on the last blank line, not the first mode 2 line.

 

Line 230 uses 15 as the last color to demonstrate that the table is now properly synced to the screen. You can change it back to 20.

 

Line 240 no longer POKES NMIEN.

 

Line 245 calls the new assembly routine to set NMIEN=$C0 (192) after the vertical blank.

  • Like 2

Share this post


Link to post
Share on other sites

You should initialize your colour index during VBlank.

The way you're doing it here, the first DLI to occur will be random.

A way around it could be to disable screen DMA first, then enable DLIs then enable screen DMA again.

 

Add

239 POKE 559,0

249 POKE 559,34

 

That way it should guaranteed that the first DLI to occur is the one at the top.

You've also got a nasty bug which is disabling the VBlank - your Jump + Wait VBlank has the interrupt bit 7 set, you'd want to change the 29 in line 100 to a 28.

 

Once that's done, there's flicker as it alternates colour one frame to the next, I would guess it's probably your end of table pointer at location $401 needs tuning - line 200 change to POKE 1025,23

  • Like 2

Share this post


Link to post
Share on other sites

Thanks! Very helpful. It is amazing how little detail there is in the programming books from back in the day. I am guessing many authors were rehashing what was in De Re Atari which was also a bit light on details.

 

One last question. Why is the cursor still on after POKE 752,1?

  • Like 1

Share this post


Link to post
Share on other sites

One last question. Why is the cursor still on after POKE 752,1?

 

This is from "Mapping the Atari". Always keep a copy of "Mapping the Atari" nearby when coding...

 

post-6369-0-79581300-1542990924_thumb.png

  • Like 4

Share this post


Link to post
Share on other sites

Here is the cleaned up and working code. Here is a version with comments added. Thank everyone for your help! Very much appreciated. Learning this for the first time. I also did a post about this on Atari Projects. Comments welcome.

10 GRAPHICS 0:POKE 752,1:PRINT " "
20 DL=PEEK(560)+PEEK(561)*256
30 REM read in assembly code to modify graphics
40 FOR I=0 TO 49:READ B:POKE 1536+I,B:NEXT I
50 DATA 72,152,72,172,0,4,185,2,4,141,10,212
60 DATA 141,24,208,238,0,4,173,0,4,205,1,4
70 DATA 144,5,169,0,141,0,4,104,168,104,64
80 DATA 165,20,197,20,240,252,169,192,141
90 DATA 14,212,104,104,104,96
100 REM modify display list for interrupt
110 FOR I=6 TO 27:POKE DL+I,PEEK(DL+I)+128:NEXT I
120 FOR I=2 TO 3:POKE DL+I,PEEK(DL+I)+128:NEXT I
200 REM read in background color data
210 POKE 1024,0:POKE 1025,24
220 FOR I=0 TO 23:READ B:POKE 1026+I,B:NEXT I
230 DATA 25,20,25,20,25,20,25,20,25,20,25,20
240 DATA 25,20,25,20,25,20,25,20,25,20,25,20
300 REM point to DLI on page 6 and enable interrupt
310 POKE 512,0:POKE 513,6
320 X=USR(1571)
1000 GOTO 1000

DLI-Example.jpg

Edited by scitari
  • Like 1

Share this post


Link to post
Share on other sites
POKE 755,4 text upside down..  2 to go back again

true, this shadow register does a few things... but you don't have to refresh it all the time...

  • Like 1

Share this post


Link to post
Share on other sites

You need to move the cursor to make it go away, print something or just put a control character such as cursor right (just moving by POSITION command won't work).

If you POKE 752,1 before the GR. 0 statement then I think it should be invisible immediately.

  • Like 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...