WIP Background

This commit is contained in:
Nikola Petrov
2024-08-12 17:53:57 +02:00
parent 34e8e7421a
commit aaf5e45824
7 changed files with 157 additions and 47 deletions

25
src/values/MyRand.cpp Normal file
View File

@@ -0,0 +1,25 @@
#include <inttypes.h>
static uint32_t rprand_state[4] = {0};
static inline uint32_t my_rotate_left(const uint32_t x, int k)
{
return (x << k) | (x >> (32 - k));
}
uint32_t my_rprand_xoshiro(void)
{
const uint32_t result = my_rotate_left(rprand_state[1] * 5, 7) * 9;
const uint32_t t = rprand_state[1] << 9;
rprand_state[2] ^= rprand_state[0];
rprand_state[3] ^= rprand_state[1];
rprand_state[1] ^= rprand_state[2];
rprand_state[0] ^= rprand_state[3];
rprand_state[2] ^= t;
rprand_state[3] = my_rotate_left(rprand_state[3], 11);
return result;
}