diff options
author | Diegoisawesome <diego@domoreaweso.me> | 2017-11-09 19:43:30 -0600 |
---|---|---|
committer | Diegoisawesome <diego@domoreaweso.me> | 2017-11-09 20:30:56 -0600 |
commit | 09e431077af3c6fe672ad8a775b58d955596b81d (patch) | |
tree | 88d2eceb1071df85b4f73b1742885127755579c6 /src/math_util.c | |
parent | 2d3044aaa645bbad85e8e60dfe23f7f0224383ca (diff) | |
parent | af197ccd3bd62fab813154dc4311e65f9992a676 (diff) |
Merge remote-tracking branch 'pret/master' into dump_maps
Diffstat (limited to 'src/math_util.c')
-rw-r--r-- | src/math_util.c | 86 |
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; +} |