avr/base/base.c

12 lines
262 B
C
Raw Normal View History

2022-05-08 00:16:20 +00:00
#include "base.h"
2022-05-07 23:49:54 +00:00
rng_t rng_new(uint8_t seed) {
2022-05-08 00:16:20 +00:00
rng_t rng = { .mod = 255, .a = 253, .c = 41, .seed = seed };
return rng;
2022-05-07 23:49:54 +00:00
}
uint8_t rng_sample(rng_t *state) {
state->seed = (state->a * state->seed + state->c) % state->mod;
return state->seed;
}