diff options
author | Marcus Huderle <huderlem@gmail.com> | 2018-04-04 18:27:50 -0700 |
---|---|---|
committer | Marcus Huderle <huderlem@gmail.com> | 2018-04-04 18:27:50 -0700 |
commit | 3a7f68151e0f0fa71ddb35bd96439c25ffd61576 (patch) | |
tree | c8297d41af868eac80642c1f811bc009fa142099 /src/random.c | |
parent | 2c4d7844e48864d962573eb66fe4b9e68b9631f0 (diff) | |
parent | ce75a3895c73f25d6dc7b019ed06e4193965ab35 (diff) |
Merge remote-tracking branch 'upstream/master' into battle-1
Diffstat (limited to 'src/random.c')
-rw-r--r-- | src/random.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/random.c b/src/random.c new file mode 100644 index 000000000..8f82b722f --- /dev/null +++ b/src/random.c @@ -0,0 +1,18 @@ +#include "global.h" +#include "random.h" + +// The number 1103515245 comes from the example implementation of rand and srand +// in the ISO C standard. + +u32 gRngValue; + +u16 Random(void) +{ + gRngValue = 1103515245 * gRngValue + 24691; + return gRngValue >> 16; +} + +void SeedRng(u16 seed) +{ + gRngValue = seed; +} |