diff options
author | yenatch <yenatch@gmail.com> | 2017-10-08 23:54:46 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-08 23:54:46 -0400 |
commit | b0d49dbbfbfcf39c2a9f88572437b6af77c8f709 (patch) | |
tree | be0dadd4cb3a6c36e27233836a6f104359d49949 /src/engine/rng.c | |
parent | b21c159b08c57a948edb268ac9b9b5baf6b4332d (diff) | |
parent | 3776a9fb4f0531535b0b5879dab7b3b6bd231736 (diff) |
Merge branch 'master' into scaninc
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; +} |