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.
Contents
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!
|Add Spin Dash to Sonic 1/Part 4]]