summaryrefslogtreecommitdiff
path: root/src/random.c
diff options
context:
space:
mode:
authorMarcus Huderle <huderlem@gmail.com>2018-04-05 18:41:42 -0700
committerMarcus Huderle <huderlem@gmail.com>2018-04-05 18:41:42 -0700
commit66367c82ef07c10957d45ce7f0f776a178454e18 (patch)
tree0dd4fcd5cce3ef14dae4fc9ae91e54c6e070eef6 /src/random.c
parent171dd32df8a56e1f10956be8b944cb216edb8f9d (diff)
parent781d0ca44c8eab2b7751fe8f337d6acde7fe8582 (diff)
Merge remote-tracking branch 'upstream/master' into btl_attrs
Diffstat (limited to 'src/random.c')
-rw-r--r--src/random.c18
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;
+}