Actions

SCHG How-to

Add Spin Dash to Sonic 1/Part 1

From Sonic Retro

(Original guide by Lightning)

This tutorial was made possible thanks to the references, guides, and information found at Hacking CulT, The Sonic 2 Beta Page, Sonic Retro, and Sonicology. I made this for the newest Github Disassembly. Thanks to Kramlat for the latest guide before this one.

This SCHG is property of DikinBaus. Sonic and all related characters and graphics that appear on this page are property of SEGA and are used without permission for no profit.

Requirements

In making this tutorial, I used:

  • Clownacys Sonic 1 Disassembly (newest)
  • Windows' Notepad
  • Flex 2
  • Kega Fusion

Importing the Spindash

Adding a New Flag

Alright, lets get started shall we? Open Constants.asm and scroll down to line 154. Now make a new space (or press enter) and define a new RAM equate by adding this line:

spindash_flag: equ $39


Adding the SpinDash to the Player

Open sonic.asm in your text editor, and search for the phrase Sonic_MdNormal: (line 6948) and above bsr.w Sonic_Jump, make a new line and add bsr.w Sonic_SpinDash to it you should end up with this:
Sonic_MdNormal:
		bsr.w	Sonic_SpinDash
		bsr.w	Sonic_Jump
the code below bsr.w Sonic_Jump should not be worried about.

Now, to actually copy the Spin Dash subroutine. You have to add a new .asm file. To do that go into Sonic 1's disassembly, create a new file within _incObj folder named Sonic Spindash.asm, for the sake of this SCHG I will add a download right here with all the code. after that has been download and put in the _incObj folder. Go back to sonic.asm and go to loc_12EA6: (line 6996) scroll until you see include "_incObj/Sonic JumpDirection.asm". Copy it, and right below it paste it but replace Sonic JumpDirection with Sonic SpinDash it should look something like this:

		include	"_incObj/Sonic Move.asm"
		include	"_incObj/Sonic RollSpeed.asm"
		include	"_incObj/Sonic JumpDirection.asm"
		include	"_incObj/Sonic SpinDash.asm"

Save your changes, navigate back to the main part of the disassembly and run build.bat

First Bug

Uh-oh, so, as expected, there's bugs. The first being, if you collect a few rings then start SpinDashing, as you can see, the badnik(s) can hurt you in your SpinDash state. If you get hit while in state as said before, you'll still be in the SpinDashing state when you land, Sonic will charge forward (depends which way you got hit, forwards or backwards) usually it would destroy whatever badnik touches you in the first place, but that didn't happen. Second, go to high ground or somewhere where the camera can pan downward. Wait for the camera to fully pan down and start SpinDashing. The camera will continue to stay downwards until you stop SpinDashing/Rolling. Third, if you hold the Spindash button for long enough, your game will crash. Another problem that the camera can result is that if you SpinDash before an area where your vertical position radically changes (a great example is the double S-Tube in GHZ1), the camera is too slow to catch up to Sonic in time.

camera lagging behind

Animation Bugs

Now, you'll see that if you hold the Spindash button for long enough, it will show a few varieties of animations. Don't worry as we will fix this later on.


Fixing Bugs/Errors

First of all, the camera issue is already fixed. But there is one thing, the camera is still too slow. So, if you go down an S-Tube, the camera will be too slow and you'll die due to the bottom boundary. Now for the Spindash badnik hurt bug. Go to _incObj/sub ReactToItem and look for React_Enemy: (line 167) and find this peice of code:

React_Enemy:
		tst.b	(v_invinc).w	; is Sonic invincible?
		bne.s	.donthurtsonic	; if yes, branch
		cmpi.b	#id_Roll,obAnim(a0) ; is Sonic rolling/jumping?
		bne.w	React_ChkHurt	; if not, branch

and replace it with this,

React_Enemy:
		tst.b	(v_invinc).w	; is Sonic invincible?
		bne.s	.donthurtsonic	; if yes, branch
		cmpi.b	#$1F,$1C(a0)	; is Sonic Spin Dashing?
		beq.w	.donthurtsonic	; if yes, branch
		cmpi.b	#id_Roll,obAnim(a0) ; is Sonic rolling/jumping?
		bne.w	React_ChkHurt	; if not, branch

