Actions

SCHG How-to

Difference between revisions of "Add Extra Characters"

From Sonic Retro

(Extra Characters Tutorial by Sonic 65)
 
(Optional improvements)
 
(29 intermediate revisions by 13 users not shown)
Line 1: Line 1:
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.
+
{{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 [[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</asm>
+
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</asm>
+
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</asm>
+
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)     ; 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, ($FFFFFFFE)   ; set the multiple character flag to $01 (indicating Metal Sonic)
+
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:</asm>
+
StartCheck:</syntaxhighlight>
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.
+
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, and find this instruction:
+
== Making the game load art for the extra character ==
<asm>                 lea    (Art_Sonic).l,a1</asm>
+
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:
 +
<syntaxhighlight lang="asm"> lea    (Art_Sonic).l,a1</syntaxhighlight>
 
Replace it With:
 
Replace it With:
<asm> cmpi.b       #$01, ($FFFFFFFE)   ; is the multiple character flag set to $01 (Metal Sonic)?
+
<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         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:</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 @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:</syntaxhighlight>
 +
 
 +
for the GitHub/SVN disassemblies
  
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).
 
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).
  
 +
== Optional improvements ==
 +
'''Note from the editor: This entire section may need to be thoroughly tested to see if it actually works or not. You can skip straight to the conclusion below for now. Any improvements and/or additions are welcome. - JGMR'''
 +
 +
These optional improvements are here for you to give your new character(s) a distinct and unique personality separate from Sonic himself.
 +
 +
=== Making the extra character load its own mappings and PLC ===
 +
If you think using only Sonic's art and not touching the mappings and PLC data is limiting and you want your new character to have different mappings and PLCs from Sonic, then this part of the tutorial will show you how to do that.
 +
 +
==== Beginning the process ====
 +
First, make a copy of Sonic's mapping and DPLC data. The mappings go to the '_maps' folder of your split disassembly, while your DPLCs goes to either the '_inc' or '_maps' folder of your split disassembly, depending on if you're using the Hivebrain or GitHub/SVN disassemblies. The copied mapping file will be called 'MetalSonic.asm', while the copied DPLC file will either have the names 'MetalSonic dynamic pattern load cues.asm' or 'MetalSonic - Dynamic Gfx Script.asm', depending on if you're using the Hivebrain or GitHub/SVN disassemblies. Again, you can have any name you want for your files; just replace all instances of 'MetalSonic' that I say with your chosen name.
 +
 +
But before we dive into putting our mappings and DPLCs in, we need to do some prerequisite work here to avoid any potential errors when compiling the code.
 +
 +
First, open up your mappings and DPLC files in your text editor of choice. Depending on whether you have the Hivebrain or GitHub/SVN versions of the files, here are some things that you may want to watch out for:
 +
* Hivebrain: mappings have the labels 'Map_Sonic' and 'byte_XXXXX', while DPLCs have the words 'SonPLC' and 'SonicDynPLC' on the labels.
 +
**'Map_Sonic:' and 'SonicDynPLC:' are located in the main ASM file (sonic1.asm).
 +
* GitHub/SVN: mappings have the labels 'Map_Sonic' and 'MS_XXXXXX', while DPLCs have the words 'SonPLC' and 'SonicDynPLC' on the labels.
 +
**'Map_Sonic:' and 'SonicDynPLC:' are located directly within their own files, with 'Map_Sonic:' placed under 'Sonic.asm' and 'Sonic - Dynamic Gfx Script.asm' respectively, located in ''_maps''.
 +
**The mappings file also has additional code for use with Constants, with labels 'ptr_MS_XXXXXX' and 'fr_XXXXXX'. If you have a mappings file generated by another program, these additions will be absent.
 +
**In later versions of the GitHub disassembly, the 'Map_Sonic' and 'SonicDynPLC' labels will have the words '_internal' prefixed after the words. These won't be present if you have a mappings file generated by another program.
 +
 +
To prevent a double name conflict in compiling the code, we need to change several name instances so that they don't cause the aforementioned naming conflict. To do that, replace instances of 'Son' and 'Sonic' with your character's name, and then add a '2' to the labels before the underscore ('_') in several labels ('byte_XXXXXX' => 'byte2_XXXXXX') except for those with 'Map_' on them, such as 'Map_XXXXXX'. This will resolve the problem with compiling the code in the future.
 +
 +
Now we need to include our files. Make a search for 'Nem_JapNames:' in your disassembly, and below it, you will see following instructions. Depending on which type of disassembly you have, here's what you'll find in the Hivebrain disassembly:
 +
<syntaxhighlight lang="asm">; ---------------------------------------------------------------------------
 +
; Sprite mappings - Sonic
 +
; ---------------------------------------------------------------------------
 +
Map_Sonic:
 +
include "_maps\Sonic.asm"
 +
 +
; ---------------------------------------------------------------------------
 +
; Uncompressed graphics loading array for Sonic
 +
; ---------------------------------------------------------------------------
 +
SonicDynPLC:
 +
include "_inc\Sonic dynamic pattern load cues.asm"</syntaxhighlight>
 +
For the GitHub/SVN disassemblies, it looks like this:
 +
<syntaxhighlight lang="asm"> include "_maps\Sonic.asm"
 +
include "_maps\Sonic - Dynamic Gfx Script.asm"</syntaxhighlight>
 +
And for later versions of the GitHub disassembly, it looks like this:
 +
<syntaxhighlight lang="asm">Map_Sonic: include "_maps/Sonic.asm"
 +
SonicDynPLC: include "_maps/Sonic - Dynamic Gfx Script.asm"</syntaxhighlight>
 +
 +
Copy what you see below and change it so that it resembles our results below. For the Hivebrain disassembly:
 +
<syntaxhighlight lang="asm">; ---------------------------------------------------------------------------
 +
; Sprite mappings - Sonic
 +
; ---------------------------------------------------------------------------
 +
Map_Sonic:
 +
include "_maps\Sonic.asm"
 +
 +
; ---------------------------------------------------------------------------
 +
; Uncompressed graphics loading array for Sonic
 +
; ---------------------------------------------------------------------------
 +
SonicDynPLC:
 +
include "_inc\Sonic dynamic pattern load cues.asm"
 +
 +
; ---------------------------------------------------------------------------
 +
; Sprite mappings - Metal Sonic
 +
; ---------------------------------------------------------------------------
 +
Map_MetalSonic:
 +
include "_maps\MetalSonic.asm"
 +
 +
; ---------------------------------------------------------------------------
 +
; Uncompressed graphics loading array for Metal Sonic
 +
; ---------------------------------------------------------------------------
 +
MetalSonicDynPLC:
 +
include "_inc\MetalSonic dynamic pattern load cues.asm"</syntaxhighlight>
 +
For the GitHub/SVN disassemblies:
 +
<syntaxhighlight lang="asm"> include "_maps\Sonic.asm"
 +
include "_maps\Sonic - Dynamic Gfx Script.asm"
 +
include "_maps\MetalSonic.asm"
 +
include "_maps\MetalSonic - Dynamic Gfx Script.asm"</syntaxhighlight>
 +
And for later versions of the GitHub disassembly:
 +
<syntaxhighlight lang="asm">Map_Sonic: include "_maps/Sonic.asm"
 +
SonicDynPLC: include "_maps/Sonic - Dynamic Gfx Script.asm"
 +
Map_MetalSonic: include "_maps\MetalSonic.asm"
 +
MetalSonicDynPLC: include "_maps\MetalSonic - Dynamic Gfx Script.asm"</syntaxhighlight>
 +
 +
==== Making the game load mappings and PLC for the extra character ====
 +
Now go to the code for Sonic, which should be 'Obj01' in the Hivebrain disassembly and 'SonicPlayer' in the GitHub/SVN disassembly. From there, locate 'Obj01_Main' for the Hivebrain disassembly and 'Sonic_Main' in the GitHub/SVN disassembly and find these instructions below. Depending on which type of disassembly you have, in the Hivebrain disassembly it should look like this:
 +
<syntaxhighlight lang="asm>
 +
move.l #Map_Sonic,4(a0)</syntaxhighlight>
 +
For the GitHub/SVN disassemblies, it looks like this:
 +
<syntaxhighlight lang="asm>
 +
move.l #Map_Sonic,obMap(a0)</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 ContLoadMap ; if not, load Sonic's mappings
 +
move.l #Map_MetalSonic,4(a0) ; load Metal Sonic's mappings
 +
bra.s ContLoadMap ; 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 @loadmap ; if not, load Sonic's mappings
 +
move.l #Map_MetalSonic,obMap(a0) ; load Metal Sonic's mappings
 +
bra.s @loadmap ; branch to rest of code
 +
 +
@loadtile:</syntaxhighlight>
 +
 +
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 mappings like normal and continues to the ContLoadMap subroutine. If it is, it loads Metal Sonic's mappings and jumps directly to the ContLoadMap subroutine (so that we don't load Sonic's mappings at all).
 +
 +
Now 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 DPLC
 +
lea (MetalSonicDynPLC).l,a1 ; load Metal Sonic's DPLC
 +
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 @loadplc ; if not, load Sonic's DPLC
 +
lea (MetalSonicDynPLC).l,a1 ; load Metal Sonic's DPLC
 +
bra.s @loadplc ; branch to rest of code
 +
 +
@loadtile:</syntaxhighlight>
 +
 +
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 DPLCs like normal and continues to the ContLoadPLC subroutine. If it is, it loads Metal Sonic's DPLCs and jumps directly to the ContLoadPLC subroutine (so that we don't load Sonic's DPLCs at all).
 +
 +
== 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}}
 +
