diff options
Diffstat (limited to 'keyboards/lily58/keymaps/druotoni/fast_random.c')
| -rw-r--r-- | keyboards/lily58/keymaps/druotoni/fast_random.c | 17 |
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 000000000..3028b57ac --- /dev/null +++ b/keyboards/lily58/keymaps/druotoni/fast_random.c | |||
| @@ -0,0 +1,17 @@ | |||
| 1 | // Copyright 2021 Nicolas Druoton (druotoni) | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | #include "fast_random.h" | ||
| 4 | |||
| 5 | // seed for random | ||
| 6 | static unsigned long g_seed = 0; | ||
| 7 | |||
| 8 | int fastrand(void) { | ||
| 9 | // todo : try with random16(); | ||
| 10 | g_seed = (214013 * g_seed + 2531011); | ||
| 11 | return (g_seed >> 16) & 0x7FFF; | ||
| 12 | } | ||
| 13 | |||
| 14 | unsigned long fastrand_long(void) { | ||
| 15 | g_seed = (214013 * g_seed + 2531011); | ||
| 16 | return g_seed; | ||
| 17 | } | ||
