summaryrefslogtreecommitdiff
path: root/src/random.c
diff options
context:
space:
mode:
authorPikalaxALT <pikalaxalt@gmail.com>2018-03-16 08:40:24 -0400
committerPikalaxALT <pikalaxalt@gmail.com>2018-03-16 08:40:24 -0400
commit0e372d2fb6785ba47011b6ee0ad1b68ea05ae198 (patch)
tree72a7d12902002dc661cd543a270a11bda45a7645 /src/random.c
parentb98c803e6d25785b3b268c2c26a87ac74a7e3a95 (diff)
parentd51855dfadf9e1357ef8e33e90b5156f8561405c (diff)
Merge branch 'master' into tomomichi_debug_menu
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;
+}