diff options
author | DizzyEggg <jajkodizzy@wp.pl> | 2017-12-17 20:22:56 +0100 |
---|---|---|
committer | DizzyEggg <jajkodizzy@wp.pl> | 2017-12-17 20:22:56 +0100 |
commit | 46fa2557d777096803ff90ba95d5500a9c03d2c5 (patch) | |
tree | ded4f0e046be43e371631fca3ac013d96fa244e0 /src/random.c | |
parent | 930fea6fad24692773b930ec7448c59d599844b8 (diff) | |
parent | 6d73bb4b57efb3ff81dcc2aa0d00d5de380add9e (diff) |
merge mail with master, fix conflicts
Diffstat (limited to 'src/random.c')
-rw-r--r-- | src/random.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/random.c b/src/random.c new file mode 100644 index 000000000..f2f0ede58 --- /dev/null +++ b/src/random.c @@ -0,0 +1,32 @@ +#include "global.h" +#include "random.h" + +// The number 1103515245 comes from the example implementation of rand and srand +// in the ISO C standard. + +EWRAM_DATA static u8 sUnknown = 0; +EWRAM_DATA static u32 sRandCount = 0; + +u16 Random(void) +{ + 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; +} |