GBDK 2020 Docs
API Documentation for GBDK 2020
|
#include <types.h>
Go to the source code of this file.
Functions | |
void | initrand (UINT16 seed) NONBANKED |
INT8 | rand (void) |
UINT16 | randw (void) |
void | initarand (UINT16 seed) |
INT8 | arand (void) |
Random generator using the linear congruential method
void initrand | ( | UINT16 | seed | ) |
Initalise the pseudo-random number generator.
seed | The value for initializing the random number generator. |
The seed should be different each time, otherwise the same pseudo-random sequence will be generated.
The DIV Register (DIV_REG) is sometimes used as a seed, particularly if read at some variable point in time (such as when the player presses a button).
Only needs to be called once to initialize, buy may be called again to re-initialize with the same or a different seed.
INT8 rand | ( | void | ) |
Returns a random byte (8 bit) value.
initrand() should be used to initialize the random number generator before using rand()
UINT16 randw | ( | void | ) |
Returns a random word (16 bit) value.
initrand() should be used to initialize the random number generator before using rand()
void initarand | ( | UINT16 | seed | ) |
Random generator using the linear lagged additive method
seed | The value for initializing the random number generator. |
Note: initarand() calls initrand() with the same seed value, and uses rand() to initialize the random generator.
INT8 arand | ( | void | ) |
Returns a random number generated with the linear lagged additive method.
initarand() should be used to initialize the random number generator before using arand()