Actions

SCHG How-to

Difference between revisions of "Add Extra Characters"

From Sonic Retro

m (How-to'd)
(Restored tabs in ASM snippets)
Line 7: Line 7:
 
; Uncompressed graphics    - Sonic
 
; Uncompressed graphics    - Sonic
 
; ---------------------------------------------------------------------------
 
; ---------------------------------------------------------------------------
Art_Sonic:   incbin   artunc\sonic.bin; Sonic
+
Art_Sonic: incbin artunc\sonic.bin; Sonic
        even</asm>
+
even</asm>
 
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:
 
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:
 
<asm>; ---------------------------------------------------------------------------
 
<asm>; ---------------------------------------------------------------------------
 
; Uncompressed graphics    - Metal Sonic
 
; Uncompressed graphics    - Metal Sonic
 
; ---------------------------------------------------------------------------
 
; ---------------------------------------------------------------------------
Art_MetalSonic:   incbin   artunc\msonic.bin; Metal Sonic
+
Art_MetalSonic: incbin artunc\msonic.bin; Metal Sonic
        even</asm>
+
even</asm>
 
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:
 
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:
 
<asm>loc_3230:
 
<asm>loc_3230:
        tst.w   ($FFFFF614).w
+
tst.w ($FFFFF614).w
        beq.w   Demo
+
beq.w Demo
        andi.b   #$80,($FFFFF605).w; check if Start is pressed
+
andi.b #$80,($FFFFF605).w; check if Start is pressed
        beq.w   loc_317C; if not, branch</asm>
+
beq.w loc_317C; if not, branch</asm>
 
After the beq.w Demo, put this in:
 
After the beq.w Demo, put this in:
 
<asm>Title_CheckForB:
 
<asm>Title_CheckForB:
        cmpi.b   #$10, ($FFFFF605)     ; has B been pressed?
+
cmpi.b #$10, ($FFFFF605) ; has B been pressed?
        bne.s   StartCheck               ; if not, branch
+
bne.s StartCheck ; if not, branch
  
 
Title_SecondCharacter:
 
Title_SecondCharacter:
        move.b   #$01, ($FFFFFFFE)   ; set the multiple character flag to $01 (indicating Metal Sonic)
+
move.b #$01, ($FFFFFFFE) ; set the multiple character flag to $01 (indicating Metal Sonic)
        move.b   #$B5,d0                 ; put value of ring sound into d0
+
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)
+
bsr.w PlaySound_Special ; jump to the subroutine that plays the sound currently in d0 ($B5, at the moment)
  
 
StartCheck:</asm>
 
StartCheck:</asm>
Line 35: Line 35:
  
 
Now, go to the LoadSonicDynPLC subroutine, and find this instruction:
 
Now, go to the LoadSonicDynPLC subroutine, and find this instruction:
<asm>                 lea    (Art_Sonic).l,a1</asm>
+
<asm> lea    (Art_Sonic).l,a1</asm>
 
Replace it With:
 
Replace it With:
<asm> cmpi.b       #$01, ($FFFFFFFE)   ; is the multiple character flag set to $01 (Metal Sonic)?
+
<asm> cmpi.b #$01, ($FFFFFFFE) ; is the multiple character flag set to $01 (Metal Sonic)?
                bne.s         SonicArtLoad     ; if not, load Sonic's art
+
bne.s SonicArtLoad ; if not, load Sonic's art
                lea   (Art_MetalSonic).l,a1     ; load Metal Sonic's art
+
lea (Art_MetalSonic).l,a1 ; load Metal Sonic's art
                bra.s         ContLoadPLC     ; branch to rest of code
+
bra.s ContLoadPLC ; branch to rest of code
  
 
SonicArtLoad:
 
SonicArtLoad:
                lea           (Art_Sonic).l, a1 ; load Sonic's art
+
lea (Art_Sonic).l, a1 ; load Sonic's art
  
 
ContLoadPLC:</asm>
 
ContLoadPLC:</asm>

Revision as of 14:19, 2 January 2008

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 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: <asm>; ---------------------------------------------------------------------------

Uncompressed graphics - Sonic
---------------------------------------------------------------------------

Art_Sonic: incbin artunc\sonic.bin; Sonic even</asm> 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: <asm>; ---------------------------------------------------------------------------

Uncompressed graphics - Metal Sonic
---------------------------------------------------------------------------

Art_MetalSonic: incbin artunc\msonic.bin; Metal Sonic even</asm> 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: <asm>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</asm> After the beq.w Demo, put this in: <asm>Title_CheckForB: cmpi.b #$10, ($FFFFF605) ; has B been pressed? bne.s StartCheck ; if not, branch

Title_SecondCharacter: move.b #$01, ($FFFFFFFE) ; 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:</asm> This checks if B is pressed, and sets a flag at $FFFFFFFE 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, and find this instruction: <asm> lea (Art_Sonic).l,a1</asm> Replace it With: <asm> cmpi.b #$01, ($FFFFFFFE) ; 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:</asm> 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!