From f57776c74cded4b10f974828c991c095faaa6d67 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sat, 28 Oct 2017 15:58:07 -0400 Subject: through sub_8151574 --- src/math_util.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 src/math_util.c (limited to 'src/math_util.c') diff --git a/src/math_util.c b/src/math_util.c new file mode 100644 index 000000000..f249d0a51 --- /dev/null +++ b/src/math_util.c @@ -0,0 +1,43 @@ + +// Includes +#include "global.h" + +// Static type declarations + +// Static RAM declarations + +// Static ROM declarations + +// .rodata + +// .text + +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; +} -- cgit v1.2.3 From 8613e8a54d1981dc8f204ecae139726144e640ed Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sat, 28 Oct 2017 16:09:31 -0400 Subject: through sub_81515FC --- src/math_util.c | 43 +++++++++++++++++++++++++++++++------------ 1 file changed, 31 insertions(+), 12 deletions(-) (limited to 'src/math_util.c') diff --git a/src/math_util.c b/src/math_util.c index f249d0a51..3eb995d27 100644 --- a/src/math_util.c +++ b/src/math_util.c @@ -1,17 +1,5 @@ - -// Includes #include "global.h" -// Static type declarations - -// Static RAM declarations - -// Static ROM declarations - -// .rodata - -// .text - s16 sub_8151534(s16 x, s16 y) { s32 result; @@ -41,3 +29,34 @@ s32 sub_8151574(s32 x, s32 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; +} -- cgit v1.2.3 From 6d3778948d39884d5d5069837b047cd95c9f5a31 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sat, 28 Oct 2017 16:15:36 -0400 Subject: finish math_util --- src/math_util.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/math_util.c') diff --git a/src/math_util.c b/src/math_util.c index 3eb995d27..83935454a 100644 --- a/src/math_util.c +++ b/src/math_util.c @@ -60,3 +60,27 @@ s32 sub_81515FC(s32 x, s32 y) _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; +} -- cgit v1.2.3