resonance 1.0.1
Loading...
Searching...
No Matches
r250.h File Reference

Go to the source code of this file.

Functions

void SeedR250 (int nSeed)
 Fill the state table from a linear congruential sequence and reset both indices.
int NextR250 ()
 Draw the next value.
int RandomInt (int nLow, int nHigh)
 Draw an integer in a half-open range.
float RandomFloat ()
 Draw a float in [0, 1).

Variables

constexpr int kR250TableSize = 256
 Words in the R250 generator's state table.
int g_aR250Table [kR250TableSize]
 State table of the R250 generator.
int g_nR250Index
 Index of the word NextR250() replaces next.
int g_nR250LagIndex
 Index of the word NextR250() combines with the replaced one.

Function Documentation

◆ SeedR250()

void SeedR250 ( int nSeed)

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

Each word is the high half of one step of the sequence plus the next step masked to 0x7fff0000.

MetRenderer's constructor and the routine at 0x0030e2c8 are the recovered callers.

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

◆ NextR250()

int NextR250 ( )

Draw the next value.

Both indices wrap to zero on reaching 249, so the draws cycle through the first 249 words of the table.

Returns
The replaced word.
Ghidra address:
NTSC-U/C: 0x0052cfd0
Ghidra address:
PAL: 0x0056d660

◆ RandomInt()

int RandomInt ( int nLow,
int nHigh )

Draw an integer in a half-open range.

Parameters
nLowThe smallest value.
nHighThe value the range stops below.
Returns
nLow plus the remainder of a draw divided by the width of the range.
Ghidra address:
NTSC-U/C: 0x0052d098
Ghidra address:
PAL: 0x0056d728

◆ RandomFloat()

float RandomFloat ( )

Draw a float in [0, 1).

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

Variable Documentation

◆ kR250TableSize

int kR250TableSize = 256
constexpr

Words in the R250 generator's state table.

SeedR250() fills all of them.

◆ g_aR250Table

int g_aR250Table[kR250TableSize]
extern

State table of the R250 generator.

SeedR250() fills every word, and NextR250() replaces one word per draw with the exclusive or of two others.

Ghidra address:
NTSC-U/C: 0x0071c8e8
Ghidra address:
PAL: 0x00760828

◆ g_nR250Index

int g_nR250Index
extern

Index of the word NextR250() replaces next.

Zero at startup and after SeedR250().

Ghidra address:
NTSC-U/C: 0x0071c8e0
Ghidra address:
PAL: 0x00760820

◆ g_nR250LagIndex

int g_nR250LagIndex
extern

Index of the word NextR250() combines with the replaced one.

103 at startup and after SeedR250().

Ghidra address:
NTSC-U/C: 0x0071c8e4
Ghidra address:
PAL: 0x00760824