2019-01-01 20:46:06 +01:00
|
|
|
//----------------------------------------------------------------------------//
|
|
|
|
// GNU GPL OS/K //
|
|
|
|
// //
|
|
|
|
// Authors: spectral` //
|
|
|
|
// NeoX //
|
|
|
|
// //
|
|
|
|
// Desc: RNG related functions //
|
|
|
|
//----------------------------------------------------------------------------//
|
|
|
|
|
|
|
|
#include <kaleid.h>
|
|
|
|
|
|
|
|
//
|
2019-01-14 14:31:49 +01:00
|
|
|
// Seed value
|
2019-01-01 20:46:06 +01:00
|
|
|
//
|
|
|
|
static ulong next = 7756;
|
|
|
|
|
|
|
|
//
|
2019-01-14 14:31:49 +01:00
|
|
|
// Returns a pseudo-random integer
|
|
|
|
// To be improved
|
2019-01-01 20:46:06 +01:00
|
|
|
//
|
|
|
|
int rand(void)
|
|
|
|
{
|
|
|
|
next = next * 1103515245 + 12345;
|
|
|
|
return (uint)(next / 65536) % INT_MAX;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
2019-01-14 14:31:49 +01:00
|
|
|
// (Re)Set the random seed
|
2019-01-01 20:46:06 +01:00
|
|
|
//
|
|
|
|
void srand(uint seed)
|
|
|
|
{
|
|
|
|
next = (ulong)seed;
|
|
|
|
}
|
|
|
|
|