|Add Extra Characters]]

Latest revision as of 01:54, 2 May 2024

(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.

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).

Optional improvements

Note from the editor: This entire section may need to be thoroughly tested to see if it actually works or not. You can skip straight to the conclusion below for now. Any improvements and/or additions are welcome. - JGMR

These optional improvements are here for you to give your new character(s) a distinct and unique personality separate from Sonic himself.

Making the extra character load its own mappings and PLC

If you think using only Sonic's art and not touching the mappings and PLC data is limiting and you want your new character to have different mappings and PLCs from Sonic, then this part of the tutorial will show you how to do that.

Beginning the process

First, make a copy of Sonic's mapping and DPLC data. The mappings go to the '_maps' folder of your split disassembly, while your DPLCs goes to either the '_inc' or '_maps' folder of your split disassembly, depending on if you're using the Hivebrain or GitHub/SVN disassemblies. The copied mapping file will be called 'MetalSonic.asm', while the copied DPLC file will either have the names 'MetalSonic dynamic pattern load cues.asm' or 'MetalSonic - Dynamic Gfx Script.asm', depending on if you're using the Hivebrain or GitHub/SVN disassemblies. Again, you can have any name you want for your files; just replace all instances of 'MetalSonic' that I say with your chosen name.

But before we dive into putting our mappings and DPLCs in, we need to do some prerequisite work here to avoid any potential errors when compiling the code.