So, to fix this go into the _incObj folder and look for Sonic LevelBound once you find it, open it. Look for .bottom: (line 48) You should see this,

.bottom:
		cmpi.w	#(id_SBZ<<8)+1,(v_zone).w ; is level SBZ2 ?
		bne.w	KillSonic	; if not, kill Sonic
		cmpi.w	#$2000,(v_player+obX).w
		blo.w	KillSonic
		clr.b	(v_lastlamp).w	; clear	lamppost counter
		move.w	#1,(f_restart).w ; restart the level
		move.w	#(id_LZ<<8)+3,(v_zone).w ; set level to SBZ3 (LZ4)
		rts

Replace that whole code with this one

.bottom:		
		move.w (v_limitbtm1).w,d0 
		move.w (v_limitbtm2).w,d1 
		cmp.w d0,d1 ; screen still scrolling down? 
		blt.s .dontkill; if so, don't kill Sonic
		cmpi.w	#(id_SBZ<<8)+1,(v_zone).w ; is level SBZ2 ?
		bne.w	KillSonic	; if not, kill Sonic
		cmpi.w	#$2000,(v_player+obX).w
		blo.w	KillSonic
		clr.b	(v_lastlamp).w	; clear	lamppost counter
		move.w	#1,(f_restart).w ; restart the level
		move.w	#(id_LZ<<8)+3,(v_zone).w ; set level to SBZ3 (LZ4)
		rts
.dontkill: 
		rts
Now, if you go back to build your ROM. As you can see, you don't die even if the camera doesn't catch up to Sonic.

Sonic Spindash Sprites

As you can see, Sonic doesn't have a SpinDash sprite as it's not present in Sonic 1, so open up Flex 2. Now, download Sonic 1 Sprites (needed) and the Spindash sprites. Extract the file if not yet, and go back in Flex 2. Now, go to the File section in Flex, and make sure to turn on DPLCs (look to the right until you see it) and put the following sprites as shown in this picture. Sonic-Flex.png If all is well, your sprites should be correct. Here comes the part if gets confusing. Find the SpinDash sprites you downloaded earlier, and extract them if not yet, once extracted. Go to the Mappings section in Flex 2 and scroll down until you see a Import Spritesheet button (It's in the blue buttons to the right) and select the SpinDash sprite. Click Detect Sprites and then Import Sprites (You have to do it for each SpinDash sprite.) Once finished, while on the Mapping section, go on the right where the sprites are and scroll to the bottom until you see the SpinDash sprites you added. Select the sprites, and on the display select the whole sprite and press the down arrow key 9 times. (Do this for each sprite.) If you're confused, I'll add an image right below.

Sonic-spindash-flex.png

Once that's finished, go back and build your ROM. Awesome! You now have a functional SpinDash! Remember when I said, "Now, you'll see that if you hold the Spindash button for long enough, it will show a few varieties of animations. Don't worry as we will fix this later on."? This is later on, go to _anim/Sonic.asm and go to the very bottom. Once there, paste this in.

id_Spindash:	equ (ptr_Spindash-Ani_Sonic)/2	; $1F

Once that's done, go below the line,

SonAni_Float4:	dc.b 3,	fr_Float1, afChange, id_Walk
		even
(line 101)

and paste this in.

SonAni_SpinDash: dc.b 0, $5A, $59, $5A, $5A, $5A, $5B, $5A, $5C, $5A, $5D, afEnd
		even

We're one step away from getting a functioning Spindash! Now go below,

ptr_Float4:	dc.w SonAni_Float4-Ani_Sonic
(line 36)

and paste this in.

ptr_Spindash:	dc.w SonAni_SpinDash-Ani_Sonic ;1F

We did it! We successfully imported the Spindash into Sonic 1! It's still not fully complete though. No need to worry for Pu7o has written a wonderful guide that picks up from this point.




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 Spin Dash to Sonic 1 (GitHub)]]