![]() ![]() That is, it is like having the 65536 (excluding 0) possible 16-bits values ordered in a pseudo-random manner, and getting each one at a time. This Shift Register does produce 65535 16-bits values without repetition, then cycles again. This function implements a Galois Linear-Feedback Shift Register with a 16 bits state. However, a combination with other functions may yield much better results. This function is not recommended when good quality random numbers are required. Although the whole sequence has a period of 65535 numbers without repetition, the way numbers are traversed is quite predictable.This limitation does not affect u8 return values. Returned value using all 16 bits ( u16) will never be 0, so it is advisable to use returned value-1 as final random number.Seed (machine state) must never be zero.This function will not work from a ROM, as it uses self-modifying code.U8 cpct_getRandom_glfsr16_u8 () Assembly call (Input parameter on L) call cpct_getRandom_glfsr16_u8_asm Return value (Assembly calls, return L=A=random 8-bits, HL=random 16-bits) Return a pseudo-random byte using Galois Linear-Feedback Shift Register (G-LFSR) method, with a 16-bits state register. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |