Actions

SCHG How-to

Add Spin Dash to Sonic 1/Part 4

From Sonic Retro

(Original guide by Mercury)
(Guide updated by JGMR)

This final part of the guide will fix a few final bugs to our ported Spin Dash code from Sonic 2 in Sonic 1 after following the previous three guides.

Hivebrain's 2005 disassembly

This section is designed for users of the legacy Hivebrain 2005 disassembly of Sonic 1. For users of the GitHub disassembly of Sonic 1, head over to the GitHub section below.

Fixing camera bugs

This will fix the issue which causes weird camera movements if the player performs a Spin Dash at the very beginning of a level since the camera will try to follow bad data from the array of Sonic's previous positions. The following code therefore clears the aforementioned array and should be added right after the loc_60D0 label:

		clr.w	($FFFFF7A8).w	; reset Sonic's position tracking index
		lea	($FFFFCB00).w,a2	; load the tracking array into a2
		moveq	#63,d2	; begin a 64-step loop

@looppoint:
		move.w	d1,(a2)+	; fill in X
		move.w	d0,(a2)+	; fill in Y
		dbf	d2,@looppoint	; loop

Fixing the Spring object bug

Another issue is that when using objects like a spring after Spin Dashing, the game does not know how to accommodate this after you suddenly change direction. Fourtunately, this is a fairly easy fix, so go to Obj41_AniLR and right below the label, add this line:

		clr.w	($FFFFC904).w	; clear screen delay counter

Fixing the Caterkiller bug

And finally, there's an annoying bug that occurs when rolling into a Caterkiller too fast, which will result Sonic in taking damage despite the head being destroyed already. This happens because the spiked body segments are actually not getting deleted immediately after destroying the head, but rather one frame later. To fix this, go to loc_16C7C: and right below the label add:

		clr.b	$20(a1)		; immediately remove all touch response values when destroying the head to avoid taking damage

GitHub disassembly

This section is designed for those using the GitHub disassembly of Sonic 1. It will assume that you have followed DikinBaus' revamped guide and the GitHub versions of Part 2 and Part 3 in that order. The following codes are designed for the AS version of the Sonic 1 GitHub disassembly.

Fixing camera bugs

This will fix the issue which causes weird camera movements if the player performs a Spin Dash at the very beginning of a level since the camera will try to follow bad data from the array of Sonic's previous positions. The following code therefore clears the aforementioned array. Open _inc\LevelSizeLoad & BgScrollSpeed (JP1).asm (or its non-JP1 counterpart if you have the REV00 revision enabled), and add these lines at the beginning of the LevSz_SkipStartPos label:

		clr.w	(v_trackpos).w	; reset Sonic's position tracking index 
		lea	(v_tracksonic).w,a2	; load the tracking array into a2 
		moveq	#63,d2	; begin a 64-step loop

	.looppoint: 
		move.w	d1,(a2)+	; fill in X 
		move.w	d0,(a2)+	; fill in Y 
		dbf d2,.looppoint	; loop

Fixing the Spring object bug

Another issue is that when using objects like a spring after Spin Dashing, the game does not know how to accommodate this after you suddenly change direction. Fourtunately, this is a fairly easy fix, so open up _incObj\41 Springs.asm and find Spring_AniLR, and right below the label, add this line:

		clr.w	(v_sgfx_buffer+$104).w	; clear screen delay counter

Fixing the Caterkiller bug

And finally, there's an annoying bug that occurs when rolling into a Caterkiller too fast, which will result Sonic in taking damage despite the head being destroyed already. This happens because the spiked body segments are actually not getting deleted immediately after destroying the head, but rather one frame later. To fix this, open up _incObj\78 Caterkiller.asm and go to .delete under loc_16C64: and right below the label add:

		clr.b	obColType(a1)	; immediately remove all touch response values when destroying the head to avoid taking damage

Conclusion

That's it! You now have a fully working Spin Dash from Sonic 2, complete with the proper animations, sounds, physics, and the like! Enjoy your newly-ported Spin Dash!

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 | Add Sonic 2 Level Select | Collide with Water After Being Hurt | Smooth Out Rotation in Special Stages
Adding Features
Add Spin Dash ( Part 1 (GitHub)/(Hivebrain) / Part 2 / Part 3 / Part 4 ) | Add Eggman Monitor | Add Super Sonic | Add Extended Camera | Add the Air Roll | Add 6-Button Support
Sound Features
Expand the Sound Index | Play Different Songs Per Act | Port Sonic 2 Final Sound Driver | Port Sonic 3's Sound Driver | Change The SEGA Sound | Correct PAL Music Tempo
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/Part 4]]