diff --git a/include/random.h b/include/random.h index 99ec280474..d15aa28bfb 100644 --- a/include/random.h +++ b/include/random.h @@ -17,6 +17,7 @@ * LocalRandom(*val) allows you to have local random states that are the same * type as the global states regardless of HQ_RANDOM setting, which is useful * if you want to be able to set them from or assign them to gRngValue. +* LocalRandomSeed(u32) returns a properly seeded rng_value_t. * * Random2_32() was added to HQ_RANDOM because the output of the generator is * always 32 bits and Random()/Random2() are just wrappers in that mode. It is @@ -61,6 +62,7 @@ static inline u16 Random(void) void SeedRng(u32 seed); void SeedRng2(u32 seed); +rng_value_t LocalRandomSeed(u32 seed); static inline u16 Random2(void) { @@ -96,6 +98,11 @@ static inline void AdvanceRandom(void) Random(); } +static inline rng_value_t LocalRandomSeed(u32 seed) +{ + return seed; +} + #endif extern rng_value_t gRngValue; diff --git a/src/random.c b/src/random.c index 8e8dae8f3d..3ec3638fe1 100644 --- a/src/random.c +++ b/src/random.c @@ -91,6 +91,13 @@ void SeedRng2(u32 seed) SFC32_Seed(&gRng2Value, seed, STREAM2); } +rng_value_t LocalRandomSeed(u32 seed) +{ + rng_value_t result; + SFC32_Seed(&result, seed, STREAM1); + return result; +} + void AdvanceRandom(void) { if (sRngLoopUnlocked == TRUE)