summaryrefslogtreecommitdiff
path: root/src/code
diff options
context:
space:
mode:
Diffstat (limited to 'src/code')
-rw-r--r--src/code/code_800FCE80.c100
-rw-r--r--src/code/code_800FD970.c18
-rw-r--r--src/code/sys_math.c31
-rw-r--r--src/code/sys_math3d.c4
-rw-r--r--src/code/sys_math_atan.c26
-rw-r--r--src/code/sys_matrix.c56
-rw-r--r--src/code/z_actor.c154
-rw-r--r--src/code/z_camera.c118
-rw-r--r--src/code/z_demo.c2
-rw-r--r--src/code/z_eff_blure.c24
-rw-r--r--src/code/z_eff_shield_particle.c7
-rw-r--r--src/code/z_eff_spark.c20
-rw-r--r--src/code/z_eff_ss_dead.c8
-rw-r--r--src/code/z_effect_soft_sprite_old_init.c40
-rw-r--r--src/code/z_elf_message.c2
-rw-r--r--src/code/z_en_a_keep.c4
-rw-r--r--src/code/z_en_item00.c42
-rw-r--r--src/code/z_fbdemo_fade.c6
-rw-r--r--src/code/z_kankyo.c2
-rw-r--r--src/code/z_lib.c292
-rw-r--r--src/code/z_olib.c16
-rw-r--r--src/code/z_path.c2
-rw-r--r--src/code/z_play.c2
-rw-r--r--src/code/z_player_lib.c12
-rw-r--r--src/code/z_quake.c22
-rw-r--r--src/code/z_scene.c6
-rw-r--r--src/code/z_scene_table.c24
-rw-r--r--src/code/z_skelanime.c16
-rw-r--r--src/code/z_skin_matrix.c28
29 files changed, 563 insertions, 521 deletions
diff --git a/src/code/code_800FCE80.c b/src/code/code_800FCE80.c
index 2acf1ed02..d81d4f91b 100644
--- a/src/code/code_800FCE80.c
+++ b/src/code/code_800FCE80.c
@@ -1,38 +1,38 @@
#include "global.h"
#include "fp.h"
-s32 use_cfrac;
+s32 gUseAtanContFrac;
-f32 Math_tanf(f32 x) {
+f32 Math_FTanF(f32 x) {
f32 sin = sinf(x);
f32 cos = cosf(x);
return sin / cos;
}
-f32 Math_floorf(f32 x) {
+f32 Math_FFloorF(f32 x) {
return floorf(x);
}
-f32 Math_ceilf(f32 x) {
+f32 Math_FCeilF(f32 x) {
return ceilf(x);
}
-f32 Math_roundf(f32 x) {
+f32 Math_FRoundF(f32 x) {
return roundf(x);
}
-f32 Math_truncf(f32 x) {
+f32 Math_FTruncF(f32 x) {
return truncf(x);
}
-f32 Math_nearbyintf(f32 x) {
+f32 Math_FNearbyIntF(f32 x) {
return nearbyintf(x);
}
/* Arctangent approximation using a Taylor series (one quadrant) */
-f32 Math_atanf_taylor_q(f32 x) {
+f32 Math_FAtanTaylorQF(f32 x) {
static const f32 coeffs[] = {
- -1.f / 3, +1.f / 5, -1.f / 7, +1.f / 9, -1.f / 11, +1.f / 13, -1.f / 15, +1.f / 17, 0.f,
+ -1.0f / 3, +1.0f / 5, -1.0f / 7, +1.0f / 9, -1.0f / 11, +1.0f / 13, -1.0f / 15, +1.0f / 17, 0.0f,
};
f32 poly = x;
@@ -54,31 +54,31 @@ f32 Math_atanf_taylor_q(f32 x) {
}
/* Ditto for two quadrants */
-f32 Math_atanf_taylor(f32 x) {
+f32 Math_FAtanTaylorF(f32 x) {
f32 t;
f32 q;
- if (x > 0.f) {
+ if (x > 0.0f) {
t = x;
- } else if (x < 0.f) {
+ } else if (x < 0.0f) {
t = -x;
- } else if (x == 0.f) {
- return 0.f;
+ } else if (x == 0.0f) {
+ return 0.0f;
} else {
return qNaN0x10000;
}
- if (t <= M_SQRT2 - 1.f) {
- return Math_atanf_taylor_q(x);
+ if (t <= M_SQRT2 - 1.0f) {
+ return Math_FAtanTaylorQF(x);
}
- if (t >= M_SQRT2 + 1.f) {
- q = M_PI / 2 - Math_atanf_taylor_q(1.f / t);
+ if (t >= M_SQRT2 + 1.0f) {
+ q = M_PI / 2 - Math_FAtanTaylorQF(1.0f / t);
} else {
- q = M_PI / 4 - Math_atanf_taylor_q((1.f - t) / (1.f + t));
+ q = M_PI / 4 - Math_FAtanTaylorQF((1.0f - t) / (1.0f + t));
}
- if (x > 0.f) {
+ if (x > 0.0f) {
return q;
} else {
return -q;
@@ -86,33 +86,33 @@ f32 Math_atanf_taylor(f32 x) {
}
/* Arctangent approximation using a continued fraction */
-f32 Math_atanf_cfrac(f32 x) {
+f32 Math_FAtanContFracF(f32 x) {
s32 sector;
f32 z;
f32 conv;
f32 sq;
s32 i;
- if (x >= -1.f && x <= 1.f) {
+ if (x >= -1.0f && x <= 1.0f) {
sector = 0;
- } else if (x > 1.f) {
+ } else if (x > 1.0f) {
sector = 1;
- x = 1.f / x;
- } else if (x < -1.f) {
+ x = 1.0f / x;
+ } else if (x < -1.0f) {
sector = -1;
- x = 1.f / x;
+ x = 1.0f / x;
} else {
return qNaN0x10000;
}
sq = SQ(x);
- conv = 0.f;
- z = 8.f;
+ conv = 0.0f;
+ z = 8.0f;
for (i = 8; i != 0; i--) {
- conv = SQ(z) * sq / (2.f * z + 1.f + conv);
- z -= 1.f;
+ conv = SQ(z) * sq / (2.0f * z + 1.0f + conv);
+ z -= 1.0f;
}
- conv = x / (1.f + conv);
+ conv = x / (1.0f + conv);
if (sector == 0) {
return conv;
@@ -123,38 +123,38 @@ f32 Math_atanf_cfrac(f32 x) {
}
}
-f32 Math_atanf(f32 x) {
- if (use_cfrac == 0) {
- return Math_atanf_taylor(x);
+f32 Math_FAtanF(f32 x) {
+ if (!gUseAtanContFrac) {
+ return Math_FAtanTaylorF(x);
} else {
- return Math_atanf_cfrac(x);
+ return Math_FAtanContFracF(x);
}
}
-f32 Math_atan2f(f32 y, f32 x) {
- if (x == 0.f) {
- if (y == 0.f) {
- return 0.f;
- } else if (y > 0.f) {
+f32 Math_FAtan2F(f32 y, f32 x) {
+ if (x == 0.0f) {
+ if (y == 0.0f) {
+ return 0.0f;
+ } else if (y > 0.0f) {
return M_PI / 2;
- } else if (y < 0.f) {
+ } else if (y < 0.0f) {
return -M_PI / 2;
} else {
return qNaN0x10000;
}
- } else if (x >= 0.f) {
- return Math_atanf(y / x);
- } else if (y < 0.f) {
- return Math_atanf(y / x) - M_PI;
+ } else if (x >= 0.0f) {
+ return Math_FAtanF(y / x);
+ } else if (y < 0.0f) {
+ return Math_FAtanF(y / x) - M_PI;
} else {
- return M_PI - Math_atanf(-(y / x));
+ return M_PI - Math_FAtanF(-(y / x));
}
}
-f32 Math_asinf(f32 x) {
- return Math_atan2f(x, sqrtf(1.f - SQ(x)));
+f32 Math_FAsinF(f32 x) {
+ return Math_FAtan2F(x, sqrtf(1.0f - SQ(x)));
}
-f32 Math_acosf(f32 x) {
- return M_PI / 2 - Math_asinf(x);
+f32 Math_FAcosF(f32 x) {
+ return M_PI / 2 - Math_FAsinF(x);
}
diff --git a/src/code/code_800FD970.c b/src/code/code_800FD970.c
index 04d5f8118..7478bfe0b 100644
--- a/src/code/code_800FD970.c
+++ b/src/code/code_800FD970.c
@@ -9,14 +9,14 @@ static u32 sRandFloat;
/**
* Gets the next integer in the sequence of pseudo-random numbers.
*/
-u32 Math_Rand_Next(void) {
+u32 Rand_Next(void) {
return sRandInt = (sRandInt * 1664525) + 1013904223;
}
/**
* Seeds the pseudo-random number generator by providing a starting value.
*/
-void Math_Rand_Seed(u32 seed) {
+void Rand_Seed(u32 seed) {
sRandInt = seed;
}
@@ -25,7 +25,7 @@ void Math_Rand_Seed(u32 seed) {
* the next integer and masking it to an IEEE-754 compliant floating-point number
* between 1.0f and 2.0f, returning the result subtract 1.0f.
*/
-f32 Math_Rand_ZeroOne(void) {
+f32 Rand_ZeroOne(void) {
sRandInt = (sRandInt * 1664525) + 1013904223;
sRandFloat = ((sRandInt >> 9) | 0x3F800000);
return *((f32*)&sRandFloat) - 1.0f;
@@ -33,9 +33,9 @@ f32 Math_Rand_ZeroOne(void) {
/**
* Returns a pseudo-random floating-point number between -0.5f and 0.5f by the same
- * manner in which Math_Rand_ZeroOne generates its result.
+ * manner in which Rand_ZeroOne generates its result.
*/
-f32 Math_Rand_Centered(void) {
+f32 Rand_Centered(void) {
sRandInt = (sRandInt * 1664525) + 1013904223;
sRandFloat = ((sRandInt >> 9) | 0x3F800000);
return *((f32*)&sRandFloat) - 1.5f;
@@ -44,14 +44,14 @@ f32 Math_Rand_Centered(void) {
/**
* Seeds a pseudo-random number at rndNum with a provided seed.
*/
-void Math_Rand_Seed_Variable(u32* rndNum, u32 seed) {
+void Rand_Seed_Variable(u32* rndNum, u32 seed) {
*rndNum = seed;
}
/**
* Generates the next pseudo-random integer from the provided rndNum.
*/
-u32 Math_Rand_Next_Variable(u32* rndNum) {
+u32 Rand_Next_Variable(u32* rndNum) {
return *rndNum = (*rndNum * 1664525) + 1013904223;
}
@@ -59,7 +59,7 @@ u32 Math_Rand_Next_Variable(u32* rndNum) {
* Generates the next pseudo-random floating-point number between 0.0f and
* 1.0f from the provided rndNum.
*/
-f32 Math_Rand_ZeroOne_Variable(u32* rndNum) {
+f32 Rand_ZeroOne_Variable(u32* rndNum) {
u32 next;
next = (*rndNum * 1664525) + 1013904223;
@@ -73,7 +73,7 @@ f32 Math_Rand_ZeroOne_Variable(u32* rndNum) {
* Generates the next pseudo-random floating-point number between -0.5f and
* 0.5f from the provided rndNum.
*/
-f32 Math_Rand_Centered_Variable(u32* rndNum) {
+f32 Rand_Centered_Variable(u32* rndNum) {
u32 next;
next = (*rndNum * 1664525) + 1013904223;
diff --git a/src/code/sys_math.c b/src/code/sys_math.c
index 87a1eacd8..c72d8cbee 100644
--- a/src/code/sys_math.c
+++ b/src/code/sys_math.c
@@ -3,42 +3,45 @@
f32 sFactorialTbl[] = { 1.0f, 1.0f, 2.0f, 6.0f, 24.0f, 120.0f, 720.0f,
5040.0f, 40320.0f, 362880.0f, 3628800.0f, 39916800.0f, 479001600.0f };
-f32 func_800CA540(f32 arg0) {
+f32 Math_FactorialF(f32 n) {
f32 ret = 1.0f;
s32 i;
- for (i = arg0; i > 1; i--) {
+
+ for (i = n; i > 1; i--) {
ret *= i;
}
return ret;
}
-f32 func_800CA63C(u32 arg0) {
+f32 Math_Factorial(s32 n) {
f32 ret;
s32 i;
- if (arg0 > 12) {
+
+ if (n > 12U) {
ret = sFactorialTbl[12];
- for (i = 13; i <= (s32)arg0; i++) {
+ for (i = 13; i <= n; i++) {
ret *= i;
}
} else {
- ret = sFactorialTbl[arg0];
+ ret = sFactorialTbl[n];
}
return ret;
}
-f32 func_800CA6FC(f32 arg0, s32 arg1) {
+f32 Math_PowF(f32 base, s32 exp) {
f32 ret = 1.0f;
- while (arg1 > 0) {
- arg1--;
- ret *= arg0;
+
+ while (exp > 0) {
+ exp--;
+ ret *= base;
}
return ret;
}
-f32 func_800CA720(f32 arg0) {
- return sins((s16)(arg0 * (32767.0f / M_PI))) * SHT_MINV;
+f32 Math_SinF(f32 angle) {
+ return sins((s16)(angle * (32767.0f / M_PI))) * SHT_MINV;
}
-f32 func_800CA774(f32 arg0) {
- return coss((s16)(arg0 * (32767.0f / M_PI))) * SHT_MINV;
+f32 Math_CosF(f32 angle) {
+ return coss((s16)(angle * (32767.0f / M_PI))) * SHT_MINV;
}
diff --git a/src/code/sys_math3d.c b/src/code/sys_math3d.c
index 4a0006c32..04a7fa864 100644
--- a/src/code/sys_math3d.c
+++ b/src/code/sys_math3d.c
@@ -870,8 +870,8 @@ s32 Math3D_LineVsCubeShort(Vec3s* min, Vec3s* max, Vec3s* a, Vec3s* b) {
* outputs the plane equation `a``pointOnPlane->x` + 0y + `c``pointOnPlane->z`+`d` = 0
*/
void Math3D_RotateXZPlane(Vec3f* pointOnPlane, s16 angle, f32* a, f32* c, f32* d) {
- *a = Math_Sins(angle) * 32767.0f;
- *c = Math_Coss(angle) * 32767.0f;
+ *a = Math_SinS(angle) * 32767.0f;
+ *c = Math_CosS(angle) * 32767.0f;
*d = -((*a * pointOnPlane->x) + (*c * pointOnPlane->z));
}
diff --git a/src/code/sys_math_atan.c b/src/code/sys_math_atan.c
index b468818c8..d2f1b3467 100644
--- a/src/code/sys_math_atan.c
+++ b/src/code/sys_math_atan.c
@@ -1,6 +1,6 @@
#include "global.h"
-u16 sATan2Tbl[] = {
+static u16 sATan2Tbl[] = {
0x0000, 0x000A, 0x0014, 0x001F, 0x0029, 0x0033, 0x003D, 0x0047, 0x0051, 0x005C, 0x0066, 0x0070, 0x007A, 0x0084,
0x008F, 0x0099, 0x00A3, 0x00AD, 0x00B7, 0x00C2, 0x00CC, 0x00D6, 0x00E0, 0x00EA, 0x00F4, 0x00FF, 0x0109, 0x0113,
0x011D, 0x0127, 0x0131, 0x013C, 0x0146, 0x0150, 0x015A, 0x0164, 0x016F, 0x0179, 0x0183, 0x018D, 0x0197, 0x01A1,
@@ -77,7 +77,7 @@ u16 sATan2Tbl[] = {
0x1FF6, 0x1FFB, 0x2000,
};
-u16 GetAtan2Tbl(f32 x, f32 y) {
+u16 Math_GetAtan2Tbl(f32 x, f32 y) {
s32 tblIdx;
u16 ret;
@@ -93,41 +93,41 @@ u16 GetAtan2Tbl(f32 x, f32 y) {
return ret;
}
-s16 atan2s(f32 x, f32 y) {
+s16 Math_Atan2S(f32 x, f32 y) {
s32 ret;
if (y >= 0.0f) {
if (x >= 0.0f) {
if (y <= x) {
- ret = GetAtan2Tbl(y, x);
+ ret = Math_GetAtan2Tbl(y, x);
} else {
- ret = 0x4000 - GetAtan2Tbl(x, y);
+ ret = 0x4000 - Math_GetAtan2Tbl(x, y);
}
} else {
if (-x < y) {
- ret = GetAtan2Tbl(-x, y) + 0x4000;
+ ret = Math_GetAtan2Tbl(-x, y) + 0x4000;
} else {
- ret = 0x8000 - GetAtan2Tbl(y, -x);
+ ret = 0x8000 - Math_GetAtan2Tbl(y, -x);
}
}
} else {
if (x < 0.0f) {
if (-y <= -x) {
- ret = GetAtan2Tbl(-y, -x) + 0x8000;
+ ret = Math_GetAtan2Tbl(-y, -x) + 0x8000;
} else {
- ret = 0xC000 - GetAtan2Tbl(-x, -y);
+ ret = 0xC000 - Math_GetAtan2Tbl(-x, -y);
}
} else {
if (x < -y) {
- ret = GetAtan2Tbl(x, -y) + 0xC000;
+ ret = Math_GetAtan2Tbl(x, -y) + 0xC000;
} else {
- ret = -GetAtan2Tbl(-y, x);
+ ret = -Math_GetAtan2Tbl(-y, x);
}
}
}
return ret;
}
-f32 atan2f(f32 x, f32 y) {
- return atan2s(x, y) * (M_PI / 32768.0f);
+f32 Math_Atan2F(f32 x, f32 y) {
+ return Math_Atan2S(x, y) * (M_PI / 32768.0f);
}
diff --git a/src/code/sys_matrix.c b/src/code/sys_matrix.c
index ab800b5bf..0ce2e74c2 100644
--- a/src/code/sys_matrix.c
+++ b/src/code/sys_matrix.c
@@ -308,8 +308,8 @@ void Matrix_RotateRPY(s16 x, s16 y, s16 z, u8 mode) {
f32 cos;
if (mode == MTXMODE_APPLY) {
- sin = Math_Sins(z);
- cos = Math_Coss(z);
+ sin = Math_SinS(z);
+ cos = Math_CosS(z);
temp1 = cmf->xx;
temp2 = cmf->yx;
@@ -332,8 +332,8 @@ void Matrix_RotateRPY(s16 x, s16 y, s16 z, u8 mode) {
cmf->yw = temp2 * cos - temp1 * sin;
if (y != 0) {
- sin = Math_Sins(y);
- cos = Math_Coss(y);
+ sin = Math_SinS(y);
+ cos = Math_CosS(y);
temp1 = cmf->xx;
temp2 = cmf->zx;
@@ -357,8 +357,8 @@ void Matrix_RotateRPY(s16 x, s16 y, s16 z, u8 mode) {
}
if (x != 0) {
- sin = Math_Sins(x);
- cos = Math_Coss(x);
+ sin = Math_SinS(x);
+ cos = Math_CosS(x);
temp1 = cmf->yx;
temp2 = cmf->zx;
@@ -395,8 +395,8 @@ void Matrix_JointPosition(Vec3f* position, Vec3s* rotation) {
f32 temp1;
f32 temp2;
- sin = Math_Sins(rotation->z);
- cos = Math_Coss(rotation->z);
+ sin = Math_SinS(rotation->z);
+ cos = Math_CosS(rotation->z);
temp1 = cmf->xx;
temp2 = cmf->yx;
@@ -423,8 +423,8 @@ void Matrix_JointPosition(Vec3f* position, Vec3s* rotation) {
cmf->yw = temp2 * cos - temp1 * sin;
if (rotation->y != 0) {
- sin = Math_Sins(rotation->y);
- cos = Math_Coss(rotation->y);
+ sin = Math_SinS(rotation->y);
+ cos = Math_CosS(rotation->y);
temp1 = cmf->xx;
temp2 = cmf->zx;
@@ -448,8 +448,8 @@ void Matrix_JointPosition(Vec3f* position, Vec3s* rotation) {
}
if (rotation->x != 0) {
- sin = Math_Sins(rotation->x);
- cos = Math_Coss(rotation->x);
+ sin = Math_SinS(rotation->x);
+ cos = Math_CosS(rotation->x);
temp1 = cmf->yx;
temp2 = cmf->zx;
@@ -480,8 +480,8 @@ void func_800D1694(f32 x, f32 y, f32 z, Vec3s* vec) {
f32 sp28;
f32 sp24;
- sp30 = Math_Sins(vec->y);
- sp2C = Math_Coss(vec->y);
+ sp30 = Math_SinS(vec->y);
+ sp2C = Math_CosS(vec->y);
cmf->xx = sp2C;
cmf->xz = -sp30;
@@ -494,8 +494,8 @@ void func_800D1694(f32 x, f32 y, f32 z, Vec3s* vec) {
cmf->ww = 1.0f;
if (vec->x != 0) {
- sp24 = Math_Sins(vec->x);
- sp28 = Math_Coss(vec->x);
+ sp24 = Math_SinS(vec->x);
+ sp28 = Math_CosS(vec->x);
cmf->zz = sp2C * sp28;
cmf->yz = sp2C * sp24;
@@ -513,8 +513,8 @@ void func_800D1694(f32 x, f32 y, f32 z, Vec3s* vec) {
}
if (vec->z != 0) {
- sp24 = Math_Sins(vec->z);
- sp28 = Math_Coss(vec->z);
+ sp24 = Math_SinS(vec->z);
+ sp28 = Math_CosS(vec->z);
sp30 = cmf->xx;
sp2C = cmf->yx;
@@ -752,17 +752,17 @@ void func_800D20CC(MtxF* mf, Vec3s* vec, s32 flag) {
temp = mf->zx;
temp *= temp;
temp += SQ(mf->zz);
- vec->x = Math_atan2f(-mf->zy, sqrtf(temp)) * (32768 / M_PI);
+ vec->x = Math_FAtan2F(-mf->zy, sqrtf(temp)) * (32768 / M_PI);
if ((vec->x == 0x4000) || (vec->x == -0x4000)) {
vec->z = 0;
- vec->y = Math_atan2f(-mf->xz, mf->xx) * (32768 / M_PI);
+ vec->y = Math_FAtan2F(-mf->xz, mf->xx) * (32768 / M_PI);
} else {
- vec->y = Math_atan2f(mf->zx, mf->zz) * (32768 / M_PI);
+ vec->y = Math_FAtan2F(mf->zx, mf->zz) * (32768 / M_PI);
if (!flag) {
- vec->z = Math_atan2f(mf->xy, mf->yy) * (32768 / M_PI);
+ vec->z = Math_FAtan2F(mf->xy, mf->yy) * (32768 / M_PI);
} else {
temp = mf->xx;
temp4 = mf->xz;
@@ -783,7 +783,7 @@ void func_800D20CC(MtxF* mf, Vec3s* vec, s32 flag) {
temp2 = sqrtf(temp2);
temp2 = temp3 / temp2;
- vec->z = Math_atan2f(temp, temp2) * (32768 / M_PI);
+ vec->z = Math_FAtan2F(temp, temp2) * (32768 / M_PI);
}
}
}
@@ -800,18 +800,18 @@ void func_800D2264(MtxF* mf, Vec3s* vec, s32 flag) {
temp = mf->xx;
temp *= temp;
temp += SQ(mf->xy);
- vec->y = Math_atan2f(-mf->xz, sqrtf(temp)) * (32768 / M_PI);
+ vec->y = Math_FAtan2F(-mf->xz, sqrtf(temp)) * (32768 / M_PI);
if ((vec->y == 0x4000) || (vec->y == -0x4000)) {
vec->x = 0;
- vec->z = Math_atan2f(-mf->yx, mf->yy) * (32768 / M_PI);
+ vec->z = Math_FAtan2F(-mf->yx, mf->yy) * (32768 / M_PI);
return;
}
- vec->z = Math_atan2f(mf->xy, mf->xx) * (32768 / M_PI);
+ vec->z = Math_FAtan2F(mf->xy, mf->xx) * (32768 / M_PI);
if (!flag) {
- vec->x = Math_atan2f(mf->yz, mf->zz) * (32768 / M_PI);
+ vec->x = Math_FAtan2F(mf->yz, mf->zz) * (32768 / M_PI);
} else {
temp = mf->yx;
temp *= temp;
@@ -827,7 +827,7 @@ void func_800D2264(MtxF* mf, Vec3s* vec, s32 flag) {
temp2 = sqrtf(temp2);
temp2 = mf->zz / temp2;
- vec->x = Math_atan2f(temp, temp2) * (32768 / M_PI);
+ vec->x = Math_FAtan2F(temp, temp2) * (32768 / M_PI);
}
}
#else
diff --git a/src/code/z_actor.c b/src/code/z_actor.c
index 42c96d473..331837e71 100644
--- a/src/code/z_actor.c
+++ b/src/code/z_actor.c
@@ -28,7 +28,7 @@ void func_8002B200(Actor* actor, Lights* lights, GlobalContext* globalCtx, Gfx*
COMBINED);
temp1 = (temp1 < 0.0f) ? 0.0f : ((temp1 > 150.0f) ? 150.0f : temp1);
- temp2 = 1.0f - (temp1 * (1.f / 350));
+ temp2 = 1.0f - (temp1 * (1.0f / 350));
if (color != NULL) {
gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, color->r, color->g, color->b,
@@ -44,7 +44,7 @@ void func_8002B200(Actor* actor, Lights* lights, GlobalContext* globalCtx, Gfx*
Matrix_RotateY(actor->shape.rot.y * (M_PI / 32768), MTXMODE_APPLY);
}
- temp2 = (1.0f - (temp1 * (1.f / 350))) * actor->shape.unk_10;
+ temp2 = (1.0f - (temp1 * (1.0f / 350))) * actor->shape.unk_10;
Matrix_Scale(actor->scale.x * temp2, 1.0f, actor->scale.z * temp2, MTXMODE_APPLY);
gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_actor.c", 1588),
@@ -80,7 +80,7 @@ void func_8002B66C(GlobalContext* globalCtx, Light* light, MtxF* arg2, s32 arg3,
gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 0, 0, 0,
(u32)(((arg3 * 0.00005f) > 1.0f ? 1.0f : (arg3 * 0.00005f)) * arg4) & 0xFF);
- sp58 = Math_atan2f(light->l.dir[0], light->l.dir[2]);
+ sp58 = Math_FAtan2F(light->l.dir[0], light->l.dir[2]);
arg6 *= (4.5f - (light->l.dir[1] * 0.035f));
arg6 = (arg6 < 1.0f) ? 1.0f : arg6;
Matrix_Put(arg2);
@@ -463,7 +463,7 @@ void func_8002C7BC(TargetContext* targetCtx, Player* player, Actor* actorArg, Gl
unkActor = &player->actor;
}
- if (Math_ApproxF(&targetCtx->unk_40, 0.0f, 0.25f) == 0) {
+ if (Math_StepToF(&targetCtx->unk_40, 0.0f, 0.25f) == 0) {
temp1 = 0.25f / targetCtx->unk_40;
temp2 = unkActor->posRot.pos.x - targetCtx->naviRefPos.x;
temp3 = (unkActor->posRot.pos.y + (unkActor->unk_4C * unkActor->scale.y)) - targetCtx->naviRefPos.y;
@@ -502,7 +502,7 @@ void func_8002C7BC(TargetContext* targetCtx, Player* player, Actor* actorArg, Gl
if (targetCtx->unk_4B == 0) {
temp5 = (500.0f - targetCtx->unk_44) * 3.0f;
temp6 = (temp5 < 30.0f) ? 30.0f : ((100.0f < temp5) ? 100.0f : temp5);
- if (Math_ApproxF(&targetCtx->unk_44, 80.0f, temp6) != 0) {
+ if (Math_StepToF(&targetCtx->unk_44, 80.0f, temp6) != 0) {
targetCtx->unk_4B++;
}
} else {
@@ -511,7 +511,7 @@ void func_8002C7BC(TargetContext* targetCtx, Player* player, Actor* actorArg, Gl
}
} else {
targetCtx->targetedActor = NULL;
- Math_ApproxF(&targetCtx->unk_44, 500.0f, 80.0f);
+ Math_StepToF(&targetCtx->unk_44, 500.0f, 80.0f);
}
}
@@ -697,11 +697,11 @@ void TitleCard_InitPlaceName(GlobalContext* globalCtx, TitleCardContext* titleCt
void TitleCard_Update(GlobalContext* globalCtx, TitleCardContext* titleCtx) {
if (DECR(titleCtx->delayB) == 0) {
if (DECR(titleCtx->delayA) == 0) {
- Math_ApproxS(&titleCtx->unk_C, 0, 30);
- Math_ApproxS(&titleCtx->unk_E, 0, 70);
+ Math_StepToS(&titleCtx->unk_C, 0, 30);
+ Math_StepToS(&titleCtx->unk_E, 0, 70);
} else {
- Math_ApproxS(&titleCtx->unk_C, 255, 10);
- Math_ApproxS(&titleCtx->unk_E, 255, 20);
+ Math_StepToS(&titleCtx->unk_C, 255, 10);
+ Math_StepToS(&titleCtx->unk_E, 255, 20);
}
}
}
@@ -853,8 +853,8 @@ void func_8002D7EC(Actor* actor) {
}
void func_8002D868(Actor* actor) {
- actor->velocity.x = Math_Sins(actor->posRot.rot.y) * actor->speedXZ;
- actor->velocity.z = Math_Coss(actor->posRot.rot.y) * actor->speedXZ;
+ actor->velocity.x = Math_SinS(actor->posRot.rot.y) * actor->speedXZ;
+ actor->velocity.z = Math_CosS(actor->posRot.rot.y) * actor->speedXZ;
actor->velocity.y += actor->gravity;
if (actor->velocity.y < actor->minVelocityY) {
@@ -868,10 +868,10 @@ void Actor_MoveForward(Actor* actor) {
}
void func_8002D908(Actor* actor) {
- f32 sp24 = Math_Coss(actor->posRot.rot.x) * actor->speedXZ;
- actor->velocity.x = Math_Sins(actor->posRot.rot.y) * sp24;
- actor->velocity.y = Math_Sins(actor->posRot.rot.x) * actor->speedXZ;
- actor->velocity.z = Math_Coss(actor->posRot.rot.y) * sp24;
+ f32 sp24 = Math_CosS(actor->posRot.rot.x) * actor->speedXZ;
+ actor->velocity.x = Math_SinS(actor->posRot.rot.y) * sp24;
+ actor->velocity.y = Math_SinS(actor->posRot.rot.x) * actor->speedXZ;
+ actor->velocity.z = Math_CosS(actor->posRot.rot.y) * sp24;
}
void func_8002D97C(Actor* actor) {
@@ -880,8 +880,8 @@ void func_8002D97C(Actor* actor) {
}
void func_8002D9A4(Actor* actor, f32 arg1) {
- actor->speedXZ = Math_Coss(actor->posRot.rot.x) * arg1;
- actor->velocity.y = -Math_Sins(actor->posRot.rot.x) * arg1;
+ actor->speedXZ = Math_CosS(actor->posRot.rot.x) * arg1;
+ actor->velocity.y = -Math_SinS(actor->posRot.rot.x) * arg1;
}
void func_8002D9F8(Actor* actor, SkelAnime* skelAnime) {
@@ -938,8 +938,8 @@ void func_8002DBD0(Actor* actor, Vec3f* result, Vec3f* arg2) {
f32 deltaX;
f32 deltaZ;
- cosRot2Y = Math_Coss(actor->shape.rot.y);
- sinRot2Y = Math_Sins(actor->shape.rot.y);
+ cosRot2Y = Math_CosS(actor->shape.rot.y);
+ sinRot2Y = Math_SinS(actor->shape.rot.y);
deltaX = arg2->x - actor->posRot.pos.x;
deltaZ = arg2->z - actor->posRot.pos.z;
@@ -1223,7 +1223,7 @@ void func_8002E4B4(GlobalContext* globalCtx, Actor* actor, f32 arg2, f32 arg3, f
&actor->wallPoly, &sp60, actor, arg2))) {
sp5C = actor->wallPoly;
Math_Vec3f_Copy(&actor->posRot.pos, &sp64);
- actor->wallPolyRot = atan2s(sp5C->norm.z, sp5C->norm.x);
+ actor->wallPolyRot = Math_Atan2S(sp5C->norm.z, sp5C->norm.x);
actor->bgCheckFlags |= 8;
actor->wallPolySource = sp60;
} else {
@@ -1829,7 +1829,7 @@ void func_8002FBAC(GlobalContext* globalCtx) {
sp9C = (1.0f / D_8015BC18) * temp_ret;
phi_f14 = 20.0f / sp9C;
phi_f14 = (phi_f14 < 0.05f) ? 0.05f : phi_f14;
- Math_ApproxF(&D_8015BC18, 0.0f, phi_f14);
+ Math_StepToF(&D_8015BC18, 0.0f, phi_f14);
temp_f2 = ((D_8015BC18 / spC0) * temp_ret) / temp_ret;
gSaveContext.respawn[RESPAWN_MODE_TOP].pos.x =
gSaveContext.respawn[RESPAWN_MODE_DOWN].pos.x + (spB4.x * temp_f2);
@@ -1843,9 +1843,9 @@ void func_8002FBAC(GlobalContext* globalCtx) {
osSyncPrintf("-------- DISPLAY Y=%f\n", spD8);
}
- spA4.x = Math_Rand_CenteredFloat(6.0f) + gSaveContext.respawn[RESPAWN_MODE_TOP].pos.x;
- spA4.y = Math_Rand_ZeroOne() * 6.0f + gSaveContext.respawn[RESPAWN_MODE_TOP].pos.y + 80.0f;
- spA4.z = Math_Rand_CenteredFloat(6.0f) + gSaveContext.respawn[RESPAWN_MODE_TOP].pos.z;
+ spA4.x = Rand_CenteredFloat(6.0f) + gSaveContext.respawn[RESPAWN_MODE_TOP].pos.x;
+ spA4.y = Rand_ZeroOne() * 6.0f + gSaveContext.respawn[RESPAWN_MODE_TOP].pos.y + 80.0f;
+ spA4.z = Rand_CenteredFloat(6.0f) + gSaveContext.respawn[RESPAWN_MODE_TOP].pos.z;
EffectSsKiraKira_SpawnDispersed(globalCtx, &spA4, &D_80116048, &D_80116054, &D_80116060, &D_80116064, 1000,
16);
@@ -3011,7 +3011,7 @@ void func_80032C7C(GlobalContext* globalCtx, Actor* actor) {
s16 func_80032CB4(s16* arg0, s16 arg1, s16 arg2, s16 arg3) {
if (DECR(arg0[1]) == 0) {
- arg0[1] = Math_Rand_S16Offset(arg1, arg2);
+ arg0[1] = Rand_S16Offset(arg1, arg2);
}
if ((arg0[1] - arg3) > 0) {
@@ -3027,11 +3027,11 @@ s16 func_80032CB4(s16* arg0, s16 arg1, s16 arg2, s16 arg3) {
s16 func_80032D60(s16* arg0, s16 arg1, s16 arg2, s16 arg3) {
if (DECR(arg0[1]) == 0) {
- arg0[1] = Math_Rand_S16Offset(arg1, arg2);
+ arg0[1] = Rand_S16Offset(arg1, arg2);
arg0[0]++;
if ((arg0[0] % 3) == 0) {
- arg0[0] = (s32)(Math_Rand_ZeroOne() * arg3) * 3;
+ arg0[0] = (s32)(Rand_ZeroOne() * arg3) * 3;
}
}
@@ -3148,15 +3148,15 @@ void func_80033260(GlobalContext* globalCtx, Actor* actor, Vec3f* arg2, f32 arg3
f32 var;
s32 i;
- var = (Math_Rand_ZeroOne() - 0.5f) * 6.28f;
+ var = (Rand_ZeroOne() - 0.5f) * 6.28f;
pos.y = actor->groundY;
- accel.y += (Math_Rand_ZeroOne() - 0.5f) * 0.2f;
+ accel.y += (Rand_ZeroOne() - 0.5f) * 0.2f;
for (i = arg4; i >= 0; i--) {
- pos.x = (func_800CA720(var) * arg3) + arg2->x;
- pos.z = (func_800CA774(var) * arg3) + arg2->z;
- accel.x = (Math_Rand_ZeroOne() - 0.5f) * arg5;
- accel.z = (Math_Rand_ZeroOne() - 0.5f) * arg5;
+ pos.x = (Math_SinF(var) * arg3) + arg2->x;
+ pos.z = (Math_CosF(var) * arg3) + arg2->z;
+ accel.x = (Rand_ZeroOne() - 0.5f) * arg5;
+ accel.z = (Rand_ZeroOne() - 0.5f) * arg5;
if (scale == 0) {
func_8002857C(globalCtx, &pos, &velocity, &accel);
@@ -3179,11 +3179,11 @@ void func_80033480(GlobalContext* globalCtx, Vec3f* arg1, f32 arg2, s32 arg3, s1
s32 i;
for (i = arg3; i >= 0; i--) {
- pos.x = arg1->x + ((Math_Rand_ZeroOne() - 0.5f) * arg2);
- pos.y = arg1->y + ((Math_Rand_ZeroOne() - 0.5f) * arg2);
- pos.z = arg1->z + ((Math_Rand_ZeroOne() - 0.5f) * arg2);
+ pos.x = arg1->x + ((Rand_ZeroOne() - 0.5f) * arg2);
+ pos.y = arg1->y + ((Rand_ZeroOne() - 0.5f) * arg2);
+ pos.z = arg1->z + ((Rand_ZeroOne() - 0.5f) * arg2);
- scale = (s16)((Math_Rand_ZeroOne() * arg4) * 0.2f) + arg4;
+ scale = (s16)((Rand_ZeroOne() * arg4) * 0.2f) + arg4;
var2 = arg6;
if (var2 != 0) {
@@ -3256,9 +3256,9 @@ Actor* func_80033780(GlobalContext* globalCtx, Actor* refActor, f32 arg2) {
(itemActor->unk_210 == 0)) {
actor = actor->next;
} else {
- deltaX = Math_Sins(itemActor->actor.posRot.rot.y) * (itemActor->actor.speedXZ * 10.0f);
+ deltaX = Math_SinS(itemActor->actor.posRot.rot.y) * (itemActor->actor.speedXZ * 10.0f);
deltaY = itemActor->actor.velocity.y + (itemActor->actor.gravity * 10.0f);
- deltaZ = Math_Coss(itemActor->actor.posRot.rot.y) * (itemActor->actor.speedXZ * 10.0f);
+ deltaZ = Math_CosS(itemActor->actor.posRot.rot.y) * (itemActor->actor.speedXZ * 10.0f);
spA8.x = itemActor->actor.posRot.pos.x + deltaX;
spA8.y = itemActor->actor.posRot.pos.y + deltaY;
@@ -3366,8 +3366,8 @@ s16 func_800339B8(Actor* actor, GlobalContext* globalCtx, f32 arg2, s16 arg3) {
Math_Vec3f_Copy(&sp30, &actor->posRot.pos);
sp44 = actor->bgCheckFlags;
- sp40 = Math_Sins(arg3) * arg2;
- sp3C = Math_Coss(arg3) * arg2;
+ sp40 = Math_SinS(arg3) * arg2;
+ sp3C = Math_CosS(arg3) * arg2;
actor->posRot.pos.x += sp40;
actor->posRot.pos.z += sp3C;
func_8002E4B4(globalCtx, actor, 0.0f, 0.0f, 0.0f, 4);
@@ -3403,13 +3403,13 @@ f32 func_80033AEC(Vec3f* arg0, Vec3f* arg1, f32 arg2, f32 arg3, f32 arg4, f32 ar
f32 ret = 0.0f;
if (arg4 <= Math_Vec3f_DistXYZ(arg0, arg1)) {
- ret = Math_SmoothScaleMaxMinF(&arg1->x, arg0->x, arg2, arg3, 0.0f);
- ret += Math_SmoothScaleMaxMinF(&arg1->y, arg0->y, arg2, arg3, 0.0f);
- ret += Math_SmoothScaleMaxMinF(&arg1->z, arg0->z, arg2, arg3, 0.0f);
+ ret = Math_SmoothStepToF(&arg1->x, arg0->x, arg2, arg3, 0.0f);
+ ret += Math_SmoothStepToF(&arg1->y, arg0->y, arg2, arg3, 0.0f);
+ ret += Math_SmoothStepToF(&arg1->z, arg0->z, arg2, arg3, 0.0f);
} else if (arg5 < Math_Vec3f_DistXYZ(arg0, arg1)) {
- ret = Math_SmoothScaleMaxMinF(&arg1->x, arg0->x, arg2, arg3, 0.0f);
- ret += Math_SmoothScaleMaxMinF(&arg1->y, arg0->y, arg2, arg3, 0.0f);
- ret += Math_SmoothScaleMaxMinF(&arg1->z, arg0->z, arg2, arg3, 0.0f);
+ ret = Math_SmoothStepToF(&arg1->x, arg0->x, arg2, arg3, 0.0f);
+ ret += Math_SmoothStepToF(&arg1->y, arg0->y, arg2, arg3, 0.0f);
+ ret += Math_SmoothStepToF(&arg1->z, arg0->z, arg2, arg3, 0.0f);
}
return ret;
@@ -3475,12 +3475,12 @@ void func_80033E88(Actor* actor, GlobalContext* globalCtx, s16 arg2, s16 arg3) {
func_80033DB8(globalCtx, arg2, arg3);
}
-f32 Math_Rand_ZeroFloat(f32 f) {
- return Math_Rand_ZeroOne() * f;
+f32 Rand_ZeroFloat(f32 f) {
+ return Rand_ZeroOne() * f;
}
-f32 Math_Rand_CenteredFloat(f32 f) {
- return (Math_Rand_ZeroOne() - 0.5f) * f;
+f32 Rand_CenteredFloat(f32 f) {
+ return (Rand_ZeroOne() - 0.5f) * f;
}
typedef struct {
@@ -3666,7 +3666,7 @@ void func_800344BC(Actor* actor, struct_80034A14_arg1* arg1, s16 arg2, s16 arg3,
sp40 = Math_Vec3f_Yaw(&actor->posRot.pos, &arg1->unk_18) - actor->shape.rot.y;
temp1 = CLAMP(sp40, -arg2, arg2);
- Math_SmoothScaleMaxMinS(&arg1->unk_08.y, temp1, 6, 2000, 1);
+ Math_SmoothStepToS(&arg1->unk_08.y, temp1, 6, 2000, 1);
sp40 = (ABS(sp40) >= 0x8000) ? 0 : ABS(sp40);
arg1->unk_08.y = CLAMP(arg1->unk_08.y, -sp40, sp40);
@@ -3674,23 +3674,23 @@ void func_800344BC(Actor* actor, struct_80034A14_arg1* arg1, s16 arg2, s16 arg3,
sp40 = sp40 - arg1->unk_08.y;
temp1 = CLAMP(sp40, -arg5, arg5);
- Math_SmoothScaleMaxMinS(&arg1->unk_0E.y, temp1, 6, 2000, 1);
+ Math_SmoothStepToS(&arg1->unk_0E.y, temp1, 6, 2000, 1);
sp40 = (ABS(sp40) >= 0x8000) ? 0 : ABS(sp40);
arg1->unk_0E.y = CLAMP(arg1->unk_0E.y, -sp40, sp40);
if (arg8 != 0) {
if (arg3) {} // Seems necessary to match
- Math_SmoothScaleMaxMinS(&actor->shape.rot.y, sp44, 6, 2000, 1);
+ Math_SmoothStepToS(&actor->shape.rot.y, sp44, 6, 2000, 1);
}
temp1 = CLAMP(sp46, arg4, arg3);
- Math_SmoothScaleMaxMinS(&arg1->unk_08.x, temp1, 6, 2000, 1);
+ Math_SmoothStepToS(&arg1->unk_08.x, temp1, 6, 2000, 1);
temp2 = sp46 - arg1->unk_08.x;
temp1 = CLAMP(temp2, arg7, arg6);
- Math_SmoothScaleMaxMinS(&arg1->unk_0E.x, temp1, 6, 2000, 1);
+ Math_SmoothStepToS(&arg1->unk_0E.x, temp1, 6, 2000, 1);
}
#else
#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800344BC.s")
@@ -3734,11 +3734,11 @@ s16 func_80034810(Actor* actor, struct_80034A14_arg1* arg1, f32 arg2, s16 arg3,
switch (arg1->unk_06) {
case 0:
case 2:
- arg1->unk_04 = Math_Rand_S16Offset(30, 30);
+ arg1->unk_04 = Rand_S16Offset(30, 30);
arg1->unk_06++;
return 1;
case 1:
- arg1->unk_04 = Math_Rand_S16Offset(10, 10);
+ arg1->unk_04 = Rand_S16Offset(10, 10);
arg1->unk_06++;
return 3;
}
@@ -3839,10 +3839,10 @@ s16 func_80034DD4(Actor* actor, GlobalContext* globalCtx, s16 arg2, f32 arg3) {
if (arg3 < var) {
actor->flags &= ~1;
- Math_SmoothScaleMaxMinS(&arg2, 0, 6, 0x14, 1);
+ Math_SmoothStepToS(&arg2, 0, 6, 0x14, 1);
} else {
actor->flags |= 1;
- Math_SmoothScaleMaxMinS(&arg2, 0xFF, 6, 0x14, 1);
+ Math_SmoothStepToS(&arg2, 0xFF, 6, 0x14, 1);
}
return arg2;
@@ -3885,7 +3885,7 @@ s32 func_80035124(Actor* actor, GlobalContext* globalCtx) {
actor->params = 1;
} else if (!(actor->bgCheckFlags & 1)) {
Actor_MoveForward(actor);
- Math_SmoothScaleMaxMinF(&actor->speedXZ, 0.0f, 1.0f, 0.1f, 0.0f);
+ Math_SmoothStepToF(&actor->speedXZ, 0.0f, 1.0f, 0.1f, 0.0f);
} else if ((actor->bgCheckFlags & 2) && (actor->velocity.y < -4.0f)) {
ret = 1;
} else {
@@ -4070,8 +4070,8 @@ void func_80035844(Vec3f* arg0, Vec3f* arg1, s16* arg2, s32 arg3) {
f32 dz = arg1->z - arg0->z;
f32 dy = arg3 ? (arg1->y - arg0->y) : (arg0->y - arg1->y);
- arg2[1] = atan2s(dz, dx);
- arg2[0] = atan2s(sqrtf(SQ(dx) + SQ(dz)), dy);
+ arg2[1] = Math_Atan2S(dz, dx);
+ arg2[0] = Math_Atan2S(sqrtf(SQ(dx) + SQ(dz)), dy);
}
/**
@@ -4117,15 +4117,15 @@ void func_800359B8(Actor* actor, s16 arg1, Vec3s* arg2) {
sp40 = floorPoly->norm.y * (1.0f / 32767);
sp3C = floorPoly->norm.z * (1.0f / 32767);
- sp38 = Math_Sins(arg1);
- sp34 = Math_Coss(arg1);
+ sp38 = Math_SinS(arg1);
+ sp34 = Math_CosS(arg1);
sp28 = (-(sp44 * sp38) - (sp3C * sp34));
- arg2->x = -(s16)(Math_atan2f(sp28 * sp40, 1.0f) * (32768 / M_PI));
+ arg2->x = -(s16)(Math_FAtan2F(sp28 * sp40, 1.0f) * (32768 / M_PI));
- sp2C = Math_Sins(arg1 - 16375);
- sp30 = Math_Coss(arg1 - 16375);
+ sp2C = Math_SinS(arg1 - 16375);
+ sp30 = Math_CosS(arg1 - 16375);
sp24 = (-(sp44 * sp2C) - (sp3C * sp30));
- arg2->z = -(s16)(Math_atan2f(sp24 * sp40, 1.0f) * (32768 / M_PI));
+ arg2->z = -(s16)(Math_FAtan2F(sp24 * sp40, 1.0f) * (32768 / M_PI));
}
}
@@ -5433,10 +5433,10 @@ s32 func_80037D98(GlobalContext* globalCtx, Actor* actor, s16 arg2, s32* arg3) {
}
s32 func_80037F30(Vec3s* arg0, Vec3s* arg1) {
- Math_SmoothScaleMaxMinS(&arg0->y, 0, 6, 6200, 100);
- Math_SmoothScaleMaxMinS(&arg0->x, 0, 6, 6200, 100);
- Math_SmoothScaleMaxMinS(&arg1->y, 0, 6, 6200, 100);
- Math_SmoothScaleMaxMinS(&arg1->x, 0, 6, 6200, 100);
+ Math_SmoothStepToS(&arg0->y, 0, 6, 6200, 100);
+ Math_SmoothStepToS(&arg0->x, 0, 6, 6200, 100);
+ Math_SmoothStepToS(&arg1->y, 0, 6, 6200, 100);
+ Math_SmoothStepToS(&arg1->x, 0, 6, 6200, 100);
return 1;
}
@@ -5448,17 +5448,17 @@ s32 func_80037FC8(Actor* actor, Vec3f* arg1, Vec3s* arg2, Vec3s* arg3) {
sp36 = Math_Vec3f_Pitch(&actor->posRot2.pos, arg1);
sp34 = Math_Vec3f_Yaw(&actor->posRot2.pos, arg1) - actor->posRot.rot.y;
- Math_SmoothScaleMaxMinS(&arg2->x, sp36, 6, 2000, 1);
+ Math_SmoothStepToS(&arg2->x, sp36, 6, 2000, 1);
arg2->x = (arg2->x < -6000) ? -6000 : ((arg2->x > 6000) ? 6000 : arg2->x);
- var = Math_SmoothScaleMaxMinS(&arg2->y, sp34, 6, 2000, 1);
+ var = Math_SmoothStepToS(&arg2->y, sp34, 6, 2000, 1);
arg2->y = (arg2->y < -8000) ? -8000 : ((arg2->y > 8000) ? 8000 : arg2->y);
if (var && (ABS(arg2->y) < 8000)) {
return 0;
}
- Math_SmoothScaleMaxMinS(&arg3->y, sp34 - arg2->y, 4, 2000, 1);
+ Math_SmoothStepToS(&arg3->y, sp34 - arg2->y, 4, 2000, 1);
arg3->y = (arg3->y < -12000) ? -12000 : ((arg3->y > 12000) ? 12000 : arg3->y);
return 1;
diff --git a/src/code/z_camera.c b/src/code/z_camera.c
index b0db5de01..87c3cf85a 100644
--- a/src/code/z_camera.c
+++ b/src/code/z_camera.c
@@ -558,7 +558,7 @@ f32 Camera_GetWaterSurface(Camera* camera, Vec3f* chkPos, s32* envProp) {
* Calculates the angle between points `from` and `to`
*/
s16 Camera_XZAngle(Vec3f* to, Vec3f* from) {
- return DEGF_TO_BINANG(RADF_TO_DEGF(Math_atan2f(from->x - to->x, from->z - to->z)));
+ return DEGF_TO_BINANG(RADF_TO_DEGF(Math_FAtan2F(from->x - to->x, from->z - to->z)));
}
s16 func_80044ADC(Camera* camera, s16 yaw, s16 arg2) {
@@ -580,8 +580,8 @@ s16 func_80044ADC(Camera* camera, s16 yaw, s16 arg2) {
f32 phi_f16;
f32 playerHeight;
- sinYaw = Math_Sins(yaw);
- cosYaw = Math_Coss(yaw);
+ sinYaw = Math_SinS(yaw);
+ cosYaw = Math_CosS(yaw);
playerHeight = Player_GetHeight(camera->player);
temp_f2 = PCT(OREG(19)) * playerHeight;
sp30 = PCT(OREG(17)) * playerHeight;
@@ -623,8 +623,8 @@ s16 func_80044ADC(Camera* camera, s16 yaw, s16 arg2) {
}
phi_f16 = PCT(OREG(20)) * (D_8015CE50 - camera->playerGroundY);
phi_f18 = (1.0f - PCT(OREG(20))) * (D_8015CE54 - camera->playerGroundY);
- temp_s0 = DEGF_TO_BINANG(RADF_TO_DEGF(Math_atan2f(phi_f16, sp30)));
- temp_s1 = DEGF_TO_BINANG(RADF_TO_DEGF(Math_atan2f(phi_f18, sp2C)));
+ temp_s0 = DEGF_TO_BINANG(RADF_TO_DEGF(Math_FAtan2F(phi_f16, sp30)));
+ temp_s1 = DEGF_TO_BINANG(RADF_TO_DEGF(Math_FAtan2F(phi_f18, sp2C)));
return temp_s0 + temp_s1;
}
@@ -653,13 +653,13 @@ Vec3f* Camera_CalcUpFromPitchYawRoll(Vec3f* dest, s16 pitch, s16 yaw, s16 roll)
f32 temp_f8_2;
f32 temp_f8_3;
- sinPitch = Math_Sins(pitch);
- cosPitch = Math_Coss(pitch);
- sinYaw = Math_Sins(yaw);
- cosYaw = Math_Coss(yaw);
+ sinPitch = Math_SinS(pitch);
+ cosPitch = Math_CosS(pitch);
+ sinYaw = Math_SinS(yaw);
+ cosYaw = Math_CosS(yaw);
negSinPitch = -sinPitch;
- sinNegRoll = Math_Sins(-roll);
- cosNegRoll = Math_Coss(-roll);
+ sinNegRoll = Math_SinS(-roll);
+ cosNegRoll = Math_CosS(-roll);
negSinPitchSinYaw = negSinPitch * sinYaw;
temp_f14 = 1.0f - cosNegRoll;
cosPitchSinYaw = cosPitch * sinYaw;
@@ -884,8 +884,8 @@ f32 Camera_CalcSlopeYAdj(Vec3f* floorNorm, s16 playerYRot, s16 eyeAtYaw, f32 adj
OLib_Vec3fToVecSphGeo(&floorNormSph, floorNorm);
- tmp = Math_Coss(floorNormSph.pitch) * Math_Coss(playerYRot - floorNormSph.yaw);
- return (fabsf(tmp) * adjAmt) * Math_Coss(playerYRot - eyeAtYaw);
+ tmp = Math_CosS(floorNormSph.pitch) * Math_CosS(playerYRot - floorNormSph.yaw);
+ return (fabsf(tmp) * adjAmt) * Math_CosS(playerYRot - eyeAtYaw);
}
/**
@@ -940,7 +940,7 @@ s32 func_800458D4(Camera* camera, VecSph* eyeAtDir, f32 arg2, f32* arg3, s16 arg
}
deltaY = playerPosRot->pos.y - *arg3;
- eyeAtAngle = Math_atan2f(deltaY, OLib_Vec3fDistXZ(&camera->at, &camera->eye));
+ eyeAtAngle = Math_FAtan2F(deltaY, OLib_Vec3fDistXZ(&camera->at, &camera->eye));
if (eyeAtAngle > DEGF_TO_RADF(OREG(32))) {
if (1) {}
@@ -975,12 +975,12 @@ s32 func_80045B08(Camera* camera, VecSph* eyeAtDir, f32 yExtra, s16 arg3) {
posOffsetTarget.x = 0.0f;
posOffsetTarget.z = 0.0f;
- temp_ret = Math_Sins(arg3);
+ temp_ret = Math_SinS(arg3);
if (temp_ret < 0.0f) {
- phi_f2 = Math_Coss(playerPosRot->rot.y - eyeAtDir->yaw);
+ phi_f2 = Math_CosS(playerPosRot->rot.y - eyeAtDir->yaw);
} else {
- phi_f2 = -Math_Coss(playerPosRot->rot.y - eyeAtDir->yaw);
+ phi_f2 = -Math_CosS(playerPosRot->rot.y - eyeAtDir->yaw);
}
posOffsetTarget.y -= temp_ret * phi_f2 * OREG(9);
@@ -1031,8 +1031,8 @@ s32 Camera_CalcAtForParallel(Camera* camera, VecSph* arg1, f32 arg2, f32* arg3,
phi_f20 = playerPosRot->pos.y - *arg3;
sp54 = OLib_Vec3fDistXZ(at, &camera->eye);
phi_f16 = sp54;
- Math_atan2f(phi_f20, sp54);
- temp_f2 = Math_tanf(DEG_TO_RAD(camera->fov * 0.4f)) * phi_f16;
+ Math_FAtan2F(phi_f20, sp54);
+ temp_f2 = Math_FTanF(DEG_TO_RAD(camera->fov * 0.4f)) * phi_f16;
if (temp_f2 < phi_f20) {
*arg3 += phi_f20 - temp_f2;
phi_f20 = temp_f2;
@@ -1043,7 +1043,7 @@ s32 Camera_CalcAtForParallel(Camera* camera, VecSph* arg1, f32 arg2, f32* arg3,
posOffsetTarget.y -= phi_f20;
} else {
phi_f20 = playerPosRot->pos.y - *arg3;
- temp_f2 = Math_atan2f(phi_f20, OLib_Vec3fDistXZ(at, eye));
+ temp_f2 = Math_FAtan2F(phi_f20, OLib_Vec3fDistXZ(at, eye));
if (DEG_TO_RAD(OREG(32)) < temp_f2) {
phi_f16 = 1 - sinf(temp_f2 - DEG_TO_RAD(OREG(32)));
} else if (temp_f2 < DEG_TO_RAD(OREG(33))) {
@@ -1133,8 +1133,8 @@ s32 Camera_CalcAtForLockOn(Camera* camera, VecSph* eyeAtDir, Vec3f* targetPos, f
yPosDelta = playerPosRot->pos.y - *yPosOffset;
eyeAtDist = OLib_Vec3fDistXZ(at, &camera->eye);
phi_f16 = eyeAtDist;
- Math_atan2f(yPosDelta, eyeAtDist);
- temp_f0_2 = Math_tanf(DEG_TO_RAD(camera->fov * 0.4f)) * phi_f16;
+ Math_FAtan2F(yPosDelta, eyeAtDist);
+ temp_f0_2 = Math_FTanF(DEG_TO_RAD(camera->fov * 0.4f)) * phi_f16;
if (temp_f0_2 < yPosDelta) {
*yPosOffset = *yPosOffset + (yPosDelta - temp_f0_2);
yPosDelta = temp_f0_2;
@@ -1145,7 +1145,7 @@ s32 Camera_CalcAtForLockOn(Camera* camera, VecSph* eyeAtDir, Vec3f* targetPos, f
tmpPos0.y = tmpPos0.y - yPosDelta;
} else {
yPosDelta = playerPosRot->pos.y - *yPosOffset;
- temp_f0_2 = Math_atan2f(yPosDelta, OLib_Vec3fDistXZ(at, &camera->eye));
+ temp_f0_2 = Math_FAtan2F(yPosDelta, OLib_Vec3fDistXZ(at, &camera->eye));
if (temp_f0_2 > DEG_TO_RAD(OREG(32))) {
phi_f16 = 1.0f - sinf(temp_f0_2 - DEG_TO_RAD(OREG(32)));
@@ -1227,7 +1227,7 @@ f32 Camera_LERPClampDist(Camera* camera, f32 dist, f32 min, f32 max) {
}
camera->rUpdateRateInv = Camera_LERPCeilF(rUpdateRateInvTarget, camera->rUpdateRateInv, PCT(OREG(25)), 0.1f);
- return Camera_LERPCeilF(distTarget, camera->dist, 1.f / camera->rUpdateRateInv, 0.2f);
+ return Camera_LERPCeilF(distTarget, camera->dist, 1.0f / camera->rUpdateRateInv, 0.2f);
}
f32 Camera_ClampDist(Camera* camera, f32 dist, f32 minDist, f32 maxDist, s16 timer) {
@@ -1261,7 +1261,7 @@ s16 Camera_CalcDefaultPitch(Camera* camera, s16 arg1, s16 arg2, s16 arg3) {
s16 sp1C;
phi_v1 = ABS(arg1);
- phi_v0 = arg3 > 0 ? (s16)(Math_Coss(arg3) * arg3) : arg3;
+ phi_v0 = arg3 > 0 ? (s16)(Math_CosS(arg3) * arg3) : arg3;
sp1C = arg2 - phi_v0;
if (ABS(sp1C) < phi_v1) {
@@ -1380,7 +1380,7 @@ void func_80046E20(Camera* camera, VecSph* eyeAdjustment, f32 minDist, f32 arg3,
anim->atEyePoly = NULL;
if (temp_f0 < OREG(21)) {
sp40.yaw = eyeAdjustment->yaw;
- sp40.pitch = Math_Sins(atEyeColChk.sphNorm.pitch + 0x3FFF) * 16380.0f;
+ sp40.pitch = Math_SinS(atEyeColChk.sphNorm.pitch + 0x3FFF) * 16380.0f;
sp40.r = (OREG(21) - temp_f0) * PCT(OREG(22));
Camera_Vec3fVecSphGeoAdd(eye, eye, &sp40);
}
@@ -1537,7 +1537,7 @@ s32 Camera_Normal1(Camera* camera) {
}
spA0 = ((anim->swing.unk_18 != 0) && (norm1->yOffset > -40.0f))
- ? (sp9C = Math_Sins(anim->swing.unk_14), ((-40.0f * sp9C) + (norm1->yOffset * (1.0f - sp9C))))
+ ? (sp9C = Math_SinS(anim->swing.unk_14), ((-40.0f * sp9C) + (norm1->yOffset * (1.0f - sp9C))))
: norm1->yOffset;
if (norm1->interfaceFlags & 0x80) {
@@ -1614,7 +1614,7 @@ s32 Camera_Normal1(Camera* camera) {
// crit wiggle
if (gSaveContext.health <= 16 && ((camera->globalCtx->state.frames % 256) == 0)) {
- wiggleAdj = Math_Rand_ZeroOne() * 10000.0f;
+ wiggleAdj = Rand_ZeroOne() * 10000.0f;
camera->inputDir.y = wiggleAdj + camera->inputDir.y;
}
} else {
@@ -2420,9 +2420,9 @@ s32 Camera_Jump2(Camera* camera) {
}
// Check the floor at the top of the climb
- bgChkPos.x = playerPosRot->pos.x + (Math_Sins(playerPosRot->rot.y) * 25.0f);
+ bgChkPos.x = playerPosRot->pos.x + (Math_SinS(playerPosRot->rot.y) * 25.0f);
bgChkPos.y = playerPosRot->pos.y + (playerHeight * 2.2f);
- bgChkPos.z = playerPosRot->pos.z + (Math_Coss(playerPosRot->rot.y) * 25.0f);
+ bgChkPos.z = playerPosRot->pos.z + (Math_CosS(playerPosRot->rot.y) * 25.0f);
sp90 = Camera_GetFloorYNorm(camera, &floorNorm, &bgChkPos, &bgId);
if ((sp90 != BGCHECK_Y_MIN) && (playerPosRot->pos.y < sp90)) {
@@ -4211,13 +4211,13 @@ s32 Camera_Subj3(Camera* camera) {
func_80044340(camera, at, eye);
}
} else {
- sp58 = Math_Sins(-sp60.rot.x);
- temp_f0_3 = Math_Coss(-sp60.rot.x);
+ sp58 = Math_SinS(-sp60.rot.x);
+ temp_f0_3 = Math_CosS(-sp60.rot.x);
sp98.x = subj3->atOffset.x;
sp98.y = (subj3->atOffset.y * temp_f0_3) - (subj3->atOffset.z * sp58);
sp98.z = (subj3->atOffset.y * sp58) + (subj3->atOffset.z * temp_f0_3);
- sp58 = Math_Sins(BINANG_ROT180(sp60.rot.y));
- temp_f0_3 = Math_Coss(BINANG_ROT180(sp60.rot.y));
+ sp58 = Math_SinS(BINANG_ROT180(sp60.rot.y));
+ temp_f0_3 = Math_CosS(BINANG_ROT180(sp60.rot.y));
subj3->atOffset.x = (sp98.z * sp58) + (sp98.x * temp_f0_3);
subj3->atOffset.y = sp98.y;
subj3->atOffset.z = (sp98.z * temp_f0_3) - (sp98.x * sp58);
@@ -4341,7 +4341,7 @@ s32 Camera_Subj4(Camera* camera) {
sp64.pitch = 0x238C;
Camera_Vec3fVecSphGeoAdd(&sp98, eyeNext, &sp64);
anim->unk_2C += 0xBB8;
- temp_f16 = Math_Coss(anim->unk_2C);
+ temp_f16 = Math_CosS(anim->unk_2C);
eye->x += (sp98.x - eye->x) * fabsf(temp_f16);
eye->y += (sp98.y - eye->y) * fabsf(temp_f16);
eye->z += (sp98.z - eye->z) * fabsf(temp_f16);
@@ -4360,9 +4360,9 @@ s32 Camera_Subj4(Camera* camera) {
camera->player->actor.shape.rot.y = sp64.yaw;
temp_f16 = ((240.0f * temp_f16) * (anim->unk_24 * 0.416667f));
temp_a0 = temp_f16 + anim->unk_30;
- at->x = eye->x + (Math_Sins(temp_a0) * 10.0f);
+ at->x = eye->x + (Math_SinS(temp_a0) * 10.0f);
at->y = eye->y;
- at->z = eye->z + (Math_Coss(temp_a0) * 10.0f);
+ at->z = eye->z + (Math_CosS(temp_a0) * 10.0f);
camera->roll = Camera_LERPCeilS(0, camera->roll, 0.5f, 0xA);
return 1;
}
@@ -4975,7 +4975,7 @@ s32 Camera_Unique7(Camera* camera) {
// 0x7D0 ~ 10.98 degres.
unk08->unk_00.x = Camera_LERPFloorS(playerPosEyeOffset.yaw, unk08->unk_00.x, 0.4f, 0x7D0);
playerPosEyeOffset.pitch =
- -BGCAM_ROT(sceneCamData).x * Math_Coss(playerPosEyeOffset.yaw - BGCAM_ROT(sceneCamData).y);
+ -BGCAM_ROT(sceneCamData).x * Math_CosS(playerPosEyeOffset.yaw - BGCAM_ROT(sceneCamData).y);
Camera_Vec3fVecSphGeoAdd(at, eye, &playerPosEyeOffset);
camera->unk_14C |= 0x400;
return true;
@@ -5630,9 +5630,9 @@ s32 Camera_Demo3(Camera* camera) {
anim->initialAt.y = camera->playerGroundY;
}
angle = camPlayerPosRot->rot.y;
- sp68.x = anim->initialAt.x + (Math_Sins(angle) * 40.0f);
+ sp68.x = anim->initialAt.x + (Math_SinS(angle) * 40.0f);
sp68.y = anim->initialAt.y + 40.0f;
- sp68.z = anim->initialAt.z + (Math_Coss(angle) * 40.0f);
+ sp68.z = anim->initialAt.z + (Math_CosS(angle) * 40.0f);
if (camera->globalCtx->state.frames & 1) {
angle -= 0x3FFF;
anim->yawDir = 1;
@@ -5640,9 +5640,9 @@ s32 Camera_Demo3(Camera* camera) {
angle += 0x3FFF;
anim->yawDir = -1;
}
- sp74.x = sp68.x + (D_8011D658[1].r * Math_Sins(angle));
+ sp74.x = sp68.x + (D_8011D658[1].r * Math_SinS(angle));
sp74.y = anim->initialAt.y + 5.0f;
- sp74.z = sp68.z + (D_8011D658[1].r * Math_Coss(angle));
+ sp74.z = sp68.z + (D_8011D658[1].r * Math_CosS(angle));
if (Camera_BGCheck(camera, &sp68, &sp74)) {
anim->yawDir = -anim->yawDir;
}
@@ -5838,8 +5838,8 @@ s32 Camera_Demo5(Camera* camera) {
// camera is targeting a(the) player actor
if (eyePlayerGeo.r > 30.0f) {
D_8011D6AC[1].timerInit = camera->timer - 1;
- D_8011D6AC[1].atTargetInit.z = Math_Rand_ZeroOne() * 10.0f;
- D_8011D6AC[1].eyeTargetInit.x = Math_Rand_ZeroOne() * 10.0f;
+ D_8011D6AC[1].atTargetInit.z = Rand_ZeroOne() * 10.0f;
+ D_8011D6AC[1].eyeTargetInit.x = Rand_ZeroOne() * 10.0f;
ONEPOINTDEMO->keyFrames = D_8011D6AC;
ONEPOINTDEMO->keyFrameCnt = ARRAY_COUNT(D_8011D6AC);
if (camera->parentCamIdx != 0) {
@@ -5848,7 +5848,7 @@ s32 Camera_Demo5(Camera* camera) {
camera->timer += D_8011D6AC[2].timerInit;
}
} else {
- D_8011D724[1].eyeTargetInit.x = Math_Rand_ZeroOne() * 10.0f;
+ D_8011D724[1].eyeTargetInit.x = Rand_ZeroOne() * 10.0f;
D_8011D724[1].timerInit = camera->timer - 1;
ONEPOINTDEMO->keyFrames = D_8011D724;
ONEPOINTDEMO->keyFrameCnt = ARRAY_COUNT(D_8011D724);
@@ -5906,7 +5906,7 @@ s32 Camera_Demo5(Camera* camera) {
} else {
D_8011D8DC[0].atTargetInit.z = eyeTargetDist * 0.6f;
D_8011D8DC[0].eyeTargetInit.z = eyeTargetDist + 50.0f;
- D_8011D8DC[0].eyeTargetInit.x = Math_Rand_ZeroOne() * 10.0f;
+ D_8011D8DC[0].eyeTargetInit.x = Rand_ZeroOne() * 10.0f;
if (BINANG_SUB(eyePlayerGeo.yaw, playerTargetGeo.yaw) > 0) {
D_8011D8DC[0].atTargetInit.x = -D_8011D8DC[0].atTargetInit.x;
D_8011D8DC[0].eyeTargetInit.x = -D_8011D8DC[0].eyeTargetInit.x;
@@ -5937,14 +5937,14 @@ s32 Camera_Demo5(Camera* camera) {
D_8011D954[0].atTargetInit.y = D_8011D954[0].eyeTargetInit.y = D_8011D954[1].atTargetInit.y =
camera->target->shape.rot.y == sp4A ? 180.0f : 0.0f;
- sp90 = (BINANG_SUB(playerTargetGeo.yaw, sp4A) < 0 ? 20.0f : -20.0f) * Math_Rand_ZeroOne();
+ sp90 = (BINANG_SUB(playerTargetGeo.yaw, sp4A) < 0 ? 20.0f : -20.0f) * Rand_ZeroOne();
D_8011D954[0].eyeTargetInit.y = D_8011D954->eyeTargetInit.y + sp90;
- temp_v0 = Math_Rand_ZeroOne() * (sp90 * -0.2f);
+ temp_v0 = Rand_ZeroOne() * (sp90 * -0.2f);
D_8011D954[1].rollTargetInit = temp_v0;
D_8011D954[0].rollTargetInit = temp_v0;
func_8002EEE4(&targetPosRot2, camera->target);
- targetPosRot2.pos.x += 50.0f * Math_Sins(BINANG_ROT180(sp4A));
- targetPosRot2.pos.z += 50.0f * Math_Coss(BINANG_ROT180(sp4A));
+ targetPosRot2.pos.x += 50.0f * Math_SinS(BINANG_ROT180(sp4A));
+ targetPosRot2.pos.z += 50.0f * Math_CosS(BINANG_ROT180(sp4A));
if (Camera_BGCheck(camera, &playerPosRot2.pos, &targetPosRot2.pos)) {
D_8011D954[1].actionFlags = 0xC1;
D_8011D954[2].actionFlags = 0x8F;
@@ -5964,7 +5964,7 @@ s32 Camera_Demo5(Camera* camera) {
D_8011D9F4[0].atTargetInit.z = playerTargetGeo.r * 0.25f;
}
if (playerTargetGeo.r < 400.0f) {
- D_8011D9F4[0].eyeTargetInit.x = Math_Rand_ZeroOne() * 25.0f;
+ D_8011D9F4[0].eyeTargetInit.x = Rand_ZeroOne() * 25.0f;
}
Player_GetHeight(camera->player);
D_8011D9F4[0].timerInit = camera->timer;
@@ -6347,9 +6347,9 @@ s32 Camera_Special4(Camera* camera) {
// 0x3E8 ~ 5.49 degrees
sp3A = BINANG_ROT180(curTargetPosRot.rot.y) + 0x3E8;
- camera->eye.x = camera->eyeNext.x = (Math_Sins(sp3A) * 780.0f) + camera->at.x;
+ camera->eye.x = camera->eyeNext.x = (Math_SinS(sp3A) * 780.0f) + camera->at.x;
camera->eyeNext.y = camera->at.y;
- camera->eye.z = camera->eyeNext.z = (Math_Coss(sp3A) * 780.0f) + camera->at.z;
+ camera->eye.z = camera->eyeNext.z = (Math_CosS(sp3A) * 780.0f) + camera->at.z;
camera->eye.y = curTargetPosRot.pos.y;
camera->eye.y = Camera_GetFloorY(camera, &camera->eye) + 20.0f;
(*timer)--;
@@ -6425,7 +6425,7 @@ s32 Camera_Special5(Camera* camera) {
OLib_Vec3fToVecSphGeo(&sp6C, &sp7C.norm);
spA4 = BINANG_SUB(playerPosRot->rot.y, sp6C.yaw);
sp74.r = spec5->eyeDist;
- temp_f0_2 = Math_Rand_ZeroOne();
+ temp_f0_2 = Rand_ZeroOne();
sp74.yaw =
BINANG_ROT180(playerPosRot->rot.y) + (s16)(spA4 < 0 ? -(s16)(0x1553 + (s16)(temp_f0_2 * 2730.0f))
: (s16)(0x1553 + (s16)(temp_f0_2 * 2730.0f)));
@@ -7285,12 +7285,12 @@ void func_80058E8C(Camera* camera) {
}
D_8011DB08 += DEGF_TO_BINANG(phi_f0);
D_8011DB0C += DEGF_TO_BINANG(phi_f2);
- Math_Coss(D_8011DB08);
- Math_Sins(D_8011DB08);
- Math_Sins(D_8011DB0C);
+ Math_CosS(D_8011DB08);
+ Math_SinS(D_8011DB08);
+ Math_SinS(D_8011DB0C);
func_800AA76C(&camera->globalCtx->view, 0.0f, 0.0f, 0.0f);
- func_800AA78C(&camera->globalCtx->view, Math_Sins(D_8011DB0C) * (sp40 * phi_f20) + 1.0f,
- Math_Coss(D_8011DB0C) * (sp3C * phi_f20) + 1.0f, Math_Coss(D_8011DB08) * (sp38 * phi_f20) + 1.0f);
+ func_800AA78C(&camera->globalCtx->view, Math_SinS(D_8011DB0C) * (sp40 * phi_f20) + 1.0f,
+ Math_CosS(D_8011DB0C) * (sp3C * phi_f20) + 1.0f, Math_CosS(D_8011DB08) * (sp38 * phi_f20) + 1.0f);
func_800AA7AC(&camera->globalCtx->view, sp34 * sp60);
camera->unk_14C |= 0x40;
} else if (camera->unk_14C & 0x40) {
diff --git a/src/code/z_demo.c b/src/code/z_demo.c
index 93b2bf85b..2ef4cbe52 100644
--- a/src/code/z_demo.c
+++ b/src/code/z_demo.c
@@ -132,7 +132,7 @@ void func_80064720(GlobalContext* globalCtx, CutsceneContext* csCtx) {
}
u32 func_8006472C(GlobalContext* globalCtx, CutsceneContext* csCtx, f32 target) {
- return Math_ApproxF(&csCtx->unk_0C, target, 0.1f);
+ return Math_StepToF(&csCtx->unk_0C, target, 0.1f);
}
void func_80064760(GlobalContext* globalCtx, CutsceneContext* csCtx) {
diff --git a/src/code/z_eff_blure.c b/src/code/z_eff_blure.c
index d376bbf98..bc3d3465b 100644
--- a/src/code/z_eff_blure.c
+++ b/src/code/z_eff_blure.c
@@ -602,16 +602,16 @@ void EffectBlure_DrawElemHermiteInterpolation(EffectBlure* this, EffectBlureElem
vtx[0].v = baseVtx;
vtx[1].v = baseVtx;
- vtx[0].v.ob[0] = Math_nearbyintf(sp158.x);
- vtx[0].v.ob[1] = Math_nearbyintf(sp158.y);
- vtx[0].v.ob[2] = Math_nearbyintf(sp158.z);
+ vtx[0].v.ob[0] = Math_FNearbyIntF(sp158.x);
+ vtx[0].v.ob[1] = Math_FNearbyIntF(sp158.y);
+ vtx[0].v.ob[2] = Math_FNearbyIntF(sp158.z);
vtx[0].v.cn[0] = sp148.r;
vtx[0].v.cn[1] = sp148.g;
vtx[0].v.cn[2] = sp148.b;
vtx[0].v.cn[3] = sp148.a;
- vtx[1].v.ob[0] = Math_nearbyintf(sp14C.x);
- vtx[1].v.ob[1] = Math_nearbyintf(sp14C.y);
- vtx[1].v.ob[2] = Math_nearbyintf(sp14C.z);
+ vtx[1].v.ob[0] = Math_FNearbyIntF(sp14C.x);
+ vtx[1].v.ob[1] = Math_FNearbyIntF(sp14C.y);
+ vtx[1].v.ob[2] = Math_FNearbyIntF(sp14C.z);
vtx[1].v.cn[0] = sp144.r;
vtx[1].v.cn[1] = sp144.g;
vtx[1].v.cn[2] = sp144.b;
@@ -644,17 +644,17 @@ void EffectBlure_DrawElemHermiteInterpolation(EffectBlure* this, EffectBlureElem
vtx[j1].v = baseVtx;
vtx[j2].v = baseVtx;
- vtx[j1].v.ob[0] = Math_nearbyintf(sp158.x);
- vtx[j1].v.ob[1] = Math_nearbyintf(sp158.y);
- vtx[j1].v.ob[2] = Math_nearbyintf(sp158.z);
+ vtx[j1].v.ob[0] = Math_FNearbyIntF(sp158.x);
+ vtx[j1].v.ob[1] = Math_FNearbyIntF(sp158.y);
+ vtx[j1].v.ob[2] = Math_FNearbyIntF(sp158.z);
vtx[j1].v.cn[0] = func_80027E84(sp1A4.r, sp19C.r, temp_f28);
vtx[j1].v.cn[1] = func_80027E84(sp1A4.g, sp19C.g, temp_f28);
vtx[j1].v.cn[2] = func_80027E84(sp1A4.b, sp19C.b, temp_f28);
vtx[j1].v.cn[3] = func_80027E84(sp1A4.a, sp19C.a, temp_f28);
- vtx[j2].v.ob[0] = Math_nearbyintf(sp14C.x);
- vtx[j2].v.ob[1] = Math_nearbyintf(sp14C.y);
- vtx[j2].v.ob[2] = Math_nearbyintf(sp14C.z);
+ vtx[j2].v.ob[0] = Math_FNearbyIntF(sp14C.x);
+ vtx[j2].v.ob[1] = Math_FNearbyIntF(sp14C.y);
+ vtx[j2].v.ob[2] = Math_FNearbyIntF(sp14C.z);
vtx[j2].v.cn[0] = func_80027E84(sp1A0.r, sp198.r, temp_f28);
vtx[j2].v.cn[1] = func_80027E84(sp1A0.g, sp198.g, temp_f28);
vtx[j2].v.cn[2] = func_80027E84(sp1A0.b, sp198.b, temp_f28);
diff --git a/src/code/z_eff_shield_particle.c b/src/code/z_eff_shield_particle.c
index 6005c3faf..852eaeefe 100644
--- a/src/code/z_eff_shield_particle.c
+++ b/src/code/z_eff_shield_particle.c
@@ -37,14 +37,13 @@ void EffectShieldParticle_Init(void* thisx, void* initParamsx) {
this->timer = 0;
for (elem = &this->elements[0]; elem < &this->elements[this->numElements]; elem++) {
- elem->initialSpeed =
- (Math_Rand_ZeroOne() * (this->maxInitialSpeed * 0.5f)) + (this->maxInitialSpeed * 0.5f);
+ elem->initialSpeed = (Rand_ZeroOne() * (this->maxInitialSpeed * 0.5f)) + (this->maxInitialSpeed * 0.5f);
elem->endX = 0.0f;
elem->startXChange = 0.0f;
elem->startX = 0.0f;
elem->endXChange = elem->initialSpeed;
- elem->yaw = Math_Rand_ZeroOne() * 65534.0f;
- elem->pitch = Math_Rand_ZeroOne() * 65534.0f;
+ elem->yaw = Rand_ZeroOne() * 65534.0f;
+ elem->pitch = Rand_ZeroOne() * 65534.0f;
}
this->lightDecay = initParams->lightDecay;
diff --git a/src/code/z_eff_spark.c b/src/code/z_eff_spark.c
index c17633053..c310d4a3b 100644
--- a/src/code/z_eff_spark.c
+++ b/src/code/z_eff_spark.c
@@ -66,9 +66,9 @@ void EffectSpark_Init(void* thisx, void* initParamsx) {
elem->position.x = this->position.x;
elem->position.y = this->position.y;
elem->position.z = this->position.z;
- elem->velocity.x = Math_Rand_ZeroOne() - 0.5f;
- elem->velocity.y = Math_Rand_ZeroOne() - 0.5f;
- elem->velocity.z = Math_Rand_ZeroOne() - 0.5f;
+ elem->velocity.x = Rand_ZeroOne() - 0.5f;
+ elem->velocity.y = Rand_ZeroOne() - 0.5f;
+ elem->velocity.z = Rand_ZeroOne() - 0.5f;
velocityNorm = sqrtf(SQ(elem->velocity.x) + SQ(elem->velocity.y) + SQ(elem->velocity.z));
@@ -81,12 +81,12 @@ void EffectSpark_Init(void* thisx, void* initParamsx) {
elem->velocity.y = this->speed;
}
- elem->unkVelocity.x = 30000.0f - Math_Rand_ZeroOne() * 15000.0f;
- elem->unkVelocity.y = 30000.0f - Math_Rand_ZeroOne() * 15000.0f;
- elem->unkVelocity.z = 30000.0f - Math_Rand_ZeroOne() * 15000.0f;
- elem->unkPosition.x = Math_Rand_ZeroOne() * 65534.0f;
- elem->unkPosition.y = Math_Rand_ZeroOne() * 65534.0f;
- elem->unkPosition.z = Math_Rand_ZeroOne() * 65534.0f;
+ elem->unkVelocity.x = 30000.0f - Rand_ZeroOne() * 15000.0f;
+ elem->unkVelocity.y = 30000.0f - Rand_ZeroOne() * 15000.0f;
+ elem->unkVelocity.z = 30000.0f - Rand_ZeroOne() * 15000.0f;
+ elem->unkPosition.x = Rand_ZeroOne() * 65534.0f;
+ elem->unkPosition.y = Rand_ZeroOne() * 65534.0f;
+ elem->unkPosition.z = Rand_ZeroOne() * 65534.0f;
}
this->timer = 0;
@@ -214,7 +214,7 @@ void EffectSpark_Draw(void* thisx, GraphicsContext* gfxCtx) {
elem = &this->elements[i];
SkinMatrix_SetTranslate(&spEC, elem->position.x, elem->position.y, elem->position.z);
- temp = ((Math_Rand_ZeroOne() * 2.5f) + 1.5f) * 0.015625f;
+ temp = ((Rand_ZeroOne() * 2.5f) + 1.5f) * 0.015625f;
SkinMatrix_SetScale(&spAC, temp, temp, 1.0f);
SkinMatrix_MtxFMtxFMult(&spEC, &globalCtx->mf_11DA0, &sp6C);
SkinMatrix_MtxFMtxFMult(&sp6C, &spAC, &sp12C);
diff --git a/src/code/z_eff_ss_dead.c b/src/code/z_eff_ss_dead.c
index 9b5a552cb..aebee67b3 100644
--- a/src/code/z_eff_ss_dead.c
+++ b/src/code/z_eff_ss_dead.c
@@ -8,7 +8,7 @@ void func_80026230(GlobalContext* globalCtx, Color_RGBA8* color, s16 arg2, s16 a
OPEN_DISPS(globalCtx->state.gfxCtx, "../z_eff_ss_dead.c", 113);
displayListHead = POLY_OPA_DISP;
- cos = Math_Coss((0x8000 / arg3) * arg2);
+ cos = Math_CosS((0x8000 / arg3) * arg2);
absCos = ABS(cos);
gDPPipeSync(displayListHead++);
@@ -35,7 +35,7 @@ void func_80026400(GlobalContext* globalCtx, Color_RGBA8* color, s16 arg2, s16 a
if (arg3 != 0) {
OPEN_DISPS(globalCtx->state.gfxCtx, "../z_eff_ss_dead.c", 141);
- cos = Math_Coss((0x4000 / arg3) * arg2);
+ cos = Math_CosS((0x4000 / arg3) * arg2);
displayListHead = POLY_OPA_DISP;
gDPPipeSync(displayListHead++);
@@ -69,7 +69,7 @@ void func_80026690(GlobalContext* globalCtx, Color_RGBA8* color, s16 arg2, s16 a
OPEN_DISPS(globalCtx->state.gfxCtx, "../z_eff_ss_dead.c", 178);
displayListHead = POLY_XLU_DISP;
- cos = Math_Coss((0x8000 / arg3) * arg2);
+ cos = Math_CosS((0x8000 / arg3) * arg2);
absCos = ABS(cos);
gDPPipeSync(displayListHead++);
@@ -96,7 +96,7 @@ void func_80026860(GlobalContext* globalCtx, Color_RGBA8* color, s16 arg2, s16 a
OPEN_DISPS(globalCtx->state.gfxCtx, "../z_eff_ss_dead.c", 201);
displayListHead = POLY_XLU_DISP;
- cos = Math_Coss((0x4000 / arg3) * arg2);
+ cos = Math_CosS((0x4000 / arg3) * arg2);
gDPPipeSync(displayListHead++);
gDPSetFogColor(displayListHead++, color->r, color->g, color->b, color->a);
diff --git a/src/code/z_effect_soft_sprite_old_init.c b/src/code/z_effect_soft_sprite_old_init.c
index c990f02f0..991d280ec 100644
--- a/src/code/z_effect_soft_sprite_old_init.c
+++ b/src/code/z_effect_soft_sprite_old_init.c
@@ -182,17 +182,17 @@ void func_80028894(Vec3f* srcPos, f32 randScale, Vec3f* newPos, Vec3f* velocity,
s16 randAngle;
f32 rand;
- rand = Math_Rand_ZeroOne() * randScale;
- randAngle = (Math_Rand_ZeroOne() * 65536.0f);
+ rand = Rand_ZeroOne() * randScale;
+ randAngle = (Rand_ZeroOne() * 65536.0f);
*newPos = *srcPos;
- newPos->x += Math_Sins(randAngle) * rand;
- newPos->z += Math_Coss(randAngle) * rand;
+ newPos->x += Math_SinS(randAngle) * rand;
+ newPos->z += Math_CosS(randAngle) * rand;
velocity->y = 1.0f;
- velocity->x = Math_Sins(randAngle);
- velocity->z = Math_Coss(randAngle);
+ velocity->x = Math_SinS(randAngle);
+ velocity->z = Math_CosS(randAngle);
accel->x = 0.0f;
accel->y = 0.0f;
@@ -243,13 +243,13 @@ void EffectSsKiraKira_SpawnDispersed(GlobalContext* globalCtx, Vec3f* pos, Vec3f
Math_Vec3f_Copy(&initParams.pos, pos);
Math_Vec3f_Copy(&initParams.velocity, velocity);
- initParams.velocity.y = ((Math_Rand_ZeroOne() * initParams.velocity.y) + initParams.velocity.y) * 0.5f;
+ initParams.velocity.y = ((Rand_ZeroOne() * initParams.velocity.y) + initParams.velocity.y) * 0.5f;
Math_Vec3f_Copy(&initParams.accel, accel);
- initParams.accel.y = ((Math_Rand_ZeroOne() * initParams.accel.y) + initParams.accel.y) * 0.5f;
+ initParams.accel.y = ((Rand_ZeroOne() * initParams.accel.y) + initParams.accel.y) * 0.5f;
initParams.life = life;
initParams.updateMode = 0;
initParams.rotSpeed = 0x1518;
- initParams.yaw = Math_Rand_ZeroOne() * 16384.0f;
+ initParams.yaw = Rand_ZeroOne() * 16384.0f;
initParams.scale = scale;
initParams.primColor = *primColor;
initParams.envColor = *envColor;
@@ -268,7 +268,7 @@ void EffectSsKiraKira_SpawnFocused(GlobalContext* globalCtx, Vec3f* pos, Vec3f*
initParams.life = life;
initParams.updateMode = 1;
initParams.rotSpeed = 0x1518;
- initParams.yaw = Math_Rand_ZeroOne() * 16384.0f;
+ initParams.yaw = Rand_ZeroOne() * 16384.0f;
initParams.scale = scale;
Color_RGBA8_Copy(&initParams.primColor, primColor);
Color_RGBA8_Copy(&initParams.envColor, envColor);
@@ -410,7 +410,7 @@ void EffectSsGSpk_SpawnRandColor(GlobalContext* globalCtx, Actor* actor, Vec3f*
Color_RGBA8 envColor = { 255, 0, 0, 0 };
s32 randOffset;
- randOffset = (Math_Rand_ZeroOne() * 20.0f) - 10.0f;
+ randOffset = (Rand_ZeroOne() * 20.0f) - 10.0f;
primColor.r += randOffset;
primColor.g += randOffset;
@@ -619,12 +619,12 @@ void EffectSsHahen_SpawnBurst(GlobalContext* globalCtx, Vec3f* pos, f32 burstSca
accel.x = accel.z = 0.0f;
for (i = 0; i < count; i++) {
- velocity.x = (Math_Rand_ZeroOne() - 0.5f) * burstScale;
- velocity.z = (Math_Rand_ZeroOne() - 0.5f) * burstScale;
- velocity.y = ((Math_Rand_ZeroOne() * 0.5f) + 0.5f) * burstScale;
+ velocity.x = (Rand_ZeroOne() - 0.5f) * burstScale;
+ velocity.z = (Rand_ZeroOne() - 0.5f) * burstScale;
+ velocity.y = ((Rand_ZeroOne() * 0.5f) + 0.5f) * burstScale;
- EffectSsHahen_Spawn(globalCtx, pos, &velocity, &accel, unused, Math_Rand_S16Offset(scale, randScaleRange),
- objId, life, dList);
+ EffectSsHahen_Spawn(globalCtx, pos, &velocity, &accel, unused, Rand_S16Offset(scale, randScaleRange), objId,
+ life, dList);
}
}
@@ -664,7 +664,7 @@ void EffectSsSibuki_SpawnBurst(GlobalContext* globalCtx, Vec3f* pos) {
Vec3f unusedZeroVec1 = { 0.0f, 0.0f, 0.0f };
Vec3f unusedZeroVec2 = { 0.0f, 0.0f, 0.0f };
Vec3f zeroVec = { 0.0f, 0.0f, 0.0f };
- s16 randDirection = Math_Rand_ZeroOne() * 1.99f;
+ s16 randDirection = Rand_ZeroOne() * 1.99f;
for (i = 0; i < KREG(19) + 30; i++) {
EffectSsSibuki_Spawn(globalCtx, pos, &zeroVec, &zeroVec, i / (KREG(27) + 6), randDirection, KREG(18) + 40);
@@ -864,7 +864,7 @@ void EffectSsIcePiece_SpawnBurst(GlobalContext* globalCtx, Vec3f* refPos, f32 sc
for (i = 0; i < ARRAY_COUNT(vecScales); i++) {
pos = *refPos;
- velocityScale = Math_Rand_ZeroFloat(1.0f) + 0.5f;
+ velocityScale = Rand_ZeroFloat(1.0f) + 0.5f;
velocity.x = (vecScales[i].x * 0.18f) * velocityScale;
velocity.y = (vecScales[i].y * 0.18f) * velocityScale;
velocity.z = (vecScales[i].z * 0.18f) * velocityScale;
@@ -872,8 +872,8 @@ void EffectSsIcePiece_SpawnBurst(GlobalContext* globalCtx, Vec3f* refPos, f32 sc
pos.y += vecScales[i].y;
pos.z += vecScales[i].z;
- EffectSsIcePiece_Spawn(globalCtx, &pos, (Math_Rand_ZeroFloat(1.0f) + 0.5f) * ((scale * 1.3f) * 100.0f),
- &velocity, &accel, 25);
+ EffectSsIcePiece_Spawn(globalCtx, &pos, (Rand_ZeroFloat(1.0f) + 0.5f) * ((scale * 1.3f) * 100.0f), &velocity,
+ &accel, 25);
}
}
diff --git a/src/code/z_elf_message.c b/src/code/z_elf_message.c
index 1f5c522cf..babfd19f8 100644
--- a/src/code/z_elf_message.c
+++ b/src/code/z_elf_message.c
@@ -90,7 +90,7 @@ u32 func_8006BF1C(ElfMessage** msgp) {
return false;
}
- temp3 = Math_Rand_ZeroFloat(temp1);
+ temp3 = Rand_ZeroFloat(temp1);
for (temp1 = 0; temp1 < temp2; temp1++) {
if (sp44[temp1]) {
if (temp3 > 0) {
diff --git a/src/code/z_en_a_keep.c b/src/code/z_en_a_keep.c
index c23701d19..81c1b9395 100644
--- a/src/code/z_en_a_keep.c
+++ b/src/code/z_en_a_keep.c
@@ -244,7 +244,7 @@ void func_8001D480(EnAObj* this, s16 params) {
}
void func_8001D4A8(EnAObj* this, GlobalContext* globalCtx) {
- Math_SmoothScaleMaxMinF(&this->dyna.actor.speedXZ, 1.0f, 1.0f, 0.5f, 0.0f);
+ Math_SmoothStepToF(&this->dyna.actor.speedXZ, 1.0f, 1.0f, 0.5f, 0.0f);
this->dyna.actor.shape.rot.x = this->dyna.actor.shape.rot.x + (this->dyna.actor.posRot.rot.x >> 1);
this->dyna.actor.shape.rot.z = this->dyna.actor.shape.rot.z + (this->dyna.actor.posRot.rot.z >> 1);
@@ -282,7 +282,7 @@ void func_8001D608(EnAObj* this, GlobalContext* globalCtx) {
? -2.5f
: ((this->dyna.actor.speedXZ > 2.5f) ? 2.5f : this->dyna.actor.speedXZ);
- Math_SmoothScaleMaxMinF(&this->dyna.actor.speedXZ, 0.0f, 1.0f, 1.0f, 0.0f);
+ Math_SmoothStepToF(&this->dyna.actor.speedXZ, 0.0f, 1.0f, 1.0f, 0.0f);
if (this->dyna.actor.speedXZ != 0.0f) {
Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_ROCK_SLIDE - SFX_FLAG);
diff --git a/src/code/z_en_item00.c b/src/code/z_en_item00.c
index 1ae9c71c4..0a79d0dc4 100644
--- a/src/code/z_en_item00.c
+++ b/src/code/z_en_item00.c
@@ -96,7 +96,7 @@ void EnItem00_Init(Actor* thisx, GlobalContext* globalCtx) {
this->unk_15C = 0.02f;
break;
case ITEM00_HEART:
- this->actor.initPosRot.rot.z = Math_Rand_CenteredFloat(65535.0f);
+ this->actor.initPosRot.rot.z = Rand_CenteredFloat(65535.0f);
sp34 = 430.0f;
Actor_SetScale(&this->actor, 0.02f);
this->unk_15C = 0.02f;
@@ -286,25 +286,25 @@ void func_8001DFC8(EnItem00* this, GlobalContext* globalCtx) {
} else {
if ((this->actor.params >= ITEM00_SHIELD_DEKU) && (this->actor.params != ITEM00_BOMBS_SPECIAL)) {
if (this->unk_15A == -1) {
- if (!Math_SmoothScaleMaxMinS(&this->actor.shape.rot.x, this->actor.posRot.rot.x - 0x4000, 2, 3000,
+ if (!Math_SmoothStepToS(&this->actor.shape.rot.x, this->actor.posRot.rot.x - 0x4000, 2, 3000,
1500)) {
this->unk_15A = -2;
}
} else {
- if (!Math_SmoothScaleMaxMinS(&this->actor.shape.rot.x, -this->actor.posRot.rot.x - 0x4000, 2, 3000,
+ if (!Math_SmoothStepToS(&this->actor.shape.rot.x, -this->actor.posRot.rot.x - 0x4000, 2, 3000,
1500)) {
this->unk_15A = -1;
}
}
- Math_SmoothScaleMaxMinS(&this->actor.posRot.rot.x, 0, 2, 2500, 500);
+ Math_SmoothStepToS(&this->actor.posRot.rot.x, 0, 2, 2500, 500);
}
}
if (this->actor.params == ITEM00_HEART_PIECE) {
- this->actor.shape.unk_08 = Math_Sins(this->actor.shape.rot.y) * 150.0f + 850.0f;
+ this->actor.shape.unk_08 = Math_SinS(this->actor.shape.rot.y) * 150.0f + 850.0f;
}
- Math_SmoothScaleMaxMinF(&this->actor.speedXZ, 0.0f, 1.0f, 0.5f, 0.0f);
+ Math_SmoothStepToF(&this->actor.speedXZ, 0.0f, 1.0f, 0.5f, 0.0f);
if (this->unk_154 == 0) {
if ((this->actor.params != ITEM00_SMALL_KEY) && (this->actor.params != ITEM00_HEART_PIECE) &&
@@ -334,9 +334,9 @@ void func_8001E1C8(EnItem00* this, GlobalContext* globalCtx) {
}
if (globalCtx->gameplayFrames & 1) {
- pos.x = this->actor.posRot.pos.x + Math_Rand_CenteredFloat(10.0f);
- pos.y = this->actor.posRot.pos.y + Math_Rand_CenteredFloat(10.0f);
- pos.z = this->actor.posRot.pos.z + Math_Rand_CenteredFloat(10.0f);
+ pos.x = this->actor.posRot.pos.x + Rand_CenteredFloat(10.0f);
+ pos.y = this->actor.posRot.pos.y + Rand_CenteredFloat(10.0f);
+ pos.z = this->actor.posRot.pos.z + Rand_CenteredFloat(10.0f);
EffectSsKiraKira_SpawnSmall(globalCtx, &pos, &D_80115518, &D_80115524, &D_80115510, &D_80115514);
}
@@ -368,9 +368,9 @@ void func_8001E304(EnItem00* this, GlobalContext* globalCtx) {
}
this->actor.initPosRot.rot.z += (s16)((this->actor.velocity.y + 3.0f) * 1000.0f);
this->actor.posRot.pos.x +=
- Math_Coss(this->actor.yawTowardsLink) * (-3.0f * Math_Coss(this->actor.initPosRot.rot.z));
+ Math_CosS(this->actor.yawTowardsLink) * (-3.0f * Math_CosS(this->actor.initPosRot.rot.z));
this->actor.posRot.pos.z +=
- Math_Sins(this->actor.yawTowardsLink) * (-3.0f * Math_Coss(this->actor.initPosRot.rot.z));
+ Math_SinS(this->actor.yawTowardsLink) * (-3.0f * Math_CosS(this->actor.initPosRot.rot.z));
}
}
@@ -392,9 +392,9 @@ void func_8001E304(EnItem00* this, GlobalContext* globalCtx) {
}
if (!(globalCtx->gameplayFrames & 1)) {
- pos.x = this->actor.posRot.pos.x + (Math_Rand_ZeroOne() - 0.5f) * 10.0f;
- pos.y = this->actor.posRot.pos.y + (Math_Rand_ZeroOne() - 0.5f) * 10.0f;
- pos.z = this->actor.posRot.pos.z + (Math_Rand_ZeroOne() - 0.5f) * 10.0f;
+ pos.x = this->actor.posRot.pos.x + (Rand_ZeroOne() - 0.5f) * 10.0f;
+ pos.y = this->actor.posRot.pos.y + (Rand_ZeroOne() - 0.5f) * 10.0f;
+ pos.z = this->actor.posRot.pos.z + (Rand_ZeroOne() - 0.5f) * 10.0f;
EffectSsKiraKira_SpawnSmall(globalCtx, &pos, &D_80115518, &D_80115524, &D_80115510, &D_80115514);
}
@@ -431,7 +431,7 @@ void func_8001E5C8(EnItem00* this, GlobalContext* globalCtx) {
this->actor.shape.rot.y = 0;
}
- this->actor.posRot.pos.y += 40.0f + Math_Sins(this->unk_15A * 15000) * (this->unk_15A * 0.3f);
+ this->actor.posRot.pos.y += 40.0f + Math_SinS(this->unk_15A * 15000) * (this->unk_15A * 0.3f);
if (LINK_IS_ADULT) {
this->actor.posRot.pos.y += 20.0f;
@@ -463,7 +463,7 @@ void EnItem00_Update(Actor* thisx, GlobalContext* globalCtx) {
this->actionFunc(this, globalCtx);
- Math_SmoothScaleMaxMinF(&this->actor.scale.x, this->unk_15C, 0.1f, this->unk_15C * 0.1f, 0.0f);
+ Math_SmoothStepToF(&this->actor.scale.x, this->unk_15C, 0.1f, this->unk_15C * 0.1f, 0.0f);
this->actor.scale.z = this->actor.scale.x;
this->actor.scale.y = this->actor.scale.x;
@@ -506,7 +506,7 @@ void EnItem00_Update(Actor* thisx, GlobalContext* globalCtx) {
if ((this->actor.params == ITEM00_SHIELD_DEKU) || (this->actor.params == ITEM00_SHIELD_HYLIAN) ||
(this->actor.params == ITEM00_TUNIC_ZORA) || (this->actor.params == ITEM00_TUNIC_GORON)) {
- f32 newUnkBC = Math_Coss(this->actor.shape.rot.x) * 37.0f;
+ f32 newUnkBC = Math_CosS(this->actor.shape.rot.x) * 37.0f;
this->actor.shape.unk_08 = newUnkBC;
if (newUnkBC >= 0.0f) {
this->actor.shape.unk_08 = this->actor.shape.unk_08;
@@ -892,7 +892,7 @@ EnItem00* Item_DropCollectible(GlobalContext* globalCtx, Vec3f* spawnPos, s16 pa
spawnedActor->actor.velocity.y = !param4000 ? 8.0f : -2.0f;
spawnedActor->actor.speedXZ = 2.0f;
spawnedActor->actor.gravity = -0.9f;
- spawnedActor->actor.posRot.rot.y = Math_Rand_CenteredFloat(65536.0f);
+ spawnedActor->actor.posRot.rot.y = Rand_CenteredFloat(65536.0f);
Actor_SetScale(&spawnedActor->actor, 0.0f);
EnItem00_SetupAction(spawnedActor, func_8001E304);
spawnedActor->unk_15A = 220;
@@ -933,7 +933,7 @@ EnItem00* Item_DropCollectible2(GlobalContext* globalCtx, Vec3f* spawnPos, s16 p
spawnedActor->actor.velocity.y = 0.0f;
spawnedActor->actor.speedXZ = 0.0f;
spawnedActor->actor.gravity = param4000 ? 0.0f : -0.9f;
- spawnedActor->actor.posRot.rot.y = Math_Rand_CenteredFloat(65536.0f);
+ spawnedActor->actor.posRot.rot.y = Rand_CenteredFloat(65536.0f);
spawnedActor->actor.flags |= 0x0010;
}
}
@@ -950,7 +950,7 @@ void Item_DropCollectibleRandom(GlobalContext* globalCtx, Actor* fromActor, Vec3
s16 dropTableIndex;
u8 dropId;
- dropTableIndex = Math_Rand_ZeroOne() * 16.0f;
+ dropTableIndex = Rand_ZeroOne() * 16.0f;
param8000 = params & 0x8000;
params = params & 0x7FFF;
@@ -1045,7 +1045,7 @@ void Item_DropCollectibleRandom(GlobalContext* globalCtx, Actor* fromActor, Vec3
spawnedActor->actor.velocity.y = 8.0f;
spawnedActor->actor.speedXZ = 2.0f;
spawnedActor->actor.gravity = -0.9f;
- spawnedActor->actor.posRot.rot.y = Math_Rand_ZeroOne() * 40000.0f;
+ spawnedActor->actor.posRot.rot.y = Rand_ZeroOne() * 40000.0f;
Actor_SetScale(&spawnedActor->actor, 0.0f);
EnItem00_SetupAction(spawnedActor, func_8001E304);
spawnedActor->actor.flags |= 0x0010;
diff --git a/src/code/z_fbdemo_fade.c b/src/code/z_fbdemo_fade.c
index 57c58f274..e70c1a81d 100644
--- a/src/code/z_fbdemo_fade.c
+++ b/src/code/z_fbdemo_fade.c
@@ -60,12 +60,12 @@ void TransitionFade_Update(TransitionFade* this, s32 updateRate) {
newAlpha = this->fadeColor.a;
if (iREG(50) != 0) {
if (iREG(50) < 0) {
- if (Math_ApproxS(&newAlpha, 255, 255)) {
+ if (Math_StepToS(&newAlpha, 255, 255)) {
iREG(50) = 150;
}
} else {
- Math_ApproxS(&iREG(50), 20, 60);
- if (Math_ApproxS(&newAlpha, 0, iREG(50))) {
+ Math_StepToS(&iREG(50), 20, 60);
+ if (Math_StepToS(&newAlpha, 0, iREG(50))) {
iREG(50) = 0;
this->isDone = 1;
}
diff --git a/src/code/z_kankyo.c b/src/code/z_kankyo.c
index 016743503..eccb1a799 100644
--- a/src/code/z_kankyo.c
+++ b/src/code/z_kankyo.c
@@ -31,7 +31,7 @@
#pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/func_80073A5C.s")
f32 func_800746DC() {
- return Math_Rand_ZeroOne() - 0.5f;
+ return Rand_ZeroOne() - 0.5f;
}
#pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/func_80074704.s")
diff --git a/src/code/z_lib.c b/src/code/z_lib.c
index 5c6336890..177217f3c 100644
--- a/src/code/z_lib.c
+++ b/src/code/z_lib.c
@@ -8,19 +8,21 @@ void Lib_MemSet(u8* dest, size_t size, u8 val) {
// clang-format on
}
-f32 Math_Coss(s16 angle) {
- return coss(angle) * (1.0f / 32767);
+f32 Math_CosS(s16 angle) {
+ return coss(angle) * SHT_MINV;
}
-f32 Math_Sins(s16 angle) {
- return sins(angle) * (1.0f / 32767);
+f32 Math_SinS(s16 angle) {
+ return sins(angle) * SHT_MINV;
}
-s32 Math_ApproxUpdateScaledS(s16* pValue, s16 target, s16 step) {
- f32 updateScale;
-
+/**
+ * Changes pValue by step (scaled by the update rate) towards target, setting it equal when the target is reached.
+ * Returns true when target is reached, false otherwise.
+ */
+s32 Math_ScaledStepToS(s16* pValue, s16 target, s16 step) {
if (step != 0) {
- updateScale = R_UPDATE_RATE * 0.5f;
+ f32 updateScale = R_UPDATE_RATE * 0.5f;
if ((s16)(*pValue - target) > 0) {
step = -step;
@@ -30,16 +32,20 @@ s32 Math_ApproxUpdateScaledS(s16* pValue, s16 target, s16 step) {
if (((s16)(*pValue - target) * step) >= 0) {
*pValue = target;
- return 1;
+ return true;
}
} else if (target == *pValue) {
- return 1;
+ return true;
}
- return 0;
+ return false;
}
-s32 Math_ApproxS(s16* pValue, s16 target, s16 step) {
+/**
+ * Changes pValue by step towards target, setting it equal when the target is reached.
+ * Returns true when target is reached, false otherwise.
+ */
+s32 Math_StepToS(s16* pValue, s16 target, s16 step) {
if (step != 0) {
if (target < *pValue) {
step = -step;
@@ -49,16 +55,20 @@ s32 Math_ApproxS(s16* pValue, s16 target, s16 step) {
if (((*pValue - target) * step) >= 0) {
*pValue = target;
- return 1;
+ return true;
}
} else if (target == *pValue) {
- return 1;
+ return true;
}
- return 0;
+ return false;
}
-s32 Math_ApproxF(f32* pValue, f32 target, f32 step) {
+/**
+ * Changes pValue by step towards target, setting it equal when the target is reached.
+ * Returns true when target is reached, false otherwise.
+ */
+s32 Math_StepToF(f32* pValue, f32 target, f32 step) {
if (step != 0.0f) {
if (target < *pValue) {
step = -step;
@@ -68,84 +78,104 @@ s32 Math_ApproxF(f32* pValue, f32 target, f32 step) {
if (((*pValue - target) * step) >= 0) {
*pValue = target;
- return 1;
+ return true;
}
} else if (target == *pValue) {
- return 1;
+ return true;
}
- return 0;
+ return false;
}
-s32 func_80077A90(s16* pValue, s16 target, s16 step) {
+/**
+ * Changes pValue by step. If pvalue reaches limit angle or its opposite, sets it equal to limit angle.
+ * Returns true when limit angle or its opposite is reached, false otherwise.
+ */
+s32 Math_StepUntilAngleS(s16* pValue, s16 limit, s16 step) {
s16 orig = *pValue;
*pValue += step;
- if (((s16)(*pValue - target) * (s16)(orig - target)) <= 0) {
- *pValue = target;
- return 1;
+ if (((s16)(*pValue - limit) * (s16)(orig - limit)) <= 0) {
+ *pValue = limit;
+ return true;
}
- return 0;
+ return false;
}
-s32 func_80077AF8(s16* pValue, s16 target, s16 step) {
+/**
+ * Changes pValue by step. If pvalue reaches limit, sets it equal to limit.
+ * Returns true when limit is reached, false otherwise.
+ */
+s32 Math_StepUntilS(s16* pValue, s16 limit, s16 step) {
s16 orig = *pValue;
*pValue += step;
- if (((*pValue - target) * ((s16)orig - target)) <= 0) {
- *pValue = target;
- return 1;
+ if (((*pValue - limit) * (orig - limit)) <= 0) {
+ *pValue = limit;
+ return true;
}
- return 0;
+ return false;
}
-s32 func_80077B58(s16* pValue, s16 target, s16 step) {
- s32 phi_v0 = target - *pValue;
+/**
+ * Changes pValue by step towards target angle, setting it equal when the target is reached.
+ * Returns true when target is reached, false otherwise.
+ */
+s32 Math_StepToAngleS(s16* pValue, s16 target, s16 step) {
+ s32 diff = target - *pValue;
- if (phi_v0 < 0) {
+ if (diff < 0) {
step = -step;
}
- if (phi_v0 >= 0x8000) {
+ if (diff >= 0x8000) {
step = -step;
- phi_v0 = 0xFFFF0001 - -phi_v0;
- } else if (phi_v0 <= -0x8000) {
- phi_v0 += 0xFFFF;
+ diff = -0xFFFF - -diff;
+ } else if (diff <= -0x8000) {
+ diff += 0xFFFF;
step = -step;
}
if (step != 0) {
*pValue += step;
- if ((phi_v0 * step) <= 0) {
+ if ((diff * step) <= 0) {
*pValue = target;
- return 1;
+ return true;
}
} else if (target == *pValue) {
- return 1;
+ return true;
}
- return 0;
+ return false;
}
-s32 func_80077C1C(f32* pValue, f32 target, f32 step) {
+/**
+ * Changes pValue by step. If pvalue reaches limit, sets it equal to limit.
+ * Returns true when limit is reached, false otherwise.
+ */
+s32 Math_StepUntilF(f32* pValue, f32 limit, f32 step) {
f32 orig = *pValue;
*pValue += step;
- if (((*pValue - target) * (orig - target)) <= 0) {
- *pValue = target;
- return 1;
+ if (((*pValue - limit) * (orig - limit)) <= 0) {
+ *pValue = limit;
+ return true;
}
- return 0;
+ return false;
}
-s32 func_80077C6C(f32* pValue, f32 target, f32 incrStep, f32 decrStep) {
+/**
+ * Changes pValue toward target by incrStep if pValue is smaller and by decrStep if it is greater, setting it equal when
+ * target is reached. Returns true when target is reached, false otherwise.
+ */
+s32 Math_AymStepToF(f32* pValue, f32 target, f32 incrStep, f32 decrStep) {
f32 step = (target >= *pValue) ? incrStep : decrStep;
if (step != 0.0f) {
@@ -173,15 +203,15 @@ void func_80077D10(f32* arg0, s16* arg1, Input* input) {
*arg0 = sqrtf(SQ(relX) + SQ(relY));
*arg0 = (60.0f < *arg0) ? 60.0f : *arg0;
- *arg1 = atan2s(relY, -relX);
+ *arg1 = Math_Atan2S(relY, -relX);
}
-s16 Math_Rand_S16Offset(s16 base, s16 range) {
- return (s16)(Math_Rand_ZeroOne() * range) + base;
+s16 Rand_S16Offset(s16 base, s16 range) {
+ return (s16)(Rand_ZeroOne() * range) + base;
}
-s16 Math_Rand_S16OffsetStride(s16 base, s16 stride, s16 range) {
- return (s16)(Math_Rand_ZeroOne() * range) * stride + base;
+s16 Rand_S16OffsetStride(s16 base, s16 stride, s16 range) {
+ return (s16)(Rand_ZeroOne() * range) * stride + base;
}
void Math_Vec3f_Copy(Vec3f* dest, Vec3f* src) {
@@ -251,11 +281,11 @@ s16 Math_Vec3f_Yaw(Vec3f* a, Vec3f* b) {
f32 dx = b->x - a->x;
f32 dz = b->z - a->z;
- return atan2s(dz, dx);
+ return Math_Atan2S(dz, dx);
}
s16 Math_Vec3f_Pitch(Vec3f* a, Vec3f* b) {
- return atan2s(Math_Vec3f_DistXZ(a, b), a->y - b->y);
+ return Math_Atan2S(Math_Vec3f_DistXZ(a, b), a->y - b->y);
}
void IChain_Apply_u8(u8* ptr, InitChainEntry* ichain);
@@ -351,32 +381,34 @@ void IChain_Apply_Vec3s(u8* ptr, InitChainEntry* ichain) {
vec->x = val;
}
-f32 Math_SmoothScaleMaxMinF(f32* pValue, f32 target, f32 scale, f32 maxStep, f32 minStep) {
- f32 var;
-
+/**
+ * Changes pValue by step towards target. If this step is more than fraction of the remaining distance, step by that
+ * instead, with a minimum step of minStep. Returns remaining distance to target.
+ */
+f32 Math_SmoothStepToF(f32* pValue, f32 target, f32 fraction, f32 step, f32 minStep) {
if (*pValue != target) {
- var = (target - *pValue) * scale;
+ f32 stepSize = (target - *pValue) * fraction;
- if ((var >= minStep) || (var <= -minStep)) {
- if (var > maxStep) {
- var = maxStep;
+ if ((stepSize >= minStep) || (stepSize <= -minStep)) {
+ if (stepSize > step) {
+ stepSize = step;
}
- if (var < -maxStep) {
- var = -maxStep;
+ if (stepSize < -step) {
+ stepSize = -step;
}
- *pValue += var;
+ *pValue += stepSize;
} else {
- if (var < minStep) {
+ if (stepSize < minStep) {
*pValue += minStep;
- var = minStep;
+ stepSize = minStep;
if (target < *pValue) {
*pValue = target;
}
}
- if (var > -minStep) {
+ if (stepSize > -minStep) {
*pValue += -minStep;
if (*pValue < target) {
@@ -389,73 +421,76 @@ f32 Math_SmoothScaleMaxMinF(f32* pValue, f32 target, f32 scale, f32 maxStep, f32
return fabsf(target - *pValue);
}
-void Math_SmoothScaleMaxF(f32* pValue, f32 target, f32 scale, f32 maxStep) {
- f32 step;
-
+/**
+ * Changes pValue by step towards target. If step is more than fraction of the remaining distance, step by that instead.
+ */
+void Math_ApproachF(f32* pValue, f32 target, f32 fraction, f32 step) {
if (*pValue != target) {
- step = (target - *pValue) * scale;
+ f32 stepSize = (target - *pValue) * fraction;
- if (step > maxStep) {
- step = maxStep;
- } else if (step < -maxStep) {
- step = -maxStep;
+ if (stepSize > step) {
+ stepSize = step;
+ } else if (stepSize < -step) {
+ stepSize = -step;
}
- *pValue += step;
+ *pValue += stepSize;
}
}
-void Math_SmoothDownscaleMaxF(f32* pValue, f32 scale, f32 maxStep) {
- f32 step;
-
- step = *pValue * scale;
+/**
+ * Changes pValue by step towards zero. If step is more than fraction of the remaining distance, step by that instead.
+ */
+void Math_ApproachZeroF(f32* pValue, f32 fraction, f32 step) {
+ f32 stepSize = *pValue * fraction;
- if (step > maxStep) {
- step = maxStep;
- } else if (step < -maxStep) {
- step = -maxStep;
+ if (stepSize > step) {
+ stepSize = step;
+ } else if (stepSize < -step) {
+ stepSize = -step;
}
- *pValue -= step;
+ *pValue -= stepSize;
}
-f32 func_800784D8(f32* pValue, f32 target, f32 scale, f32 maxStep, f32 minStep) {
- f32 step;
- f32 baseStep;
-
- step = 0.0f;
- baseStep = target - *pValue;
+/**
+ * Changes pValue by step towards target angle in degrees. If this step is more than fraction of the remaining distance,
+ * step by that instead, with a minimum step of minStep. Returns the value of the step taken.
+ */
+f32 Math_SmoothStepToDegF(f32* pValue, f32 target, f32 fraction, f32 step, f32 minStep) {
+ f32 stepSize = 0.0f;
+ f32 diff = target - *pValue;
if (*pValue != target) {
- if (baseStep > 180.0f) {
- baseStep = -(360.0f - baseStep);
- } else if (baseStep < -180.0f) {
- baseStep = 360.0f + baseStep;
+ if (diff > 180.0f) {
+ diff = -(360.0f - diff);
+ } else if (diff < -180.0f) {
+ diff = 360.0f + diff;
}
- step = baseStep * scale;
+ stepSize = diff * fraction;
- if ((step >= minStep) || (step <= -minStep)) {
- if (step > maxStep) {
- step = maxStep;
+ if ((stepSize >= minStep) || (stepSize <= -minStep)) {
+ if (stepSize > step) {
+ stepSize = step;
}
- if (step < -maxStep) {
- step = -maxStep;
+ if (stepSize < -step) {
+ stepSize = -step;
}
- *pValue += step;
+ *pValue += stepSize;
} else {
- if (step < minStep) {
- step = minStep;
- *pValue += step;
+ if (stepSize < minStep) {
+ stepSize = minStep;
+ *pValue += stepSize;
if (*pValue > target) {
*pValue = target;
}
}
- if (step > -minStep) {
- step = -minStep;
- *pValue += step;
+ if (stepSize > -minStep) {
+ stepSize = -minStep;
+ *pValue += stepSize;
if (*pValue < target) {
*pValue = target;
}
@@ -471,28 +506,30 @@ f32 func_800784D8(f32* pValue, f32 target, f32 scale, f32 maxStep, f32 minStep)
*pValue += 360.0f;
}
- return step;
+ return stepSize;
}
-s16 Math_SmoothScaleMaxMinS(s16* pValue, s16 target, s16 invScale, s16 maxStep, s16 minStep) {
- s16 step = 0;
- s16 diff = (target - *pValue);
-
- s32 baseStep = diff / invScale;
+/**
+ * Changes pValue by step towards target. If this step is more than 1/scale of the remaining distance, step by that
+ * instead, with a minimum step of minStep. Returns remaining distance to target.
+ */
+s16 Math_SmoothStepToS(s16* pValue, s16 target, s16 scale, s16 step, s16 minStep) {
+ s16 stepSize = 0;
+ s16 diff = target - *pValue;
if (*pValue != target) {
- step = baseStep;
+ stepSize = diff / scale;
- if ((step > minStep) || (step < -minStep)) {
- if (step > maxStep) {
- step = maxStep;
+ if ((stepSize > minStep) || (stepSize < -minStep)) {
+ if (stepSize > step) {
+ stepSize = step;
}
- if (step < -maxStep) {
- step = -maxStep;
+ if (stepSize < -step) {
+ stepSize = -step;
}
- *pValue += step;
+ *pValue += stepSize;
} else {
if (diff >= 0) {
*pValue += minStep;
@@ -513,17 +550,20 @@ s16 Math_SmoothScaleMaxMinS(s16* pValue, s16 target, s16 invScale, s16 maxStep,
return diff;
}
-void Math_SmoothScaleMaxS(s16* pValue, s16 target, s16 invScale, s16 maxStep) {
- s16 step = target - *pValue;
+/**
+ * Changes pValue by step towards target. If step is more than 1/scale of the remaining distance, step by that instead.
+ */
+void Math_ApproachS(s16* pValue, s16 target, s16 scale, s16 maxStep) {
+ s16 diff = target - *pValue;
- step /= invScale;
+ diff /= scale;
- if (step > maxStep) {
+ if (diff > maxStep) {
*pValue += maxStep;
- } else if (step < -maxStep) {
+ } else if (diff < -maxStep) {
*pValue -= maxStep;
} else {
- *pValue += step;
+ *pValue += diff;
}
}
diff --git a/src/code/z_olib.c b/src/code/z_olib.c
index 92d66a2d3..9c1ca8861 100644
--- a/src/code/z_olib.c
+++ b/src/code/z_olib.c
@@ -80,10 +80,10 @@ Vec3f* OLib_VecSphToVec3f(Vec3f* dest, VecSph* sph) {
f32 sinYaw;
f32 cosYaw;
- cosPitch = Math_Coss(sph->pitch);
- cosYaw = Math_Coss(sph->yaw);
- sinPitch = Math_Sins(sph->pitch);
- sinYaw = Math_Sins(sph->yaw);
+ cosPitch = Math_CosS(sph->pitch);
+ cosYaw = Math_CosS(sph->yaw);
+ sinPitch = Math_SinS(sph->pitch);
+ sinYaw = Math_SinS(sph->yaw);
v.x = sph->r * sinPitch * sinYaw;
v.y = sph->r * cosPitch;
@@ -122,14 +122,14 @@ VecSph* OLib_Vec3fToVecSph(VecSph* dest, Vec3f* vec) {
if ((dist == 0.0f) && (vec->y == 0.0f)) {
sph.pitch = 0;
} else {
- sph.pitch = DEGF_TO_BINANG(RADF_TO_DEGF(Math_atan2f(dist, vec->y)));
+ sph.pitch = DEGF_TO_BINANG(RADF_TO_DEGF(Math_FAtan2F(dist, vec->y)));
}
sph.r = sqrtf(SQ(vec->y) + distSquared);
if ((vec->x == 0.0f) && (vec->z == 0.0f)) {
sph.yaw = 0;
} else {
- sph.yaw = DEGF_TO_BINANG(RADF_TO_DEGF(Math_atan2f(vec->x, vec->z)));
+ sph.yaw = DEGF_TO_BINANG(RADF_TO_DEGF(Math_FAtan2F(vec->x, vec->z)));
}
*dest = sph;
@@ -183,8 +183,8 @@ VecSph* OLib_Vec3fDiffToVecSphGeo(VecSph* dest, Vec3f* a, Vec3f* b) {
Vec3f* OLib_Vec3fDiffRad(Vec3f* dest, Vec3f* a, Vec3f* b) {
Vec3f anglesRad;
- anglesRad.x = Math_atan2f(b->z - a->z, b->y - a->y);
- anglesRad.y = Math_atan2f(b->x - a->x, b->z - a->z);
+ anglesRad.x = Math_FAtan2F(b->z - a->z, b->y - a->y);
+ anglesRad.y = Math_FAtan2F(b->x - a->x, b->z - a->z);
anglesRad.z = 0;
*dest = anglesRad;
diff --git a/src/code/z_path.c b/src/code/z_path.c
index f9bcac084..0f50fe02a 100644
--- a/src/code/z_path.c
+++ b/src/code/z_path.c
@@ -27,7 +27,7 @@ f32 Path_OrientAndGetDistSq(Actor* actor, Path* path, s16 waypoint, s16* yaw) {
dx = pointPos->x - actor->posRot.pos.x;
dz = pointPos->z - actor->posRot.pos.z;
- *yaw = Math_atan2f(dx, dz) * (32768 / M_PI);
+ *yaw = Math_FAtan2F(dx, dz) * (32768 / M_PI);
return SQ(dx) + SQ(dz);
}
diff --git a/src/code/z_play.c b/src/code/z_play.c
index 95d973dff..4d27f4d13 100644
--- a/src/code/z_play.c
+++ b/src/code/z_play.c
@@ -339,7 +339,7 @@ void Gameplay_Init(GameState* thisx) {
gTrnsnUnkState = 0;
globalCtx->transitionMode = 0;
func_8008E6A0(&globalCtx->sub_7B8);
- Math_Rand_Seed((u32)osGetTime());
+ Rand_Seed((u32)osGetTime());
Matrix_Init(&globalCtx->state);
globalCtx->state.main = Gameplay_Main;
globalCtx->state.destroy = Gameplay_Destroy;
diff --git a/src/code/z_player_lib.c b/src/code/z_player_lib.c
index 0e3291372..6d1d6204a 100644
--- a/src/code/z_player_lib.c
+++ b/src/code/z_player_lib.c
@@ -754,7 +754,7 @@ void func_8008F87C(GlobalContext* globalCtx, Player* this, SkelAnime* skelAnime,
sp58 = sp7C - SQ(sp60);
sp58 = (sp7C < SQ(sp60)) ? 0.0f : sqrtf(sp58);
- sp54 = Math_atan2f(sp58, sp60);
+ sp54 = Math_FAtan2F(sp58, sp60);
sp6C = sp80 - spA4.y;
@@ -765,9 +765,9 @@ void func_8008F87C(GlobalContext* globalCtx, Player* this, SkelAnime* skelAnime,
sp58 = sp7C - SQ(sp60);
sp58 = (sp7C < SQ(sp60)) ? 0.0f : sqrtf(sp58);
- sp50 = Math_atan2f(sp58, sp60);
+ sp50 = Math_FAtan2F(sp58, sp60);
- temp1 = (M_PI - (Math_atan2f(sp5C, sp58) + ((M_PI / 2) - sp50))) * 10430.378f;
+ temp1 = (M_PI - (Math_FAtan2F(sp5C, sp58) + ((M_PI / 2) - sp50))) * 10430.378f;
temp1 = temp1 - skelAnime->limbDrawTbl[shinLimbIndex].z;
if ((s16)(ABS(skelAnime->limbDrawTbl[shinLimbIndex].x) + ABS(skelAnime->limbDrawTbl[shinLimbIndex].y)) <
@@ -814,7 +814,7 @@ s32 func_8008FCC8(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* p
pos->y -= this->unk_6C4;
if (this->unk_6C2 != 0) {
- Matrix_Translate(pos->x, ((Math_Coss(this->unk_6C2) - 1.0f) * 200.0f) + pos->y, pos->z, MTXMODE_APPLY);
+ Matrix_Translate(pos->x, ((Math_CosS(this->unk_6C2) - 1.0f) * 200.0f) + pos->y, pos->z, MTXMODE_APPLY);
Matrix_RotateX(this->unk_6C2 * (M_PI / 32768), MTXMODE_APPLY);
Matrix_RotateRPY(rot->x, rot->y, rot->z, MTXMODE_APPLY);
pos->x = pos->y = pos->z = 0.0f;
@@ -1034,8 +1034,8 @@ void Player_DrawGetItemImpl(GlobalContext* globalCtx, Player* this, Vec3f* refPo
gSPSegment(POLY_OPA_DISP++, 0x06, this->giObjectSegment);
gSPSegment(POLY_XLU_DISP++, 0x06, this->giObjectSegment);
- Matrix_Translate(refPos->x + (3.3f * Math_Sins(this->actor.shape.rot.y)), refPos->y + height,
- refPos->z + ((3.3f + (IREG(90) / 10.0f)) * Math_Coss(this->actor.shape.rot.y)), MTXMODE_NEW);
+ Matrix_Translate(refPos->x + (3.3f * Math_SinS(this->actor.shape.rot.y)), refPos->y + height,
+ refPos->z + ((3.3f + (IREG(90) / 10.0f)) * Math_CosS(this->actor.shape.rot.y)), MTXMODE_NEW);
Matrix_RotateRPY(0, globalCtx->gameplayFrames * 1000, 0, MTXMODE_APPLY);
Matrix_Scale(0.2f, 0.2f, 0.2f, MTXMODE_APPLY);
diff --git a/src/code/z_quake.c b/src/code/z_quake.c
index 3638e3a76..8bf332420 100644
--- a/src/code/z_quake.c
+++ b/src/code/z_quake.c
@@ -64,8 +64,8 @@ void Quake_UpdateShakeInfo(QuakeRequest* req, ShakeInfo* shake, f32 y, f32 x) {
s16 Quake_Callback1(QuakeRequest* req, ShakeInfo* shake) {
s32 pad;
if (req->countdown > 0) {
- f32 a = Math_Sins(req->speed * req->countdown);
- Quake_UpdateShakeInfo(req, shake, a, Math_Rand_ZeroOne() * a);
+ f32 a = Math_SinS(req->speed * req->countdown);
+ Quake_UpdateShakeInfo(req, shake, a, Rand_ZeroOne() * a);
req->countdown--;
}
return req->countdown;
@@ -73,7 +73,7 @@ s16 Quake_Callback1(QuakeRequest* req, ShakeInfo* shake) {
s16 Quake_Callback5(QuakeRequest* req, ShakeInfo* shake) {
if (req->countdown > 0) {
- f32 a = Math_Sins(req->speed * req->countdown);
+ f32 a = Math_SinS(req->speed * req->countdown);
Quake_UpdateShakeInfo(req, shake, a, a);
req->countdown--;
}
@@ -85,14 +85,14 @@ s16 Quake_Callback6(QuakeRequest* req, ShakeInfo* shake) {
f32 a;
req->countdown--;
- a = Math_Sins(req->speed * ((req->countdown & 0xF) + 500));
- Quake_UpdateShakeInfo(req, shake, a, Math_Rand_ZeroOne() * a);
+ a = Math_SinS(req->speed * ((req->countdown & 0xF) + 500));
+ Quake_UpdateShakeInfo(req, shake, a, Rand_ZeroOne() * a);
return 1;
}
s16 Quake_Callback3(QuakeRequest* req, ShakeInfo* shake) {
if (req->countdown > 0) {
- f32 a = Math_Sins(req->speed * req->countdown) * ((f32)req->countdown / (f32)req->countdownMax);
+ f32 a = Math_SinS(req->speed * req->countdown) * ((f32)req->countdown / (f32)req->countdownMax);
Quake_UpdateShakeInfo(req, shake, a, a);
req->countdown--;
}
@@ -101,8 +101,8 @@ s16 Quake_Callback3(QuakeRequest* req, ShakeInfo* shake) {
s16 Quake_Callback2(QuakeRequest* req, ShakeInfo* shake) {
if (req->countdown > 0) {
- f32 a = Math_Rand_ZeroOne();
- Quake_UpdateShakeInfo(req, shake, a, Math_Rand_ZeroOne() * a);
+ f32 a = Rand_ZeroOne();
+ Quake_UpdateShakeInfo(req, shake, a, Rand_ZeroOne() * a);
req->countdown--;
}
return req->countdown;
@@ -110,8 +110,8 @@ s16 Quake_Callback2(QuakeRequest* req, ShakeInfo* shake) {
s16 Quake_Callback4(QuakeRequest* req, ShakeInfo* shake) {
if (req->countdown > 0) {
- f32 a = Math_Rand_ZeroOne() * ((f32)req->countdown / (f32)req->countdownMax);
- Quake_UpdateShakeInfo(req, shake, a, Math_Rand_ZeroOne() * a);
+ f32 a = Rand_ZeroOne() * ((f32)req->countdown / (f32)req->countdownMax);
+ Quake_UpdateShakeInfo(req, shake, a, Rand_ZeroOne() * a);
req->countdown--;
}
return req->countdown;
@@ -151,7 +151,7 @@ QuakeRequest* Quake_AddImpl(Camera* cam, u32 callbackIdx) {
req->camPtrIdx = cam->thisIdx;
req->callbackIdx = callbackIdx;
req->unk_1C = 1;
- req->randIdx = ((s16)(Math_Rand_ZeroOne() * (f32)0x10000) & ~3) + idx;
+ req->randIdx = ((s16)(Rand_ZeroOne() * (f32)0x10000) & ~3) + idx;
sQuakeRequestCount++;
return req;
diff --git a/src/code/z_scene.c b/src/code/z_scene.c
index 58069b1ca..7a1af1ee6 100644
--- a/src/code/z_scene.c
+++ b/src/code/z_scene.c
@@ -384,11 +384,11 @@ void func_80098D80(GlobalContext* globalCtx, SceneCmd* cmd) {
}
dayTime = gSaveContext.dayTime;
- globalCtx->envCtx.unk_04.x = -(Math_Sins(dayTime - 0x8000) * 120.0f) * 25.0f;
+ globalCtx->envCtx.unk_04.x = -(Math_SinS(dayTime - 0x8000) * 120.0f) * 25.0f;
dayTime = gSaveContext.dayTime;
- globalCtx->envCtx.unk_04.y = (Math_Coss(dayTime - 0x8000) * 120.0f) * 25.0f;
+ globalCtx->envCtx.unk_04.y = (Math_CosS(dayTime - 0x8000) * 120.0f) * 25.0f;
dayTime = gSaveContext.dayTime;
- globalCtx->envCtx.unk_04.z = (Math_Coss(dayTime - 0x8000) * 20.0f) * 25.0f;
+ globalCtx->envCtx.unk_04.z = (Math_CosS(dayTime - 0x8000) * 20.0f) * 25.0f;
if (((globalCtx->envCtx.unk_02 == 0) && (gSaveContext.cutsceneIndex < 0xFFF0)) ||
(gSaveContext.entranceIndex == 0x0604)) {
diff --git a/src/code/z_scene_table.c b/src/code/z_scene_table.c
index 8de6d86ad..5d10ded73 100644
--- a/src/code/z_scene_table.c
+++ b/src/code/z_scene_table.c
@@ -1449,11 +1449,11 @@ void func_8009BEEC(GlobalContext* globalCtx) {
Quake_SetCountdown(var, 127);
}
- if ((globalCtx->gameplayFrames % 64 == 0) && (Math_Rand_ZeroOne() > 0.6f)) {
+ if ((globalCtx->gameplayFrames % 64 == 0) && (Rand_ZeroOne() > 0.6f)) {
var = Quake_Add(ACTIVE_CAM, 3);
- Quake_SetSpeed(var, 32000.0f + (Math_Rand_ZeroOne() * 3000.0f));
- Quake_SetQuakeValues(var, 10.0f - (Math_Rand_ZeroOne() * 9.0f), 0, 0, 0);
- Quake_SetCountdown(var, 48.0f - (Math_Rand_ZeroOne() * 15.0f));
+ Quake_SetSpeed(var, 32000.0f + (Rand_ZeroOne() * 3000.0f));
+ Quake_SetQuakeValues(var, 10.0f - (Rand_ZeroOne() * 9.0f), 0, 0, 0);
+ Quake_SetCountdown(var, 48.0f - (Rand_ZeroOne() * 15.0f));
}
}
@@ -1836,11 +1836,11 @@ void func_8009DA30(GlobalContext* globalCtx) {
} else {
if (gSaveContext.dayTime > 0xC555) {
if (globalCtx->unk_11D30[0] != 255) {
- Math_ApproxS(&globalCtx->unk_11D30[0], 255, 5);
+ Math_StepToS(&globalCtx->unk_11D30[0], 255, 5);
}
} else if (gSaveContext.dayTime >= 0x4000) {
if (globalCtx->unk_11D30[0] != 0) {
- Math_ApproxS(&globalCtx->unk_11D30[0], 0, 10);
+ Math_StepToS(&globalCtx->unk_11D30[0], 0, 10);
}
}
@@ -2189,11 +2189,11 @@ void func_8009F5D4(GlobalContext* globalCtx) {
} else {
if (gSaveContext.dayTime > 0xC000) {
if (globalCtx->unk_11D30[0] != 255) {
- Math_ApproxS(&globalCtx->unk_11D30[0], 255, 5);
+ Math_StepToS(&globalCtx->unk_11D30[0], 255, 5);
}
} else if (gSaveContext.dayTime >= 0x4000) {
if (globalCtx->unk_11D30[0] != 0) {
- Math_ApproxS(&globalCtx->unk_11D30[0], 0, 10);
+ Math_StepToS(&globalCtx->unk_11D30[0], 0, 10);
}
}
@@ -2343,10 +2343,10 @@ void func_8009FE58(GlobalContext* globalCtx) {
D_8012A3A0 += 1820;
temp = 0.020000001f;
- func_800AA76C(&globalCtx->view, 0.00009587531f * temp * Math_Coss(D_8012A39C),
- 0.00009587531f * temp * Math_Sins(D_8012A39C), 0.00009587531f * temp * Math_Sins(D_8012A3A0));
- func_800AA78C(&globalCtx->view, 1.f + (0.79999995f * temp * Math_Sins(D_8012A3A0)),
- 1.f + (0.39999998f * temp * Math_Coss(D_8012A3A0)), 1.f + (1 * temp * Math_Coss(D_8012A39C)));
+ func_800AA76C(&globalCtx->view, 0.00009587531f * temp * Math_CosS(D_8012A39C),
+ 0.00009587531f * temp * Math_SinS(D_8012A39C), 0.00009587531f * temp * Math_SinS(D_8012A3A0));
+ func_800AA78C(&globalCtx->view, 1.f + (0.79999995f * temp * Math_SinS(D_8012A3A0)),
+ 1.f + (0.39999998f * temp * Math_CosS(D_8012A3A0)), 1.f + (1 * temp * Math_CosS(D_8012A39C)));
func_800AA7AC(&globalCtx->view, 0.95f);
switch (globalCtx->unk_11D30[0]) {
diff --git a/src/code/z_skelanime.c b/src/code/z_skelanime.c
index e57b770dd..2ab52c9e2 100644
--- a/src/code/z_skelanime.c
+++ b/src/code/z_skelanime.c
@@ -1397,11 +1397,11 @@ s32 func_800A4AD8(SkelAnime* skelAnime) {
}
temp_a1 = skelAnime->transCurrentFrame * 0x4000;
if (skelAnime->unk_03 < 0) {
- sp28 = 1.0f - Math_Coss(temp_a2);
- phi_f2 = 1.0f - Math_Coss(temp_a1);
+ sp28 = 1.0f - Math_CosS(temp_a2);
+ phi_f2 = 1.0f - Math_CosS(temp_a1);
} else {
- sp28 = Math_Sins(temp_a2);
- phi_f2 = Math_Sins(temp_a1);
+ sp28 = Math_SinS(temp_a2);
+ phi_f2 = Math_SinS(temp_a1);
}
if (phi_f2 != 0.0f) {
phi_f2 /= sp28;
@@ -1614,15 +1614,15 @@ void func_800A54FC(SkelAnime* skelAnime, Vec3f* pos, s16 angle) {
// `angle` rotation around y axis.
x = skelAnime->limbDrawTbl[0].x;
z = skelAnime->limbDrawTbl[0].z;
- sin = Math_Sins(angle);
- cos = Math_Coss(angle);
+ sin = Math_SinS(angle);
+ cos = Math_CosS(angle);
pos->x = x * cos + z * sin;
pos->z = z * cos - x * sin;
x = skelAnime->prevFramePos.x;
z = skelAnime->prevFramePos.z;
// `prevFrameRot` rotation around y axis.
- sin = Math_Sins(skelAnime->prevFrameRot);
- cos = Math_Coss(skelAnime->prevFrameRot);
+ sin = Math_SinS(skelAnime->prevFrameRot);
+ cos = Math_CosS(skelAnime->prevFrameRot);
pos->x -= x * cos + z * sin;
pos->z -= z * cos - x * sin;
}
diff --git a/src/code/z_skin_matrix.c b/src/code/z_skin_matrix.c
index f299f76c9..1392b1fb0 100644
--- a/src/code/z_skin_matrix.c
+++ b/src/code/z_skin_matrix.c
@@ -330,8 +330,8 @@ void SkinMatrix_SetRotateRPY(MtxF* mf, s16 roll, s16 pitch, s16 yaw) {
f32 yy;
f32 zy;
- sin = Math_Sins(yaw);
- cos = Math_Coss(yaw);
+ sin = Math_SinS(yaw);
+ cos = Math_CosS(yaw);
mf->yy = cos;
mf->yx = -sin;
mf->xw = mf->yw = mf->zw = 0;
@@ -339,8 +339,8 @@ void SkinMatrix_SetRotateRPY(MtxF* mf, s16 roll, s16 pitch, s16 yaw) {
mf->ww = 1;
if (pitch != 0) {
- sin2 = Math_Sins(pitch);
- cos2 = Math_Coss(pitch);
+ sin2 = Math_SinS(pitch);
+ cos2 = Math_CosS(pitch);
mf->xx = cos * cos2;
mf->zx = cos * sin2;
@@ -361,8 +361,8 @@ void SkinMatrix_SetRotateRPY(MtxF* mf, s16 roll, s16 pitch, s16 yaw) {
}
if (roll != 0) {
- sin2 = Math_Sins(roll);
- cos2 = Math_Coss(roll);
+ sin2 = Math_SinS(roll);
+ cos2 = Math_CosS(roll);
yx = mf->yx;
zx = mf->zx;
@@ -395,8 +395,8 @@ void SkinMatrix_SetRotateYRP(MtxF* mf, s16 yaw, s16 roll, s16 pitch) {
f32 yz;
f32 xx;
f32 yx;
- sin = Math_Sins(roll);
- cos = Math_Coss(roll);
+ sin = Math_SinS(roll);
+ cos = Math_CosS(roll);
mf->xx = cos;
mf->xz = -sin;
mf->zw = 0;
@@ -408,8 +408,8 @@ void SkinMatrix_SetRotateYRP(MtxF* mf, s16 yaw, s16 roll, s16 pitch) {
mf->ww = 1;
if (yaw != 0) {
- sin2 = Math_Sins(yaw);
- cos2 = Math_Coss(yaw);
+ sin2 = Math_SinS(yaw);
+ cos2 = Math_CosS(yaw);
mf->zz = cos * cos2;
mf->yz = cos * sin2;
@@ -430,8 +430,8 @@ void SkinMatrix_SetRotateYRP(MtxF* mf, s16 yaw, s16 roll, s16 pitch) {
}
if (pitch != 0) {
- sin2 = Math_Sins(pitch);
- cos2 = Math_Coss(pitch);
+ sin2 = Math_SinS(pitch);
+ cos2 = Math_CosS(pitch);
xx = mf->xx;
yx = mf->yx;
mf->xx = (xx * cos2) + (yx * sin2);
@@ -620,8 +620,8 @@ void func_800A7EC0(MtxF* mf, s16 a, f32 x, f32 y, f32 z) {
f32 xz;
f32 pad;
- sinA = Math_Sins(a);
- cosA = Math_Coss(a);
+ sinA = Math_SinS(a);
+ cosA = Math_CosS(a);
xx = x * x;
yy = y * y;