Files

90 lines
2.1 KiB
C++
Raw Permalink Normal View History

2021-04-01 02:07:58 +02:00
//
2021-03-28 22:49:05 +02:00
// Generated By: dol2asm
// Translation Unit: JMATrigonometric
2021-04-01 02:07:58 +02:00
//
2021-03-28 22:49:05 +02:00
// don't include header until this "zero" mess is figured out
// #include "JSystem/JMath/JMATrigonometric.h"
#include "math.h"
2021-03-28 22:49:05 +02:00
#include "dol2asm.h"
#include "global.h"
2021-03-28 22:49:05 +02:00
namespace std {
2021-04-01 02:07:58 +02:00
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;
}
2024-04-04 19:05:50 -04:00
template<int N, typename T>
struct TSinCosTable {
2024-04-04 19:05:50 -04:00
std::pair<T, T> table[1 << N];
TSinCosTable() {
2024-04-04 19:05:50 -04:00
for (int i = 0; i < 1 << N; i++) {
table[i].a1 = sin((i * getConst()) / (1 << N));
table[i].b1 = cos((i * getConst()) / (1 << N));
}
}
2021-03-28 22:49:05 +02:00
};
inline f64 getConst2() {
return 9.765625E-4;
}
2021-04-01 02:07:58 +02:00
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
}
2021-04-08 01:47:05 +02:00
};
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
}
};
2021-03-28 22:49:05 +02:00
2021-04-01 02:07:58 +02:00
//
2021-03-28 22:49:05 +02:00
// Declarations:
2021-04-01 02:07:58 +02:00
//
2021-03-28 22:49:05 +02:00
namespace JMath {
2021-03-28 22:49:05 +02:00
/* ############################################################################################## */
2021-04-06 18:00:35 +02:00
/* 80439A20-80449A20 066740 10000+00 1/1 265/265 705/705 .bss sincosTable___5JMath */
2024-04-04 19:05:50 -04:00
TSinCosTable<13, f32> sincosTable_;
2021-03-28 22:49:05 +02:00
2021-04-06 18:00:35 +02:00
/* 80449A20-8044AA40 076740 1020+00 1/1 0/0 0/0 .bss atanTable___5JMath */
TAtanTable atanTable_;
2021-03-28 22:49:05 +02:00
2021-04-06 18:00:35 +02:00
/* 8044AA40-8044BA60 077760 1020+00 1/1 1/1 0/0 .bss asinAcosTable___5JMath */
TAsinAcosTable asinAcosTable_;
2021-03-28 22:49:05 +02:00
} // namespace JMath