Fancy giving your loading screens a speed boost? Sonic 1's Nemesis-compressed art adds quite the chunk to the loading times, and you'll find yourself staring at that blue oval more than you would that blue screen in Sonic 2. Porting Sonic 2's level art loading process cuts down a significant amount of waiting time, and here's how:
It's no secret, swapping out level-related decompression is trivial. You just change the compression of the mappings, go to LevelDataLoad and change the decompressors to something else, making sure to push whatever needed registers to the stack, and clear d0 if it's EniDec.
It's straightforward, even for a noob, granted that the noob's good with registers, but what about the art?
Oh crap, it's part of the PLCs.
Preparation
Grab yourself a KENS compressor. You can find some here (KENS) and here (KENSC). Get familiar with them. Also, you'll want to have ported QueueDMATransfer.
Recompression
First, we'll want to recompress our art from Nemesis to Kosinski, Sonic 2's standard level art compression.
Inside the 'artnem' folder of your disassembly, take the following files, and place them in a separate folder. However, keep a copy of '8x8 - GHZ1.bin' in artnem, and rename it to "8x8 - Title.bin"
Inside the new folder, decompress all of these files, then delete the Nemesis originals. Open both GHZ1 and GHZ2 in a hex editor, and append the latter to the end of the former, save the result as "8x8 - GHZ.bin". Delete GHZ1 and GHZ2. Now compress all of the files in Kosinski and move them to the 'artkos' folder.
Changing the pointers
Inside sonic.asm, change this...
...to this:
Follow this theme with the rest of the level art incbins: change the "Nem_" prefix to "Kos_", and change "artnem" to "artkos".
Now find this...
...and change it to this:
This is simply correcting the title screen's pointer. Like in Sonic 2, the title art is still Nemesis-compressed.
Inside the '_inc' folder, open Pattern Load Cues.asm and LevelHeaders.asm.
In LevelHeaders.asm, you can see entries for the level art, but, like the music entries, they are unused. As seen above, the level art is actually chosen by the Pattern Load Cues. Sonic 2 would go on to actually use these entries, and, after the completion of this guide, your hack will too. But first, let's correct them to match our new labels.
Go to Pattern Load Cues.asm and comment out the entries for the level art. GHZ and the ending have two, the other levels have only the one.
Porting the level art loading process
Above LevelDataLoad, paste this:
This is a modified Sonic 2 LoadZoneTiles, changed to match Sonic 1's LevelHeaders block size ($10 bytes over Sonic 2's $12 bytes).
Now to add some branches to this code.
Go to Level_SkipTtlCard and, above this...
...add this:
Do the same at End_LoadData.
And with that, we're done, a short guide for shorter loading times! Save and build.
Improvements
As mentioned before, this can be taken even further:
Go grab Vladikcomper's improved KosDec and NemDec, along with CompDec. By using the improved KosDec, or switching to Comper compression, you can achieve even better load times. If going the Comper way, you can even switch the 16x16s and 256x256s to Comper and experience an even bigger boost (but be sure to backup a2 under LevelDataLoad).
That's about it. Enjoy your faster loading times!
It's no secret, swapping out level-related decompression is trivial. You just change the compression of the mappings, go to LevelDataLoad and change the decompressors to something else, making sure to push whatever needed registers to the stack, and clear d0 if it's EniDec.
It's straightforward, even for a noob, granted that the noob's good with registers, but what about the art?
PLC_GHZ: dc.w ((PLC_GHZ2-PLC_GHZ-2)/6)-1 plcm Nem_GHZ_1st, 0 ; GHZ main patterns plcm Nem_GHZ_2nd, $39A0 ; GHZ secondary patterns plcm Nem_Stalk, $6B00 ; flower stalk plcm Nem_PplRock, $7A00 ; purple rock plcm Nem_Crabmeat, $8000 ; crabmeat enemy plcm Nem_Buzz, $8880 ; buzz bomber enemy plcm Nem_Chopper, $8F60 ; chopper enemy plcm Nem_Newtron, $9360 ; newtron enemy
Oh crap, it's part of the PLCs.
Preparation
Grab yourself a KENS compressor. You can find some here (KENS) and here (KENSC). Get familiar with them. Also, you'll want to have ported QueueDMATransfer.
Recompression
First, we'll want to recompress our art from Nemesis to Kosinski, Sonic 2's standard level art compression.
Inside the 'artnem' folder of your disassembly, take the following files, and place them in a separate folder. However, keep a copy of '8x8 - GHZ1.bin' in artnem, and rename it to "8x8 - Title.bin"
- 8x8 - GHZ1.bin
- 8x8 - GHZ2.bin
- 8x8 - LZ.bin
- 8x8 - MZ.bin
- 8x8 - SBZ.bin
- 8x8 - SLZ.bin
- 8x8 - SYZ.bin
Inside the new folder, decompress all of these files, then delete the Nemesis originals. Open both GHZ1 and GHZ2 in a hex editor, and append the latter to the end of the former, save the result as "8x8 - GHZ.bin". Delete GHZ1 and GHZ2. Now compress all of the files in Kosinski and move them to the 'artkos' folder.
Changing the pointers
Inside sonic.asm, change this...
Nem_GHZ_1st: incbin "artnem\8x8 - GH1.bin" ; GHZ primary patterns even Nem_GHZ_2nd: incbin "artnem\8x8 - GHZ2.bin" ; GHZ secondary patterns even
...to this:
Nem_Title: incbin "artnem\8x8 - Title.bin" ; Title patterns even Kos_GHZ: incbin "artkos\8x8 - GHZ.bin" ; GHZ primary patterns even
Follow this theme with the rest of the level art incbins: change the "Nem_" prefix to "Kos_", and change "artnem" to "artkos".
Now find this...
lea (Nem_GHZ_1st).l,a0 ; load GHZ patterns bsr.w NemDec
...and change it to this:
lea (Nem_Title).l,a0 ; load Title patterns bsr.w NemDec
This is simply correcting the title screen's pointer. Like in Sonic 2, the title art is still Nemesis-compressed.
Inside the '_inc' folder, open Pattern Load Cues.asm and LevelHeaders.asm.
In LevelHeaders.asm, you can see entries for the level art, but, like the music entries, they are unused. As seen above, the level art is actually chosen by the Pattern Load Cues. Sonic 2 would go on to actually use these entries, and, after the completion of this guide, your hack will too. But first, let's correct them to match our new labels.
- Nem_GHZ_2nd → Kos_GHZ
- Nem_LZ → Kos_LZ
- Nem_MZ → Kos_MZ
- Nem_SLZ → Kos_SLZ
- Nem_SYZ → Kos_SYZ
- Nem_SBZ → Kos_SBZ
Go to Pattern Load Cues.asm and comment out the entries for the level art. GHZ and the ending have two, the other levels have only the one.
Porting the level art loading process
Above LevelDataLoad, paste this:
LoadZoneTiles: moveq #0,d0 move.b (v_zone).w,d0 lsl.w #4,d0 lea (LevelHeaders).l,a2 lea (a2,d0.w),a2 move.l (a2)+,d0 andi.l #$FFFFFF,d0 ; 8x8 tile pointer movea.l d0,a0 lea ($FF0000).l,a1 bsr.w KosDec move.w a1,d3 move.w d3,d7 andi.w #$FFF,d3 lsr.w #1,d3 rol.w #4,d7 andi.w #$F,d7 @loop: move.w d7,d2 lsl.w #7,d2 lsl.w #5,d2 move.l #$FFFFFF,d1 move.w d2,d1 jsr (QueueDMATransfer).l move.w d7,-(sp) move.b #$C,(v_vbla_routine).w bsr.w WaitForVBla bsr.w RunPLC move.w (sp)+,d7 move.w #$800,d3 dbf d7,@loop rts ; End of function LoadZoneTiles
This is a modified Sonic 2 LoadZoneTiles, changed to match Sonic 1's LevelHeaders block size ($10 bytes over Sonic 2's $12 bytes).
Now to add some branches to this code.
Go to Level_SkipTtlCard and, above this...
bsr.w LevelDataLoad ; load block mappings and palettes
...add this:
bsr.w LoadZoneTiles ; load level art
Do the same at End_LoadData.
And with that, we're done, a short guide for shorter loading times! Save and build.
Improvements
As mentioned before, this can be taken even further:
Go grab Vladikcomper's improved KosDec and NemDec, along with CompDec. By using the improved KosDec, or switching to Comper compression, you can achieve even better load times. If going the Comper way, you can even switch the 16x16s and 256x256s to Comper and experience an even bigger boost (but be sure to backup a2 under LevelDataLoad).
That's about it. Enjoy your faster loading times!
This post has been edited by Clownacy: 10 November 2014 - 12:39 PM


05