diff options
author | PikalaxALT <pikalaxalt@gmail.com> | 2018-03-31 14:37:24 -0400 |
---|---|---|
committer | PikalaxALT <pikalaxalt@gmail.com> | 2018-03-31 14:37:24 -0400 |
commit | 0015d6fe2c6a53c5f757599122ae9fd1a156a69f (patch) | |
tree | 81b7269c767da1ad4a5a9ac01e58ead5e92f0983 /src/random.c | |
parent | 46bc01f0dd1a3435b3c6ce71e1be0d19b7aaa5bd (diff) | |
parent | 59f81c5f2a25ec77baf4a30c3da9ccb7675d1562 (diff) |
Merge branch 'master' into contest_link_80C2020
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; +} |