Skip to content

Commit

Permalink
Fix ninja all_source build (doldecomp#1134)
Browse files Browse the repository at this point in the history
* Fix `ninja all_source` build

* Fix math headers

---------

Co-authored-by: Robin Avery <[email protected]>
  • Loading branch information
BR- and ribbanya authored Jan 27, 2024
1 parent 321851f commit 51e33bd
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 30 deletions.
18 changes: 18 additions & 0 deletions src/MSL/math.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
10 changes: 7 additions & 3 deletions src/MSL/trigf.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@

#include <platform.h>

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
2 changes: 1 addition & 1 deletion src/melee/it/items/itluigifireball.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
#include "it/it_2725.h"
#include "it/itCommonItems.h"
#include "it/item.h"
#include "lb/lbvector.h"

#include <common_structs.h>
#include <math.h>
#include <dolphin/mtx/vec.h>
#include <baselib/gobj.h>

Expand Down
1 change: 1 addition & 0 deletions src/melee/lb/lbcollision.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <dolphin/mtx/mtxvec.h>
#include <dolphin/mtx/types.h>
#include <baselib/baselib_shared_data_003.h>
#include <baselib/cobj.h>
#include <baselib/debug.h>
#include <baselib/jobj.h>
#include <baselib/mtx.h>
Expand Down
20 changes: 0 additions & 20 deletions src/melee/lb/lbvector.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 0 additions & 1 deletion src/sysdolphin/baselib/cobj.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions src/sysdolphin/baselib/jobj.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
#include "robj.h"
#include "spline.h"

#include "lb/lbrefract.h"

#include <__mem.h>
#include <math.h>
#include <trigf.h>
#include <dolphin/mtx/mtxvec.h>
#include <dolphin/mtx/vec.h>
#include <dolphin/os.h>
Expand Down
1 change: 0 additions & 1 deletion src/sysdolphin/baselib/mtx.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include <dolphin/mtx/forward.h>

#include "baselib/objalloc.h"
#include "lb/lbrefract.h"

void HSD_MtxInverse(Mtx src, Mtx dest);
void HSD_MtxInverseConcat(Mtx inv, Mtx src, Mtx dest);
Expand Down
4 changes: 2 additions & 2 deletions src/sysdolphin/baselib/tobj.h
Original file line number Diff line number Diff line change
Expand Up @@ -200,15 +200,15 @@ typedef struct _HSD_TexLODDesc {
u32 max_anisotropy; // GXAnisotropy
} HSD_TexLODDesc;

typedef struct _HSD_ImageDesc {
struct _HSD_ImageDesc {
void* img_ptr;
u16 width;
u16 height;
u32 format;
u32 mipmap;
f32 minLOD;
f32 maxLOD;
} HSD_ImageDesc;
};

typedef struct _HSD_TObjTev {
u8 color_op;
Expand Down

0 comments on commit 51e33bd

Please sign in to comment.