summaryrefslogtreecommitdiff
path: root/src/random.c
diff options
context:
space:
mode:
authorPikalaxALT <pikalaxalt@gmail.com>2018-03-31 14:37:24 -0400
committerPikalaxALT <pikalaxalt@gmail.com>2018-03-31 14:37:24 -0400
commit0015d6fe2c6a53c5f757599122ae9fd1a156a69f (patch)
tree81b7269c767da1ad4a5a9ac01e58ead5e92f0983 /src/random.c
parent46bc01f0dd1a3435b3c6ce71e1be0d19b7aaa5bd (diff)
parent59f81c5f2a25ec77baf4a30c3da9ccb7675d1562 (diff)
Merge branch 'master' into contest_link_80C2020
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;
+}