source: abuse/trunk/src/imlib/jrand.cpp @ 39

Last change on this file since 39 was 2, checked in by Sam Hocevar, 18 years ago
  • imported original 0.7.0 tarball
File size: 498 bytes
Line 
1#include "jrand.hpp"
2#include <time.h>
3#include <stdio.h>
4
5unsigned short rtable[RAND_TABLE_SIZE];
6unsigned short rand_on=0;
7
8void jrand_init()
9{
10  // make sure random table is always the same.
11  unsigned long rseed=('F'<<24)|('U'<<16)|('C'<<8)|'K';
12  int i;
13  unsigned short *tp=rtable;
14  for (i=0;i<RAND_TABLE_SIZE;i++,tp++)
15  {
16    rseed=rseed*0x41c64e6d+12345;
17    *tp=(rseed>>16)&0xffff;
18  }
19
20  time_t t=time(NULL);         // get an original random seed now.
21  rand_on=t%RAND_TABLE_SIZE;
22}
23
Note: See TracBrowser for help on using the repository browser.