Actions

SCHG How-to

Modify Transformation Behavior in Sonic 2

From Sonic Retro

(Original guide by Vladikcomper) (Addition by redhotsonic)

One stark contrast between Sonic 2 and Sonic 3 is the transformation behavior of one Sonic the Hedgehog. Sonic 2 introduced Super Sonic, and used the simple method of jumping to transform. This made it quick and easy to transform, but it doesn't allow for an option of when to transform. If you had 50+ rings and didn't want to transform, you'd have to avoid jumping, or lose your rings. Many would argue that Sonic 3 really got it right (While I wouldn't be one of those people... I don't think either game really perfected it, but anyway...), as Sonic 3 allows for free will transformation by requiring a double jump to transform. The only real downside to this method is that if you have a desire/need to use your double jump abilities, and you have 50+ rings, you can't use them... you would transform instead.

Now, Sonic 2 doesn't have double jump abilities, so we don't need to worry about that. So, why not make transformation a double jump ability?

Applying the change

Part 1

The first thing you do is locate the label Sonic_JumpHeight. You should see something like this:

; loc_1AAF0:
Sonic_JumpHeight:
        tst.b   jumping(a0)     ; is Sonic jumping?
        beq.s   Sonic_UpVelCap  ; if not, branch

        move.w  #-$400,d1
        btst    #6,status(a0)   ; is Sonic underwater?
        beq.s   +               ; if not, branch
        move.w  #-$200,d1
+
        cmp.w   y_vel(a0),d1    ; is Sonic going up faster than d1?
        ble.s   +               ; if not, branch
        move.b  (Ctrl_1_Held_Logical).w,d0
        andi.b  #button_B_mask|button_C_mask|button_A_mask,d0 ; is a jump button pressed?
        bne.s   +               ; if yes, branch
        move.w  d1,y_vel(a0)    ; immediately reduce Sonic's upward speed to d1
+
        tst.b   y_vel(a0)               ; is Sonic exactly at the height of his jump?
        beq.s   Sonic_CheckGoSuper      ; if yes, test for turning into Super Sonic
        rts

Replace this:

        tst.b   y_vel(a0)               ; is Sonic exactly at the height of his jump?
        beq.s   Sonic_CheckGoSuper      ; if yes, test for turning into Super Sonic
        rts


with this:

        move.b  (Ctrl_1_Press_Logical).w,d0
        andi.b  #button_B_mask|button_C_mask|button_A_mask,d0 ; is a jump button pressed?
        bne.s   Sonic_CheckGoSuper      ; if yes, test for turning into Super Sonic
        rts

That's it! Now you can make Sonic transform at will just like in Sonic 3.

Part 2

Now, as previously mentioned, I stated that I didn't think that either game did transformations correctly. Why is that? Well, at those times when you are low on rings, what if you want to cancel out of your Super Sonic form? There is also a fix for that.

Go to Sonic_JumpHeight and replace this:

        tst.b   y_vel(a0)               ; is Sonic exactly at the height of his jump?
        beq.s   Sonic_CheckGoSuper      ; if yes, test for turning into Super Sonic
        rts

with this:

        move.b  (Ctrl_1_Press_Logical).w,d0
        andi.b  #button_B_mask|button_C_mask|button_A_mask,d0 ; is a jump button pressed?
        bne.s   Sonic_CheckGoSuper      ; if yes, test for turning into Super Sonic
        rts

Go to Sonic_CheckGoSuper and replace:

        tst.b	(Super_Sonic_flag).w	; is Sonic already Super?
	beq.s	return_1ABA4		; if yes, branch

with this:

        tst.b	(Super_Sonic_flag).w	; is Sonic already Super?
	bne.w	Sonic_RevertToNormal	; if yes, branch (This allows for reverting manually)

That's it. Now you can cancel out Super Sonic at any time without having to wait for your rings to run out.

Extra Option

You can also use just one button to make Sonic transform and cancel out by replacing this in each step:

        andi.b  #button_B_mask|button_C_mask|button_A_mask,d0 ; is a jump button pressed?

With one of these:

        andi.b  #button_A_mask,d0
        andi.b  #button_B_mask,d0
        andi.b  #button_C_mask,d0

Fixing bugs

Now, everything should be all well and good. But there are few bugs:
1) Sonic's transformation palette bug.
2) Sonic freezing in air after revert to normal bug.
3) A bug involving the Wing Fortress Zone cutscene.
They are much easier to fix, so let's fix them.

