Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-1-2-2013-Decompilation
Path: blob/main/RSDKv4/Math.hpp
817 views
1
#ifndef MATH_H
2
#define MATH_H
3
4
#ifndef M_PI
5
#define M_PI 3.14159265358979323846264338327950288
6
#endif
7
8
#undef M_PI_2
9
#define M_PI_2 (M_PI * 2.0)
10
11
#undef M_PI_H
12
#define M_PI_H (M_PI * 0.5)
13
14
#define MEM_ZERO(x) memset(&(x), 0, sizeof((x)))
15
#define MEM_ZEROP(x) memset((x), 0, sizeof(*(x)))
16
17
extern int sinM7LookupTable[0x200];
18
extern int cosM7LookupTable[0x200];
19
20
extern int sin512LookupTable[0x200];
21
extern int cos512LookupTable[0x200];
22
23
extern int sin256LookupTable[0x100];
24
extern int cos256LookupTable[0x100];
25
26
extern byte arcTan256LookupTable[0x100 * 0x100];
27
28
// Setup Angles
29
void CalculateTrigAngles();
30
31
inline int Sin512(int angle)
32
{
33
if (angle < 0)
34
angle = 0x200 - angle;
35
36
angle &= 0x1FF;
37
return sin512LookupTable[angle];
38
}
39
40
inline int Cos512(int angle)
41
{
42
if (angle < 0)
43
angle = 0x200 - angle;
44
angle &= 0x1FF;
45
return cos512LookupTable[angle];
46
}
47
48
inline int Sin256(int angle)
49
{
50
if (angle < 0)
51
angle = 0x100 - angle;
52
angle &= 0xFF;
53
return sin256LookupTable[angle];
54
}
55
56
inline int Cos256(int angle)
57
{
58
if (angle < 0)
59
angle = 0x100 - angle;
60
angle &= 0xFF;
61
return cos256LookupTable[angle];
62
}
63
64
// Get Arc Tan value
65
byte ArcTanLookup(int X, int Y);
66
67
inline double DegreesToRad(float degrees) { return (M_PI / 180) * degrees; }
68
69
#endif // !MATH_H
70
71