1
0
mirror of https://gitlab.os-k.eu/os-k-team/os-k.git synced 2023-08-25 14:03:10 +02:00
os-k/kaleid/common/rand.c

35 lines
961 B
C
Raw Normal View History

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;
}