• Welcome Guest to the new PlayerSquared! Please be aware the site is a work in progress & we'd appreciate your help in letting us know which features from the old site we're currently missing as well as report any bugs you find via this thread here: Bugs/Missing Features
  • If this is your first visit You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. Sign up today to get the latest PS4 GameSaves, Game Mods and much more!

V Smooth Scroll (ASM/C)

NotYourDope

JIMZO-F
JIMZO-F
January 12, 2019
324
470
0
2,253
Hi PlayerSquared, today I present to you my smooth scroll code.

ASM
Code:
:SmoothScroll_ //(float destinationCoord, float currentCoord)
Function 2 5 0
getF1 0
setF1 5
getF1 1
JumpFalse @EndSmoothScroll_
getF1 0
getF1 1
JumpLT @SubFromScrollbarCoord_
getF1 0
getF1 1
JumpGT @AddToScrollbarCoord_
Jump @EndSmoothScroll_
:SubFromScrollbarCoord_
getF1 1
getF1 0
fSub
fPush 0.007
JumpLE @EndSmoothScroll_
getF1 1
getF1 1
getF1 0
fSub
fPush 1.7
fDiv
fSub
setF1 5
Jump @EndSmoothScroll_
:AddToScrollbarCoord_
getF1 0
getF1 1
fSub
fPush 0.007
JumpLE @EndSmoothScroll_
getF1 1
getF1 0
getF1 1
fSub
fPush 1.7
fDiv
fAdd
setF1 5
:EndSmoothScroll_
getF1 5
Return 2 1 //scrollbarCoord

C
Code:
float SmoothScroll(float destinationCoord, float currentCoord)
{
float newCoord = destinationCoord;
if (!(currentCoord == 0.0f))
{
if (destinationCoord < currentCoord)
{
if (!(currentCoord - destinationCoord <= 0.007f))
{
newCoord = currentCoord - (currentCoord - destinationCoord) / 1.7f;
}
}
if (destinationCoord > currentCoord)
{
if (!(destinationCoord - currentCoord <= 0.007f))
{
newCoord = currentCoord + (destinationCoord - currentCoord) / 1.7f;
}
}
}
return newCoord;
}
 
Last edited by a moderator: