Twilight Princess
Decompilation of The Legend of Zelda: Twilight Princess
Loading...
Searching...
No Matches
JMath.h
Go to the documentation of this file.
1#ifndef JMATH_H
2#define JMATH_H
3
4#include "dolphin/mtx.h"
5
6void JMAMTXApplyScale(const Mtx, Mtx, f32, f32, f32);
9void JMAFastVECNormalize(register const Vec* src, register Vec* dst);
10void JMAVECScaleAdd(register const Vec* vec1, register const Vec* vec2, register Vec* dst,
11 register f32 scale);
12
13inline int JMAAbs(int value) {
14 return (value >> 0x1f ^ value) - (value >> 0x1f);
15}
16
17inline f32 JMAFastReciprocal(f32 value) {
18 return __fres(value);
19}
20
21inline float __frsqrtes(register double f) {
22 register float out;
23 // clang-format off
24 asm {
25 frsqrte out, f
26 }
27 // clang-format on
28 return out;
29}
30
31inline f32 JMAFastSqrt(register f32 input) {
32 if (input > 0.0f) {
33 register f32 out;
34 asm {
35 frsqrte out, input
36 }
37 return out * input;
38 } else {
39 return input;
40 }
41}
42
43inline f32 JMAHermiteInterpolation(register f32 p1, register f32 p2, register f32 p3,
44 register f32 p4, register f32 p5, register f32 p6,
45 register f32 p7) {
46 register f32 ff25;
47 register f32 ff31;
48 register f32 ff30;
49 register f32 ff29;
50 register f32 ff28;
51 register f32 ff27;
52 register f32 ff26;
53 // clang-format off
54 asm {
55 fsubs ff31, p1, p2
56 fsubs ff30, p5, p2
61 fsubs ff30, p3, p6
68
69 }
70 // clang-format on
71 return ff25;
72}
73
74namespace JMath {
75
76inline f32 fastReciprocal(f32 value) {
77 return JMAFastReciprocal(value);
78}
79
80inline void gekko_ps_copy3(register void* dst, register const void* src) {
81 register f32 src0;
82 register f32 src1;
83 asm {
84 psq_l src0, 0(src), 0, 0
85 lfs src1, 8(src)
86 psq_st src0, 0(dst), 0, 0
87 stfs src1, 8(dst)
88 };
89}
90
91inline void gekko_ps_copy6(register void* dst, register const void* src) {
92 register f32 src0;
93 register f32 src1;
94 register f32 src2;
95 asm {
96 psq_l src0, 0(src), 0, 0
97 psq_l src1, 8(src), 0, 0
98 psq_l src2, 16(src), 0, 0
99 psq_st src0, 0(dst), 0, 0
100 psq_st src1, 8(dst), 0, 0
101 psq_st src2, 16(dst), 0, 0
102 };
103}
104
105inline void gekko_ps_copy12(register void* dst, register const void* src) {
106 register f32 src0;
107 register f32 src1;
108 register f32 src2;
109 register f32 src3;
110 register f32 src4;
111 register f32 src5;
112 asm {
113 psq_l src0, 0(src), 0, 0
114 psq_l src1, 8(src), 0, 0
115 psq_l src2, 16(src), 0, 0
116 psq_l src3, 24(src), 0, 0
117 psq_l src4, 32(src), 0, 0
118 psq_l src5, 40(src), 0, 0
119 psq_st src0, 0(dst), 0, 0
120 psq_st src1, 8(dst), 0, 0
121 psq_st src2, 16(dst), 0, 0
122 psq_st src3, 24(dst), 0, 0
123 psq_st src4, 32(dst), 0, 0
124 psq_st src5, 40(dst), 0, 0
125 };
126}
127
128inline void gekko_ps_copy16(register void* dst, register const void* src) {
129 register f32 src0;
130 register f32 src1;
131 register f32 src2;
132 register f32 src3;
133 register f32 src4;
134 register f32 src5;
135 register f32 src6;
136 register f32 src7;
137 asm {
138 psq_l src0, 0(src), 0, 0
139 psq_l src1, 8(src), 0, 0
140 psq_l src2, 16(src), 0, 0
141 psq_l src3, 24(src), 0, 0
142 psq_l src4, 32(src), 0, 0
143 psq_l src5, 40(src), 0, 0
144 psq_l src6, 48(src), 0, 0
145 psq_l src7, 56(src), 0, 0
146 psq_st src0, 0(dst), 0, 0
147 psq_st src1, 8(dst), 0, 0
148 psq_st src2, 16(dst), 0, 0
149 psq_st src3, 24(dst), 0, 0
150 psq_st src4, 32(dst), 0, 0
151 psq_st src5, 40(dst), 0, 0
152 psq_st src6, 48(dst), 0, 0
153 psq_st src7, 56(dst), 0, 0
154 };
155}
156
157}; // namespace JMath
158
159#endif /* JMATH_H */
f32 JMAFastSqrt(register f32 input)
Definition JMath.h:31
float __frsqrtes(register double f)
Definition JMath.h:21
void JMAEulerToQuat(s16 param_0, s16 param_1, s16 param_2, Quaternion *param_3)
Definition JMath.cpp:11
f32 JMAFastReciprocal(f32 value)
Definition JMath.h:17
void JMAVECScaleAdd(register const Vec *vec1, register const Vec *vec2, register Vec *dst, register f32 scale)
Definition JMath.cpp:84
void JMAQuatLerp(const Quaternion *, const Quaternion *, f32, Quaternion *)
int JMAAbs(int value)
Definition JMath.h:13
f32 JMAHermiteInterpolation(register f32 p1, register f32 p2, register f32 p3, register f32 p4, register f32 p5, register f32 p6, register f32 p7)
Definition JMath.h:43
void JMAFastVECNormalize(register const Vec *src, register Vec *dst)
Definition JMath.cpp:64
void JMAMTXApplyScale(const Mtx, Mtx, f32, f32, f32)
T cLib_calcTimer(T *value)
Definition c_lib.h:74
f32 Mtx[3][4]
Definition mtx.h:15
Definition JMATrigonometric.cpp:78
void gekko_ps_copy3(register void *dst, register const void *src)
Definition JMath.h:80
f32 fastReciprocal(f32 value)
Definition JMath.h:76
void gekko_ps_copy6(register void *dst, register const void *src)
Definition JMath.h:91
void gekko_ps_copy12(register void *dst, register const void *src)
Definition JMath.h:105
void gekko_ps_copy16(register void *dst, register const void *src)
Definition JMath.h:128
Definition d_a_hozelda.cpp:16
Definition d_a_hozelda.cpp:18
float f32
Definition types.h:22
signed short s16
Definition types.h:5