From 51e33bd341860ab3861ee7ac2a8a588a7329c5e5 Mon Sep 17 00:00:00 2001 From: BR- Date: Fri, 26 Jan 2024 20:44:33 -0800 Subject: [PATCH] Fix `ninja all_source` build (#1134) * Fix `ninja all_source` build * Fix math headers --------- Co-authored-by: Robin Avery --- src/MSL/math.h | 18 ++++++++++++++++++ src/MSL/trigf.h | 10 +++++++--- src/melee/it/items/itluigifireball.c | 2 +- src/melee/lb/lbcollision.c | 1 + src/melee/lb/lbvector.h | 20 -------------------- src/sysdolphin/baselib/cobj.c | 1 - src/sysdolphin/baselib/jobj.c | 4 ++-- src/sysdolphin/baselib/mtx.h | 1 - src/sysdolphin/baselib/tobj.h | 4 ++-- 9 files changed, 31 insertions(+), 30 deletions(-) diff --git a/src/MSL/math.h b/src/MSL/math.h index e215ef53d2..5b5bb27afb 100644 --- a/src/MSL/math.h +++ b/src/MSL/math.h @@ -103,6 +103,24 @@ static inline f32 fabs_inline(f32 x) } } +inline float sqrtf_accurate(float x) +{ + volatile float y; + if (x > 0.0f) { + double guess = __frsqrte((double) x); // returns an approximation to + guess = + 0.5 * guess * (3.0 - guess * guess * x); // now have 12 sig bits + guess = + 0.5 * guess * (3.0 - guess * guess * x); // now have 24 sig bits + guess = + 0.5 * guess * (3.0 - guess * guess * x); // now have 32 sig bits + guess = 0.5 * guess * (3.0 - guess * guess * x); // extra iteration + y = (float) (x * guess); + return y; + } + return x; +} + double frexp(double x, int* exponent); double fabsf__Ff(double); float tanf(float x); diff --git a/src/MSL/trigf.h b/src/MSL/trigf.h index f22c761be1..081635a96a 100644 --- a/src/MSL/trigf.h +++ b/src/MSL/trigf.h @@ -3,8 +3,12 @@ #include -f32 tanf(f32); -f32 cosf(f32); -f32 sinf(f32); +float acosf(float); +float asinf(float); +float atan2f(float y, float x); +float atanf(float); +float cosf(float); +float sinf(float); +float tanf(float); #endif diff --git a/src/melee/it/items/itluigifireball.c b/src/melee/it/items/itluigifireball.c index a7a183235c..78c7f2386e 100644 --- a/src/melee/it/items/itluigifireball.c +++ b/src/melee/it/items/itluigifireball.c @@ -9,9 +9,9 @@ #include "it/it_2725.h" #include "it/itCommonItems.h" #include "it/item.h" -#include "lb/lbvector.h" #include +#include #include #include diff --git a/src/melee/lb/lbcollision.c b/src/melee/lb/lbcollision.c index a24e7d5405..2ac6d00d9e 100644 --- a/src/melee/lb/lbcollision.c +++ b/src/melee/lb/lbcollision.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include diff --git a/src/melee/lb/lbvector.h b/src/melee/lb/lbvector.h index bca1170f77..f1899d6484 100644 --- a/src/melee/lb/lbvector.h +++ b/src/melee/lb/lbvector.h @@ -44,24 +44,4 @@ Vec3* lbVector_WorldToScreen(HSD_CObj* cobj, const Vec3* pos3d, void lbVector_CreateEulerMatrix(Mtx m, Vec3* angles); float lbVector_8000E838(Vec3* a, Vec3* b, Vec3* c, Vec3* d); -/// @todo Doesn't belong here. -/// Exactly the same as the one from math.h, but with one extra iteration -static inline float sqrtf_accurate(float x) -{ - volatile float y; - if (x > 0.0f) { - double guess = __frsqrte((double) x); // returns an approximation to - guess = - 0.5 * guess * (3.0 - guess * guess * x); // now have 12 sig bits - guess = - 0.5 * guess * (3.0 - guess * guess * x); // now have 24 sig bits - guess = - 0.5 * guess * (3.0 - guess * guess * x); // now have 32 sig bits - guess = 0.5 * guess * (3.0 - guess * guess * x); // extra iteration - y = (float) (x * guess); - return y; - } - return x; -} - #endif diff --git a/src/sysdolphin/baselib/cobj.c b/src/sysdolphin/baselib/cobj.c index 37d118c67b..d43b93d884 100644 --- a/src/sysdolphin/baselib/cobj.c +++ b/src/sysdolphin/baselib/cobj.c @@ -6,7 +6,6 @@ #include "class.h" #include "debug.h" #include "displayfunc.h" -#include "fobj.h" #include "initialize.h" #include "mtx.h" #include "video.h" diff --git a/src/sysdolphin/baselib/jobj.c b/src/sysdolphin/baselib/jobj.c index 4dca404b6b..18966498a2 100644 --- a/src/sysdolphin/baselib/jobj.c +++ b/src/sysdolphin/baselib/jobj.c @@ -14,9 +14,9 @@ #include "robj.h" #include "spline.h" -#include "lb/lbrefract.h" - #include <__mem.h> +#include +#include #include #include #include diff --git a/src/sysdolphin/baselib/mtx.h b/src/sysdolphin/baselib/mtx.h index 9b824c783c..2d72d337ad 100644 --- a/src/sysdolphin/baselib/mtx.h +++ b/src/sysdolphin/baselib/mtx.h @@ -5,7 +5,6 @@ #include #include "baselib/objalloc.h" -#include "lb/lbrefract.h" void HSD_MtxInverse(Mtx src, Mtx dest); void HSD_MtxInverseConcat(Mtx inv, Mtx src, Mtx dest); diff --git a/src/sysdolphin/baselib/tobj.h b/src/sysdolphin/baselib/tobj.h index 50e655d858..812777e155 100644 --- a/src/sysdolphin/baselib/tobj.h +++ b/src/sysdolphin/baselib/tobj.h @@ -200,7 +200,7 @@ typedef struct _HSD_TexLODDesc { u32 max_anisotropy; // GXAnisotropy } HSD_TexLODDesc; -typedef struct _HSD_ImageDesc { +struct _HSD_ImageDesc { void* img_ptr; u16 width; u16 height; @@ -208,7 +208,7 @@ typedef struct _HSD_ImageDesc { u32 mipmap; f32 minLOD; f32 maxLOD; -} HSD_ImageDesc; +}; typedef struct _HSD_TObjTev { u8 color_op;