SSBM Decomp
Toggle main menu visibility
Loading...
Searching...
No Matches
math.h
Go to the documentation of this file.
1
#ifndef MSL_MATH_H
2
#define MSL_MATH_H
3
4
#include <
Runtime/platform.h
>
5
6
#ifdef MWERKS_GEKKO
7
#include <
math_ppc.h
>
8
9
#include <
MetroTRK/intrinsics.h
>
10
#endif
11
12
#define MSL_HI(x) *(int*) &x
13
#define MSL_LO(x) *(1 + (int*) &x)
14
15
enum
FloatType
{
16
FP_NAN
= 1,
17
FP_INFINITE
= 2,
18
FP_ZERO
= 3,
19
FP_NORMAL
= 4,
20
FP_SUBNORMAL
= 5
21
};
22
23
static
inline
s32
__fpclassifyf
(
float
x
)
24
{
25
const
s32
exp_mask = 0x7F800000;
26
const
s32
mantissa_mask = 0x007FFFFF;
27
switch
((*(
s32
*) &
x
) & exp_mask) {
28
case
exp_mask:
29
return
((*(
s32
*) &
x
) & mantissa_mask) ?
FP_NAN
:
FP_INFINITE
;
30
case
0:
31
return
((*(
s32
*) &
x
) & mantissa_mask) ?
FP_SUBNORMAL
:
FP_ZERO
;
32
default
:
33
return
FP_NORMAL
;
34
}
35
}
36
37
extern
int
__HI
(
double
);
38
extern
int
__LO
(
double
);
39
40
static
inline
s32
__fpclassifyd
(
double
x
)
41
{
42
switch
(
__HI
(
x
) & 0x7ff00000) {
43
case
0x7ff00000:
44
return
((
__HI
(
x
) & 0x000fffff) || (
__LO
(
x
) & 0xffffffff))
45
?
FP_NAN
46
:
FP_INFINITE
;
47
case
0:
48
return
((
__HI
(
x
) & 0x000fffff) || (
__LO
(
x
) & 0xffffffff))
49
?
FP_SUBNORMAL
50
:
FP_ZERO
;
51
default
:
52
return
FP_NORMAL
;
53
}
54
}
55
56
#define fpclassify(x) \
57
((sizeof(x) == sizeof(float)) ? __fpclassifyf((float) (x)) \
58
: __fpclassifyd((double) (x)))
59
60
#ifdef MWERKS_GEKKO
61
#define fabsf __fabsf
62
static
inline
double
fabs
(
double
f)
63
{
64
return
__fabs
(f);
65
}
66
#endif
67
68
double
fabs
(
double
);
69
double
frexp
(
double
x
,
int
* exponent);
70
float
acosf
(
float
);
71
float
asinf
(
float
);
72
float
atan2f
(
float
y
,
float
x
);
73
float
atanf
(
float
);
74
float
cos__Ff
(
float
x
);
75
float
cosf
(
float
);
76
float
expf
(
float
);
77
float
fabsf
(
float
);
78
float
fabsf__Ff
(
float
);
79
float
logf
(
float
);
80
float
sin__Ff
(
float
x
);
81
float
sinf
(
float
);
82
float
sqrt
(
double
);
83
float
sqrtf
(
float
);
84
void
__sinit_trigf_c
(
void
);
85
86
static
inline
float
fmodf
(
float
a,
float
b)
87
{
88
s64
quotient;
89
90
if
(
fabsf
(b) >
fabsf
(a)) {
91
return
a;
92
}
93
quotient = a / b;
94
return
a - b * quotient;
95
}
96
97
#endif
__LO
#define __LO(x)
Definition
ansi_fp.c:6
__HI
#define __HI(x)
Definition
ansi_fp.c:5
intrinsics.h
s32
signed int s32
Definition
types.h:12
s64
signed long long int s64
Definition
types.h:15
FP_NAN
#define FP_NAN
Definition
math.h:90
FP_ZERO
#define FP_ZERO
Definition
math.h:92
sqrtf
float sqrtf(float x)
Definition
math.h:30
FP_INFINITE
#define FP_INFINITE
Definition
math.h:91
sqrt
float sqrt(float x)
@TODO: this isn't correct! It's just to generate sdata2 in GXDraw.o
Definition
math.h:55
cosf
float cosf(float x)
Definition
trigf.c:68
__fpclassifyd
long __fpclassifyd(double x)
sinf
float sinf(float x)
Definition
trigf.c:24
fmodf
float fmodf(float x, float m)
Definition
math.h:101
fabs
double fabs(double x)
acosf
float acosf(float x)
Definition
lbtrigf.c:45
fabsf
float fabsf(float x)
__fpclassifyf
long __fpclassifyf(float x)
FP_NORMAL
#define FP_NORMAL
Definition
math.h:93
FP_SUBNORMAL
#define FP_SUBNORMAL
Definition
math.h:94
math_ppc.h
__fabs
#define __fabs(f)
Definition
placeholder.h:17
platform.h
expf
float expf(float)
Definition
lb_00CE.c:27
sin__Ff
float sin__Ff(float x)
Definition
trigf.c:109
frexp
double frexp(double x, int *exponent)
Definition
math_1.c:13
fabsf__Ff
float fabsf__Ff(float)
Definition
math_1.c:8
cos__Ff
float cos__Ff(float x)
Definition
trigf.c:114
asinf
float asinf(float)
Definition
lbtrigf.c:63
logf
float logf(float)
Definition
math.c:64
FloatType
FloatType
Definition
math.h:15
__sinit_trigf_c
void __sinit_trigf_c(void)
Definition
trigf.c:14
atanf
float atanf(float)
atan2f
float atan2f(float y, float x)
Definition
lbtrigf.c:22
y
int y
Definition
types.h:1
x
int x
Definition
types.h:0
src
MSL
math.h
Generated by
1.17.0