Difference between revisions of "Add Extra Characters"
From Sonic Retro
GerbilSoft (talk | contribs) m (s/SNV/SVN/g) |
(Rewrote parts of the guide to a concise language and refined some things, including formatting and layout) |
||
(7 intermediate revisions by 5 users not shown) | |||
Line 1: | Line 1: | ||
− | {{GuideBy|Sonic 65}} | + | {{GuideBy|Sonic 65}}<br> |
+ | ''(Guide updated by [[User:Makotoyuki|Makotoyuki]] and [[User:JGMR|JGMR]])'' | ||
− | 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|Hivebrain's]] 2005 and the SVN and GitHub [[Disassemblies|disassembly]]. It is also assuming that your art fits with Sonic's mappings. | + | 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 [[User:Hivebrain|Hivebrain's]] 2005 and the SVN and GitHub [[Disassemblies|disassembly]]. It is also assuming that your art fits with Sonic's mappings. |
+ | == Beginning the process == | ||
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. | 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: | The first step is to search for 'Art_Sonic:' in your disassembly. The result of the search should look something like this: | ||
− | <asm>; --------------------------------------------------------------------------- | + | <syntaxhighlight lang="asm">; --------------------------------------------------------------------------- |
; Uncompressed graphics - Sonic | ; Uncompressed graphics - Sonic | ||
; --------------------------------------------------------------------------- | ; --------------------------------------------------------------------------- | ||
Art_Sonic: incbin artunc\sonic.bin; Sonic | Art_Sonic: incbin artunc\sonic.bin; Sonic | ||
− | even</ | + | even</syntaxhighlight> |
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>; --------------------------------------------------------------------------- | + | <syntaxhighlight lang="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</ | + | even</syntaxhighlight> |
+ | |||
+ | == Load the extra character on the title screen == | ||
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: | + | <syntaxhighlight lang="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</ | + | beq.w loc_317C; if not, branch</syntaxhighlight> |
After the beq.w Demo, put this in: | After the beq.w Demo, put this in: | ||
− | <asm>Title_CheckForB: | + | <syntaxhighlight lang="asm">Title_CheckForB: |
cmpi.b #$10, ($FFFFF605).w ; has B been pressed? | cmpi.b #$10, ($FFFFF605).w ; has B been pressed? | ||
bne.s StartCheck ; if not, branch | bne.s StartCheck ; if not, branch | ||
Title_SecondCharacter: | Title_SecondCharacter: | ||
− | move.b #$01, ($ | + | 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 | 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:</ | + | StartCheck:</syntaxhighlight> |
− | This checks if B is pressed, and sets a flag at $ | + | 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. |
+ | == Making the game load art for the extra character == | ||
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: | 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: | ||
− | <asm> lea (Art_Sonic).l,a1</ | + | <syntaxhighlight lang="asm"> lea (Art_Sonic).l,a1</syntaxhighlight> |
Replace it With: | Replace it With: | ||
− | <asm> cmpi.b #$01, ($ | + | <syntaxhighlight lang="asm"> cmpi.b #$01, ($FFFFFFF9).w ; 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 | ||
Line 47: | Line 52: | ||
lea (Art_Sonic).l, a1 ; load Sonic's art | lea (Art_Sonic).l, a1 ; load Sonic's art | ||
− | ContLoadPLC:</ | + | ContLoadPLC:</syntaxhighlight> |
For the Hivebrain disassembly and | For the Hivebrain disassembly and | ||
− | <asm> cmpi.b #$01, ($ | + | <syntaxhighlight lang="asm"> cmpi.b #$01, ($FFFFFFF9).w ; 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 @loadtile ; branch to rest of code | bra.s @loadtile ; 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 | ||
− | @loadtile:</ | + | @loadtile:</syntaxhighlight> |
for the GitHub/SVN disassemblies | for the GitHub/SVN disassemblies | ||
Line 65: | Line 70: | ||
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). | 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). | ||
+ | == Making the extra character load its own PLC == | ||
+ | If you want your character to have different PLCs from Sonic (e.g. with different mappings, etc.), this part of the tutorial will show you how to do that. Go back to the LoadSonicDynPLC subroutine in the Hivebrain disassembly or open up SonicLoad GFX under ''_incobj'' in the GitHub/SVN disassembly and find this instruction: | ||
+ | |||
+ | <syntaxhighlight lang="asm"> | ||
+ | lea (SonicDynPLC).l,a2</syntaxhighlight> | ||
+ | |||
+ | Underneath it, insert this: | ||
+ | <syntaxhighlight lang="asm"> cmpi.b #$01, ($FFFFFFF9).w ; is the multiple character flag set to $01 (Metal Sonic)? | ||
+ | bne.s ContLoadPLC ; if not, load Sonic's art | ||
+ | lea (MetalSonicDynPLC).l,a1 ; load Metal Sonic's art | ||
+ | bra.s ContLoadPLC ; branch to rest of code | ||
+ | |||
+ | ContLoadPLC:</syntaxhighlight> | ||
+ | |||
+ | For the Hivebrain disassembly and | ||
+ | |||
+ | <syntaxhighlight lang="asm"> cmpi.b #$01, ($FFFFFFF9).w ; is the multiple character flag set to $01 (Metal Sonic)? | ||
+ | bne.s @loadtile ; if not, load Sonic's art | ||
+ | lea (MetalSonicDynPLC).l,a1 ; load Metal Sonic's art | ||
+ | bra.s @loadtile ; branch to rest of code | ||
+ | |||
+ | @loadtile:</syntaxhighlight> | ||
+ | |||
+ | for the GitHub/SVN disassemblies | ||
+ | |||
+ | == Conclusion == | ||
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! | 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! | ||
− | |||
− | |||
{{S1Howtos}} | {{S1Howtos}} | ||
− | + | |Add Extra Characters]] |
Revision as of 09:00, 10 July 2023
(Original guide by Sonic 65)
(Guide updated by Makotoyuki and JGMR)
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.
Contents
Beginning the process
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
Load the extra character on the title screen
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.
Making the game load art for the extra character
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).
Making the extra character load its own PLC
If you want your character to have different PLCs from Sonic (e.g. with different mappings, etc.), this part of the tutorial will show you how to do that. Go back 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 (SonicDynPLC).l,a2
Underneath it, insert this:
cmpi.b #$01, ($FFFFFFF9).w ; is the multiple character flag set to $01 (Metal Sonic)?
bne.s ContLoadPLC ; if not, load Sonic's art
lea (MetalSonicDynPLC).l,a1 ; load Metal Sonic's art
bra.s ContLoadPLC ; branch to rest of code
ContLoadPLC:
For the Hivebrain disassembly and
cmpi.b #$01, ($FFFFFFF9).w ; is the multiple character flag set to $01 (Metal Sonic)?
bne.s @loadtile ; if not, load Sonic's art
lea (MetalSonicDynPLC).l,a1 ; load Metal Sonic's art
bra.s @loadtile ; branch to rest of code
@loadtile:
for the GitHub/SVN disassemblies
Conclusion
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!
|Add Extra Characters]]