summaryrefslogtreecommitdiff
path: root/keyboards/lily58/keymaps/druotoni/fast_random.c
diff options
context:
space:
mode:
Diffstat (limited to 'keyboards/lily58/keymaps/druotoni/fast_random.c')
-rw-r--r--keyboards/lily58/keymaps/druotoni/fast_random.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/keyboards/lily58/keymaps/druotoni/fast_random.c b/keyboards/lily58/keymaps/druotoni/fast_random.c
new file mode 100644
index 0000000000..3028b57ac6
--- /dev/null
+++ b/keyboards/lily58/keymaps/druotoni/fast_random.c
@@ -0,0 +1,17 @@
+// Copyright 2021 Nicolas Druoton (druotoni)
+// SPDX-License-Identifier: GPL-2.0-or-later
+#include "fast_random.h"
+
+// seed for random
+static unsigned long g_seed = 0;
+
+int fastrand(void) {
+ // todo : try with random16();
+ g_seed = (214013 * g_seed + 2531011);
+ return (g_seed >> 16) & 0x7FFF;
+}
+
+unsigned long fastrand_long(void) {
+ g_seed = (214013 * g_seed + 2531011);
+ return g_seed;
+}