NSMBW-Decomp
A decompilation of New Super Mario Bros. Wii
Loading...
Searching...
No Matches
c_random.hpp
1#pragma once
2#include <types.h>
3
4/// @brief Random number generation helper class.
5/// @ingroup clib
6class cRandom_c {
7public:
8
9 /// @brief Initializes the class with the given seed.
10 cRandom_c(u32 seed) : mSeed(seed) {}
11
12 u32 getRandomByAsm(ulong max); ///< Generates an integer between 0 and the given max.
13 float getRandomFByAsm(); ///< Generates a floating point number between 0 and 1.
14 float getRandomF2ByAsm(); ///< Generates a floating point number between -0.5 and 0.5.
15
16 u32 mSeed; ///< The current seed.
17
18private:
19 /// @brief Implementation of the @p ranqd1 algorithm.
20 /// @bug The implementation is flawed.
21 /// @xlink{https://roadrunnerwmc.github.io/blog/2020/05/08/nsmb-rng.html, This post explains why}.
22 inline u32 ranqdStep();
23};
float getRandomFByAsm()
Generates a floating point number between 0 and 1.
Definition c_random.cpp:37
cRandom_c(u32 seed)
Initializes the class with the given seed.
Definition c_random.hpp:10
float getRandomF2ByAsm()
Generates a floating point number between -0.5 and 0.5.
Definition c_random.cpp:43
u32 mSeed
The current seed.
Definition c_random.hpp:16
u32 getRandomByAsm(ulong max)
Generates an integer between 0 and the given max.
Definition c_random.cpp:32
u32 ranqdStep()
Implementation of the ranqd1 algorithm.
Definition c_random.cpp:13