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)
|
|
|
|
{
|
2019-01-21 09:53:54 +01:00
|
|
|
next = next * 1103515245 + 12347;
|
|
|
|
return (uint)(next / 65536);
|
2019-01-01 20:46:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
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;
|
|
|
|
}
|
|
|
|
|