by throwaway7767 · 9y ago · 0 comments
I32 RandI32()
{//Random I32. Xor with TimsStamp.
sys_rnd_seed.i32[0]=(1664525*sys_rnd_seed.i32[0]+1013904223)^GetTSC>>4;
return sys_rnd_seed.i32[0];
}
There are very similar RNG functions for signed and unsigned versions of 16, 32 and 64 bit ints. The GetTSC function just calls RDTSC, combines the two 32-bit halves in EAX and EDX and returns the recombined 64-bit TSC.So the last returned value is used as part of the seed for the next one. The initial seed is set in kend.cpp:
sys_rnd_seed =93186752^GetTSC;
I have to admit, I was a bit disappointed that god would be quite so deterministic.