sysprog-basic/include/rand.c

16 lines
328 B
C
Raw Normal View History

2023-12-09 14:36:58 +01:00
#include "adc.h"
2023-12-09 14:20:18 +01:00
int rand() {
static unsigned int seed = 1337191337;
2023-12-09 14:36:58 +01:00
seed *= adc_read(3);
2023-12-09 14:20:18 +01:00
unsigned int buf[] = {
(seed*31832)%677,
(seed*32932)%2332
};
seed = buf[1]*223238;
seed *= seed << 4;
seed %= 410829;
seed = buf[0] * 1892823 % 23891;
seed = buf[0];
return seed;
}