First, open up your mappings and DPLC files in your text editor of choice. Depending on whether you have the Hivebrain or GitHub/SVN versions of the files, here are some things that you may want to watch out for:

  • Hivebrain: mappings have the labels 'Map_Sonic' and 'byte_XXXXX', while DPLCs have the words 'SonPLC' and 'SonicDynPLC' on the labels.
    • 'Map_Sonic:' and 'SonicDynPLC:' are located in the main ASM file (sonic1.asm).
  • GitHub/SVN: mappings have the labels 'Map_Sonic' and 'MS_XXXXXX', while DPLCs have the words 'SonPLC' and 'SonicDynPLC' on the labels.
    • 'Map_Sonic:' and 'SonicDynPLC:' are located directly within their own files, with 'Map_Sonic:' placed under 'Sonic.asm' and 'Sonic - Dynamic Gfx Script.asm' respectively, located in _maps.
    • The mappings file also has additional code for use with Constants, with labels 'ptr_MS_XXXXXX' and 'fr_XXXXXX'. If you have a mappings file generated by another program, these additions will be absent.
    • In later versions of the GitHub disassembly, the 'Map_Sonic' and 'SonicDynPLC' labels will have the words '_internal' prefixed after the words. These won't be present if you have a mappings file generated by another program.

To prevent a double name conflict in compiling the code, we need to change several name instances so that they don't cause the aforementioned naming conflict. To do that, replace instances of 'Son' and 'Sonic' with your character's name, and then add a '2' to the labels before the underscore ('_') in several labels ('byte_XXXXXX' => 'byte2_XXXXXX') except for those with 'Map_' on them, such as 'Map_XXXXXX'. This will resolve the problem with compiling the code in the future.

