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/crtlib/rand.c

35 lines
952 B
C
Raw Normal View History

2019-01-21 15:00:04 +01:00
//----------------------------------------------------------------------------//
// 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;
}