Sets the new 32-bits seed value for Marsaglia’s XOR-shift random number generator.
void cpct_setSeed_mxor (u32 newseed) __z88dk_fastcall;
(4B DE:HL) *newseed* | New seed to be set for the random number generator. |
call cpct_setSeed_mxor_asm
This function sets the internal 32-bits seed used by Marsaglia’s XOR-shift random number generator. This generator is implemented by the function cpct_nextRandom_mxor_u32 and its internal seed is hold by the variable cpct_mxor32_seed. This last variable is the one that this function changes. Under some concrete circumstances, directly setting cpct_mxor32_seed instead of calling this function could be a nice optimization. However, take into account that this approach could not be portable among different versions of this API.
If you are using cpct_getRandom_mxor_u8 or cpct_getRandom_mxor_u16, only setting the seed will not ensure you get the same sequence. Depending on the internal index state of this two generators, you may get part of your seed as first random values. To prevent this from happening, you have to call cpct_restoreState_mxor_u8 or cpct_restoreState_mxor_u16 right after setting the seed with cpct_setSeed_mxor. This will ensure you get a predictable random sequence.
Setting the mxor seed affects all functions using that seed, namely cpct_nextRandom_mxor_u32, <cpct_nextRandom_mxor_u16> and cpct_nextRandom_mxor_u8.
All preserved
8 bytes
Case | microSecs (us) | CPU Cycles ----------------------------------------- Any | 14 | 56 -----------------------------------------
Contains the 32-bits seed for Marsaglia’s XOR-shift random number generator.
_cpct_mxor32_seed:: .dw #0x1A7B, #0x59F2