/*
 * rand.h
 *
 * [Generated from rand, 25 September 1996]
 */

#if !defined(__CC_NORCROFT) || !defined(__arm)
  #error You must use the Norcroft ARM Compiler for Sapphire programs
#endif

#pragma include_only_once
#pragma force_top_level

#ifndef __rand_h
#define __rand_h

#ifndef __sapphire_h
  #include "sapphire.h"
#endif

/*----- Overview ----------------------------------------------------------*
 *
 * Functions provided:
 *
 *  rand
 *  rand_setSeed
 *  rnd
 *  rand_init
 */

/* --- rand --- *
 *
 * On entry:	--
 *
 * On exit:	R0 == a pseudorandom number between 0 and &7FFFFFFF
 *
 * Use:		Returns a pseudorandom number.  The algorithm used is the
 *		additive generator found in Knuth.  The table is generated
 *		from the current monotonic time using a linear congruential
 *		generator.  Randomness is fairly good, and it's very quick.
 */

extern routine rand;

/* --- rand_setSeed --- *
 *
 * On entry:	R0 == a pseudorandom seed
 *
 * On exit:	--
 *
 * Use:		Sets up the random number generator (rand) to the given start
 *		position.  The table of values is initialised from the seed
 *		in a psuedorandom manner, using a linear congruential
 *		generator.
 */

extern routine rand_setSeed;

/* --- rnd --- *
 *
 * On entry:	R0 == start value (inclusive)
 *		R1 == end value (inclusive)
 *
 * On exit:	R0 == random number between the boundaries given
 *
 * Use:		Returns a random integer between the boundaries given.
 *		The distribution is slightly skewed towards lower numbers,
 *		but there's not a lot I can do about this, folks.
 */

extern routine rnd;

/* --- rand_init --- *
 *
 * On entry:	--
 *
 * On exit:	--
 *
 * Use:		Initialise the random number table.
 */

extern routine rand_init;

/*----- That's all, folks -------------------------------------------------*/

#endif
