Modify Transformation Behavior in Sonic 2

From Sonic Retro

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

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?

```        move.b  (Ctrl_1_Press_Logical).w,d0
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