2004-05-12 07:32:50 +00:00
|
|
|
/* $Id: rand.c,v 1.4 2004-05-12 07:31:37 btb Exp $ */
|
2003-02-18 20:23:22 +00:00
|
|
|
/*
|
2004-05-12 07:32:50 +00:00
|
|
|
*
|
2003-02-18 20:23:22 +00:00
|
|
|
* Descent random number stuff...
|
|
|
|
* rand has different ranges on different machines...
|
2004-05-12 07:32:50 +00:00
|
|
|
*
|
2003-02-18 20:23:22 +00:00
|
|
|
*/
|
2001-01-19 03:30:16 +00:00
|
|
|
|
2001-01-31 15:18:05 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
2001-01-19 03:30:16 +00:00
|
|
|
#include <conf.h>
|
2001-01-31 15:18:05 +00:00
|
|
|
#endif
|
|
|
|
|
2001-01-19 03:30:16 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#ifdef NO_WATCOM_RAND
|
2004-05-12 07:32:50 +00:00
|
|
|
|
2001-01-19 03:30:16 +00:00
|
|
|
void d_srand(unsigned int seed)
|
|
|
|
{
|
2004-05-12 07:32:50 +00:00
|
|
|
srand(seed);
|
2001-01-19 03:30:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int d_rand()
|
|
|
|
{
|
2004-05-12 07:32:50 +00:00
|
|
|
return rand() & 0x7fff;
|
2001-01-19 03:30:16 +00:00
|
|
|
}
|
2004-05-12 07:32:50 +00:00
|
|
|
|
2001-01-19 03:30:16 +00:00
|
|
|
#else
|
2004-05-12 07:32:50 +00:00
|
|
|
|
2001-01-19 03:30:16 +00:00
|
|
|
static unsigned int d_rand_seed;
|
|
|
|
|
2004-05-12 07:32:50 +00:00
|
|
|
int d_rand()
|
|
|
|
{
|
2001-01-19 03:30:16 +00:00
|
|
|
return ((d_rand_seed = d_rand_seed * 0x41c64e6d + 0x3039) >> 16) & 0x7fff;
|
|
|
|
}
|
|
|
|
|
2004-05-12 07:32:50 +00:00
|
|
|
void d_srand(unsigned int seed)
|
|
|
|
{
|
2001-01-19 03:30:16 +00:00
|
|
|
d_rand_seed = seed;
|
|
|
|
}
|
2004-05-12 07:32:50 +00:00
|
|
|
|
2001-01-19 03:30:16 +00:00
|
|
|
#endif
|