From 8b67a3ada3ba4ad041cebd87906e9000a94ea12c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Lam?= Date: Sat, 10 Jun 2017 19:46:31 +0200 Subject: [PATCH 1/3] Core: Only restore config after HW shutdown The config must only be restored after the HW has shut down, not while it is still running, because the HW can still query the config, which can lead to inconsistent states. This fixes WiiRoot not being able to copy back saves on shutdown. --- Source/Core/Core/Core.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/Source/Core/Core/Core.cpp b/Source/Core/Core/Core.cpp index 760d16d95d..128a2a228d 100644 --- a/Source/Core/Core/Core.cpp +++ b/Source/Core/Core/Core.cpp @@ -481,6 +481,16 @@ static void EmuThread(std::unique_ptr boot) INFO_LOG(CONSOLE, "%s", StopMessage(false, "Shutting down HW").c_str()); HW::Shutdown(); INFO_LOG(CONSOLE, "%s", StopMessage(false, "HW shutdown").c_str()); + + // Clear on screen messages that haven't expired + OSD::ClearMessages(); + + // The config must be restored only after the whole HW has shut down, + // not when it is still running. + BootManager::RestoreConfig(); + + PatchEngine::Shutdown(); + HLE::Clear(); }}; if (!g_video_backend->Initialize(s_window_handle)) @@ -638,13 +648,6 @@ static void EmuThread(std::unique_ptr boot) if (core_parameter.bCPUThread) g_video_backend->Video_Cleanup(); - // Clear on screen messages that haven't expired - OSD::ClearMessages(); - - BootManager::RestoreConfig(); - - PatchEngine::Shutdown(); - HLE::Clear(); // If we shut down normally, the stop message does not need to be triggered. stop_message_guard.Dismiss(); } From 3eecf67a2abdc85da596c731f40a20c3ffa847b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Lam?= Date: Sat, 10 Jun 2017 19:51:41 +0200 Subject: [PATCH 2/3] Core: Remove useless InitializeWiiRoot call --- Source/Core/Core/Core.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Source/Core/Core/Core.cpp b/Source/Core/Core/Core.cpp index 128a2a228d..75b36ef0fd 100644 --- a/Source/Core/Core/Core.cpp +++ b/Source/Core/Core/Core.cpp @@ -964,7 +964,10 @@ void UpdateWantDeterminism(bool initial) // We need to clear the cache because some parts of the JIT depend on want_determinism, e.g. use // of FMA. JitInterface::ClearCache(); - Core::InitializeWiiRoot(s_wants_determinism); + + // Don't call InitializeWiiRoot during boot, because IOS already does it. + if (!initial) + Core::InitializeWiiRoot(s_wants_determinism); Core::PauseAndLock(false, was_unpaused); } From 91bcd756ffe060319cb858572dbe118657c2ddfd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Lam?= Date: Sat, 10 Jun 2017 19:48:45 +0200 Subject: [PATCH 3/3] Core: Remove useless ShutdownWiiRoot calls I don't see why we need to call ShutdownWiiRoot on InitializeWiiRoot. Also, atexit? Really? Not only is this unnecessary, it will also cause ShutdownWiiRoot to be called twice in rapid succession for no reason. --- Source/Core/Core/WiiRoot.cpp | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/Source/Core/Core/WiiRoot.cpp b/Source/Core/Core/WiiRoot.cpp index 995e633522..7a2f5104b3 100644 --- a/Source/Core/Core/WiiRoot.cpp +++ b/Source/Core/Core/WiiRoot.cpp @@ -16,10 +16,6 @@ #include "Core/Movie.h" #include "Core/NetPlayClient.h" -#ifdef _WIN32 -#include -#endif - namespace Core { static std::string s_temp_wii_root; @@ -56,8 +52,6 @@ static void InitializeDeterministicWiiSaves() void InitializeWiiRoot(bool use_temporary) { - ShutdownWiiRoot(); - if (use_temporary) { s_temp_wii_root = File::CreateTempDir(); @@ -69,12 +63,6 @@ void InitializeWiiRoot(bool use_temporary) File::CopyDir(File::GetSysDirectory() + WII_USER_DIR, s_temp_wii_root); WARN_LOG(IOS_FILEIO, "Using temporary directory %s for minimal Wii FS", s_temp_wii_root.c_str()); - static bool s_registered; - if (!s_registered) - { - s_registered = true; - atexit(ShutdownWiiRoot); - } File::SetUserPath(D_SESSION_WIIROOT_IDX, s_temp_wii_root); // Generate a SYSCONF with default settings for the temporary Wii NAND. SysConf sysconf{Common::FromWhichRoot::FROM_SESSION_ROOT};