Speed Caps - RetroKoH/S1Fixed GitHub Wiki
(Original Guides by Tweaker, Puto, and RetroKoH)
Source: SCHG Page
Original Commit: 7d4da8d
Updated Commit: 561325a
Ground Speed Cap can be toggled in S1Fixed by setting GroundSpeedCapEnabled to 0 or 1.
Air Speed Cap can be toggled in S1Fixed by setting AirSpeedCapEnabled to 0 or 1.
Rolling Speed Cap can be toggled in S1Fixed by setting RollSpeedCapEnabled to 0 or 1.
Here's a breakdown of the speed cap from the Sonic Physics Guide, courtesy of Lapper:
In Sonic 1, while Sonic is already running at a higher speed than he can possibly achieve on his own (such as having been bounced by a Spring on a wall), if you press in the direction he's moving, v_sonspeedacc will be added to obInertia as usual. However, notice that obInertia now exceeds v_sonspeedmax, which means obInertia will be set to v_sonspeedmax. Thus it is possible to curtail your forward momentum by pressing in the very direction of your motion. This can be solved in your engine (and was fixed in Sonic 2 and beyond) by checking to see if obInertia is less than v_sonspeedmax before adding v_sonspeedacc. Only if obInertia is already less than top will it check if obInertia exceeds v_sonspeedmax.
NOTE: I edited this explanation with variable names from the disassembly.
Ground Speed Cap
(Original guide by Tweaker)
Right, so let's remove that speed cap. Open _incObj/Sonic Move.asm and go to the label loc_1309A. Add these three lines:
loc_1309A:
sub.w d5,d0
move.w d6,d1
neg.w d1
cmp.w d1,d0
bgt.s loc_130A6
+ add.w d5,d0
+ cmp.w d1,d0
+ ble.s loc_130A6
move.w d1,d0
This takes care of the speed cap when moving on the ground to the left, now to handle ground movement to the right. Find the label loc_13104. Add these three lines:
loc_13104:
add.w d5,d0
cmp.w d6,d0
blt.s loc_1310C
+ sub.w d5,d0
+ cmp.w d6,d0
+ bge.s loc_1310C
move.w d6,d0
Air Speed Cap
(Original guide by Puto)
We're not done just yet. We have one more to remove. This time we're opening _incObj/Sonic JumpDirection.asm. Just before loc_13278, immediately after the branch to that very label, we are going to add three lines that should look familiar:
bgt.s loc_13278
+ add.w d5,d0
+ cmp.w d1,d0
+ ble.s loc_13278
move.w d1,d0
loc_13278:
This removes the airborne speed cap to the left, now to remove the other. We are already at label loc_13278, so let's just add these three lines:
loc_13278:
btst #bitR,(v_jpadhold2).w ; is right being pressed?
beq.s Obj01_JumpMove ; if not, branch
bclr #0,obStatus(a0)
add.w d5,d0
cmp.w d6,d0
blt.s Obj01_JumpMove
+ sub.w d5,d0
+ cmp.w d6,d0
+ bge.s Obj01_JumpMove
move.w d6,d0
Obj01_JumpMove:
That handles that! Air Speed Cap removed.
Rolling Speed Cap
(Original guide by RetroKoH)
Devon recently gave us a bugfix that gave us a consistent rolling speed cap. Yes, that's right! There is a third speed cap! I've since added a toggle to S1Fixed that allows us to disable this speed cap as well. To do this, apply the rolling cap fix, then remove the highlighted lines:
loc_131CC:
move.b obAngle(a0),d0
jsr (CalcSine).w
move.w obInertia(a0),d2
muls.w d2,d0
asr.l #8,d0
- cmpi.w #$1000,d0
- ble.s .checkNegY
- move.w #$1000,d0
-.checkNegY:
- cmpi.w #-$1000,d0
- bge.s .setVelocityY
- move.w #-$1000,d0
.setVelocityY:
move.w d0,obVelY(a0)
muls.w d2,d1
asr.l #8,d1
- cmpi.w #$1000,d1
- ble.s .checkNegX
- move.w #$1000,d1
-.checkNegX:
- cmpi.w #-$1000,d1
- bge.s .setVelocityX
- move.w #-$1000,d1
.setVelocityX:
move.w d1,obVelX(a0)
bra.w loc_1300C
; End of function Sonic_RollSpeed