cpct_setSeed_lcg_u8

Sets the random seed used by cpct_getRandom_lcg_u8.

C Definition

void cpct_setSeed_lcg_u8 (u8 seed) __z88dk_fastcall;

Input Parameters (1 byte)

(1B L) seedNew seed to be set for the random number generator.

Assembly call (Input parameter on L)

call cpct_setSeed_lcg_u8_asm

Parameter Restrictions

  • seed New seed byte that will be set internally in the random number generator.  There is no restriction about the value of this byte.

Known limitations

  • This function will not work from a ROM.  It does not specifically use self-modifying code, but indirectly modifies the code of cpct_getRandom_lcg_u8.

Details

This function sets the random seed that cpct_getRandom_lcg_u8 uses internally for generating pseudo-random numbers.  This can be used to randomize the start of the pseudo-random sequence or to make it predictable (setting the same seed again).

Please, do read documentation from cpct_getRandom_lcg_u8 for more details about how this random generator works.

Destroyed Register values

A

Required memory

2 bytes

Time Measures

   Case     | microSecs (us) | CPU Cycles
-----------------------------------------
   Any      |       7        |    28
-----------------------------------------

Credits

Random generation original code comes from Fast RND, which can be found published by z80-info.  The original code is reported to be from Spectrum ROM.

Returns a pseudo-random byte using a fast Linear-Congruential-Algebra (LCG) method (33*Seed mod 257)
Sets the random seed used by cpct_getRandom_lcg_u8.
unsigned char (u8 = unsigned 8-bits, 1 byte )
Close