Removed debug
[tpg/acess2.git] / Kernel / lib.c
index b69bdd0..c106351 100644 (file)
@@ -8,6 +8,7 @@
 #define        RANDOM_SEED     0xACE55052
 #define        RANDOM_A        0x00731ADE
 #define        RANDOM_C        12345
+#define        RANDOM_SPRUCE   0xf12b02b
 //                          Jan Feb Mar Apr May  Jun  Jul  Aug  Sept Oct  Nov  Dec
 const short DAYS_BEFORE[] = {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334};
 #define UNIX_TO_2K     ((30*365*3600*24) + (7*3600*24))        //Normal years + leap years
@@ -318,17 +319,12 @@ Sint64 timestamp(int sec, int mins, int hrs, int day, int month, int year)
  */
 Uint rand()
 {
-       #if 0
-       Uint    ret = giRandomState;
-        int    roll = randomState & 31;
-       randomState = (randomState << roll) | (randomState >> (32-roll));
-       randomState ^= 0x9A3C5E78;
-       return ret;
-       #else
+       Uint    old = giRandomState;
+       // Get the next state value
        giRandomState = (RANDOM_A*giRandomState + RANDOM_C) & 0xFFFFFFFF;
-       Log("giRandomState = 0x%x", giRandomState);
+       // Check if it has changed, and if it hasn't, change it
+       if(giRandomState == old)        giRandomState += RANDOM_SPRUCE;
        return giRandomState;
-       #endif
 }
 
 EXPORT(timestamp);

UCC git Repository :: git.ucc.asn.au