~ruther/qmk_firmware

ref: 07dc49a918588fbb7ca69f82d97bf6a341730ee7 qmk_firmware/keyboards/lily58/keymaps/druotoni/fast_random.c -rw-r--r-- 405 bytes
07dc49a9 — QMK Bot Merge remote-tracking branch 'origin/master' into develop 2 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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;
}