Sets 40-bits initial state (seed) for cpct_getRandom_xsp40_u8 pseudo-random number generator.
void cpct_setSeed_xsp40_u8 (u16 plusSeed, u32 seed32) __z88dk_callee;
(4B DE:HL) *seed32* | Main 32-bits seed for generating pseudo-random numbers |
(1B A) *plusSeed* | Value that is used to do a final XOR operation with resulting sequence numbers (Default: 255) |
call cpct_setSeed_xsp40_u8_asm
This function sets the initial internal 40-bits state for the pseudo-random number generator implemented in cpct_getRandom_xsp40_u8. It is important to properly seed the random number generator, never setting its 32-bits main seed as 0.
The internal state has 2 parts,
Therefore, you may have different sequences by selecting a different plusSeed, whereas you will start the sequence in a different number by setting a new seed32. As each sequence has a period of 2^40-256 numbers, any new sequence could be considered approximately random once a relatively random seed has been set.
AF, BC, DE, HL
C-bindings | 16 bytes |
ASM-bindings | 11 bytes |
Case | microSecs (us) | CPU Cycles ----------------------------------------- Any | 34 | 136 ----------------------------------------- ASM-Saving | -16 | -64 -----------------------------------------