Streamlined init code for Sonic the Hedgehog 1, 2, and 3 & Knuckles made by OrionNavattan (under BSD Zero Clause).
The code targets SonicRetro's disassemblies, S1 Hivebrain 2022, and Sonic 2 OrnNv.
These are intended as drop-in replacements for the standard ICDBLK_4 library, and the game-specific init code that immediately follows. Compared to the original, these are streamlined, eliminating all redundancy (particularly on cold boot) and in-lining the VDP and joypad init, Z80 code load, and the checksum check (which is easy to remove!)
- Replace everything from
EntryPointtoMainGameLoopwith the contents ofStreamlined Sonic 1 Init AS.asm. - Find GM_Title and delete the
bsr.w DACDriverLoadinstruction. - Delete
CheckSumError,VDPSetupGame,JoypadInit, andDACDriverLoad, as all of their functionality is incorporated into the new init code. (DACDriverLoadwas calledSoundDriverLoadbefore commitea75d0f)
- Replace the
Mega Drive Setup.asminclude and all code fromGameProgramtoMainGameLoopwith the contents ofStreamlined Sonic 1 Init HB 2022.asm. - Delete the same instruction and subroutines.
- Replace everything from
EntryPointtoMainGameLoopwith the contents ofStreamlined Sonic 2 Init AS.asm. - Delete
CheckSumError,VDPSetupGame,JoypadInit,SoundDriverLoad, andDecompressSoundDriverup to theSaxDec_Looplabel, as all of their functionality is incorporated into the new init code. (If you fail to do this, you will get a duplicate label/multiply defined error for movewZ80CompSize!)
- Essentially the same as Sonic 2 AS, except the file you need is
Streamlined Sonic 2 Init Orion.asm.
- Replace everything from
EntryPointup toTest_CountryCode(if you want to keep it) with the contents ofStreamlined Sonic 3K Init AS.asm, uncommenting the Sonic 3 specific portions and removing the Sonic and Knuckles specific portions - Delete the entirety of
Test_Checksum, and
lea ($FF0000).l,a6
moveq #0,d7
move.w #$3F7F,d6
loc_716:
move.l d7,(a6)+
dbf d6,loc_716
1 line after Test_Checksum_Done, then remove move.b #0,(Game_mode).w before GameLoop
- Delete
Init_VDP,SndDrvInit,Init_Controllersand remove their branches.
- Replace everything from
EntryPointup toTest_LockOnwith the contents ofStreamlined Sonic 3K Init AS.asm - Delete
Test_Checksum, the branches to it, and remove the following fromTest_LockOn
tst.w (VDP_control_port).l
move.w #$4EF9,(V_int_jump).w ; machine code for jmp
move.l #VInt,(V_int_addr).w
move.w #$4EF9,(H_int_jump).w
move.l #HInt,(H_int_addr).w
-
move.w (VDP_control_port).l,d1
btst #1,d1
bne.s - ; wait till a DMA is completed
lea (RAM_start&$FFFFFF).l,a6
moveq #0,d7
move.w #bytesToLcnt(CrossResetRAM-RAM_start),d6
-
move.l d7,(a6)+
dbf d6,-
- Delete
Init_VDP,SndDrvInit,Init_Controllersand their branches inBlueSpheresStartup,SonicAndKnucklesStartup, andChecksumError2. bra.s SonicAndKnucklesStartupwill cause an error, changebra.sto abra.w