I started looking around at sample code...
I think I have created a function that can automatically build a DLL, depending on these settings:
; ; PROGRAM EQUATES ; NTSC equ 243;number of active scanlines for NTSC PAL equ 293;number of active scanlines for PAL ; REGION equ NTSC;change this to 'PAL' for PAL regions ; YRES equ 208;screen resolution (must be a factor of DLHIGH) DLHIGH equ 16;display list height (only 8 or 16 allowed) NUMBLANK equ REGION-YRES;number of blank lines needed in total NUMBTOP equ NUMBLANK/2;number of blank lines at top of screen NUMBBOT equ (NUMBLANK/2)+1;number of blank lines at bottom of screen NUMDL equ YRES/DLHIGH;number of display lists DLLEN equ 5;display list entry length NUMSPR equ 2;number of sprites ; ; DISPLAY LIST ; DLLRAM equ $1800;DLL runs from $1800-$19FF (512 bytes max) DLRAM equ $1A00;DL runs from $1A00-$1EFF NULLDL equ $1EFD;Blank Display List (3 bytes) DLEND equ $1EFF;End of Display List
Just by changing some of the above settings, the display list list can be built for you by calling this routine:
BuildDisplayListList ; ; Top blank lines ; ldx #$00 ldy #NUMBTOP BuildDLL_TopLoop cpy #$10 bmi BuildDLL_TopLT16 BuildDLL_TopGT16 tya sec sbc #$10;subtract 16 lines tay lda #$10 jmp BuildDLL_PutTopEntry BuildDLL_TopLT16 tya ldy #$00;last entry - remainder lines BuildDLL_PutTopEntry sec sbc #$01;entry is always "Number of Lines - 1" sta DLLRAM,x inx lda >NULLDL;NULLDL = blank DL sta DLLRAM,x inx lda <NULLDL sta DLLRAM,x inx cpy #$00 bne BuildDLL_TopLoop ; ; #YRES MODE LINES DIVIDED INTO #NUMDL REGIONS ; ldy #$00 BuildDLL_MainLoop lda #DLHIGH-1;DLHIGH lines ora (#DLHIGH<<2);take DLHIGH value, shift it left 2 bits to be in line with 'Holey DMA' value sta DLLRAM,x inx lda DLPOINTH,y sta DLLRAM,x inx lda DLPOINTL,y sta DLLRAM,x inx iny cpy #NUMDL;#NUMDL DLL entries bne BuildDLL_MainLoop ; ; Bottom blank lines ; ldy #NUMBBOT BuildDLL_BotLoop cpy #$10 bmi BuildDLL_BotLT16 BuildDLL_BotGT16 tya sec sbc #$10;subtract 16 lines tay lda #$10 jmp BuildDLL_PutBotEntry BuildDLL_BotLT16 tya ldy #$00;last entry - remainder lines BuildDLL_PutBotEntry sec sbc #$01;entry is always "Number of Lines - 1" sta DLLRAM,x inx lda >NULLDL;NULLDL = blank DL sta DLLRAM,x inx lda <NULLDL sta DLLRAM,x inx cpy #$00 bne BuildDLL_BotLoop BuildDLL_FinalEntry lda #$00 sta DLLRAM,x inx sta DLLRAM,x inx sta DLLRAM,x inx BuildDLL_Rts rts
What do you guys think of this? My goal here is to also create a subroutine to automatically build a DL as well, with another setting that will allow for a Character Mode entry. It may need some tweaking, but Hopefully I can create something that can help people (including myself) not worry about display lists so much.
Bob
Edited by PacManPlus, Sun Jul 6, 2008 7:23 PM.













