summaryrefslogtreecommitdiff
path: root/src/engine/rng.c
diff options
context:
space:
mode:
authorMarcus Huderle <huderlem@gmail.com>2017-11-11 15:42:40 -0800
committerMarcus Huderle <huderlem@gmail.com>2017-11-11 16:06:44 -0800
commit267ada5ce6e2876c4df64275da9ee879a385c6f6 (patch)
tree559417726bbd5f3b18c153c1435f872decfe18b1 /src/engine/rng.c
parent20d00c58ef49fa88533fa07ab1801c381f02b7bf (diff)
parent67ad331441f29545b84d152cbbb4f188098a9c5a (diff)
Merge remote-tracking branch 'upstream/master' into 80c
Diffstat (limited to 'src/engine/rng.c')
-rw-r--r--src/engine/rng.c18
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;
+}