tp/libs/JSystem/JMath/JMATrigonometric.cpp

89 lines
2.1 KiB
C++

//
// Generated By: dol2asm
// Translation Unit: JMATrigonometric
//
// don't include header until this "zero" mess is figured out
// #include "JSystem/JMath/JMATrigonometric.h"
#include "dol2asm.h"
#include "global.h"
#include "msl_c/math.h"
namespace std {
template <typename A1, typename B1>
struct pair {
A1 a1;
B1 b1;
pair() {
f32 tmp = FLOAT_LABEL(zero);
a1 = tmp;
b1 = tmp;
// a1 = A1();
// b1 = B1();
}
};
} // namespace std
// fake, but couldn't find another way to make 0.0f go first in sdata2 in this TU
SECTION_SDATA2 static f32 zero[1 + 1] = {0.0f, 0.0f};
inline f64 getConst() {
return 6.2831854820251465;
}
struct TSinCosTable {
std::pair<f32, f32> table[0x2000];
TSinCosTable() {
for (int i = 0; i < 0x2000; i++) {
table[i].a1 = sin((i * getConst()) / 8192.0);
table[i].b1 = cos((i * getConst()) / 8192.0);
}
}
};
inline f64 getConst2() {
return 9.765625E-4;
}
struct TAtanTable {
f32 table[1025];
u8 pad[0x1C];
TAtanTable() {
// (u32) cast needed for cmplwi instead of cmpwi
for (int i = 0; i < (u32)1024; i++) {
table[i] = atan(getConst2() * i);
}
table[0] = FLOAT_LABEL(zero);
table[1024] = 0.7853982; // 0.25 * PI
}
};
struct TAsinAcosTable {
f32 table[1025];
u8 pad[0x1C];
TAsinAcosTable() {
for (int i = 0; i < 1024; i++) {
table[i] = asin(getConst2() * i);
}
table[0] = FLOAT_LABEL(zero);
table[1024] = 0.7853982; // 0.25 * PI
}
};
//
// Declarations:
//
namespace JMath {
/* ############################################################################################## */
/* 80439A20-80449A20 066740 10000+00 1/1 265/265 705/705 .bss sincosTable___5JMath */
TSinCosTable sincosTable_;
/* 80449A20-8044AA40 076740 1020+00 1/1 0/0 0/0 .bss atanTable___5JMath */
TAtanTable atanTable_;
/* 8044AA40-8044BA60 077760 1020+00 1/1 1/1 0/0 .bss asinAcosTable___5JMath */
TAsinAcosTable asinAcosTable_;
} // namespace JMath