From 64101137cd6e507942364fb7e446692d69277341 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Lam?= Date: Fri, 6 Jan 2017 21:59:02 +0100 Subject: [PATCH] Remove pre-generated SYSCONF Dolphin is able to generate one with all correct default settings, so we don't need to ship with a pre-generated SYSCONF and worry about syncing default settings. Additionally, this commit changes SysConf to work with session SYSCONFs so that Dolphin is able to generate a default one even for Movie/TAS. Which SYSCONF needs to be touched is explicitly specified to avoid confusion about which file SysConf is managing. (Another notable change is that the Wii root functions are moved into Core to prevent Common from depending on Core.) --- Data/Sys/Wii/shared2/sys/SYSCONF | Bin 16384 -> 0 bytes Source/Core/Common/NandPaths.cpp | 41 +------------ Source/Core/Common/NandPaths.h | 4 +- Source/Core/Common/SysConf.cpp | 39 ++++++------ Source/Core/Common/SysConf.h | 7 ++- Source/Core/Core/CMakeLists.txt | 1 + Source/Core/Core/ConfigManager.cpp | 5 +- Source/Core/Core/Core.cpp | 4 +- Source/Core/Core/Core.vcxproj | 2 + Source/Core/Core/Core.vcxproj.filters | 2 + Source/Core/Core/HW/HW.cpp | 6 +- .../IPC_HLE/WII_IPC_HLE_Device_usb_bt_emu.cpp | 14 ++--- Source/Core/Core/WiiRoot.cpp | 57 ++++++++++++++++++ Source/Core/Core/WiiRoot.h | 11 ++++ 14 files changed, 111 insertions(+), 82 deletions(-) delete mode 100644 Data/Sys/Wii/shared2/sys/SYSCONF create mode 100644 Source/Core/Core/WiiRoot.cpp create mode 100644 Source/Core/Core/WiiRoot.h diff --git a/Data/Sys/Wii/shared2/sys/SYSCONF b/Data/Sys/Wii/shared2/sys/SYSCONF deleted file mode 100644 index 283c84a7e4b2015ba7f49a9c49b6d298bca14a06..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 16384 zcmeI$&ui0Q7zgktU8r-2ZlhW1Po~Hm;==2YAs&P_No!b|g}zxU13|Hw7Dg+&A2_`F zANU7&(2C$qJ?!AYi&sHBco6a6CJMWX$PT{mo3Ya_gVG%KeM_6SN&7r`K6y#Y!|i28 z$LXs6Qh%#|*1zgM^iBPbanQ&aCylo8$ari%F`t^R%s1vc^Mm=({9=ALH_gBKOnx9g zGFFT%#|ujOO`YiB(accLY%RvEMtihc^C#>enqU`cFGK4}luTEm^mQf5UaH4uApn8h z1v=tZ!`*<3qkSbW^sT^~HmE^uTA+J$mzvbt{$e(khYM9L7GEif?Yw-?d5zS>56ap( zwWr`z2M;XdiP#!@#@2Sv+mpSVRzv}dv`R7E7X{rC#WZ@7IZ49lwjf*)*_+}VdOtWV ziOdhgBkp~2kuk}?D%{fs|4b+*NRvrjj^ zrNS{sTjIXkRKLP$oIv{dmr}0(U&{HD`tOLpvuTX9uYVdfBPRqP00ALz`gL~rxoip8 z#Un$x&b(|jgwwU_uG|;e9_hI*IlTzn$g-o*mhm>~^}1E%5y>{H?Rce(=%Qlmdx4Hz zc3vRYNWYqws&YQQu9m2yZ6w>tq_H&{Mj6%E3d=m{aJf@VQ#~-}8mR?Ww@YOaKr5-h zj<0FjPdRmG{etR}Rc0dXS0(hhRhg-IuD0(l0RSKX0SG_<0uX=z1Rwwb2tWV=5P$## zAOHafKmY;|fB*y_009U<00Izz00bZa0SG_<0^Jt4LZ?K?!*rSQ)K8<7-AOR1W+%k! jdGXBAAYGtiG(f|2hAz=rnj(uBjnkModWc529XI|1mw&0g diff --git a/Source/Core/Common/NandPaths.cpp b/Source/Core/Common/NandPaths.cpp index 60cb49fa26..99c75f01f8 100644 --- a/Source/Core/Common/NandPaths.cpp +++ b/Source/Core/Common/NandPaths.cpp @@ -20,46 +20,7 @@ namespace Common { -static std::string s_temp_wii_root; - -void InitializeWiiRoot(bool use_dummy) -{ - ShutdownWiiRoot(); - if (use_dummy) - { - s_temp_wii_root = File::CreateTempDir(); - if (s_temp_wii_root.empty()) - { - ERROR_LOG(WII_IPC_FILEIO, "Could not create temporary directory"); - return; - } - File::CopyDir(File::GetSysDirectory() + WII_USER_DIR, s_temp_wii_root); - WARN_LOG(WII_IPC_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); - } - else - { - File::SetUserPath(D_SESSION_WIIROOT_IDX, File::GetUserPath(D_WIIROOT_IDX)); - } -} - -void ShutdownWiiRoot() -{ - if (!s_temp_wii_root.empty()) - { - File::DeleteDirRecursively(s_temp_wii_root); - s_temp_wii_root.clear(); - } -} - -static std::string RootUserPath(FromWhichRoot from) +std::string RootUserPath(FromWhichRoot from) { int idx = from == FROM_CONFIGURED_ROOT ? D_WIIROOT_IDX : D_SESSION_WIIROOT_IDX; return File::GetUserPath(idx); diff --git a/Source/Core/Common/NandPaths.h b/Source/Core/Common/NandPaths.h index ab15d6f049..c5a3234e8c 100644 --- a/Source/Core/Common/NandPaths.h +++ b/Source/Core/Common/NandPaths.h @@ -15,15 +15,13 @@ static const std::string TITLEID_SYSMENU_STRING = "0000000100000002"; namespace Common { -void InitializeWiiRoot(bool use_temporary); -void ShutdownWiiRoot(); - enum FromWhichRoot { FROM_CONFIGURED_ROOT, // not related to currently running game - use D_WIIROOT_IDX FROM_SESSION_ROOT, // request from currently running game - use D_SESSION_WIIROOT_IDX }; +std::string RootUserPath(FromWhichRoot from); std::string GetTicketFileName(u64 _titleID, FromWhichRoot from); std::string GetTMDFileName(u64 _titleID, FromWhichRoot from); std::string GetTitleDataPath(u64 _titleID, FromWhichRoot from); diff --git a/Source/Core/Common/SysConf.cpp b/Source/Core/Common/SysConf.cpp index 3b2ab36694..e8f8fb3cef 100644 --- a/Source/Core/Common/SysConf.cpp +++ b/Source/Core/Common/SysConf.cpp @@ -17,9 +17,9 @@ #include "Core/Movie.h" -SysConf::SysConf() +SysConf::SysConf(const Common::FromWhichRoot root_type) { - UpdateLocation(); + UpdateLocation(root_type); } SysConf::~SysConf() @@ -50,6 +50,7 @@ bool SysConf::LoadFromFile(const std::string& filename) { File::CreateFullPath(filename); GenerateSysConf(); + ApplySettingsFromMovie(); return true; } @@ -61,12 +62,10 @@ bool SysConf::LoadFromFile(const std::string& filename) SYSCONF_SIZE, size)) { GenerateSysConf(); + ApplySettingsFromMovie(); return true; } - else - { - return false; - } + return false; } File::IOFile f(filename, "rb"); @@ -76,13 +75,7 @@ bool SysConf::LoadFromFile(const std::string& filename) { m_Filename = filename; m_IsValid = true; - // Apply Wii settings from normal SYSCONF on Movie recording/playback - if (Movie::IsRecordingInput() || Movie::IsPlayingInput()) - { - SetData("IPL.LNG", Movie::GetLanguage()); - SetData("IPL.E60", Movie::IsPAL60()); - SetData("IPL.PGS", Movie::IsProgressive()); - } + ApplySettingsFromMovie(); return true; } } @@ -90,6 +83,17 @@ bool SysConf::LoadFromFile(const std::string& filename) return false; } +// Apply Wii settings from normal SYSCONF on Movie recording/playback +void SysConf::ApplySettingsFromMovie() +{ + if (!Movie::IsMovieActive()) + return; + + SetData("IPL.LNG", Movie::GetLanguage()); + SetData("IPL.E60", Movie::IsPAL60()); + SetData("IPL.PGS", Movie::IsProgressive()); +} + bool SysConf::LoadFromFileInternal(File::IOFile&& file) { // Fill in infos @@ -420,7 +424,7 @@ bool SysConf::Save() return SaveToFile(m_Filename); } -void SysConf::UpdateLocation() +void SysConf::UpdateLocation(const Common::FromWhichRoot root_type) { // if the old Wii User dir had a sysconf file save any settings that have been changed to it if (m_IsValid) @@ -429,11 +433,8 @@ void SysConf::UpdateLocation() // Clear the old filename and set the default filename to the new user path // So that it can be generated if the file does not exist in the new location m_Filename.clear(); - // Note: We don't use the dummy Wii root here (if in use) because this is - // all tied up with the configuration code. In the future this should - // probably just be synced with the other settings. - m_FilenameDefault = - File::GetUserPath(D_WIIROOT_IDX) + DIR_SEP WII_SYSCONF_DIR DIR_SEP WII_SYSCONF; + // In the future the SYSCONF should probably just be synced with the other settings. + m_FilenameDefault = Common::RootUserPath(root_type) + DIR_SEP WII_SYSCONF_DIR DIR_SEP WII_SYSCONF; Reload(); } diff --git a/Source/Core/Common/SysConf.h b/Source/Core/Common/SysConf.h index 97b3a98232..5eaed702d7 100644 --- a/Source/Core/Common/SysConf.h +++ b/Source/Core/Common/SysConf.h @@ -13,6 +13,7 @@ #include "Common/CommonTypes.h" #include "Common/Logging/Log.h" #include "Common/MsgHandler.h" +#include "Common/NandPaths.h" namespace File { @@ -79,7 +80,7 @@ struct SSysConfEntry class SysConf { public: - SysConf(); + SysConf(Common::FromWhichRoot root_type); ~SysConf(); bool IsValid() { return m_IsValid; } @@ -176,13 +177,13 @@ public: bool SaveToFile(const std::string& filename); bool LoadFromFile(const std::string& filename); bool Reload(); - // This function is used when the NAND root is changed - void UpdateLocation(); + void UpdateLocation(Common::FromWhichRoot root_type); private: bool LoadFromFileInternal(File::IOFile&& file); void GenerateSysConf(); void Clear(); + void ApplySettingsFromMovie(); std::string m_Filename; std::string m_FilenameDefault; diff --git a/Source/Core/Core/CMakeLists.txt b/Source/Core/Core/CMakeLists.txt index a1c72eba39..a5825e15e7 100644 --- a/Source/Core/Core/CMakeLists.txt +++ b/Source/Core/Core/CMakeLists.txt @@ -16,6 +16,7 @@ set(SRCS ActionReplay.cpp NetPlayServer.cpp PatchEngine.cpp State.cpp + WiiRoot.cpp Boot/Boot_BS2Emu.cpp Boot/Boot.cpp Boot/Boot_DOL.cpp diff --git a/Source/Core/Core/ConfigManager.cpp b/Source/Core/Core/ConfigManager.cpp index eade56d195..a6a8c3e3b1 100644 --- a/Source/Core/Core/ConfigManager.cpp +++ b/Source/Core/Core/ConfigManager.cpp @@ -12,6 +12,7 @@ #include "Common/FileUtil.h" #include "Common/Logging/Log.h" #include "Common/MsgHandler.h" +#include "Common/NandPaths.h" #include "Common/StringUtil.h" #include "Common/SysConf.h" @@ -355,7 +356,7 @@ void SConfig::SaveSysconfSettings(IniFile& ini) void SConfig::SaveSettingsToSysconf() { - SysConf sysconf; + SysConf sysconf{Common::FromWhichRoot::FROM_CONFIGURED_ROOT}; sysconf.SetData("IPL.SSV", m_wii_screensaver); sysconf.SetData("IPL.LNG", m_wii_language); @@ -687,7 +688,7 @@ void SConfig::LoadSysconfSettings(IniFile& ini) void SConfig::LoadSettingsFromSysconf() { - SysConf sysconf; + SysConf sysconf{Common::FromWhichRoot::FROM_CONFIGURED_ROOT}; m_wii_screensaver = sysconf.GetData("IPL.SSV"); m_wii_language = sysconf.GetData("IPL.LNG"); diff --git a/Source/Core/Core/Core.cpp b/Source/Core/Core/Core.cpp index 35029c911c..992bc87b6d 100644 --- a/Source/Core/Core/Core.cpp +++ b/Source/Core/Core/Core.cpp @@ -24,7 +24,6 @@ #include "Common/Logging/LogManager.h" #include "Common/MathUtil.h" #include "Common/MemoryUtil.h" -#include "Common/NandPaths.h" #include "Common/StringUtil.h" #include "Common/Thread.h" #include "Common/Timer.h" @@ -65,6 +64,7 @@ #include "Core/PowerPC/JitInterface.h" #include "Core/PowerPC/PowerPC.h" #include "Core/State.h" +#include "Core/WiiRoot.h" #ifdef USE_GDBSTUB #include "Core/PowerPC/GDBStub.h" @@ -990,7 +990,7 @@ 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(); - Common::InitializeWiiRoot(g_want_determinism); + Core::InitializeWiiRoot(g_want_determinism); Core::PauseAndLock(false, was_unpaused); } diff --git a/Source/Core/Core/Core.vcxproj b/Source/Core/Core/Core.vcxproj index 599aa36e07..d18d130422 100644 --- a/Source/Core/Core/Core.vcxproj +++ b/Source/Core/Core/Core.vcxproj @@ -263,6 +263,7 @@ + @@ -464,6 +465,7 @@ + diff --git a/Source/Core/Core/Core.vcxproj.filters b/Source/Core/Core/Core.vcxproj.filters index 074218bbe1..4b33dd2e2e 100644 --- a/Source/Core/Core/Core.vcxproj.filters +++ b/Source/Core/Core/Core.vcxproj.filters @@ -156,6 +156,7 @@ + ActionReplay @@ -794,6 +795,7 @@ + ActionReplay diff --git a/Source/Core/Core/HW/HW.cpp b/Source/Core/Core/HW/HW.cpp index efb8590355..732009258b 100644 --- a/Source/Core/Core/HW/HW.cpp +++ b/Source/Core/Core/HW/HW.cpp @@ -4,7 +4,6 @@ #include "Common/ChunkFile.h" #include "Common/CommonTypes.h" -#include "Common/NandPaths.h" #include "Core/ConfigManager.h" #include "Core/Core.h" @@ -24,6 +23,7 @@ #include "Core/HW/WII_IPC.h" #include "Core/IPC_HLE/WII_IPC_HLE.h" #include "Core/State.h" +#include "Core/WiiRoot.h" #include "DiscIO/NANDContentLoader.h" namespace HW @@ -50,7 +50,7 @@ void Init() if (SConfig::GetInstance().bWii) { - Common::InitializeWiiRoot(Core::g_want_determinism); + Core::InitializeWiiRoot(Core::g_want_determinism); DiscIO::cUIDsys::AccessInstance().UpdateLocation(); DiscIO::CSharedContent::AccessInstance().UpdateLocation(); WII_IPCInterface::Init(); @@ -64,7 +64,7 @@ void Shutdown() { WII_IPC_HLE_Interface::Shutdown(); // Depends on Memory WII_IPCInterface::Shutdown(); - Common::ShutdownWiiRoot(); + Core::ShutdownWiiRoot(); } SystemTimers::Shutdown(); diff --git a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_usb_bt_emu.cpp b/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_usb_bt_emu.cpp index eda94545bc..f81169a140 100644 --- a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_usb_bt_emu.cpp +++ b/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_usb_bt_emu.cpp @@ -12,6 +12,7 @@ #include "Common/FileUtil.h" #include "Common/Logging/Log.h" #include "Common/MsgHandler.h" +#include "Common/NandPaths.h" #include "Common/StringUtil.h" #include "Common/SysConf.h" #include "Core/Core.h" @@ -38,17 +39,10 @@ CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CWII_IPC_HLE_Device_usb_oh1_57e_305_emu u32 _DeviceID, const std::string& _rDeviceName) : CWII_IPC_HLE_Device_usb_oh1_57e_305_base(_DeviceID, _rDeviceName) { - SysConf sysconf; - if (Core::g_want_determinism) - { - // See SysConf::UpdateLocation for comment about the Future. - sysconf.LoadFromFile(File::GetUserPath(D_SESSION_WIIROOT_IDX) + - DIR_SEP WII_SYSCONF_DIR DIR_SEP WII_SYSCONF); - } - else - { + SysConf sysconf{Core::g_want_determinism ? Common::FromWhichRoot::FROM_SESSION_ROOT : + Common::FromWhichRoot::FROM_CONFIGURED_ROOT}; + if (!Core::g_want_determinism) BackUpBTInfoSection(&sysconf); - } // Activate only first Wii Remote by default diff --git a/Source/Core/Core/WiiRoot.cpp b/Source/Core/Core/WiiRoot.cpp new file mode 100644 index 0000000000..d0be403339 --- /dev/null +++ b/Source/Core/Core/WiiRoot.cpp @@ -0,0 +1,57 @@ +// Copyright 2016 Dolphin Emulator Project +// Licensed under GPLv2+ +// Refer to the license.txt file included. + +#include + +#include "Common/CommonPaths.h" +#include "Common/FileUtil.h" +#include "Common/Logging/Log.h" +#include "Common/NandPaths.h" +#include "Common/SysConf.h" +#include "Core/WiiRoot.h" + +namespace Core +{ +static std::string s_temp_wii_root; + +void InitializeWiiRoot(bool use_temporary) +{ + ShutdownWiiRoot(); + if (use_temporary) + { + s_temp_wii_root = File::CreateTempDir(); + if (s_temp_wii_root.empty()) + { + ERROR_LOG(WII_IPC_FILEIO, "Could not create temporary directory"); + return; + } + File::CopyDir(File::GetSysDirectory() + WII_USER_DIR, s_temp_wii_root); + WARN_LOG(WII_IPC_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}; + sysconf.Save(); + } + else + { + File::SetUserPath(D_SESSION_WIIROOT_IDX, File::GetUserPath(D_WIIROOT_IDX)); + } +} + +void ShutdownWiiRoot() +{ + if (!s_temp_wii_root.empty()) + { + File::DeleteDirRecursively(s_temp_wii_root); + s_temp_wii_root.clear(); + } +} +} diff --git a/Source/Core/Core/WiiRoot.h b/Source/Core/Core/WiiRoot.h new file mode 100644 index 0000000000..7174fd9943 --- /dev/null +++ b/Source/Core/Core/WiiRoot.h @@ -0,0 +1,11 @@ +// Copyright 2016 Dolphin Emulator Project +// Licensed under GPLv2+ +// Refer to the license.txt file included. + +#pragma once + +namespace Core +{ +void InitializeWiiRoot(bool use_temporary); +void ShutdownWiiRoot(); +}