mirror of
https://gitlab.os-k.eu/os-k-team/os-k.git
synced 2023-08-25 14:03:10 +02:00
35 lines
961 B
C
35 lines
961 B
C
//----------------------------------------------------------------------------//
|
|
// GNU GPL OS/K //
|
|
// //
|
|
// Authors: spectral` //
|
|
// NeoX //
|
|
// //
|
|
// Desc: RNG related functions //
|
|
//----------------------------------------------------------------------------//
|
|
|
|
#include <kaleid.h>
|
|
|
|
//
|
|
// Seed value
|
|
//
|
|
static ulong next = 7756;
|
|
|
|
//
|
|
// Returns a pseudo-random integer
|
|
// To be improved
|
|
//
|
|
int rand(void)
|
|
{
|
|
next = next * 1103515245 + 12345;
|
|
return (uint)(next / 65536) % INT_MAX;
|
|
}
|
|
|
|
//
|
|
// (Re)Set the random seed
|
|
//
|
|
void srand(uint seed)
|
|
{
|
|
next = (ulong)seed;
|
|
}
|
|
|