Actions

SCHG How-to

Difference between revisions of "Add Extra Characters To Sonic 2"

From Sonic Retro

m (Text replacement - "\[\[Category:SCHG How-tos.*" to "")
 
(6 intermediate revisions by 5 users not shown)
Line 1: Line 1:
 
(Guide By [[User:ManicRemix|Manic Remix]])
 
(Guide By [[User:ManicRemix|Manic Remix]])
  
 +
(Revised by [[User:ThomasSpeedrunner|ThomasSpeedrunner]])
  
I was very surprised that this guide didn't exist anywhere else. It seems like nowadays this is the what everybody has in their hacks. This guide will show you how to add extra characters to Sonic The Hedgehog 2 16-bit. We will use the SVN Version of Sonic 2 Split Dissembly. In this guide, I will refer to Knuckles, and Amy.  
+
I was very surprised that this guide didn't exist anywhere else. It seems like nowadays this is the "what everybody has in their hacks" type of thing. This guide will show you how to add extra characters to Sonic The Hedgehog 2 (16-bit). We will use the SVN/Hg disassembly. In this guide, I will refer to Knuckles and Amy.  
  
First, open up s2.asm. Search for "InitPlayers".
+
First, open up s2.asm. Search for "Obj_Index:".
  
You will see:
+
You will see this or something like it (ignore the fire shield reference as I copy-pasted this from Sonic 2: Titanium Upgrade; Obj09 will be Special Stage Sonic in your hack unless, like me, you've gone and deleted the special stage code and objects):
<asm>
+
<pre>
 +
; ===========================================================================
 +
; ---------------------------------------------------------------------------
 +
; OBJECT POINTER ARRAY ; object pointers ; sprite pointers ; object list ; sprite list
 +
;
 +
; This array contains the pointers to all the objects used in the game.
 +
; ---------------------------------------------------------------------------
 +
Obj_Index:
 +
ObjPtr_Sonic: dc.l Obj01 ; Sonic
 +
ObjPtr_Tails: dc.l Obj02 ; Tails
 +
ObjPtr_PlaneSwitcher: dc.l Obj03 ; Collision plane/layer switcher
 +
ObjPtr_WaterSurface: dc.l Obj04 ; Surface of the water
 +
ObjPtr_TailsTails: dc.l Obj05 ; Tails' tails
 +
ObjPtr_Spiral: dc.l Obj06 ; Rotating cylinder in MTZ, twisting spiral pathway in EHZ
 +
ObjPtr_Oil: dc.l Obj07 ; Oil in OOZ
 +
ObjPtr_SpindashDust:
 +
ObjPtr_Splash: dc.l Obj08 ; Water splash in Aquatic Ruin Zone, Spindash dust
 +
ObjPtr_FireShield: dc.l Obj09 ; Fire Shield
 +
ObjPtr_SmallBubbles: dc.l Obj0A ; Small bubbles from Sonic's face while underwater... </pre>
  
        dc.l Obj01 ; Sonic
+
And it will go on in this format. Now, search for "dc.l ObjNull". Replace this:
dc.l Obj02 ; Tails
+
<pre>
dc.l Obj03 ; Collision plane/layer switcher
+
dc.l ObjNull ; Obj4C
dc.l Obj04 ; Surface of the water
+
dc.l ObjNull ; Obj4D
dc.l Obj05 ; Tails' tails
+
</pre>
dc.l Obj06 ; Rotating cylinder in MTZ, twisting spiral pathway in EHZ
+
with this:
dc.l Obj07 ; Oil in OOZ
+
<pre>
dc.l Obj08 ; Water splash in Aquatic Ruin Zone, Spindash dust
+
ObjPtr_Knuckles: dc.l Obj4C ; Knuckles
dc.l Obj09 ; Sonic in Special Stage
+
ObjPtr_Amy: dc.l Obj4D ; Amy
dc.l Obj0A ; Small bubbles from Sonic's face while underwater... </asm>
+
</pre>
  
And it will go on. Now, search for "dc.l ObjNull".
+
You've now created a Knuckles object and an Amy object. These are the object IDs that will be used for your two new characters.
Replace
 
<asm>
 
        dc.l ObjNull ; Obj4C
 
dc.l ObjNull ; Obj4D
 
dc.l ObjNull ; Obj4E
 
dc.l ObjNull ; Obj4F </asm>
 
with
 
<asm>
 
        dc.l Obj4C ; Knuckles
 
dc.l Obj4D ; Amy
 
dc.l ObjNull ; Obj4E
 
dc.l ObjNull ; Obj4F </asm>
 
  
You've now create an "Knuckles", and "Amy" object. These will be the object in which will be used to be your new characters.
+
Next, search for "InitPlayers:".
 
+
You will see this or something like it:
Next, search for "InitPlayers".
+
<pre>  
You will see:
 
<asm>  
 
 
         InitPlayers_TailsAlone:
 
         InitPlayers_TailsAlone:
subq.w #1,d0
+
move.b #ObjID_Tails,(MainCharacter).w; load Obj02 Tails object at $FFFFB000
move.b #2,(MainCharacter).w; load Obj02 Tails object at $FFFFB000
+
move.b #ObjID_SpindashDust,(Tails_Dust).w; load Obj08 Tails' spindash dust/splash object at $FFFFD100
move.b #8,(Tails_Dust).w; load Obj08 Tails' spindash dust/splash object at $FFFFD100
 
 
addi.w #4,(MainCharacter+y_pos).w
 
addi.w #4,(MainCharacter+y_pos).w
rts </asm>
+
rts </pre>
  
Below
+
Now, below:
<asm>
+
<pre>
subq.w #1,d0 </asm>
+
InitPlayers_TailsAlone
 +
</pre>
 
   
 
   
 
add  
 
add  
<asm>
+
<pre> subq.w #1,d0
bne.s InitPlayers_KnuxAlone
+
bne.s InitPlayers_KnuxAlone ; branch if this is a Knuckles alone game
bne.s InitPlayers_AmyAlone </asm>
+
</pre>
  
 
Now, below the "rts", add
 
Now, below the "rts", add
<asm>
+
<pre>InitPlayers_KnuxAlone:
 
+
subq.w #1,d0
InitPlayers_KnuxAlone:
+
bne.s InitPlayers_AmyAlone ; branch if this is an Amy alone game
move.b #$4E,($FFFFB000).w
+
move.b #ObjID_Knuckles,(MainCharacter+id).w
move.b #8,($FFFFD100).w
+
move.b #ObjID_SpindashDust,(Sonic_Dust+id).w
 
rts
 
rts
  
 
InitPlayers_AmyAlone:
 
InitPlayers_AmyAlone:
move.b #$4E,($FFFFB000).w
+
move.b #ObjID_Amy,(MainCharacter+id).w
move.b #8,($FFFFD100).w
+
move.b #ObjID_SpindashDust,(Sonic_Dust+id).w
rts </asm>
 
 
 
Oh No! We made a mistake. We need to replace the $4E with Knuckle's & Amy's object IDs. If you noticed, in tails code you will see:
 
<asm>
 
move.b #2,(MainCharacter).w; load Obj02 Tails object at $FFFFB000</asm>
 
 
 
The "move.b" will tell the code which object to load. Do you see it? by tails "move.b" there was a # sign, followed by a number.
 
This number is tails object ID, since Sonic's object ID is "OBJ01", Tails is "OBJ02". The OBJ0 is removed, and they put a "#2" by tails code, to state his ID.
 
We will do the same with Knuckles and Amy. Since we used "OBJ4C" and "OBJ4D" for Knuckles and Amy, we will put "#4C" for Knuckles, and "#4D" for their "move.b" codes.
 
So, replace Knuckle's "#4E" with "#4C", and Amy's "#4E" with "#4D".
 
Your code should now look like:
 
<asm>
 
 
 
InitPlayers_KnuxAlone:
 
move.b #$4C,($FFFFB000).w
 
move.b #8,($FFFFD100).w
 
 
rts
 
rts
 +
</pre>
  
InitPlayers_AmyAlone:
+
Now, go to s2.constants.asm. Find this line:
move.b #$4D,($FFFFB000).w
+
<pre>ObjID_Buzzer = id(ObjPtr_Buzzer) ; 4B
move.b #8,($FFFFD100).w
+
</pre>
rts </asm>
+
And insert this under it:
 +
<pre>ObjID_Knuckles = id(ObjPtr_Knuckles) ; 4C
 +
ObjID_Amy = id(ObjPtr_Amy) ; 4D
 +
</pre>
  
Next, search for "word_917A", and replace "dc.w $2FF" with "dc.w $4FF". The number you put there will represent the number of characters you have. This is "Sonic", "Tails", "Amy", & "Knuckles".
+
Next, go to "OptionScreen_Choices:", and find this line:
 +
<pre> dc.l (3-1)<<24|(Player_option&$FFFFFF)
 +
</pre>
 +
Change the 3 to a 5. This will allow for Knuckles and Amy player options. Now go here:
 +
<pre>off_92D2:
 +
dc.l TextOptScr_SonicAndMiles
 +
dc.l TextOptScr_SonicAlone
 +
dc.l TextOptScr_MilesAlone
 +
</pre>
 +
And add this under it:
 +
<pre> dc.l TextOptScr_KnuxAlone
 +
dc.l TextOptScr_AmyAlone
 +
</pre>
 +
Now, head here:
 +
<pre>
 +
off_92DE:
 +
dc.l TextOptScr_SonicAndTails
 +
dc.l TextOptScr_SonicAlone
 +
dc.l TextOptScr_TailsAlone
 +
</pre>
 +
Add the same two lines as before under:
 +
<pre>
 +
dc.l TextOptScr_TailsAlone
 +
</pre>
  
Now, search for "off_92DE", and below "byte_981C", add "dc.l byte_KTEA", and "dc.l byte_AYRE".
+
Now find this:
 +
<pre>
 +
TextOptScr_TailsAlone: menutxt "TAILS ALONE    " ; byte_981C:
 +
</pre>
 +
And add this below it:
 +
<pre>
 +
TextOptScr_KnuxAlone: menutxt "KNUCKLES ALONE "
 +
TextOptScr_AmyAlone: menutxt "AMY ALONE      "
 +
</pre>
  
Now search for "byte_981C: dc.b  $E,"TAILS ALONE    "", and below it add
+
And there you have it! You have two new characters. Now you will need to make new sprites, palette, and code for them to work. A good start would be to copy and paste Sonic's code into a new ASM file and change the labels so you don't get "symbol double defined" errors. Happy hacking!
<asm>
 
byte_KTEA:  dc.b  $E,"KNUCKLES ALONE  "
 
byte_AYRE:  dc.b  $E,"AMY ALONE      " </asm>
 
  
 +
{{S2Howtos}}
  
Congratulations! You have two new characters. Now you will need to make new sprites & palette! And if you want your characters to have new abilities, see [[SCHG How-to:Work with Objects]], and learn how to edit abilities.
+
|{{PAGENAME}}]]

