mirror of https://github.com/zeldaret/tp.git
add FLT_MAX, FLT_EPSILON, NAN, and HUGE_VALF to MSL_C headers (#316)
This commit is contained in:
parent
55f6707c06
commit
472340e2d6
|
|
@ -21,6 +21,11 @@
|
|||
// TODO: OK?
|
||||
#define __signbitd(x) ((*(unsigned char*)&(x)) & 0x80)
|
||||
|
||||
extern unsigned long __float_nan[];
|
||||
extern unsigned long __float_huge[];
|
||||
extern unsigned long __float_max[];
|
||||
extern unsigned long __float_epsilon[];
|
||||
|
||||
inline int __fpclassifyf(float __value) {
|
||||
unsigned long integer = *(unsigned long*)&__value;
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,10 @@
|
|||
|
||||
#ifndef MSL_FLOAT_H_
|
||||
#define MSL_FLOAT_H_
|
||||
|
||||
#include "MSL_C/MSL_Common/Src/float.h"
|
||||
|
||||
#define FLT_MAX (*(float*) __float_max)
|
||||
#define FLT_EPSILON (*(float*) __float_epsilon)
|
||||
|
||||
#endif
|
||||
|
|
@ -3,6 +3,9 @@
|
|||
|
||||
#include "MSL_C/MSL_Common/Src/float.h"
|
||||
|
||||
#define NAN (*(float*) __float_nan)
|
||||
#define HUGE_VALF (*(float*) __float_huge)
|
||||
|
||||
#define M_PI 3.14159265358979323846f
|
||||
|
||||
#define DEG_TO_RAD(degrees) (degrees * (M_PI / 180.0f))
|
||||
|
|
@ -50,10 +53,6 @@ double sqrt(double);
|
|||
double tan(double);
|
||||
float tanf(float);
|
||||
|
||||
extern float __float_nan[4];
|
||||
extern float __float_epsilon[4];
|
||||
extern float __float_max[4];
|
||||
|
||||
inline double sqrt_step(double tmpd, float mag) {
|
||||
return tmpd * 0.5 * (3.0 - mag * (tmpd * tmpd));
|
||||
}
|
||||
|
|
@ -66,9 +65,9 @@ inline float sqrtf(float mag) {
|
|||
tmpd = sqrt_step(tmpd, mag);
|
||||
return mag * tmpd;
|
||||
} else if (mag < 0.0) {
|
||||
return __float_nan[0];
|
||||
return NAN;
|
||||
} else if (fpclassify(mag) == 1) {
|
||||
return __float_nan[0];
|
||||
return NAN;
|
||||
} else {
|
||||
return mag;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -80,10 +80,8 @@
|
|||
#define _HUGE_ENUF 1e+300
|
||||
#define INFINITY ((float)(_HUGE_ENUF * _HUGE_ENUF))
|
||||
#define HUGE_VAL ((double)INFINITY)
|
||||
#define HUGE_VALF ((float)INFINITY)
|
||||
#define HUGE_VALL ((long double)INFINITY)
|
||||
|
||||
#define FLOAT_INF HUGE_VALF
|
||||
#define DOUBLE_INF HUGE_VAL
|
||||
|
||||
#pragma section ".dead"
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
#include "JSystem/JStage/JSGCamera.h"
|
||||
#include "MSL_C/math.h"
|
||||
#include "MSL_C/float.h"
|
||||
|
||||
/* 80280BA0-80280C00 27B4E0 0060+00 0/0 1/1 0/0 .text __dt__Q26JStage7TCameraFv */
|
||||
JStage::TCamera::~TCamera() {}
|
||||
|
|
@ -31,7 +31,7 @@ void JStage::TCamera::JSGSetProjectionNear(f32) {}
|
|||
|
||||
/* 80280C20-80280C2C 27B560 000C+00 1/0 0/0 0/0 .text JSGGetProjectionFar__Q26JStage7TCameraCFv */
|
||||
f32 JStage::TCamera::JSGGetProjectionFar() const {
|
||||
return __float_max[0];
|
||||
return FLT_MAX;
|
||||
}
|
||||
|
||||
/* 80280C2C-80280C30 27B56C 0004+00 1/0 0/0 0/0 .text JSGSetProjectionFar__Q26JStage7TCameraFf */
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
#include "JSystem/JStage/JSGFog.h"
|
||||
#include "MSL_C/math.h"
|
||||
#include "MSL_C/float.h"
|
||||
|
||||
/* 80280C80-80280CE0 27B5C0 0060+00 0/0 1/1 0/0 .text __dt__Q26JStage4TFogFv */
|
||||
JStage::TFog::~TFog() {}
|
||||
|
|
@ -28,7 +28,7 @@ void JStage::TFog::JSGSetStartZ(f32) {}
|
|||
|
||||
/* 80280D00-80280D0C 27B640 000C+00 1/0 1/0 0/0 .text JSGGetEndZ__Q26JStage4TFogCFv */
|
||||
f32 JStage::TFog::JSGGetEndZ() const {
|
||||
return __float_max[0];
|
||||
return FLT_MAX;
|
||||
}
|
||||
|
||||
/* 80280D0C-80280D10 27B64C 0004+00 1/0 0/0 0/0 .text JSGSetEndZ__Q26JStage4TFogFf */
|
||||
|
|
|
|||
|
|
@ -449,7 +449,7 @@ asm f64 extrapolateParameter_turn(f64 param_0, f64 param_1) {
|
|||
} // namespace functionvalue
|
||||
|
||||
void TFunctionValueAttribute_range::range_initialize() {
|
||||
fBegin_ = __float_nan[0]; // NaN
|
||||
fBegin_ = NAN; // NaN
|
||||
fEnd_ = fBegin_;
|
||||
fDifference_ = fBegin_;
|
||||
|
||||
|
|
@ -541,7 +541,7 @@ asm f64 TFunctionValueAttribute_range::range_getParameter(f64 param_0, f64 param
|
|||
#endif
|
||||
|
||||
TFunctionValueAttribute_range::TFunctionValueAttribute_range()
|
||||
: fBegin_(__float_nan[0]), fEnd_(fBegin_), fDifference_(fBegin_),
|
||||
: fBegin_(NAN), fEnd_(fBegin_), fDifference_(fBegin_),
|
||||
mProgress(TFunctionValue::PROG_INIT), mAdjust(TFunctionValue::ADJ_INIT), _20(fBegin_),
|
||||
_28(fBegin_), mBegin(TFunctionValue::OUT_INIT), mEnd(TFunctionValue::OUT_INIT) {}
|
||||
|
||||
|
|
@ -676,7 +676,7 @@ asm void TFunctionValue_composite::composite_divide(TVector_pointer<TFunctionVal
|
|||
}
|
||||
#pragma pop
|
||||
|
||||
TFunctionValue_constant::TFunctionValue_constant() : fValue_(__float_nan[0]) {}
|
||||
TFunctionValue_constant::TFunctionValue_constant() : fValue_(NAN) {}
|
||||
|
||||
u32 TFunctionValue_constant::getType() const {
|
||||
return 2;
|
||||
|
|
@ -687,7 +687,7 @@ TFunctionValueAttributeSet TFunctionValue_constant::getAttributeSet() {
|
|||
}
|
||||
|
||||
void TFunctionValue_constant::initialize() {
|
||||
fValue_ = __float_nan[0];
|
||||
fValue_ = NAN;
|
||||
}
|
||||
|
||||
void TFunctionValue_constant::prepare() {
|
||||
|
|
@ -698,7 +698,7 @@ f64 TFunctionValue_constant::getValue(f64 arg1) {
|
|||
return fValue_;
|
||||
}
|
||||
|
||||
TFunctionValue_transition::TFunctionValue_transition() : _48(__float_nan[0]), _50(_48) {}
|
||||
TFunctionValue_transition::TFunctionValue_transition() : _48(NAN), _50(_48) {}
|
||||
|
||||
u32 TFunctionValue_transition::getType() const {
|
||||
return 3;
|
||||
|
|
@ -712,7 +712,7 @@ void TFunctionValue_transition::initialize() {
|
|||
range_initialize();
|
||||
interpolate_initialize();
|
||||
|
||||
_48 = __float_nan[0];
|
||||
_48 = NAN;
|
||||
_50 = _48;
|
||||
}
|
||||
|
||||
|
|
@ -732,7 +732,7 @@ asm f64 TFunctionValue_transition::getValue(f64 param_0) {
|
|||
}
|
||||
#pragma pop
|
||||
|
||||
TFunctionValue_list::TFunctionValue_list() : _44(NULL), _48(0), _50(__float_nan[0]), _58(NULL) {}
|
||||
TFunctionValue_list::TFunctionValue_list() : _44(NULL), _48(0), _50(NAN), _58(NULL) {}
|
||||
|
||||
u32 TFunctionValue_list::getType() const {
|
||||
return 4;
|
||||
|
|
@ -748,7 +748,7 @@ void TFunctionValue_list::initialize() {
|
|||
|
||||
_44 = NULL;
|
||||
_48 = 0;
|
||||
_50 = __float_nan[0];
|
||||
_50 = NAN;
|
||||
_58 = NULL;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,16 +1,16 @@
|
|||
#include "MSL_C/MSL_Common/Src/float.h"
|
||||
|
||||
/* 80450AE0-80450AE4 000560 0004+00 0/0 204/204 1060/1060 .sdata __float_nan */
|
||||
extern unsigned long __float_nan = 0x7FFFFFFF;
|
||||
unsigned long __float_nan[] = {0x7FFFFFFF};
|
||||
|
||||
/* 80450AE4-80450AE8 000564 0004+00 0/0 1/1 0/0 .sdata __float_huge */
|
||||
extern unsigned long __float_huge = 0x7F800000;
|
||||
unsigned long __float_huge[] = {0x7F800000};
|
||||
|
||||
/* 80450AE8-80450AEC 000568 0004+00 0/0 18/18 14/14 .sdata __float_max */
|
||||
extern unsigned long __float_max = 0x7F7FFFFF;
|
||||
unsigned long __float_max[] = {0x7F7FFFFF};
|
||||
|
||||
/* 80450AEC-80450AF0 00056C 0004+00 0/0 28/28 0/0 .sdata __float_epsilon */
|
||||
extern unsigned long __float_epsilon = 0x34000000;
|
||||
unsigned long __float_epsilon[] = {0x34000000};
|
||||
|
||||
/* 80450AF0-80450AF4 000570 0004+00 0/0 1/1 0/0 .sdata None */
|
||||
extern float data_80450AF0;
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ qS4 = 7.70381505559019352791e-02; /* 0x3FB3B8C5, 0xB12E9282 */
|
|||
if(hx>0) return 0.0; /* acos(1) = 0 */
|
||||
else return pi+2.0*pio2_lo; /* acos(-1)= pi */
|
||||
}
|
||||
return *__float_nan; /* acos(|x|>1) is NaN */
|
||||
return NAN; /* acos(|x|>1) is NaN */
|
||||
}
|
||||
if(ix<0x3fe00000) { /* |x| < 0.5 */
|
||||
if(ix<=0x3c600000) return pio2_hi+pio2_lo;/*if|x|<2**-57*/
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ double __ieee754_asin(x) double x;
|
|||
if (((ix - 0x3ff00000) | __LO(x)) == 0)
|
||||
/* asin(1)=+-pi/2 with inexact */
|
||||
return x * pio2_hi + x * pio2_lo;
|
||||
return *__float_nan; /* asin(|x|>1) is NaN */
|
||||
return NAN; /* asin(|x|>1) is NaN */
|
||||
} else if (ix < 0x3fe00000) { /* |x|<0.5 */
|
||||
if (ix < 0x3e400000) { /* if |x| < 2**-27 */
|
||||
if (huge + x > one)
|
||||
|
|
|
|||
|
|
@ -257,7 +257,7 @@ double __ieee754_pow(x, y) double x, y;
|
|||
|
||||
if (((((int)hx >> 31) + 1) | yisint) == 0) {
|
||||
errno = 33;
|
||||
return (double)*__float_nan;
|
||||
return (double)NAN;
|
||||
};
|
||||
|
||||
/* |y| is huge */
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ double __ieee754_sqrt(x) double x;
|
|||
return x; /* sqrt(+-0) = +-0 */
|
||||
else if (ix0 < 0) {
|
||||
errno = 33;
|
||||
return *__float_nan;
|
||||
return NAN;
|
||||
} /* sqrt(-ve) = sNaN */
|
||||
}
|
||||
/* normalize x */
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
//
|
||||
|
||||
#include "SSystem/SComponent/c_m3d.h"
|
||||
#include "MSL_C/math.h"
|
||||
#include "MSL_C/float.h"
|
||||
#include "SSystem/SComponent/c_m3d_g_aab.h"
|
||||
#include "SSystem/SComponent/c_m3d_g_cps.h"
|
||||
#include "SSystem/SComponent/c_m3d_g_cyl.h"
|
||||
|
|
@ -113,7 +113,7 @@ extern "C" extern void* __vt__8cM3dGSph[3];
|
|||
// Declarations:
|
||||
//
|
||||
|
||||
f32 G_CM3D_F_ABS_MIN = 32 * __float_epsilon[0];
|
||||
f32 G_CM3D_F_ABS_MIN = 32 * FLT_EPSILON;
|
||||
|
||||
/* 80268560-802685B0 262EA0 0050+00 2/2 0/0 0/0 .text cM3d_InDivPos1__FPC3VecPC3VecfP3Vec
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
//
|
||||
|
||||
#include "SSystem/SComponent/c_xyz.h"
|
||||
#include "MSL_C/math.h"
|
||||
#include "MSL_C/float.h"
|
||||
#include "SSystem/SComponent/c_math.h"
|
||||
#include "dol2asm.h"
|
||||
#include "global.h"
|
||||
|
|
@ -144,9 +144,9 @@ bool cXyz::operator!=(const Vec& vec) const {
|
|||
|
||||
/* 802670AC-80267128 007C+00 s=0 e=4 z=7 None .text isZero__4cXyzCFv */
|
||||
bool cXyz::isZero(void) const {
|
||||
return fabsf(this->x) < 32.0f * __float_epsilon[0] &&
|
||||
fabsf(this->y) < 32.0f * __float_epsilon[0] &&
|
||||
fabsf(this->z) < 32.0f * __float_epsilon[0];
|
||||
return fabsf(this->x) < 32.0f * FLT_EPSILON &&
|
||||
fabsf(this->y) < 32.0f * FLT_EPSILON &&
|
||||
fabsf(this->z) < 32.0f * FLT_EPSILON;
|
||||
}
|
||||
|
||||
/* 80267128-80267150 0028+00 s=0 e=81 z=85 None .text atan2sX_Z__4cXyzCFv */
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
#include "JSystem/J3DGraphLoader/J3DAnmLoader.h"
|
||||
#include "JSystem/JMath/JMath.h"
|
||||
#include "JSystem/JStudio/JStudio/stb.h"
|
||||
#include "MSL_C/float.h"
|
||||
#include "SSystem/SComponent/c_math.h"
|
||||
#include "d/a/d_a_horse_static.h"
|
||||
#include "d/com/d_com_inf_game.h"
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ bool daAlink_c::checkHookshotShootReturnMode() const {
|
|||
void daAlink_c::resetHookshotMode() {
|
||||
mItemMode = 0;
|
||||
initLockAt();
|
||||
mSearchBallScale = __float_max[0];
|
||||
mSearchBallScale = FLT_MAX;
|
||||
}
|
||||
|
||||
/* 8010871C-80108784 10305C 0068+00 0/0 0/0 1/1 .text
|
||||
|
|
@ -367,7 +367,7 @@ void daAlink_c::setHookshotReadyAnime() {
|
|||
#ifdef NONMATCHING
|
||||
int daAlink_c::checkUpperItemActionHookshot() {
|
||||
if (checkHookshotWait()) {
|
||||
mSearchBallScale = __float_max[0];
|
||||
mSearchBallScale = FLT_MAX;
|
||||
}
|
||||
|
||||
if (mItemMode == 1) {
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
//
|
||||
|
||||
#include "d/d_demo.h"
|
||||
#include "MSL_C/float.h"
|
||||
#include "d/com/d_com_inf_game.h"
|
||||
#include "d/msg/d_msg_object.h"
|
||||
#include "dol2asm.h"
|
||||
|
|
@ -605,8 +606,8 @@ dDemo_actor_c::dDemo_actor_c() {
|
|||
mScale.set(1.0f, 1.0f, 1.0f);
|
||||
mRotate.set(0, 0, 0);
|
||||
mModel = NULL;
|
||||
mAnmFrameMax = __float_max[0];
|
||||
mTexAnmFrameMax = __float_max[0];
|
||||
mAnmFrameMax = FLT_MAX;
|
||||
mTexAnmFrameMax = FLT_MAX;
|
||||
}
|
||||
#else
|
||||
#pragma push
|
||||
|
|
@ -924,7 +925,7 @@ void dDemo_actor_c::JSGSetShape(u32 i_shape) {
|
|||
*/
|
||||
void dDemo_actor_c::JSGSetAnimation(u32 i_anmID) {
|
||||
mAnmId = i_anmID;
|
||||
mAnmFrameMax = __float_max[0];
|
||||
mAnmFrameMax = FLT_MAX;
|
||||
onEnable(0x20);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
*/
|
||||
|
||||
#include "d/map/d_map_path_dmap.h"
|
||||
#include "MSL_C/math.h"
|
||||
#include "MSL_C/float.h"
|
||||
#include "d/com/d_com_inf_game.h"
|
||||
#include "d/map/d_map_path.h"
|
||||
#include "d/meter/d_meter_HIO.h"
|
||||
|
|
@ -532,16 +532,16 @@ dDrawPath_c::room_class** dMpath_c::mLayerList;
|
|||
|
||||
/* 80450E68-80450E6C 000368 0004+00 3/3 1/1 0/0 .sbss mMinX__8dMpath_c */
|
||||
// these are needed for sinit, but its got reversed reg alloc?
|
||||
f32 dMpath_c::mMinX /* = __float_max[0] */;
|
||||
f32 dMpath_c::mMinX /* = FLT_MAX */;
|
||||
|
||||
/* 80450E6C-80450E70 00036C 0004+00 3/3 1/1 0/0 .sbss mMaxX__8dMpath_c */
|
||||
f32 dMpath_c::mMaxX /* = -__float_max[0] */;
|
||||
f32 dMpath_c::mMaxX /* = -FLT_MAX */;
|
||||
|
||||
/* 80450E70-80450E74 000370 0004+00 3/3 2/2 0/0 .sbss mMinZ__8dMpath_c */
|
||||
f32 dMpath_c::mMinZ /* = __float_max[0] */;
|
||||
f32 dMpath_c::mMinZ /* = FLT_MAX */;
|
||||
|
||||
/* 80450E74-80450E78 000374 0004+00 3/3 1/1 0/0 .sbss mMaxZ__8dMpath_c */
|
||||
f32 dMpath_c::mMaxZ /* = -__float_max[0] */;
|
||||
f32 dMpath_c::mMaxZ /* = -FLT_MAX */;
|
||||
|
||||
/* 80450E78-80450E7C 000378 0004+00 1/1 2/2 0/0 .sbss mAllCenterX__8dMpath_c */
|
||||
f32 dMpath_c::mAllCenterX;
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
//
|
||||
|
||||
#include "d/map/d_map_path_fmap.h"
|
||||
#include "MSL_C/float.h"
|
||||
#include "d/com/d_com_inf_game.h"
|
||||
#include "dol2asm.h"
|
||||
|
||||
|
|
@ -336,10 +337,10 @@ SECTION_SDATA2 static f32 lit_3894[1 + 1 /* padding */] = {
|
|||
* buildFmapStageData__23dMenu_Fmap_stage_data_cFiff */
|
||||
int dMenu_Fmap_stage_data_c::buildFmapStageData(int param_0, f32 param_1, f32 param_2) {
|
||||
dMenu_Fmap_room_data_c* room = mp_roomTop;
|
||||
f32 fvar3 = __float_max[0];
|
||||
f32 fvar4 = __float_max[0];
|
||||
f32 fvar5 = -__float_max[0];
|
||||
f32 fvar6 = -__float_max[0];
|
||||
f32 fvar3 = FLT_MAX;
|
||||
f32 fvar4 = FLT_MAX;
|
||||
f32 fvar5 = -FLT_MAX;
|
||||
f32 fvar6 = -FLT_MAX;
|
||||
int ivar = 0;
|
||||
|
||||
for (; room != NULL; room = room->getNextData()) {
|
||||
|
|
|
|||
|
|
@ -843,9 +843,9 @@ inline f32 local_sqrtf(f32 mag) {
|
|||
tmpd = DOUBLE_LABEL(lit_4745) * tmpd * (DOUBLE_LABEL(lit_4746) - tmpd * tmpd * mag);
|
||||
return DOUBLE_LABEL(lit_4745) * tmpd * (DOUBLE_LABEL(lit_4746) - tmpd * tmpd * mag) * mag;
|
||||
} else if (mag < DOUBLE_LABEL(lit_4747)) {
|
||||
return __float_nan[0];
|
||||
return NAN;
|
||||
} else if (fpclassify(mag) == 1) {
|
||||
return __float_nan[0];
|
||||
return NAN;
|
||||
} else {
|
||||
return mag;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue