diff options
author | YamaArashi <shadow962@live.com> | 2017-02-02 16:30:08 -0800 |
---|---|---|
committer | YamaArashi <shadow962@live.com> | 2017-02-02 16:30:30 -0800 |
commit | 8f9ed6e585a361e957650b871fc56a0406c2dac8 (patch) | |
tree | fc4796bcad3363136dc7130e8c5ee814104a29d7 /src | |
parent | 39299306e059d82516247aeacd04b680509eef8c (diff) |
decompile rng
Diffstat (limited to 'src')
-rw-r--r-- | src/rng.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/rng.c b/src/rng.c new file mode 100644 index 000000000..9e473ef62 --- /dev/null +++ b/src/rng.c @@ -0,0 +1,35 @@ +#include "global.h" +#include "rng.h" + +// The number 1103515245 comes from the example implementation of rand and srand +// in the ISO C standard. + +extern u32 gRngValue; +extern u32 gRng2Value; + +EWRAM_DATA u8 sUnknown = 0; +EWRAM_DATA u32 sRandCount = 0; + +u16 Random() +{ + gRngValue = 1103515245 * gRngValue + 24691; + sRandCount++; + return gRngValue >> 16; +} + +void SeedRng(u16 seed) +{ + gRngValue = seed; + sUnknown = 0; +} + +void SeedRng2(u16 seed) +{ + gRng2Value = seed; +} + +u16 Random2(void) +{ + gRng2Value = 1103515245 * gRng2Value + 24691; + return gRng2Value >> 16; +} |