Public feed #723208

Stuff

public text v1 · immutable
Raw Edit
·published 2007-10-02 16:33 UTC
rendered paste body
// Init custom rand
// instead of using (tracable) calls to time() or rand() generate a seed on the cpu timestamp counter
_asm 
{
	push eax
	push edx
	rdtsc
	xor eax, edx
	mov nextrnd, eax
	pop edx
	pop eax
}


// rand function
uint32_t nextrnd; // global var (it gets set in the code above)

__forceinline uint32_t _rand(void) {
	nextrnd = nextrnd * 1103515245 + 12345;
	return((uint32_t)(4294967296.0*(((uint32_t)(nextrnd/65536) % 32768)/(32768+1.0))));
}