Gets a high-quality 16-bit pseudo-random number using Marsaglia’s XOR-shift algorithm (using a 32-bits state)
u16 cpct_getRandom_mxor_u16 ();
call cpct_getRandom_mxor_u16_asm
<u16> | Next 16-bits pseudo-random value. |
This function uses cpct_nextRandom_mxor_u32 to produce a stream of random 32-bits numbers, and then gets 2 16-bits values out of each 32-bits number generated. Then, it returns each one of the last 2 random values produced before calling cpct_nextRandom_mxor_u32 again. It uses cpct_mxor32_seed as state storage buffer for the 32-bits number got from cpct_nextRandom_mxor_u32.
As cpct_nextRandom_mxor_u32 produces (2^32)-1 32-bits numbers without repetition, this function will produce (2^33)-1 16-bits values without repetition.
This function uses Marsaglia’s XOR-shift standard algorithm with a concrete shift tuple. Check cpct_nextRandom_mxor_u32 to know details on how this is produced.
AF, BC, DE, HL
73 bytes divided in,
Case | microSecs (us) | CPU Cycles ----------------------------------------- available | 16 | 64 production | 76 | 304 ----------------------------------------- average-2 | 46 | 184 -----------------------------------------
Contains the 32-bits seed for Marsaglia’s XOR-shift random number generator.
_cpct_mxor32_seed:: .dw #0x1A7B, #0x59F2