wavelength 1.0.0
Loading...
Searching...
No Matches
Rand Class Reference

Generator of pseudo-random numbers with a lagged Fibonacci sequence of 256 words. More...

#include <rand.h>

Public Member Functions

 Rand (int nSeed)
 Construct a generator and seed it.
void Seed (int nSeed)
 Fill the state table from a linear congruential sequence and reset both indices.
int Int (int nLow, int nHigh)
 Draw an integer.
float Float (float fLow, float fHigh)
 Draw a floating-point number.
float Float ()
 Draw a floating-point number in [0, 1).
int Int ()
 Draw the next word.
 Rand (int seed)
 Seed a new generator.
void Seed (int seed)
 Refill the table.

Static Public Attributes

static constexpr int kTableSize = 256
 Words of the state table.

Detailed Description

Generator of pseudo-random numbers with a lagged Fibonacci sequence of 256 words.

Random number generator with a table of 256 words.

The class is not polymorphic and has no RTTI. The name is inferred. The object is 0x408 bytes.

The RTTI records the class. The object is 0x408 bytes. Seed() fills the table from a linear congruential sequence and sets the two read positions 103 words apart, the R250 arrangement. The control seeds the generator and never draws from it.

Constructor & Destructor Documentation

◆ Rand() [1/2]

Rand::Rand ( int nSeed)
explicit

Construct a generator and seed it.

Parameters
nSeedThe seed.
Ghidra address:
NTSC-U/C: 0x00292230
Ghidra address:
PAL: 0x0029bbf8

◆ Rand() [2/2]

Rand::Rand ( int seed)

Seed a new generator.

Parameters
seedThe seed.
Ghidra address:
0x1001bcf0

Member Function Documentation

◆ Seed() [1/2]

void Rand::Seed ( int nSeed)

Fill the state table from a linear congruential sequence and reset both indices.

Parameters
nSeedThe starting value of the sequence.
Ghidra address:
NTSC-U/C: 0x00292260
Ghidra address:
PAL: 0x0029bc28

◆ Int() [1/2]

int Rand::Int ( int nLow,
int nHigh )

Draw an integer.

Parameters
nLowThe smallest value.
nHighOne more than the largest value.
Returns
The integer.
Ghidra address:
NTSC-U/C: 0x002922b8
Ghidra address:
PAL: 0x0029bc80

◆ Float() [1/2]

float Rand::Float ( float fLow,
float fHigh )

Draw a floating-point number.

Parameters
fLowThe smallest value.
fHighThe largest value.
Returns
The number.
Ghidra address:
NTSC-U/C: 0x00292300
Ghidra address:
PAL: 0x0029bcc8

◆ Float() [2/2]

float Rand::Float ( )

Draw a floating-point number in [0, 1).

Returns
The low sixteen bits of a draw divided by 65536.
Ghidra address:
NTSC-U/C: 0x00292340
Ghidra address:
PAL: 0x0029bd08

◆ Int() [2/2]

int Rand::Int ( )

Draw the next word.

Both indices wrap to zero on arriving at 249, so the draws cycle through the first 249 words.

Returns
The replaced word.
Ghidra address:
NTSC-U/C: 0x00292378
Ghidra address:
PAL: 0x0029bd40

◆ Seed() [2/2]

void Rand::Seed ( int seed)

Refill the table.

Parameters
seedThe seed.
Ghidra address:
0x1001bd10

Member Data Documentation

◆ kTableSize

int Rand::kTableSize = 256
staticconstexpr

Words of the state table.


The documentation for this class was generated from the following files: