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.
Contents
Requirements
- Sonic 1 Disassembly Main
- Sonic 1 Sprites
- Sonic SpinDash Sprites
- A plain text editor of your choice
- Flex 2
- A Sega Genesis emulator (Kega Fusion or BlastEm recommended)
In making this tutorial, I used:
- Clownacys Sonic 1 Disassembly
- Sonic 1 Sprites
- Sonic SpinDash Sprites
- Windows' Notepad
- Flex 2
- Kega Fusion
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
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. (please put it in the _incObj folder)
after that has been download and put in the _incObj folder. Go back to sonic.asm and go to loc_12EA6: (line 6996 lol) 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, theres'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.
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.
Other than that, it works! Great start so far, but let's not get our hopes up.
Animations and Sounds
Now, usually you'd need to worry about changing the sound and allat. But since you already downloaded the Sonic_Spindash.asm we don't have to worry so let's go to the animation.
The animation is kind of the same as the sound. Since you already downloaded the Sonic_Spindash.asm we aight. The animation is currently set to $1F, we'll worry about that later. But for now you're okay. Therefore this section is useless (Mostly).
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, you die.
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
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, remember how you downloaded a Sonic 1 Sprites? This is where it comes in handy. Extract that boy 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. If all is well, your sprites should be correct. So good so far eh? Here comes the part if gets confusing. Find the SpinDash sprites you downloaded earlier, if not then here it is, once downloaded and 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. (You have to do it for each SpinDash sprite.) Once finished, while on the Mapping 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. Once that's finished, go back and build your ROM. Awesome! You now have a functional SpinDash with animations! But wait! You still get hurt when you're in your SpinDash state! But don't worry, there's an easy fix. 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
Awesome, we did it! You have now have a functional SpinDash! There are a few bugs but they're minor. Pu7o has written a wonderful guide that picks up from this point.
Pu7o's Continuation
Pu7o has written a wonderful guide that picks up from this point.
|Add Spin Dash to Sonic 1 (GitHub)]]