From b8d8ffb3bffadbe6b51c1c24f8a08d47adf9b80d Mon Sep 17 00:00:00 2001 From: Ilari Liusvaara Date: Fri, 11 Nov 2011 19:54:34 +0200 Subject: [PATCH] Make the random seed controllable - This allows eliminating random seed differences from savestates (may be useful for some forms of sync stability testing). - Would also allow (re)recording with randomization enabled, as the seed can be set portably). --- snes/interface/interface.cpp | 4 ++++ snes/interface/interface.hpp | 1 + snes/system/system.cpp | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/snes/interface/interface.cpp b/snes/interface/interface.cpp index dcaa9da..ce55a6c 100644 --- a/snes/interface/interface.cpp +++ b/snes/interface/interface.cpp @@ -22,4 +22,8 @@ time_t Interface::currentTime() { return time(0); } +time_t Interface::randomSeed() { + return time(0); +} + } diff --git a/snes/interface/interface.hpp b/snes/interface/interface.hpp index 42de597..93d1969 100644 --- a/snes/interface/interface.hpp +++ b/snes/interface/interface.hpp @@ -6,6 +6,7 @@ struct Interface { virtual string path(Cartridge::Slot::e slot, const string &hint) = 0; virtual void message(const string &text); virtual time_t currentTime(); + virtual time_t randomSeed(); }; extern Interface *interface; diff --git a/snes/system/system.cpp b/snes/system/system.cpp index 23cff30..48f4af9 100755 --- a/snes/system/system.cpp +++ b/snes/system/system.cpp @@ -147,7 +147,7 @@ void System::unload() { } void System::power() { - random.seed((unsigned)time(0)); + random.seed((unsigned)interface->randomSeed()); region = config.region; expansion = config.expansion_port;