35 lines
952 B
C
35 lines
952 B
C
|
//----------------------------------------------------------------------------//
|
||
|
// GNU GPL OS/K //
|
||
|
// //
|
||
|
// Authors: spectral` //
|
||
|
// NeoX //
|
||
|
// //
|
||
|
// Desc: RNG related functions //
|
||
|
//----------------------------------------------------------------------------//
|
||
|
|
||
|
#include <kalbase.h>
|
||
|
|
||
|
//
|
||
|
// Seed value
|
||
|
//
|
||
|
static ulong next = 7756;
|
||
|
|
||
|
//
|
||
|
// Returns a pseudo-random integer
|
||
|
// To be improved
|
||
|
//
|
||
|
int rand(void)
|
||
|
{
|
||
|
next = next * 1103515245 + 12347;
|
||
|
return (uint)(next / 65536);
|
||
|
}
|
||
|
|
||
|
//
|
||
|
// (Re)Set the random seed
|
||
|
//
|
||
|
void srand(uint seed)
|
||
|
{
|
||
|
next = (ulong)seed;
|
||
|
}
|
||
|
|