Actions

SCHG How-to

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.

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)