Import gx, PadClamp, rest of mtx, TRK 2.6 and MSL (#525)

* Match mtx and Padclamp.c

* Match the rest of GX

* Import TRK 2.6

* Import MSL headers and files

* Merge some MSL headers into ours
This commit is contained in:
dbalatoni13 2025-01-12 15:11:23 +01:00 committed by GitHub
parent a79294aac0
commit cdb1d1fc37
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
113 changed files with 11219 additions and 394 deletions

85
include/dolphin/math.h Normal file
View file

@ -0,0 +1,85 @@
#ifndef _DOLPHIN_MATH
#define _DOLPHIN_MATH
// this file is necessary to match mtx/quat.c
#define M_PI 3.141592653589793
#ifndef _MATH_INLINE
#define _MATH_INLINE static inline
#endif
extern int __float_nan[];
extern int __float_huge[];
extern int __double_huge[];
#define INFINITY (*(float *)__float_huge)
#define NAN (*(float *)__float_nan)
#define HUGE_VAL (*(double *)__double_huge)
#ifdef __MWERKS__
extern inline double sqrt(double x)
{
if (x > 0.0) {
double guess = __frsqrte(x); /* returns an approximation to */
guess = .5 * guess * (3.0 - guess * guess * x); /* now have 8 sig bits */
guess = .5 * guess * (3.0 - guess * guess * x); /* now have 16 sig bits */
guess = .5 * guess * (3.0 - guess * guess * x); /* now have 32 sig bits */
guess = .5 * guess * (3.0 - guess * guess * x); /* now have > 53 sig bits */
return x * guess;
}
else if (x == 0)
return 0;
else if (x)
return NAN;
return INFINITY;
}
extern inline float sqrtf(float x)
{
const double _half = .5;
const double _three = 3.0;
volatile float y;
if (x > 0.0f) {
double guess = __frsqrte((double)x); // returns an approximation to
guess = _half * guess * (_three - guess * guess * x); // now have 12 sig bits
guess = _half * guess * (_three - guess * guess * x); // now have 24 sig bits
guess = _half * guess * (_three - guess * guess * x); // now have 32 sig bits
y = (float)(x * guess);
return y;
}
return x;
}
#else
double sqrt(double x);
float sqrtf(float x);
#endif
double atan(double x);
double copysign(double x, double y);
double cos(double x);
double floor(double x);
double frexp(double x, int *exp);
double ldexp(double x, int exp);
double modf(double x, double *intpart);
double sin(double x);
double tan(double x);
double acos(double x);
double asin(double x);
double atan2(double y, double x);
double fmod(double x, double y);
double log(double x);
double pow(double x, double y);
float tanf(float x);
#ifdef __MWERKS__
extern inline double fabs(double x)
{
return __fabs(x);
}
#else
double fabs(double x);
#endif
#endif

View file

@ -118,7 +118,7 @@ void PSMTXScaleApply(const Mtx src, Mtx dst, f32 xS, f32 yS, f32 zS);
void PSMTXRotRad(Mtx m, char axis, f32 rad);
void PSMTXRotTrig(Mtx m, char axis, f32 sinA, f32 cosA);
void PSMTXRotAxisRad(Mtx m, const Vec* axis, f32 rad);
void PSMTXRotAxisRad(register Mtx m, const Vec* axis, register f32 rad);
#endif
#ifdef MTX_USE_PS