summaryrefslogtreecommitdiff
path: root/src/math_util.c
diff options
context:
space:
mode:
authorPikalaxALT <pikalaxalt@gmail.com>2017-11-02 00:09:14 -0400
committerPikalaxALT <pikalaxalt@gmail.com>2017-11-02 00:09:14 -0400
commit75262c1920a0611f89e95837efb4f5e327760a8b (patch)
tree9982e4fcd275f8a1ea3c851c3dbf297d9e1c1307 /src/math_util.c
parent6e5dcf19f76b1839537848cf0fd91c7ddb27898c (diff)
parentc71f6baa8cb713a567520279ff18dca0c4ed0915 (diff)
Merge branch 'master' into bard_music
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..83935454a
--- /dev/null
+++ b/src/math_util.c
@@ -0,0 +1,86 @@
+#include "global.h"
+
+s16 sub_8151534(s16 x, s16 y)
+{
+ s32 result;
+
+ result = x;
+ result *= y;
+ result /= 256;
+ return result;
+}
+
+s16 sub_8151550(u8 s, s16 x, s16 y)
+{
+ s32 result;
+
+ result = x;
+ result *= y;
+ result /= (1 << s);
+ return result;
+}
+
+s32 sub_8151574(s32 x, s32 y)
+{
+ s64 result;
+
+ result = x;
+ result *= y;
+ result /= 256;
+ return result;
+}
+
+s16 sub_81515B0(s16 x, s16 y)
+{
+ if (y == 0)
+ {
+ return 0;
+ }
+ return (x << 8) / y;
+}
+
+s16 sub_81515D4(u8 s, s16 x, s16 y)
+{
+ if (y == 0)
+ {
+ return 0;
+ }
+ return (x << s) / y;
+}
+
+s32 sub_81515FC(s32 x, s32 y)
+{
+ s64 _x;
+
+ if (y == 0)
+ {
+ return 0;
+ }
+ _x = x;
+ _x *= 256;
+ return _x / y;
+}
+
+s16 sub_8151624(s16 y)
+{
+ s32 x;
+
+ x = 0x10000;
+ return x / y;
+}
+
+s16 sub_815163C(u8 s, s16 y)
+{
+ s32 x;
+
+ x = 0x100 << s;
+ return x / y;
+}
+
+s32 sub_815165C(s32 y)
+{
+ s64 x;
+
+ x = 0x10000;
+ return x / y;
+}