gbdk-releases/gbdk-lib/include/rand.h

43 lines
888 B
C
Raw Permalink Normal View History

2015-01-10 16:25:08 +01:00
/** @file rand.h
Random generator using the linear congruential method
@author Luc Van den Borre
*/
2015-01-10 16:25:06 +01:00
#ifndef RAND_INCLUDE
#define RAND_INCLUDE
#include <types.h>
2015-01-10 16:25:08 +01:00
/** Initalise the random number generator.
seed needs to be different each time, else the same sequence will be
2015-01-10 16:25:08 +01:00
generated. A good source is the DIV register.
2015-01-10 16:25:08 +01:00
*/
2015-01-10 16:25:06 +01:00
void
2015-01-10 16:25:08 +01:00
initrand(UINT16 seed) NONBANKED; /* Non-banked as called from asm in arand.s */
2015-01-10 16:25:06 +01:00
2015-01-10 16:25:08 +01:00
/** Returns a random value.
*/
2015-01-10 16:25:07 +01:00
INT8
2015-01-10 16:25:09 +01:00
rand(void);
2015-01-10 16:25:06 +01:00
2015-01-10 16:25:08 +01:00
/** Returns a random word.
*/
2015-01-10 16:25:07 +01:00
UINT16
2015-01-10 16:25:09 +01:00
randw(void);
2015-01-10 16:25:06 +01:00
2015-01-10 16:25:08 +01:00
/** Random generator using the linear lagged additive method
Note that 'initarand()' calls 'initrand()' with the same seed value, and
uses 'rand()' to initialize the random generator.
2015-01-10 16:25:06 +01:00
2015-01-10 16:25:08 +01:00
@author Luc Van den Borre
*/
2015-01-10 16:25:06 +01:00
void
2015-01-10 16:25:09 +01:00
initarand(UINT16 seed);
2015-01-10 16:25:06 +01:00
2015-01-10 16:25:08 +01:00
/** Generates a random number using the linear lagged additive method.
*/
2015-01-10 16:25:07 +01:00
INT8
2015-01-10 16:25:09 +01:00
arand(void);
2015-01-10 16:25:06 +01:00
#endif