OpenBarnyard
 
Loading...
Searching...
No Matches
TRandom.h
Go to the documentation of this file.
1#pragma once
2/*
3------------------------------------------------------------------------------
4rand.c: By Bob Jenkins. My random number generator, ISAAC. Public Domain.
5MODIFIED:
6 960327: Creation (addition of randinit, really)
7 970719: use context, not global variables, for internal state
8 980324: added main (ifdef'ed out), also rearranged randinit()
9 010626: Note that this is public domain
10------------------------------------------------------------------------------
11*/
12// mix with source: https://github.com/jawnsy/Math-Random-ISAAC-XS/blob/master/src/rand.c
13
14#define RANDSIZL ( 4 ) /* 8 for crypto, 4 for simulations (aka Toshi uses 4) */
15#define RANDSIZ ( 1 << RANDSIZL )
16
17#include "Toshi/THPTimer.h"
18
20
22{
23public:
24 TRandom();
25
26 TINT GetInt();
27 TINT GetInt( TUINT32 a_iLower, TUINT32 a_iUpper );
28 TINT GetInt( TUINT32 a_iUpper );
29
31 TFLOAT GetFloatMinMax( TFLOAT a_fLower, TFLOAT a_fUpper );
33
35
36 void SetSeed( TUINT a_uiSeed );
37 TUINT32 GetSeed() const { return m_uiSeed; }
38
39private:
40 void Isaac();
41 void RandInit();
42
43private:
44 TUINT32 m_uiSeed; // 0x0
45 TUINT32 m_uiRndCnt; // 0x4
46 TUINT32 m_pRandrsl[ RANDSIZ ]; //0x8
47
48 TUINT32 m_pRandmem[ RANDSIZ ]; // 0x48
49
50 TUINT32 m_uiRandA; // 0x88
51 TUINT32 m_uiRandB; // 0x8C
52 TUINT32 m_uiRandC; // 0x90
53};
54
#define RANDSIZ
Definition TRandom.h:15
#define TOSHI_NAMESPACE_START
Definition Defines.h:47
#define TOSHI_NAMESPACE_END
Definition Defines.h:50
unsigned int TUINT
Definition Typedefs.h:8
float TFLOAT
Definition Typedefs.h:4
uint32_t TUINT32
Definition Typedefs.h:13
int TINT
Definition Typedefs.h:7
TFLOAT GetFloat2()
Definition TRandom.cpp:194
TINT GetInt()
Definition TRandom.cpp:178
TUINT32 GetSeed() const
Definition TRandom.h:37
TRandom()
Definition TRandom.cpp:59
void SetSeed(TUINT a_uiSeed)
Definition TRandom.cpp:199
TFLOAT GetFloat()
Definition TRandom.cpp:183
TUINT32 RandRaw()
Definition TRandom.cpp:205
TFLOAT GetFloatMinMax(TFLOAT a_fLower, TFLOAT a_fUpper)
Definition TRandom.cpp:189