mirror of
https://github.com/zeldaret/ph
synced 2026-07-06 05:04:41 -04:00
Fix build; add RNG code
This commit is contained in:
@@ -26,6 +26,8 @@ struct Actor_UnkStruct_012 {
|
||||
/* 14 */ u32 mUnk_14;
|
||||
/* 18 */ u32 mUnk_18;
|
||||
/* 1c */
|
||||
|
||||
Actor_UnkStruct_012();
|
||||
};
|
||||
|
||||
struct Actor_UnkStruct_020 {
|
||||
|
||||
@@ -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;
|
||||
Reference in New Issue
Block a user