followup on randomization vs movies fix:
1. Save/load RAMInitSeed in config so FCEUX doesn't always start up with the same first seed. 2. Moved seeding to PowerNES (FCEU_MemoryRand can be called multiple times, reseeding causes duplication.) 3. Increased bit depth of seed randomization from 15 to 31 bits for more possibilities.
This commit is contained in:
parent
3a1d872a6d
commit
ad3797655e
|
@ -74,6 +74,7 @@ extern int palcontrast;
|
||||||
extern int palbrightness;
|
extern int palbrightness;
|
||||||
extern bool paldeemphswap;
|
extern bool paldeemphswap;
|
||||||
extern int RAMInitOption;
|
extern int RAMInitOption;
|
||||||
|
extern int RAMInitSeed;
|
||||||
|
|
||||||
extern TASEDITOR_CONFIG taseditorConfig;
|
extern TASEDITOR_CONFIG taseditorConfig;
|
||||||
extern char* recentProjectsArray[];
|
extern char* recentProjectsArray[];
|
||||||
|
@ -188,6 +189,7 @@ static CFGSTRUCT fceuconfig[] =
|
||||||
AC(force_grayscale),
|
AC(force_grayscale),
|
||||||
AC(dendy),
|
AC(dendy),
|
||||||
AC(RAMInitOption),
|
AC(RAMInitOption),
|
||||||
|
AC(RAMInitSeed),
|
||||||
AC(postrenderscanlines),
|
AC(postrenderscanlines),
|
||||||
AC(vblankscanlines),
|
AC(vblankscanlines),
|
||||||
AC(overclock_enabled),
|
AC(overclock_enabled),
|
||||||
|
|
|
@ -845,14 +845,6 @@ u64 xoroshiro128plus_next() {
|
||||||
void FCEU_MemoryRand(uint8 *ptr, uint32 size) {
|
void FCEU_MemoryRand(uint8 *ptr, uint32 size) {
|
||||||
int x = 0;
|
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) {
|
while (size) {
|
||||||
uint8 v = 0;
|
uint8 v = 0;
|
||||||
switch (RAMInitOption)
|
switch (RAMInitOption)
|
||||||
|
@ -888,6 +880,16 @@ void PowerNES(void) {
|
||||||
FCEUMOV_AddCommand(FCEUNPCMD_POWER);
|
FCEUMOV_AddCommand(FCEUNPCMD_POWER);
|
||||||
if (!GameInfo) return;
|
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_CheatResetRAM();
|
||||||
FCEU_CheatAddRAM(2, 0, RAM);
|
FCEU_CheatAddRAM(2, 0, RAM);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue