diff --git a/trunk/src/drivers/win/config.cpp b/trunk/src/drivers/win/config.cpp index a5638715..87de1a48 100644 --- a/trunk/src/drivers/win/config.cpp +++ b/trunk/src/drivers/win/config.cpp @@ -74,6 +74,7 @@ extern int palcontrast; extern int palbrightness; extern bool paldeemphswap; extern int RAMInitOption; +extern int RAMInitSeed; extern TASEDITOR_CONFIG taseditorConfig; extern char* recentProjectsArray[]; @@ -188,6 +189,7 @@ static CFGSTRUCT fceuconfig[] = AC(force_grayscale), AC(dendy), AC(RAMInitOption), + AC(RAMInitSeed), AC(postrenderscanlines), AC(vblankscanlines), AC(overclock_enabled), diff --git a/trunk/src/fceu.cpp b/trunk/src/fceu.cpp index bafe8d18..a137e8cd 100644 --- a/trunk/src/fceu.cpp +++ b/trunk/src/fceu.cpp @@ -845,14 +845,6 @@ u64 xoroshiro128plus_next() { void FCEU_MemoryRand(uint8 *ptr, uint32 size) { int x = 0; - //reseed random, unless we're in a movie - extern int disableBatteryLoading; - if(FCEUMOV_Mode(MOVIEMODE_INACTIVE) && !disableBatteryLoading) - RAMInitSeed = rand()&0x7FFF; - - //always reseed the PRNG with the current seed, for deterministic results (for that seed) - xoroshiro128plus_seed(RAMInitSeed); - while (size) { uint8 v = 0; switch (RAMInitOption) @@ -888,6 +880,16 @@ void PowerNES(void) { FCEUMOV_AddCommand(FCEUNPCMD_POWER); if (!GameInfo) return; + //reseed random, unless we're in a movie + extern int disableBatteryLoading; + if(FCEUMOV_Mode(MOVIEMODE_INACTIVE) && !disableBatteryLoading) + { + RAMInitSeed = (RAMInitSeed + (u32)(xoroshiro128plus_next())) | 1; + } + + //always reseed the PRNG with the current seed, for deterministic results (for that seed) + xoroshiro128plus_seed(RAMInitSeed); + FCEU_CheatResetRAM(); FCEU_CheatAddRAM(2, 0, RAM);