Transformation palette bug

Fixing this bug has already been documented in the guide, but it doesn't hurt to mention it here, as you are more likely to run into this bug after implementing this design change. For reference, follow this guide!

Freezing in air after reverting bug

It happens when Sonic has to revert from transformation instantly. The controls are looked when the transformation starts until a certain moment (controlled by PalCycle_SuperSonic routine), and the routine that reverts Sonic to normal doesn't bother to unlock the controls.

In the beginning of Sonic_RevertToNormal add:

	move.b	#0,(MainCharacter+obj_control).w	; restore Sonic's movement

Everything should run smoothly now! Now about the last one...

WFZ cutscene glitch

There is actually one major problem with the code. If you have more than 50 rings at the end of Wing Fortress Zone, Sonic will transform and revert multiple times when he jumps for the Tornado and fall to his death. There is a very simple fix for this. You CANNOT control Sonic at this point; his controls are locked. So, why not do this?

With your new super code you made, at "Sonic_JumpHeight:" change this:

        move.b  (Ctrl_1_Press_Logical).w,d0
        andi.b  #button_B_mask|button_C_mask|button_A_mask,d0 ; is a jump button pressed?
        bne.s   Sonic_CheckGoSuper      ; if yes, test for turning into Super Sonic
        rts

To this:

        tst.b   (Control_Locked).w      ; Are Controls locked?
        bne.s   return_1AB36            ; If so, branch, and do not bother with Super code
        move.b  (Ctrl_1_Press_Logical).w,d0
        andi.b  #button_B_mask|button_C_mask|button_A_mask,d0 ; is a jump button pressed?
        bne.s   Sonic_CheckGoSuper      ; if yes, test for turning into Super Sonic
        rts

Now, whenever controls are locked, Sonic will NOT go super, thus circumventing the issue.

SCHG How-To Guide: Sonic the Hedgehog 2 (16-bit)
Fixing Bugs
Fix Demo Playback | Fix a Race Condition with Pattern Load Cues | Fix Super Sonic Bugs | Use Correct Height When Roll Jumping | Fix Jump Height Bug When Exiting Water | Fix Spin Dash Code and Add Spin Dash Speeds | Fix Screen Boundary Spin Dash Bug | Correct Drowning Bugs | Fix Camera Y Position for Tails | Fix Tails Subanimation Error | Fix Tails' Respawn Speeds | Fix Accidental Deletion of Scattered Rings | Fix Ring Timers | Fix Rexon Crash | Fix Monitor Collision Bug | Fix EHZ Deformation Bug | Correct CPZ Boss Attack Behavior | Fix Bug in ARZ Boss Arrow's Platform Behavior | Fix ARZ Boss Walking on Air Glitch | Fix ARZ Boss Sprite Behavior | Fix Multiple CNZ Boss Bugs | Fix HTZ Background Scrolling Mountains | Fix OOZ Launcher Speed Up Glitch | Fix DEZ Giant Mech Collision Glitch | Fix Boss Deconstruction Behavior | Fix Speed Bugs
Design Choices
Remove the Air Speed Cap | Disable Floor Collision While Dying | Modify Super Sonic Transformation Methods & Behavior | Enable/Disable Tails in Certain Levels | Collide with Water After Being Hurt | Retain Rings When Returning at a Star Post | Improve the Fade In\Fade Out Progression Routines | Fix Scattered Rings' Underwater Physics | Insert LZ Water Ripple Effect | Restore Lost CPZ Boss Feature | Prevent SCZ Tornado Spin Dash Death | Improve ObjectMove Subroutines | Port S3K Rings Manager | Port S3K Object Manager | Port S3K Priority Manager | Edit Level Order with ASM‎ | Alter Ring Requirements in Special Stages | Make Special Stage Characters Use Normal DPLCs | Speed Up Ring Loss Process
Adding Features
Create Insta-kill and High Jump Monitors | Create Clone and Special Stage Monitors | Port Knuckles
Sound Features
Port Sonic 1 Sound Driver | Port Sonic 2 Clone Driver | Port Sonic 3 Sound Driver | Expand the Music Index to Start at $00 (Sonic 2 Clone Driver Version)
Extending the Game
Extend the Level Index Past $10 | Extend the Level Select | Extend Water Tables | Add Extra Characters | Free Up 2 Universal SSTs