summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorAetias <aetias@outlook.com>2024-10-20 10:39:09 +0200
committerAetias <aetias@outlook.com>2024-10-20 10:39:09 +0200
commitfb9d00b87f47a043b1f4a314be6607085947d3c8 (patch)
treec00aaee39447887818cddee5600a209ad10a24b6 /include
parent8181d30b8731685395f7499117648413ae3898a3 (diff)
Fix build; add RNG code
Diffstat (limited to 'include')
-rw-r--r--include/Actor/Actor.hpp2
-rw-r--r--include/System/Random.hpp22
2 files changed, 24 insertions, 0 deletions
diff --git a/include/Actor/Actor.hpp b/include/Actor/Actor.hpp
index ee9737c0..1063bf76 100644
--- a/include/Actor/Actor.hpp
+++ b/include/Actor/Actor.hpp
@@ -26,6 +26,8 @@ struct Actor_UnkStruct_012 {
/* 14 */ u32 mUnk_14;
/* 18 */ u32 mUnk_18;
/* 1c */
+
+ Actor_UnkStruct_012();
};
struct Actor_UnkStruct_020 {
diff --git a/include/System/Random.hpp b/include/System/Random.hpp
new file mode 100644
index 00000000..4506466d
--- /dev/null
+++ b/include/System/Random.hpp
@@ -0,0 +1,22 @@
+#pragma once
+
+#include "global.h"
+#include "types.h"
+
+struct Random {
+ /* 00 */ u64 mRandomValue;
+ /* 08 */ u64 mFactor;
+ /* 10 */ u64 mAddend;
+ /* 18 */
+
+ /**
+ * Generate a random number from 0 (inclusive) to `max` (exclusive)
+ */
+ inline u32 Next(u32 max) {
+ mRandomValue = mAddend + mFactor * mRandomValue;
+ u64 result = (mRandomValue >> 32) * max;
+ return result >> 32;
+ }
+};
+
+extern Random *gRandom;