Clear Control Lock While Jumping - RetroKoH/S1Fixed GitHub Wiki

(Original guide by Mercury)
Source: ReadySonic
Commit: 014ab05

There's a control lock that activates when Sonic hits horizontal springs or slides back down steep surfaces. It prevents the left and right buttons from affecting his speed. Without this, when Sonic runs into horizontal springs, he'd be more likely to brake (the player would likely still be pressing toward the spring a moment after Sonic hit it), and he'd walk in place forever when trying to scale steep slopes instead of sliding back down.

The trouble arises because the lock's timer doesn't decrement while Sonic is in the air. So, if it's active when Sonic jumps, it will remain active when he lands. This is rarely noticeable, but when it happens, it's frustrating to not be able to control Sonic properly for a moment after he lands.

To fix this, we simply clear the lock timer byte in Sonic's OST slot whenever Sonic jumps. In _incObj\Sonic Jump.asm, find loc_1341C: and add this line:

loc_1341C:
	moveq	#0,d0
	move.b	obAngle(a0),d0
	subi.b	#$40,d0
	jsr	(CalcSine).l
	muls.w	d2,d1
	asr.l	#8,d1
	add.w	d1,obVelX(a0)		; make Sonic jump
	muls.w	d2,d0
	asr.l	#8,d0
	add.w	d0,obVelY(a0)		; make Sonic jump
	bset	#staAir,obStatus(a0)
	bclr	#staPush,obStatus(a0)
	addq.l	#4,sp
	move.b	#1,obJumping(a0)
	clr.b	obOnWheel(a0)
+	clr.w	obLRLock(a0)		; Clear Control Lock
	move.w	#sfx_Jump,d0
	jsr	(PlaySound_Special).l	; play jumping sound