4 ; Generating random numbers
6 ; © 1994-1998 Straylight
9 ;----- Licensing note -------------------------------------------------------
11 ; This file is part of Straylight's Sapphire library.
13 ; Sapphire is free software; you can redistribute it and/or modify
14 ; it under the terms of the GNU General Public License as published by
15 ; the Free Software Foundation; either version 2, or (at your option)
18 ; Sapphire is distributed in the hope that it will be useful,
19 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
20 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 ; GNU General Public License for more details.
23 ; You should have received a copy of the GNU General Public License
24 ; along with Sapphire. If not, write to the Free Software Foundation,
25 ; 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27 ;----- Overview -------------------------------------------------------------
36 [ :LNOT::DEF:rand__dfn
43 ; On exit: R0 == a pseudorandom number between 0 and &7FFFFFFF
45 ; Use: Returns a pseudorandom number. The algorithm used is the
46 ; additive generator found in Knuth. The table is generated
47 ; from the current monotonic time using a linear congruential
48 ; generator. Randomness is fairly good, and it's very quick.
52 ; --- rand_setSeed ---
54 ; On entry: R0 == a pseudorandom seed
58 ; Use: Sets up the random number generator (rand) to the given start
59 ; position. The table of values is initialised from the seed
60 ; in a psuedorandom manner, using a linear congruential
67 ; On entry: R0 == start value (inclusive)
68 ; R1 == end value (inclusive)
70 ; On exit: R0 == random number between the boundaries given
72 ; Use: Returns a random integer between the boundaries given.
73 ; The distribution is slightly skewed towards lower numbers,
74 ; but there's not a lot I can do about this, folks.
84 ; Use: Initialise the random number table.
90 ;----- That's all, folks ----------------------------------------------------