diff options
Diffstat (limited to 'src/other_random.c')
-rw-r--r-- | src/other_random.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/other_random.c b/src/other_random.c new file mode 100644 index 0000000..847530e --- /dev/null +++ b/src/other_random.c @@ -0,0 +1,20 @@ +#include "global.h" +#include "other_random.h" + +extern u16 gOtherRngState; + +static s32 OtherRandom16(void) +{ + gOtherRngState = 109 * gOtherRngState + 1021; + return gOtherRngState; +} + +s32 OtherRandomCapped(s32 cap) +{ + return (OtherRandom16() * cap) >> 16; +} + +s32 OtherRandomRange(s32 a, s32 b) +{ + return OtherRandomCapped(b - a) + a; +} |