Ultra DMA Queue - RetroKoH/S1Fixed GitHub Wiki

(Credit: flamewing, MarkeyJester, MainMemory)
Sources: GitHub Repo, Sonic Retro thread
Commit: 9260e33

S1Fixed utilizes the Ultra DMA Queue by flamewing and MarkeyJester to better incorporate dynamic art loading throughout the game. An earlier commit in this repo utilizes a DMA Queue ported from Sonic 2 by Mercury. If you would rather keep things simple, you can follow this commit (b445229) to use that function. To instead use UltraDMAQueue, go to the GitHub Repo above for installation instructions and further details. The code in this repo is located at _inc/DMA Queue.asm.

Auto-Detection of 128kB Bank Overflows (MainMemory)

It is advised that you keep any art that utilizes the Ultra DMA Queue within a 128kB block in the ROM. This slight change can help ensure that this is the case, though it requires you to utilize MainMemory's MapMacros (which S1Fixed, as well as Sonic Retro's s1disasm does). In _maps\MapMacros.asm, modify the dplcEntry macro like so:

+ dplcTiles := 0

dplcEntry macro tiles,offset
	if SonicDplcVer=3
	dc.w	((offset&$FFF)<<4)|((tiles-1)&$F)
	elseif SonicDplcVer=4
	dc.w	(((tiles-1)&$F)<<12)|((offset&$FFF)<<4)
	else
	dc.w	(((tiles-1)&$F)<<12)|(offset&$FFF)
	endif
+	if dplcTiles <> 0
+	if ((dplcTiles+(offset*$20))/131072) <> ((dplcTiles+(offset*$20)+(tiles*$20)-1)/131072)
+	message "Warning: DPLC crosses 128K boundary! line: \{MOMLINE/1.0} start: offset count: tiles overflow: $\{(dplcTiles+(offset*$20)+(tiles*$20))#131072}"
+	endif
+	endif
	endm

Then, in sonic.asm, find where you include your DPLC files. (For example: include "_maps/Sonic - Dynamic Gfx Script.asm"), place dplcTiles := Art_Sonic (Art_Sonic being the name of the art file, change it according to the relevant art file) just before the include line, and place dplcTiles := 0 just after the include line. Here is an example:

dplcTiles := Art_Sonic			; MainMemory 128k Boundary Check for DPLCs
		include	"_maps/Sonic - DPLCs.asm"
dplcTiles := 0				; 128k Boundary Check for DPLCs End

With this modification, if any DPLCs cross a 128K boundary within the ROM, you'll get a message during assembly:
(e.g. "Warning: DPLC crosses 128K boundary! line: 705 start: $7C8 count: $10 overflow: $60")