mirror of
https://github.com/zeldaret/tp
synced 2026-07-08 14:36:36 -04:00
Decompile some SComponent data and some MSL_C.PPCEABI.bare.H headers (#115)
* data for c_angle * data c_sxyz * partially migrated c_xyz data * c_xyz data * c_xyz data decomp * c_math data * c_math data * c_lib data, some cleanup * rename some unnamed functions and create header for them * header for string functions * format and fix fabsf * cleanup * remove more unneded function prototypes * move fpclassify to math.h
This commit is contained in:
@@ -1,27 +1,7 @@
|
||||
/* c_math.cpp autogenerated by split.py v0.3 at 2020-12-31 13:20:59.345670 */
|
||||
|
||||
#include "SComponent/c_math.h"
|
||||
|
||||
extern "C" {
|
||||
double func_8036C760(double, double);
|
||||
void cM_atan2s__Fff(void);
|
||||
void U_GetAtanTable__Fff(void);
|
||||
}
|
||||
|
||||
// additional symbols needed for c_math.cpp
|
||||
// autogenerated by split.py v0.3 at 2020-12-31 13:20:59.336084
|
||||
extern double lbl_804550A8; // SComponent::@2201, 6.2831854820251465
|
||||
extern float lbl_804550B0; // SComponent::@2215, 10430.378
|
||||
extern float lbl_804550B4; // SComponent::@2232, 1024.0
|
||||
extern float lbl_804550B8; // SComponent::@2277, 0.0
|
||||
extern float lbl_804550BC; // SComponent::@2282, 9.58738E-5
|
||||
extern double lbl_804550C0; // SComponent::@2284, 4.503601774854144E15
|
||||
extern float lbl_804550C8; // SComponent::@2296, 30323.0
|
||||
extern float lbl_804550CC; // SComponent::@2297, 30269.0
|
||||
extern float lbl_804550D0; // SComponent::@2298, 30307.0
|
||||
extern double lbl_804550D8; // SComponent::@2299, 1.0
|
||||
extern float lbl_804550E0; // SComponent::@2311, 2.0
|
||||
extern float lbl_804550E4; // SComponent::@2312, 0.5
|
||||
#include "msl_c/math.h"
|
||||
|
||||
extern s32 lbl_80451168; // SComponent::r0
|
||||
extern s32 lbl_8045116C; // SComponent::r1
|
||||
@@ -33,25 +13,70 @@ extern s32 lbl_8045117C; // SComponent::r22
|
||||
extern u16 lbl_803C3778[1028]; // SComponent::atntable
|
||||
|
||||
// cM_rad2s__Ff
|
||||
asm s16 cM_rad2s(float){nofralloc
|
||||
#include "SComponent/c_math/asm/func_802675E4.s"
|
||||
s16 cM_rad2s(float f0) {
|
||||
f32 tmpF = fmod(f0, 6.2831854820251465 /* approx. 2 * PI */);
|
||||
s32 tmp = (tmpF * 10430.378f /* approx. 32768 / PI */);
|
||||
if (tmp < -0x8000) {
|
||||
tmp += 0x10000;
|
||||
} else if (tmp > 0x7FFF) {
|
||||
tmp -= 0x10000;
|
||||
}
|
||||
return tmp;
|
||||
}
|
||||
|
||||
// U_GetAtanTable__Fff
|
||||
u16 U_GetAtanTable(float f0, float f1) {
|
||||
return lbl_803C3778[(int)(f0 / f1 * lbl_804550B4)];
|
||||
return lbl_803C3778[(int)(f0 / f1 * 1024)];
|
||||
}
|
||||
|
||||
// cM_atan2s__Fff
|
||||
asm s16 cM_atan2s(float, float) {
|
||||
nofralloc
|
||||
#include "SComponent/c_math/asm/func_80267674.s"
|
||||
s16 cM_atan2s(float f0, float f1) {
|
||||
u32 retVar;
|
||||
if (fabsf(f0) < lbl_80451180) {
|
||||
if (f1 >= 0.0f) {
|
||||
retVar = 0;
|
||||
} else {
|
||||
retVar = 0x8000;
|
||||
}
|
||||
} else if (fabsf(f1) < lbl_80451180) {
|
||||
if (f0 >= 0.0f) {
|
||||
retVar = 0x4000;
|
||||
} else {
|
||||
retVar = 0xC000;
|
||||
}
|
||||
} else if (f0 >= 0.0f) {
|
||||
if (f1 >= 0.0f) {
|
||||
if (f1 >= f0) {
|
||||
retVar = U_GetAtanTable(f0, f1);
|
||||
} else {
|
||||
retVar = 0x4000 - U_GetAtanTable(f1, f0);
|
||||
}
|
||||
} else {
|
||||
if (-f1 < f0) {
|
||||
retVar = U_GetAtanTable(-f1, f0) + 0x4000;
|
||||
} else {
|
||||
retVar = 0x8000 - U_GetAtanTable(f0, -f1);
|
||||
}
|
||||
}
|
||||
} else if (f1 < 0.0f) {
|
||||
if (f1 <= f0) {
|
||||
retVar = U_GetAtanTable(-f0, -f1) + 0x8000;
|
||||
} else {
|
||||
retVar = 0xC000 - U_GetAtanTable(-f1, -f0);
|
||||
}
|
||||
} else {
|
||||
if (f1 < -f0) {
|
||||
retVar = U_GetAtanTable(f1, -f0) + 0xC000;
|
||||
} else {
|
||||
retVar = -U_GetAtanTable(-f0, f1);
|
||||
}
|
||||
}
|
||||
return retVar;
|
||||
}
|
||||
|
||||
// cM_atan2f__Fff
|
||||
asm float cM_atan2f(float, float) {
|
||||
nofralloc
|
||||
#include "SComponent/c_math/asm/func_80267814.s"
|
||||
float cM_atan2f(float f1, float f2) {
|
||||
return 9.58738E-5f * cM_atan2s(f1, f2);
|
||||
}
|
||||
|
||||
// cM_initRnd__Fiii
|
||||
@@ -62,22 +87,13 @@ void cM_initRnd(int p0, int p1, int p2) {
|
||||
}
|
||||
|
||||
// cM_rnd__Fv
|
||||
#ifdef NON_MATCHING
|
||||
float cM_rnd(void) {
|
||||
// matches besides extra double in data from int -> float conversion
|
||||
lbl_80451168 = (lbl_80451168 * 0xAB) % 0x763D;
|
||||
lbl_8045116C = (lbl_8045116C * 0xAC) % 0x7663;
|
||||
lbl_80451170 = (lbl_80451170 * 0xAA) % 0x7673;
|
||||
return fabsf((float)func_8036C760(lbl_80451168 / lbl_804550C8 + lbl_8045116C / lbl_804550CC +
|
||||
lbl_80451170 / lbl_804550D0,
|
||||
lbl_804550D8));
|
||||
return fabsf(
|
||||
fmod(lbl_80451168 / 30269.0f + lbl_8045116C / 30307.0f + lbl_80451170 / 30323.0f, 1.0));
|
||||
}
|
||||
#else
|
||||
asm float cM_rnd(void) {
|
||||
nofralloc
|
||||
#include "SComponent/c_math/asm/func_8026786C.s"
|
||||
}
|
||||
#endif
|
||||
|
||||
// cM_rndF__Ff
|
||||
float cM_rndF(float f) {
|
||||
@@ -86,7 +102,7 @@ float cM_rndF(float f) {
|
||||
|
||||
// cM_rndFX__Ff
|
||||
float cM_rndFX(float f) {
|
||||
return f * (cM_rnd() - lbl_804550E4) * lbl_804550E0;
|
||||
return f * (cM_rnd() - 0.5f) * 2.0f;
|
||||
}
|
||||
|
||||
// cM_initRnd2__Fiii
|
||||
@@ -97,22 +113,13 @@ void cM_initRnd2(int p0, int p1, int p2) {
|
||||
}
|
||||
|
||||
// cM_rnd2__Fv
|
||||
#ifdef NON_MATCHING
|
||||
float cM_rnd2(void) {
|
||||
// matches besides extra double in data from int -> float conversion
|
||||
lbl_80451174 = (lbl_80451174 * 0xAB) % 0x763D;
|
||||
lbl_80451178 = (lbl_80451178 * 0xAC) % 0x7663;
|
||||
lbl_8045117C = (lbl_8045117C * 0xAA) % 0x7673;
|
||||
return fabsf((float)func_8036C760(lbl_80451174 / lbl_804550C8 + lbl_80451178 / lbl_804550CC +
|
||||
lbl_8045117C / lbl_804550D0,
|
||||
lbl_804550D8));
|
||||
return fabsf(
|
||||
fmod(lbl_80451174 / 30269.0f + lbl_80451178 / 30307.0f + lbl_8045117C / 30323.0f, 1.0));
|
||||
}
|
||||
#else
|
||||
asm float cM_rnd2(void) {
|
||||
nofralloc
|
||||
#include "SComponent/c_math/asm/func_802679E4.s"
|
||||
}
|
||||
#endif
|
||||
|
||||
// cM_rndF2__Ff
|
||||
float cM_rndF2(float f) {
|
||||
@@ -121,5 +128,5 @@ float cM_rndF2(float f) {
|
||||
|
||||
// cM_rndFX2__Ff
|
||||
float cM_rndFX2(float f) {
|
||||
return f * (cM_rnd2() - lbl_804550E4) * lbl_804550E0;
|
||||
return f * (cM_rnd2() - 0.5f) * 2.0f;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user