Now we need to include our files. Make a search for 'Nem_JapNames:' in your disassembly, and below it, you will see following instructions. Depending on which type of disassembly you have, here's what you'll find in the Hivebrain disassembly:

; ---------------------------------------------------------------------------
; Sprite mappings - Sonic
; ---------------------------------------------------------------------------
Map_Sonic:
	include "_maps\Sonic.asm"

; ---------------------------------------------------------------------------
; Uncompressed graphics	loading	array for Sonic
; ---------------------------------------------------------------------------
SonicDynPLC:
	include "_inc\Sonic dynamic pattern load cues.asm"

For the GitHub/SVN disassemblies, it looks like this:

		include	"_maps\Sonic.asm"
		include	"_maps\Sonic - Dynamic Gfx Script.asm"

And for later versions of the GitHub disassembly, it looks like this:

Map_Sonic:	include	"_maps/Sonic.asm"
SonicDynPLC:	include	"_maps/Sonic - Dynamic Gfx Script.asm"

Copy what you see below and change it so that it resembles our results below. For the Hivebrain disassembly:

; ---------------------------------------------------------------------------
; Sprite mappings - Sonic
; ---------------------------------------------------------------------------
Map_Sonic:
	include "_maps\Sonic.asm"

; ---------------------------------------------------------------------------
; Uncompressed graphics	loading	array for Sonic
; ---------------------------------------------------------------------------
SonicDynPLC:
	include "_inc\Sonic dynamic pattern load cues.asm"

; ---------------------------------------------------------------------------
; Sprite mappings - Metal Sonic
; ---------------------------------------------------------------------------
Map_MetalSonic:
	include "_maps\MetalSonic.asm"

; ---------------------------------------------------------------------------
; Uncompressed graphics	loading	array for Metal Sonic
; ---------------------------------------------------------------------------
MetalSonicDynPLC:
	include "_inc\MetalSonic dynamic pattern load cues.asm"

For the GitHub/SVN disassemblies:

		include	"_maps\Sonic.asm"
		include	"_maps\Sonic - Dynamic Gfx Script.asm"
		include	"_maps\MetalSonic.asm"
		include	"_maps\MetalSonic - Dynamic Gfx Script.asm"

And for later versions of the GitHub disassembly:

Map_Sonic:	include	"_maps/Sonic.asm"
SonicDynPLC:	include	"_maps/Sonic - Dynamic Gfx Script.asm"
Map_MetalSonic:	include	"_maps\MetalSonic.asm"
MetalSonicDynPLC:	include	"_maps\MetalSonic - Dynamic Gfx Script.asm"

Making the game load mappings and PLC for the extra character

Now go to the code for Sonic, which should be 'Obj01' in the Hivebrain disassembly and 'SonicPlayer' in the GitHub/SVN disassembly. From there, locate 'Obj01_Main' for the Hivebrain disassembly and 'Sonic_Main' in the GitHub/SVN disassembly and find these instructions below. Depending on which type of disassembly you have, in the Hivebrain disassembly it should look like this:

		move.l	#Map_Sonic,4(a0)

