summaryrefslogtreecommitdiff
path: root/src/JSystem/JMath/random.cpp
diff options
context:
space:
mode:
authorJcw87 <Jcw87@users.noreply.github.com>2023-12-14 18:39:42 -0800
committerJcw87 <Jcw87@users.noreply.github.com>2023-12-15 00:01:48 -0800
commitc285bf4aca7f63504bad44d0e38d7e6ff13ffd9e (patch)
tree57d254387e10a20c1a7b9d67d29431308e02283e /src/JSystem/JMath/random.cpp
parent71c44930092eb19a65d09e51331a5df3d06c2527 (diff)
JMath::random
Diffstat (limited to 'src/JSystem/JMath/random.cpp')
-rw-r--r--src/JSystem/JMath/random.cpp33
1 files changed, 25 insertions, 8 deletions
diff --git a/src/JSystem/JMath/random.cpp b/src/JSystem/JMath/random.cpp
index f576d8b5..1c6997cf 100644
--- a/src/JSystem/JMath/random.cpp
+++ b/src/JSystem/JMath/random.cpp
@@ -3,21 +3,38 @@
// Translation Unit: random.cpp
//
-#include "random.h"
+#include "JSystem/JMath/random.h"
#include "dolphin/types.h"
/* 80301350-80301358 .text __ct__Q25JMath13TRandom_fast_FUl */
-JMath::TRandom_fast_::TRandom_fast_(unsigned long) {
- /* Nonmatching */
+JMath::TRandom_fast_::TRandom_fast_(u32 value) {
+ this->value = value;
}
/* 80301358-8030142C .text setSeed__Q25JMath15TRandom_enough_FUl */
-void JMath::TRandom_enough_::setSeed(unsigned long) {
- /* Nonmatching */
+void JMath::TRandom_enough_::setSeed(u32 value) {
+ field_0x4 = 0;
+ field_0x0 = value + 1;
+ if (field_0x0 == 0) {
+ field_0x0 += 1;
+ }
+ u32 i;
+ for (i = 8; i != 0; i--) {
+ next_();
+ }
+ for (i = 32; i != 0;) {
+ i--;
+ next_();
+ field_0x8[i] = field_0x0;
+ }
}
/* 8030142C-803014CC .text get__Q25JMath15TRandom_enough_Fv */
-void JMath::TRandom_enough_::get() {
- /* Nonmatching */
+f32 JMath::TRandom_enough_::get() {
+ next_();
+ u8 idx = (field_0x4 >> 24 & ~3) / 4;
+ field_0x4 = field_0x8[idx];
+ field_0x8[idx] = field_0x0;
+ f32 var3 = field_0x4 * 4.656613E-10f;
+ return var3 < 0.9999999f ? var3 : 0.9999999f;
}
-