I understand the basics of how DLIs work and how to implement them in BASIC with assembly routines. However, I have found them to be very fussy and have come to believe maybe I missing something important. The DLI BASIC code below successfully draws the screen with four different shades of blue. The assembly code for setting the background color registers comes from listing 8.2 of Compute's Second Book of Atari. It reads from a table of colors stored in page 4 of memory.
Here are some weird observations I don't understand and need your help with. First, if I remove the POKE 752,1 from line 1000 I get a black screen. This seems odd. Why? Second, if I move lines 5000+ up between lines 2000+ and 3000+ the colors are shifted down by six lines. Why would that matter?
Thanks for any insight you can provide! The code is below. I have also attached it as a .txt file and with the BASIC code in an ATR.
1000 GRAPHICS 1+16:POKE 752,1:PRINT " "
1010 DIM DLI$(35)
2000 REM read in assembly code to modify graphics
2010 FOR I=1 TO 35:READ X:DLI$(I)=CHR$(X):NEXT I
2020 DATA 72,152,72,172,0,4,185,2,4,141,10,212
2030 DATA 141,24,208,238,0,4,173,0,4,205,1,4
2040 DATA 144,5,169,0,141,0,4,104,168,104,64
3000 REM modify display list for interrupt
3010 FOR I=2 TO 3:POKE DL+I,PEEK(DL+I)+128:NEXT I
3020 FOR I=6 TO 27:POKE DL+I,PEEK(DL+I)+128:NEXT I
4000 REM point to DLI in memory and enable interrupt
4030 POKE 512,DLILO:POKE 513,DLIHI
4040 POKE 54286,128+64
5000 REM read background color data to page 4
5010 POKE 1024,0:POKE 1025,24
5020 FOR I=0 TO 23:READ X:POKE 1026+I,X:NEXT I
5030 DATA 112,112,112,112,112,112,114,114,114,114,114,114
5040 DATA 116,116,116,116,116,116,118,118,118,118,118,118
10000 GOTO 10000