For the GitHub/SVN disassemblies, it looks like this:

		move.l	#Map_Sonic,obMap(a0)

Underneath it, insert this:

		cmpi.b	#$01, ($FFFFFFF9).w	; is the multiple character flag set to $01 (Metal Sonic)?
		bne.s	ContLoadMap		; if not, load Sonic's mappings
		move.l	#Map_MetalSonic,4(a0)	; load Metal Sonic's mappings
		bra.s	ContLoadMap		; 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	@loadmap		; if not, load Sonic's mappings
		move.l	#Map_MetalSonic,obMap(a0)	; load Metal Sonic's mappings
		bra.s	@loadmap		; branch to rest of code

@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 mappings like normal and continues to the ContLoadMap subroutine. If it is, it loads Metal Sonic's mappings and jumps directly to the ContLoadMap subroutine (so that we don't load Sonic's mappings at all).

Now 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 DPLC
		lea	(MetalSonicDynPLC).l,a1	; load Metal Sonic's DPLC
		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	@loadplc		; if not, load Sonic's DPLC
		lea	(MetalSonicDynPLC).l,a1	; load Metal Sonic's DPLC
		bra.s	@loadplc		; branch to rest of code

@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 DPLCs like normal and continues to the ContLoadPLC subroutine. If it is, it loads Metal Sonic's DPLCs and jumps directly to the ContLoadPLC subroutine (so that we don't load Sonic's DPLCs at all).

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!

SCHG How-To Guide: Sonic the Hedgehog (16-bit)
Fixing Bugs
Fix Demo Playback | Fix a Race Condition with Pattern Load Cues | Fix the SEGA Sound | Display the Press Start Button Text | Fix the Level Select Menu | Fix the Hidden Points Bug | Fix Accidental Deletion of Scattered Rings | Fix Ring Timers | Fix the Walk-Jump Bug | Correct Drowning Bugs | Fix the Death Boundary Bug | Fix the Camera Follow Bug | Fix Song Restoration Bugs | Fix the HUD Blinking | Fix the Level Select Graphics Bug | Fix a remember sprite related bug
Changing Design Choices
Change Spike Behavior | Collide with Water After Being Hurt | Fix Special Stage Jumping Physics | Improve the Fade In\Fade Out Progression Routines | Fix Scattered Rings' Underwater Physics | Remove the Speed Cap | Port the REV01 Background Effects | Port Sonic 2's Level Art Loader | Retain Rings Between Acts | Add Sonic 2 (Simon Wai Prototype) Level Select | Improve ObjectMove Subroutines | Port Sonic 2 Level Select
Adding Features
Add Spin Dash ( Part 1 / Part 2 / Part 3 / Part 4 ) | Add Eggman Monitor | Add Super Sonic | Add the Air Roll
Sound Features
Expand the Sound Index | Play Different Songs Per Act | Port Sonic 2 Final Sound Driver | Port Sonic 3's Sound Driver | Port Flamewing's Sonic 3 & Knuckles Sound Driver | Change The SEGA Sound
Extending the Game
Load Chunks From ROM | Add Extra Characters | Make an Alternative Title Screen | Use Dynamic Tilesets | Make GHZ Load Alternate Art | Make Ending Load Alternate Art | Add a New Zone | Set Up the Goggle Monitor | Add New Moves | Add a Dynamic Collision System | Dynamic Special Stage Walls System | Extend Sprite Mappings and Art Limit | Enigma Credits | Use Dynamic Palettes
Miscellaneous
Convert the Hivebrain 2005 Disassembly to ASM68K
Split Disassembly Guides
Set Up a Split Disassembly | Basic Level Editing | Basic Art Editing | Basic ASM Editing (Spin Dash)

|Add Extra Characters]]