Actions

SCHG How-to

Difference between revisions of "Add Spin Dash to Sonic 1/Part 1"

From Sonic Retro

Line 24: Line 24:
  
  
== GitHub Disassembly ==
+
== 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:
 
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:
  
Line 30: Line 30:
  
  
===Directly copying the object code===
+
===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: <syntaxhighlight lang="asm">Sonic_MdNormal:
 
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: <syntaxhighlight lang="asm">Sonic_MdNormal:
 
bsr.w Sonic_SpinDash
 
bsr.w Sonic_SpinDash

Revision as of 22:31, 26 December 2023

(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. It was inspired by the guide at The Glowing Bridge that details porting the simpler Spin Dash from the Sonic 2 early beta.

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
  • 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
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. (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. Spin Dashing with low camera

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

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
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, 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. Sonic-Flex.png 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. Sonic-spindash-flex.png 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.


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