Returns a pseudo-random byte uniformly distributed using fast method (33*Seed mod 257)
u8 cpct_getRandomUniform_u8_f (u8 entropy_byte) __z88dk_fastcall;
(1B L) entropy_byte | An optional byte coming from an entropy source to mix up the sequence. Use 0 if you have no entropy byte. |
call cpct_getRandomUniform_u8_f_asm
This function returns a pseudo-random byte uniformly distributed. Each new byte returned is obtained as a result of the function byte = (33*Seed % 257). Seed is then updated to the value byte - 1, to be used for the next call to the function. The seed may be manually updated using the function cpct_setRandomSeedUniform_u8 to create predictable sequences (starting always with the same seed) or to randomize the start of a the sequence (by entering a seed coming out of an entropy source).
The parameter entropy_byte is an addition to this function to let the user improve the random quality of the sequence by inputting mixer bytes coming from entropy sources. The function does an XOR operation between entropy_byte and the previous seed before doing the calculations for the next random byte. Therefore, if you use *entropy_byte*s coming from good entropy sources, you will be effectively mixing up the sequence and getting better quality random numbers. This could also be used for other purposes, like creating restricted or repeating sequences, up to the user imagination.
If you have no entropy source or do not want to use the entropy_byte, just input 0 which will have no effect on the sequence.
AF, C, L
2 bytes
Case | microSecs (us) | CPU Cycles ----------------------------------------- Any | 20 | 80 -----------------------------------------
This function comes from Fast RND, which can be found published by z80-info. The original code is reported to be from Spectrum ROM.