Latest revision as of 10:50, 25 August 2018

(Guide By Manic Remix)

(Revised by ThomasSpeedrunner)

I was very surprised that this guide didn't exist anywhere else. It seems like nowadays this is the "what everybody has in their hacks" type of thing. This guide will show you how to add extra characters to Sonic The Hedgehog 2 (16-bit). We will use the SVN/Hg disassembly. In this guide, I will refer to Knuckles and Amy.

First, open up s2.asm. Search for "Obj_Index:".

You will see this or something like it (ignore the fire shield reference as I copy-pasted this from Sonic 2: Titanium Upgrade; Obj09 will be Special Stage Sonic in your hack unless, like me, you've gone and deleted the special stage code and objects):

; ===========================================================================
; ---------------------------------------------------------------------------
; OBJECT POINTER ARRAY ; object pointers ; sprite pointers ; object list ; sprite list
;
; This array contains the pointers to all the objects used in the game.
; ---------------------------------------------------------------------------
Obj_Index:
ObjPtr_Sonic:			dc.l Obj01	; Sonic
ObjPtr_Tails:			dc.l Obj02	; Tails
ObjPtr_PlaneSwitcher:		dc.l Obj03	; Collision plane/layer switcher
ObjPtr_WaterSurface:		dc.l Obj04	; Surface of the water
ObjPtr_TailsTails:		dc.l Obj05	; Tails' tails
ObjPtr_Spiral:			dc.l Obj06	; Rotating cylinder in MTZ, twisting spiral pathway in EHZ
ObjPtr_Oil:			dc.l Obj07	; Oil in OOZ
ObjPtr_SpindashDust:
ObjPtr_Splash:			dc.l Obj08	; Water splash in Aquatic Ruin Zone, Spindash dust
ObjPtr_FireShield:		dc.l Obj09	; Fire Shield
ObjPtr_SmallBubbles:		dc.l Obj0A	; Small bubbles from Sonic's face while underwater... 

And it will go on in this format. Now, search for "dc.l ObjNull". Replace this:

				dc.l ObjNull	; Obj4C
				dc.l ObjNull	; Obj4D

with this:

ObjPtr_Knuckles:		dc.l Obj4C	; Knuckles
ObjPtr_Amy:			dc.l Obj4D	; Amy

You've now created a Knuckles object and an Amy object. These are the object IDs that will be used for your two new characters.

Next, search for "InitPlayers:". You will see this or something like it:

 
        InitPlayers_TailsAlone:
	move.b	#ObjID_Tails,(MainCharacter).w; load Obj02 Tails object at $FFFFB000
	move.b	#ObjID_SpindashDust,(Tails_Dust).w; load Obj08 Tails' spindash dust/splash object at $FFFFD100
	addi.w	#4,(MainCharacter+y_pos).w
	rts 

Now, below:

InitPlayers_TailsAlone

add

	subq.w	#1,d0
	bne.s	InitPlayers_KnuxAlone			; branch if this is a Knuckles alone game

Now, below the "rts", add

InitPlayers_KnuxAlone:
	subq.w	#1,d0
	bne.s	InitPlayers_AmyAlone			; branch if this is an Amy alone game
	move.b	#ObjID_Knuckles,(MainCharacter+id).w
	move.b	#ObjID_SpindashDust,(Sonic_Dust+id).w
	rts

InitPlayers_AmyAlone:
	move.b	#ObjID_Amy,(MainCharacter+id).w
	move.b	#ObjID_SpindashDust,(Sonic_Dust+id).w
	rts

Now, go to s2.constants.asm. Find this line:

ObjID_Buzzer =			id(ObjPtr_Buzzer)		; 4B

And insert this under it:

ObjID_Knuckles =		id(ObjPtr_Knuckles)		; 4C
ObjID_Amy =			id(ObjPtr_Amy)			; 4D

Next, go to "OptionScreen_Choices:", and find this line:

	dc.l (3-1)<<24|(Player_option&$FFFFFF)

Change the 3 to a 5. This will allow for Knuckles and Amy player options. Now go here:

off_92D2:
	dc.l TextOptScr_SonicAndMiles
	dc.l TextOptScr_SonicAlone
	dc.l TextOptScr_MilesAlone

And add this under it:

	dc.l TextOptScr_KnuxAlone
	dc.l TextOptScr_AmyAlone

Now, head here:

off_92DE:
	dc.l TextOptScr_SonicAndTails
	dc.l TextOptScr_SonicAlone
	dc.l TextOptScr_TailsAlone

Add the same two lines as before under:

	dc.l TextOptScr_TailsAlone

Now find this:

TextOptScr_TailsAlone:		menutxt	"TAILS ALONE    "	; byte_981C:

And add this below it:

TextOptScr_KnuxAlone:		menutxt	"KNUCKLES ALONE "
TextOptScr_AmyAlone:		menutxt	"AMY ALONE      "

And there you have it! You have two new characters. Now you will need to make new sprites, palette, and code for them to work. A good start would be to copy and paste Sonic's code into a new ASM file and change the labels so you don't get "symbol double defined" errors. Happy hacking!

SCHG How-To Guide: Sonic the Hedgehog 2 (16-bit)
Fixing Bugs
Fix Demo Playback | Fix a Race Condition with Pattern Load Cues | Fix Super Sonic Bugs | Use Correct Height When Roll Jumping | Fix Jump Height Bug When Exiting Water | Fix Screen Boundary Spin Dash Bug | Correct Drowning Bugs | Fix Camera Y Position for Tails | Fix Tails Subanimation Error | Fix Tails' Respawn Speeds | Fix Accidental Deletion of Scattered Rings | Fix Ring Timers | Fix Rexon Crash | Fix Monitor Collision Bug | Fix EHZ Deformation Bug | Correct CPZ Boss Attack Behavior | Fix Bug in ARZ Boss Arrow's Platform Behavior | Fix ARZ Boss Walking on Air Glitch | Fix ARZ Boss Sprite Behavior | Fix Multiple CNZ Boss Bugs | Fix HTZ Background Scrolling Mountains | Fix OOZ Launcher Speed Up Glitch | Fix DEZ Giant Mech Collision Glitch | Fix Boss Deconstruction Behavior | Fix Speed Bugs | Fix 14 Continues Cheat | Fix Debug Mode Crash | Fix 99+ Lives | Fix Sonic 2's Sega Screen
Design Choices
Remove the Air Speed Cap | Disable Floor Collision While Dying | Modify Super Sonic Transformation Methods & Behavior | Enable/Disable Tails in Certain Levels | Collide with Water After Being Hurt | Retain Rings When Returning at a Star Post | Improve the Fade In\Fade Out Progression Routines | Fix Scattered Rings' Underwater Physics | Insert LZ Water Ripple Effect | Restore Lost CPZ Boss Feature | Prevent SCZ Tornado Spin Dash Death | Improve ObjectMove Subroutines | Port S3K Rings Manager | Port S3K Object Manager | Port S3K Priority Manager | Edit Level Order with ASM‎ | Alter Ring Requirements in Special Stages | Make Special Stage Characters Use Normal DPLCs | Speed Up Ring Loss Process | Change spike behaviour in Sonic 2
Adding Features
Create Insta-kill and High Jump Monitors | Create Clone and Special Stage Monitors | Port Knuckles
Sound Features
Expand Music Index to Start at $00 | Port Sonic 1 Sound Driver | Port Sonic 2 Clone Driver | Port Sonic 3 Sound Driver | Port Flamewing's Sonic 3 & Knuckles Sound Driver | Expand the Music Index to Start at $00 (Sonic 2 Clone Driver Version) | Play Different Songs Per Act
Extending the Game
Extend the Level Index Past $10 | Extend the Level Select | Extend Water Tables | Add Extra Characters | Free Up 2 Universal SSTs


|Add Extra Characters To Sonic 2]]