Rolling Speed Cap Fix - RetroKoH/S1Fixed GitHub Wiki

(Original Guide by Devon)
Source: Sonic Retro thread
Original Commit: 7d4da8d
Updated Commit: 561325a

We know about the air and ground speed caps, but there is an additional speed cap that is applied when Sonic is rolling. There is a problem with this third speed cap, however. It only applies horizontally, but not vertically. It might be debatable whether or not this is an actual bug, but in order to make this consistent with the regular ground movement speed cap, open _incObj/Sonic RollSpeed.asm, and go to loc_131CC. You'll see this:

loc_131CC:
	move.b	obAngle(a0),d0
	jsr	(CalcSine).l
	muls.w	obInertia(a0),d0
	asr.l	#8,d0
	move.w	d0,obVelY(a0)
	muls.w	obInertia(a0),d1
	asr.l	#8,d1
	cmpi.w	#$1000,d1
	ble.s	loc_131F0
	move.w	#$1000,d1

loc_131F0:
	cmpi.w	#-$1000,d1
	bge.s	loc_131FA
	move.w	#-$1000,d1

loc_131FA:
	move.w	d1,obVelX(a0)
	bra.w	loc_1300C
; End of function Sonic_RollSpeed

Change it to this:

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

NOTE: To avoid adversely affecting the speed with which you launch off an upward ramp, curbing the heights you can reach, the check is applied to each individual axis.