summaryrefslogtreecommitdiff
path: root/src/JSystem/JMath/JMATrigonometric.cpp
blob: b5b0ca4b02285a702820a6abd91fb4e27ec11781 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
//
// Generated By: dol2asm
// Translation Unit: JMATrigonometric
//

// don't include header until this "zero" mess is figured out
// #include "JSystem/JMath/JMATrigonometric.h"
#include "math.h"
#include "dol2asm.h"
#include "global.h"

static f32 dummy() {
    return 0.0f;
}

namespace std {
template <typename A1, typename B1>
struct pair {
    A1 a1;
    B1 b1;
    pair() {
        f32 tmp = 0.0f;
        a1 = tmp;
        b1 = tmp;
        // a1 = A1();
        // b1 = B1();
    }
};
}  // namespace std

inline f64 getConst() {
    return 6.2831854820251465;
}

template<int N, typename T>
struct TSinCosTable {
    std::pair<T, T> table[1 << N];
    TSinCosTable() {
        for (int i = 0; i < 1 << N; i++) {
            table[i].a1 = sin((i * getConst()) / (1 << N));
            table[i].b1 = cos((i * getConst()) / (1 << N));
        }
    }
};

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] = 0.0f;
        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] = 0.0f;
        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<13, f32> 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