summaryrefslogtreecommitdiff
path: root/src/code/sys_math.c
diff options
context:
space:
mode:
authorkrimtonz <33664508+krimtonz@users.noreply.github.com>2020-04-18 22:28:24 -0500
committerGitHub <noreply@github.com>2020-04-18 23:28:24 -0400
commitee48867446b9888287e9eaa304b014b5f6a54736 (patch)
treea967f9b627d5c57e08271481718e4b08a4769860 /src/code/sys_math.c
parenteefbe9afe1891ea27eb39315a3c87e87abef0828 (diff)
Math Files (#76)
* math3d wip * math3d wip * wip * wip * wip * wip * final update before pr * run format.sh * fix merge conflicts * tharo suggestions update * fig formatting suggestion * math3d pr updates * use sFactorialTbl in sys_math
Diffstat (limited to 'src/code/sys_math.c')
-rw-r--r--src/code/sys_math.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/code/sys_math.c b/src/code/sys_math.c
new file mode 100644
index 000000000..25af276ec
--- /dev/null
+++ b/src/code/sys_math.c
@@ -0,0 +1,48 @@
+#include <global.h>
+#include <math.h>
+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 ret = 1.0f;
+ s32 i;
+ for (i = arg0; i > 1; i--) {
+ ret *= i;
+ }
+ return ret;
+}
+
+#ifdef NON_MATCHING
+f32 func_800CA63C(u32 arg0) {
+ f32 ret;
+ s32 i;
+ if (arg0 > 12) {
+ ret = sFactorialTbl[12];
+ for (i = 13; i < (s32)arg0; i++) {
+ ret *= i;
+ }
+ } else {
+ ret = sFactorialTbl[arg0];
+ }
+ return ret;
+}
+#else
+#pragma GLOBAL_ASM("asm/non_matchings/code/sys_math/func_800CA63C.s")
+#endif
+
+f32 func_800CA6FC(f32 arg0, s32 arg1) {
+ f32 ret = 1.0f;
+ while (arg1 > 0) {
+ arg1--;
+ ret *= arg0;
+ }
+ return ret;
+}
+
+f32 func_800CA720(f32 arg0) {
+ return sins((s16)(arg0 * (32767.0f / M_PI))) * SHT_MINV;
+}
+
+f32 func_800CA774(f32 arg0) {
+ return coss((s16)(arg0 * (32767.0f / M_PI))) * SHT_MINV;
+}