Introduce math.h
Makes fix for introducing 0.5 and 3.0 double constants into rels less hacky
This commit is contained in:
parent
faf3b6d773
commit
79a78f4c5f
4 changed files with 46 additions and 9 deletions
|
|
@ -78,7 +78,6 @@ void fn_800B4264(s32, s32, s32);
|
||||||
void fn_8007500C(s32);
|
void fn_8007500C(s32);
|
||||||
void fn_8006F0D4(s32, f32);
|
void fn_8006F0D4(s32, f32);
|
||||||
f32 fn_8006F128(s32);
|
f32 fn_8006F128(s32);
|
||||||
f64 fmod(f32, f64);
|
|
||||||
void fn_8006F61C(s16, s32);
|
void fn_8006F61C(s16, s32);
|
||||||
void fn_800B42BC(s16);
|
void fn_800B42BC(s16);
|
||||||
s32 fn_8006DBD4(s16);
|
s32 fn_8006DBD4(s16);
|
||||||
|
|
|
||||||
43
include/math.h
Normal file
43
include/math.h
Normal file
|
|
@ -0,0 +1,43 @@
|
||||||
|
#ifndef _MATH_H
|
||||||
|
#define _MATH_H
|
||||||
|
|
||||||
|
extern inline float sqrtf(float x)
|
||||||
|
{
|
||||||
|
static const double _half=.5;
|
||||||
|
static 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
float tanf(float x);
|
||||||
|
float sinf(float x);
|
||||||
|
float cosf(float x);
|
||||||
|
float atan2f(float y, float x);
|
||||||
|
float acosf(float x);
|
||||||
|
|
||||||
|
#define abs(x) __abs(x)
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -3,9 +3,7 @@
|
||||||
#include "game/printfunc.h"
|
#include "game/printfunc.h"
|
||||||
#include "dolphin/pad.h"
|
#include "dolphin/pad.h"
|
||||||
|
|
||||||
//HACK: Force 0.5 and 3.0 double constants to appear in REL
|
#include "math.h"
|
||||||
const double _half = 0.5;
|
|
||||||
const double _three = 3.0;
|
|
||||||
|
|
||||||
static void SubchrMain(void);
|
static void SubchrMain(void);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
#include "include/REL/w10Dll.h"
|
#include "include/REL/w10Dll.h"
|
||||||
#include "game/data.h"
|
#include "game/data.h"
|
||||||
|
|
||||||
|
#include "math.h"
|
||||||
|
|
||||||
//BSS
|
//BSS
|
||||||
s16 lbl_1_bss_22[11];
|
s16 lbl_1_bss_22[11];
|
||||||
s16 lbl_1_bss_20;
|
s16 lbl_1_bss_20;
|
||||||
|
|
@ -58,11 +60,6 @@ s32 lbl_1_data_6C[2] = {
|
||||||
DATA_NUM_LISTEND
|
DATA_NUM_LISTEND
|
||||||
};
|
};
|
||||||
|
|
||||||
//RODATA
|
|
||||||
//HACK: Force 0.5 and 3.0 double constants to appear in REL
|
|
||||||
const double _half = 0.5;
|
|
||||||
const double _three = 3.0;
|
|
||||||
|
|
||||||
// function is probably global. only inlined in rels?
|
// function is probably global. only inlined in rels?
|
||||||
inline s32 get_current_board(void) {
|
inline s32 get_current_board(void) {
|
||||||
return GWSystem.unk08 & 0x1F;
|
return GWSystem.unk08 & 0x1F;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue