A Few Util function matches

Matched RadSmooth, RadSmoothA, GRandInRange, GModPositive, and SgnCompareG
This commit is contained in:
Lol Bozo 2024-08-04 14:29:43 -04:00
parent 3ab1b0fa5a
commit a1ef70781e
3 changed files with 94 additions and 20 deletions

View File

@ -766,14 +766,14 @@ g_ui = 0x275BC0;
////////////////////////////////////////////////////////////////
RadNormalize__Ff = 0x1EA408; // type:func
GLimitAbs = 0x1EA480; // type:func
GSmooth = 0x1EA4B8; // type:func
GSmoothA = 0x1EA620; // type:func
RadSmooth = 0x1EA728; // type:func
RadSmoothA = 0x1EA798; // type:func
GSmooth__FfffP3SMPPf = 0x1EA4B8; // type:func
GSmoothA__FffffP4SMPAPf = 0x1EA620; // type:func
RadSmooth__FfffP3SMPPf = 0x1EA728; // type:func
RadSmoothA__FffffP4SMPAPf = 0x1EA798; // type:func
PosSmooth = 0x1EA818; // type:func
SmoothMatrix = 0x1EA918; // type:func
NRandInRange__Fii = 0x1EAA70; // type:func
GRandInRange = 0x1EAAE0; // type:func
GRandInRange__Fff = 0x1EAAE0; // type:func
GRandGaussian = 0x1EAB48; // type:func
FFloatsNear__Ffff = 0x1EAC68; // type:func
CSolveQuadratic = 0x1EACA0; // type:func
@ -782,11 +782,11 @@ CalculateSinCos__FfPfT1 = 0x1EAD88; // type:func
GTrunc = 0x1EAE78; // type:func
GTrunc1 = 0x1EAF28; // type:func
GModPositive__Fff = 0x1EAFE0; // type:func
FitClq = 0x1EB018; // type:func
FitClq__FffffP3CLQ = 0x1EB018; // type:func
FCheckLm__FP2LMf = 0x1EB050; // type:func
FCheckAlm = 0x1EB080; // type:func
GLimitLm__FP2LMf = 0x1EB0F8; // type:func
SgnCompareG = 0x1EB128; // type:func
SgnCompareG__FPfT0 = 0x1EB128; // type:func
Force__FPv = 0x1EB160; // type:func
MinimizeRange = 0x1EB168; // type:func
@ -858,6 +858,11 @@ __main__Fv = 0x1fae18; // type:func
////////////////////////////////////////////////////////////////
atan2f = 0x205778; // type:func
////////////////////////////////////////////////////////////////
// sce/ee/gcc/src/newlib/libm/math/wf_atan2.c
////////////////////////////////////////////////////////////////
fmodf = 0x2058a0; // type:func
////////////////////////////////////////////////////////////////
// sce/eecdvd.c

View File

@ -1,10 +1,15 @@
"""
@file math.h
@brief Library math functions.
"""
/**
* @file math.h
*
* @brief Library math functions.
*/
#ifndef MATH_H
#define MATH_H
extern "C"
{
float atan2f(float x, float y);
float fmodf(float x, float y);
}
#endif // MATH_H

View File

@ -1,5 +1,6 @@
#include <util.h>
#include <sce/rand.h>
#include <sce/math.h>
static const float PI = 3.14159265359f;
@ -15,14 +16,30 @@ float RadNormalize(float rad)
INCLUDE_ASM(const s32, "P2/util", GLimitAbs);
INCLUDE_ASM(const s32, "P2/util", GSmooth);
INCLUDE_ASM(const s32, "P2/util", GSmooth__FfffP3SMPPf);
INCLUDE_ASM(const s32, "P2/util", GSmoothA);
INCLUDE_ASM(const s32, "P2/util", GSmoothA__FffffP4SMPAPf);
INCLUDE_ASM(const s32, "P2/util", func_001EA720);
INCLUDE_ASM(const s32, "P2/util", RadSmooth);
float RadSmooth(float radCur, float radTarget, float dt, SMP *psmp, float *pdradNext)
{
float fVar1;
INCLUDE_ASM(const s32, "P2/util", RadSmoothA);
fVar1 = RadNormalize(radTarget - radCur);
fVar1 = GSmooth(0.0, fVar1, dt, psmp, pdradNext);
fVar1 = RadNormalize(radCur + fVar1);
return fVar1;
}
float RadSmoothA(float radCur, float dradCur, float radTarget, float dt, SMPA *psmpa, float *pdradNext)
{
float fVar1;
fVar1 = RadNormalize(radTarget - radCur);
fVar1 = GSmoothA(0.0, dradCur, fVar1, dt, psmpa, pdradNext);
fVar1 = RadNormalize(radCur + fVar1);
return fVar1;
}
INCLUDE_ASM(const s32, "P2/util", PosSmooth);
@ -47,7 +64,23 @@ int NRandInRange(int nLow, int nHi)
return nLow + (randVal % range);
}
INCLUDE_ASM(const s32, "P2/util", GRandInRange);
float GRandInRange(float gHi,float gLow)
{
int rand_result;
float delta;
float result;
if (gHi != gLow)
{
rand_result = rand();
delta = gLow - gHi;
result = gHi + delta * (float)rand_result * 4.656613e-10f;
}
else
{
result = gHi;
}
return result;
}
INCLUDE_ASM(const s32, "P2/util", GRandGaussian);
@ -78,9 +111,25 @@ INCLUDE_ASM(const s32, "P2/util", GTrunc);
INCLUDE_ASM(const s32, "P2/util", GTrunc1);
INCLUDE_ASM(const s32, "P2/util", GModPositive__Fff);
float GModPositive(float gDividend, float gDivisor)
{
float result = fmodf(gDividend, gDivisor);
if (result < 0.0f)
{
result += gDivisor;
}
return result;
}
INCLUDE_ASM(const s32, "P2/util", FitClq);
void FitClq(float g0, float g1, float u, float gU, CLQ *pclq)
{
float fVar1;
pclq->u = g0;
fVar1 = ((gU - g0) / u - (g1 - g0)) / (u - 1.0f);
pclq->w = fVar1;
pclq->v = (g1 - g0) - fVar1;
}
int FCheckLm(LM* plm, float g)
{
@ -102,7 +151,22 @@ float GLimitLm(struct LM* plm, float g)
return g;
}
INCLUDE_ASM(const s32, "P2/util", SgnCompareG);
int SgnCompareG(float *pg1,float *pg2)
{
int iVar1;
iVar1 = 1;
if (*pg1 > *pg2)
{
return iVar1;
}
iVar1 = -1;
if(*pg2 > *pg1)
{
return iVar1;
}
return 0;
}
void Force(void *pv)
{