summaryrefslogtreecommitdiff
path: root/src/math_util.c
diff options
context:
space:
mode:
authorPikalaxALT <pikalaxalt@gmail.com>2018-11-02 14:16:03 -0400
committerPikalaxALT <pikalaxalt@gmail.com>2018-11-02 14:16:03 -0400
commit5391289fc1164eab859856617f8dede7db3fe435 (patch)
tree8cb4f701f3b49cf182715e28b0d818c778ff9e5c /src/math_util.c
parent46e006b94cf7a2e59652a083cdd01f0d5dc9a26f (diff)
parentc0a9d620919bd6403772c4e5a236d47cd40ae861 (diff)
Merge branch 'master' into quest_log
Diffstat (limited to 'src/math_util.c')
-rw-r--r--src/math_util.c86
1 files changed, 86 insertions, 0 deletions
diff --git a/src/math_util.c b/src/math_util.c
new file mode 100644
index 000000000..466a31921
--- /dev/null
+++ b/src/math_util.c
@@ -0,0 +1,86 @@
+#include "global.h"
+
+s16 sub_80D8AA0(s16 x, s16 y)
+{
+ s32 result;
+
+ result = x;
+ result *= y;
+ result /= 256;
+ return result;
+}
+
+s16 sub_80D8ABC(u8 s, s16 x, s16 y)
+{
+ s32 result;
+
+ result = x;
+ result *= y;
+ result /= (1 << s);
+ return result;
+}
+
+s32 sub_80D8AE0(s32 x, s32 y)
+{
+ s64 result;
+
+ result = x;
+ result *= y;
+ result /= 256;
+ return result;
+}
+
+s16 sub_80D8B1C(s16 x, s16 y)
+{
+ if (y == 0)
+ {
+ return 0;
+ }
+ return (x << 8) / y;
+}
+
+s16 sub_80D8B40(u8 s, s16 x, s16 y)
+{
+ if (y == 0)
+ {
+ return 0;
+ }
+ return (x << s) / y;
+}
+
+s32 sub_80D8B68(s32 x, s32 y)
+{
+ s64 _x;
+
+ if (y == 0)
+ {
+ return 0;
+ }
+ _x = x;
+ _x *= 256;
+ return _x / y;
+}
+
+s16 sub_80D8B90(s16 y)
+{
+ s32 x;
+
+ x = 0x10000;
+ return x / y;
+}
+
+s16 sub_80D8BA8(u8 s, s16 y)
+{
+ s32 x;
+
+ x = 0x100 << s;
+ return x / y;
+}
+
+s32 sub_80D8BC8(s32 y)
+{
+ s64 x;
+
+ x = 0x10000;
+ return x / y;
+}