Author | Joep Suijs, Copyright (c) 2009, all rights reserved. |
Adapted-by | |
Compiler | >=2.4i |
this library provides a (decent) random function. The formula is provided by *the* George Marsaglia. (see http://coding.derkeiler.com/Archive/C_CPP/comp.lang.c/2008-03/msg03691.html) /* initialize with any 32-bit seed x and any 32-bit y not 0 */ static unsigned long x=2282008, y=362436069; #define sK ( x=69069*x+123, y^=y<<13, y^=y>>17, y^=y<<5, x+y ) function random_byte returns an 8-bit random number function random_word returns a 16-bit random number functon dice returns a number from 1 to 6 Note: this library will recreate the same sequence. If this is undesired, assign a different (non-zero!) startup-value to -rndx and/or _rndx at startup. Note2: If you don't care about random quality and want to save a few processor cycles or memory bytes, define random_downgrade to select a basic random algorithm.
Interface Copyright (C) 2005 Stef Mientki
No dependency found
var byte nr
No documentation found
var volatile dword _rndx = 2282008
No documentation found
dice() return byte
dice - return a random number in the range [1..6]
random_word() return word
random_word - return a 16-bit random number
random_byte() return byte
random_byte - return an 8-bit random number
16f648a | 16f648a_random.jal |
16f877a | 16f877a_random.jal |
16f88 | 16f88_random.jal |
18f14k50 | 18f14k50_random.jal |
18f2450 | 18f2450_random.jal |
18f4550 | 18f4550_random.jal |