Remove the Roll-Jump Lock
From Sonic Retro
(Original guide by Selbi)
The Roll-Jump Lock is a feature in the original Sonic trilogy that prevents Sonic from changing his direction mid-air if he jumps after rolling. Some mistakenly think it's a quirk of the physics engine, but it's actually a deliberate and precise implementation using a specific flag.
In modern times, the roll-jump lock has steadily fallen out of favor. The good news is that removing it is a simple process!
Quickly Disabling the Roll-Jump Lock
The roll-jump lock is controlled by bit 4 in Sonic's object status bitfield. This flag exclusively handles the roll-jump lock, so removing the single instance where it's set will disable it completely.
To do so, go to loc_13490 (at the end of Sonic_Jump) and comment out or remove the bset line:
loc_13490:
bset #4,$22(a0) ; <-- remove this line to disable the roll-jump lock
rts
That's it. Goodbye, roll-jump lock.
Full Removal (and Clearing Up a Status Bit)
What we did above gets the job done, but it's a quick-and-dirty approach. To fully remove any remaining traces of the roll-jump lock, we need to delete all instances where bit 4 of Sonic's status bitfield is accessed.
First, let's finish what we already started in Sonic_Jump. Since all that loc_13490 does after removing the flag getting set is a single rts instruction, we can remove that routine now and instead replace all calls to it with a locret. Lucky for us, there's only one, and it's right above.
Change the branch from loc_13490 to locret_1348E and then remove the lines marked with an X:
...
btst #2,$22(a0)
bne.s loc_13490 ; <--- change this to locret_1348E
move.b #$E,$16(a0)
move.b #7,$17(a0)
move.b #2,$1C(a0)
bset #2,$22(a0)
addq.w #5,$C(a0)
locret_1348E:
rts
; ===========================================================================
loc_13490: ; X
bset #4,$22(a0) ; X (if you haven't already removed it)
rts ; X
; End of function Sonic_Jump
Next, let's remove the code that handles the physics aspect of the lock. Go to Sonic_ChgJumpDir and remove the two lines marked with an X:
Sonic_ChgJumpDir:
move.w ($FFFFF760).w,d6
move.w ($FFFFF762).w,d5
asl.w #1,d5
btst #4,$22(a0) ; X is the roll-jump lock flag set?
bne.s Obj01_ResetScr2 ; X if yes, prevent in-air movement adjustments
You can also remove the Obj01_ResetScr2 label further down, as it's not used anywhere else.
Now go to Sonic_ResetOnFloor, where there seem to be remnants of an additional effect of the roll-jump lock. Sadly, we'll never know what that might have been, as only a few redundant nop instructions remain. Time for some housekeeping! Remove each line marked with an X:
Sonic_ResetOnFloor:
btst #4,$22(a0) ; X
beq.s loc_137AE ; X
nop ; X
nop ; X
nop ; X
loc_137AE: ; X
bclr #5,$22(a0) ; <-- keep this line!
bclr #1,$22(a0) ; <-- keep this line!
bclr #4,$22(a0) ; X
Finally, remove this line in both Obj47_Hit and Obj64_Wobble:
bclr #4,$22(a1) ; X
With all that done, you've now cleared up a status bit and can use it for anything you like! I'm sure you can come up with something more interesting than the old roll-jump lock.