diff options
author | Marcus Huderle <huderlem@gmail.com> | 2017-09-30 19:23:55 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-30 19:23:55 -0700 |
commit | 83efcc9c3d1e81b78c2cd9ceab3ac6420a5f4070 (patch) | |
tree | 19bbb03916702b468956e82ed2bbe6d259b77a85 /src/engine/rng.c | |
parent | 5fb9b9052276243d54ecfc27d0514e9c35825e8c (diff) | |
parent | 70c45eb2616195eb47b8bc67d03a1589cd6c56e6 (diff) |
Merge pull request #411 from ProjectRevoTPP/refactor_src
split out src/ directory into categorized subdirectories.
Diffstat (limited to 'src/engine/rng.c')
-rw-r--r-- | src/engine/rng.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/engine/rng.c b/src/engine/rng.c new file mode 100644 index 000000000..7d4b5600e --- /dev/null +++ b/src/engine/rng.c @@ -0,0 +1,18 @@ +#include "global.h" +#include "rng.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; +} |