chiark / gitweb /
Initial revision
[ssr] / StraySrc / Libraries / Sapphire / csapph / h / rand
1 /*
2  * rand.h
3  *
4  * [Generated from rand, 25 September 1996]
5  */
6
7 #if !defined(__CC_NORCROFT) || !defined(__arm)
8   #error You must use the Norcroft ARM Compiler for Sapphire programs
9 #endif
10
11 #pragma include_only_once
12 #pragma force_top_level
13
14 #ifndef __rand_h
15 #define __rand_h
16
17 #ifndef __sapphire_h
18   #include "sapphire.h"
19 #endif
20
21 /*----- Overview ----------------------------------------------------------*
22  *
23  * Functions provided:
24  *
25  *  rand
26  *  rand_setSeed
27  *  rnd
28  *  rand_init
29  */
30
31 /* --- rand --- *
32  *
33  * On entry:    --
34  *
35  * On exit:     R0 == a pseudorandom number between 0 and &7FFFFFFF
36  *
37  * Use:         Returns a pseudorandom number.  The algorithm used is the
38  *              additive generator found in Knuth.  The table is generated
39  *              from the current monotonic time using a linear congruential
40  *              generator.  Randomness is fairly good, and it's very quick.
41  */
42
43 extern routine rand;
44
45 /* --- rand_setSeed --- *
46  *
47  * On entry:    R0 == a pseudorandom seed
48  *
49  * On exit:     --
50  *
51  * Use:         Sets up the random number generator (rand) to the given start
52  *              position.  The table of values is initialised from the seed
53  *              in a psuedorandom manner, using a linear congruential
54  *              generator.
55  */
56
57 extern routine rand_setSeed;
58
59 /* --- rnd --- *
60  *
61  * On entry:    R0 == start value (inclusive)
62  *              R1 == end value (inclusive)
63  *
64  * On exit:     R0 == random number between the boundaries given
65  *
66  * Use:         Returns a random integer between the boundaries given.
67  *              The distribution is slightly skewed towards lower numbers,
68  *              but there's not a lot I can do about this, folks.
69  */
70
71 extern routine rnd;
72
73 /* --- rand_init --- *
74  *
75  * On entry:    --
76  *
77  * On exit:     --
78  *
79  * Use:         Initialise the random number table.
80  */
81
82 extern routine rand_init;
83
84 /*----- That's all, folks -------------------------------------------------*/
85
86 #endif