summaryrefslogtreecommitdiff
path: root/src/random.c
diff options
context:
space:
mode:
authorpaul <nintendo6496@googlemail.com>2018-10-10 22:54:23 +0200
committerpaul <nintendo6496@googlemail.com>2018-10-10 22:54:23 +0200
commit3f0827128a6ba39577dbaa1ea28f8641e4a20780 (patch)
treebb4cb2804a27325561a65e133f31a1e4d2671fbe /src/random.c
parent1ee1ebe23a49bbbc040a43e0e6fb81badc588f22 (diff)
parent10fff9c6f2d29899952d1751d3de827e7e98bb60 (diff)
resolve merge conflict about graphics_file_rules.mk and prepare for adding pokemon graphics
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..54dae0824
--- /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;
+}