Twilight Princess
Decompilation of The Legend of Zelda: Twilight Princess
Loading...
Searching...
No Matches
random.h
Go to the documentation of this file.
1#ifndef RANDOM_H
2#define RANDOM_H
3
4#include "dolphin/types.h"
5
6namespace JMath {
7
14
16 u32 get(void) {
17 value = (value * 0x19660d) + 0x3c6ef35f;
18 return value;
19 }
20
21 u32 get_bit32(void) { return this->get(); }
22
23 // due to the float constant, having this function inlined adds that float to data,
24 // making it not match
25 float get_ufloat_1(void) {
26 // !@bug UB: in C++ it's not legal to read from an union member other
27 // than the last one that was written to.
28 union {
29 f32 f;
30 u32 s;
31 } out;
32 out.s = (this->get() >> 9) | 0x3f800000;
33 return out.f - 1;
34 }
35
36 void setSeed(u32 seed) { value = seed; }
37};
38
39template <class RandomT>
40class TRandom_ : public RandomT {
41public:
42 TRandom_(u32 value) : RandomT(value) {}
43
44 u8 get_uint8(u8 param_0) {
45 return this->get_ufloat_1() * param_0;
46 }
47};
48
49} // namespace JMath
50
51#endif /* RANDOM_H */
Definition random.h:40
TRandom_(u32 value)
Definition random.h:42
u8 get_uint8(u8 param_0)
Definition random.h:44
unsigned long u32
Definition types.h:12
float f32
Definition types.h:25
unsigned char u8
Definition types.h:8
s
Definition e_acos.c:94
Definition JMATrigonometric.cpp:71
Definition random.h:12
u32 get(void)
Definition random.h:16
float get_ufloat_1(void)
Definition random.h:25
TRandom_fast_(u32 value)
Definition random.cpp:5
void setSeed(u32 seed)
Definition random.h:36
u32 get_bit32(void)
Definition random.h:21
u32 value
Definition random.h:13