Last change
on this file since 608 was
80,
checked in by Sam Hocevar, 15 years ago
|
- Adding the Golgotha source code. Not sure what's going to be interesting
in there, but since it's all public domain, there's certainly stuff to
pick up.
|
File size:
1.1 KB
|
Line | |
---|
1 | /********************************************************************** <BR>
|
---|
2 | This file is part of Crack dot Com's free source code release of
|
---|
3 | Golgotha. <a href="http://www.crack.com/golgotha_release"> <BR> for
|
---|
4 | information about compiling & licensing issues visit this URL</a>
|
---|
5 | <PRE> If that doesn't help, contact Jonathan Clark at
|
---|
6 | golgotha_source@usa.net (Subject should have "GOLG" in it)
|
---|
7 | ***********************************************************************/
|
---|
8 |
|
---|
9 | #include "arch.hh"
|
---|
10 |
|
---|
11 | enum { TSIZE=512 };
|
---|
12 | static w32 w32_rtable[TSIZE];
|
---|
13 | static float f_rtable[TSIZE];
|
---|
14 | static int seed=0;
|
---|
15 | static int initialized=0;
|
---|
16 |
|
---|
17 | void next_seed()
|
---|
18 | {
|
---|
19 | if (!initialized)
|
---|
20 | {
|
---|
21 | w32 inc=0xacd2d391, mul=0xf34f9201, x=0;
|
---|
22 | for (int i=0; i<TSIZE; i++)
|
---|
23 | {
|
---|
24 | w32_rtable[i]=x;
|
---|
25 | f_rtable[i]=(double)x/(double)0xffffffff;
|
---|
26 | x=(x+inc)*mul;
|
---|
27 | }
|
---|
28 | initialized=1;
|
---|
29 | }
|
---|
30 |
|
---|
31 | seed++;
|
---|
32 | }
|
---|
33 |
|
---|
34 | w32 i4_rand()
|
---|
35 | {
|
---|
36 | next_seed();
|
---|
37 | return w32_rtable[seed];
|
---|
38 | }
|
---|
39 |
|
---|
40 | float i4_float_rand()
|
---|
41 | {
|
---|
42 | next_seed();
|
---|
43 | return f_rtable[seed];
|
---|
44 | }
|
---|
45 |
|
---|
46 | void i4_rand_reset(w32 _seed)
|
---|
47 | {
|
---|
48 | seed=_seed % TSIZE;
|
---|
49 | }
|
---|
50 |
|
---|
Note: See
TracBrowser
for help on using the repository browser.