Add Extra Characters
From Sonic Retro
(Original guide by Sonic 65)
Multiple characters is a fad in hacks nowadays, but not everyone knows how to add multiple characters to their hacks. That's what this tutorial is here for. This tutorial assumes you have basic knowledge of how to use a split disassembly, and is assuming you are using Hivebrain's 2005 and the SVN and GitHub disassembly. It is also assuming that your art fits with Sonic's mappings.
First of all, extract the art that you want from the ROM. You could do this by splitting it, or going into a hex editor and extracting the portion you want into a seperate file. Either way, once you have your file, put it into the 'artunc' folder of your split disassembly. My file is named 'msonic.bin', but yours could be named anything; just replace all instances of 'msonic.bin' that I say with your file's name.
The first step is to search for 'Art_Sonic:' in your disassembly. The result of the search should look something like this:
; ---------------------------------------------------------------------------
; Uncompressed graphics - Sonic
; ---------------------------------------------------------------------------
Art_Sonic: incbin artunc\sonic.bin; Sonic
even
Now, copy that data and paste it below. Then change Art_Sonic to another label, and replace the sonic.bin with your filename. My result was this:
; ---------------------------------------------------------------------------
; Uncompressed graphics - Metal Sonic
; ---------------------------------------------------------------------------
Art_MetalSonic: incbin artunc\msonic.bin; Metal Sonic
even
Next, you have to decide how you want to have your character be chosen. I chose to make the character Metal Sonic if B was pressed at the title screen. For the purposes of this tutorial, I will assume you want to do it that way too. So search for 'loc_3230:'. You should find something like this:
loc_3230:
tst.w ($FFFFF614).w
beq.w Demo
andi.b #$80,($FFFFF605).w; check if Start is pressed
beq.w loc_317C; if not, branch
After the beq.w Demo, put this in:
Title_CheckForB:
cmpi.b #$10, ($FFFFF605).w ; has B been pressed?
bne.s StartCheck ; if not, branch
Title_SecondCharacter:
move.b #$01, ($FFFFFFF9).w ; set the multiple character flag to $01 (indicating Metal Sonic)
move.b #$B5,d0 ; put value of ring sound into d0
bsr.w PlaySound_Special ; jump to the subroutine that plays the sound currently in d0 ($B5, at the moment)
StartCheck:
This checks if B is pressed, and sets a flag at $FFFFFFF9 if it is. It also plays the ring sound (which is $B5 in the sound test). You can change the sound it plays by changing $B5 to the sound test value of whatever sound you want to play.
Now, go to the LoadSonicDynPLC subroutine in the Hivebrain disassembly or open up SonicLoad GFX under _incobj in the GitHub/SVN disassembly and find this instruction:
lea (Art_Sonic).l,a1
Replace it With:
cmpi.b #$01, ($FFFFFFF9).w ; is the multiple character flag set to $01 (Metal Sonic)?
bne.s SonicArtLoad ; if not, load Sonic's art
lea (Art_MetalSonic).l,a1 ; load Metal Sonic's art
bra.s ContLoadPLC ; branch to rest of code
SonicArtLoad:
lea (Art_Sonic).l, a1 ; load Sonic's art
ContLoadPLC:
For the Hivebrain disassembly and
cmpi.b #$01, ($FFFFFFF9).w ; is the multiple character flag set to $01 (Metal Sonic)?
bne.s @SonicArtLoad ; if not, load Sonic's art
lea (Art_MetalSonic).l,a1 ; load Metal Sonic's art
bra.s @loadtile ; branch to rest of code
@SonicArtLoad:
lea (Art_Sonic).l, a1 ; load Sonic's art
@loadtile:
for the GitHub/SVN disassemblies
This code tests if the multiple character flag (which we set to $01 if you pressed B at the title screen) is set to $01. If it isn't, it just loads Sonic's art like normal and continues to the ContLoadPLC subroutine. If it is, it loads Metal Sonic's art and jumps directly to the ContLoadPLC subroutine (so that we don't load Sonic's art at all).
And...that's all. Compile the code, and if you run into any errors you either chose a subroutine name that was already taken or did something else wrong. Have fun putting new characters in your hacks!
Loading extra PLCs
you may want to load different PLCs for your extra character.. if that's you follow this guide.
remember when you made the game load extra art for your new character (in my case, Mighty)? well, we're gonna do the same for the DPLCs. this part of the guide assumes you've already included the DPLC in sonic1.asm
go back to LoadSonicDynPLC (hivebrain)/Sonic_LoadGFX (github) and add this beforelea (SonicDynPLC).l,a2
cmpi.b #$01, ($FFFFFFF9).w ; is the multiple character flag set to $01 (Mighty)?
bne.s @SonicPLCLoad ; if not, load Sonic's art
lea (MightyDynPLC).l,a1 ; load Mighty's art
bra.s @loadtile ; branch to rest of code
@SonicPLCLoad:
|Add Extra Characters]]