Merge pull request #4621 from leoetlino/default-sysconf

Remove pre-generated SYSCONF
This commit is contained in:
Matthew Parlane 2017-01-13 09:39:33 +13:00 committed by GitHub
commit cc51378389
14 changed files with 111 additions and 82 deletions

Binary file not shown.

View File

@ -20,46 +20,7 @@
namespace Common namespace Common
{ {
static std::string s_temp_wii_root; std::string RootUserPath(FromWhichRoot from)
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)
{ {
int idx = from == FROM_CONFIGURED_ROOT ? D_WIIROOT_IDX : D_SESSION_WIIROOT_IDX; int idx = from == FROM_CONFIGURED_ROOT ? D_WIIROOT_IDX : D_SESSION_WIIROOT_IDX;
return File::GetUserPath(idx); return File::GetUserPath(idx);

View File

@ -15,15 +15,13 @@ static const std::string TITLEID_SYSMENU_STRING = "0000000100000002";
namespace Common namespace Common
{ {
void InitializeWiiRoot(bool use_temporary);
void ShutdownWiiRoot();
enum FromWhichRoot enum FromWhichRoot
{ {
FROM_CONFIGURED_ROOT, // not related to currently running game - use D_WIIROOT_IDX 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 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 GetTicketFileName(u64 _titleID, FromWhichRoot from);
std::string GetTMDFileName(u64 _titleID, FromWhichRoot from); std::string GetTMDFileName(u64 _titleID, FromWhichRoot from);
std::string GetTitleDataPath(u64 _titleID, FromWhichRoot from); std::string GetTitleDataPath(u64 _titleID, FromWhichRoot from);

View File

@ -17,9 +17,9 @@
#include "Core/Movie.h" #include "Core/Movie.h"
SysConf::SysConf() SysConf::SysConf(const Common::FromWhichRoot root_type)
{ {
UpdateLocation(); UpdateLocation(root_type);
} }
SysConf::~SysConf() SysConf::~SysConf()
@ -50,6 +50,7 @@ bool SysConf::LoadFromFile(const std::string& filename)
{ {
File::CreateFullPath(filename); File::CreateFullPath(filename);
GenerateSysConf(); GenerateSysConf();
ApplySettingsFromMovie();
return true; return true;
} }
@ -61,13 +62,11 @@ bool SysConf::LoadFromFile(const std::string& filename)
SYSCONF_SIZE, size)) SYSCONF_SIZE, size))
{ {
GenerateSysConf(); GenerateSysConf();
ApplySettingsFromMovie();
return true; return true;
} }
else
{
return false; return false;
} }
}
File::IOFile f(filename, "rb"); File::IOFile f(filename, "rb");
if (f.IsOpen()) if (f.IsOpen())
@ -76,13 +75,7 @@ bool SysConf::LoadFromFile(const std::string& filename)
{ {
m_Filename = filename; m_Filename = filename;
m_IsValid = true; m_IsValid = true;
// Apply Wii settings from normal SYSCONF on Movie recording/playback ApplySettingsFromMovie();
if (Movie::IsRecordingInput() || Movie::IsPlayingInput())
{
SetData("IPL.LNG", Movie::GetLanguage());
SetData("IPL.E60", Movie::IsPAL60());
SetData("IPL.PGS", Movie::IsProgressive());
}
return true; return true;
} }
} }
@ -90,6 +83,17 @@ bool SysConf::LoadFromFile(const std::string& filename)
return false; 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) bool SysConf::LoadFromFileInternal(File::IOFile&& file)
{ {
// Fill in infos // Fill in infos
@ -420,7 +424,7 @@ bool SysConf::Save()
return SaveToFile(m_Filename); 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 the old Wii User dir had a sysconf file save any settings that have been changed to it
if (m_IsValid) if (m_IsValid)
@ -429,11 +433,8 @@ void SysConf::UpdateLocation()
// Clear the old filename and set the default filename to the new user path // 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 // So that it can be generated if the file does not exist in the new location
m_Filename.clear(); m_Filename.clear();
// Note: We don't use the dummy Wii root here (if in use) because this is // In the future the SYSCONF should probably just be synced with the other settings.
// all tied up with the configuration code. In the future this should m_FilenameDefault = Common::RootUserPath(root_type) + DIR_SEP WII_SYSCONF_DIR DIR_SEP WII_SYSCONF;
// probably just be synced with the other settings.
m_FilenameDefault =
File::GetUserPath(D_WIIROOT_IDX) + DIR_SEP WII_SYSCONF_DIR DIR_SEP WII_SYSCONF;
Reload(); Reload();
} }

View File

@ -13,6 +13,7 @@
#include "Common/CommonTypes.h" #include "Common/CommonTypes.h"
#include "Common/Logging/Log.h" #include "Common/Logging/Log.h"
#include "Common/MsgHandler.h" #include "Common/MsgHandler.h"
#include "Common/NandPaths.h"
namespace File namespace File
{ {
@ -79,7 +80,7 @@ struct SSysConfEntry
class SysConf class SysConf
{ {
public: public:
SysConf(); SysConf(Common::FromWhichRoot root_type);
~SysConf(); ~SysConf();
bool IsValid() { return m_IsValid; } bool IsValid() { return m_IsValid; }
@ -176,13 +177,13 @@ public:
bool SaveToFile(const std::string& filename); bool SaveToFile(const std::string& filename);
bool LoadFromFile(const std::string& filename); bool LoadFromFile(const std::string& filename);
bool Reload(); bool Reload();
// This function is used when the NAND root is changed void UpdateLocation(Common::FromWhichRoot root_type);
void UpdateLocation();
private: private:
bool LoadFromFileInternal(File::IOFile&& file); bool LoadFromFileInternal(File::IOFile&& file);
void GenerateSysConf(); void GenerateSysConf();
void Clear(); void Clear();
void ApplySettingsFromMovie();
std::string m_Filename; std::string m_Filename;
std::string m_FilenameDefault; std::string m_FilenameDefault;

View File

@ -16,6 +16,7 @@ set(SRCS ActionReplay.cpp
NetPlayServer.cpp NetPlayServer.cpp
PatchEngine.cpp PatchEngine.cpp
State.cpp State.cpp
WiiRoot.cpp
Boot/Boot_BS2Emu.cpp Boot/Boot_BS2Emu.cpp
Boot/Boot.cpp Boot/Boot.cpp
Boot/Boot_DOL.cpp Boot/Boot_DOL.cpp

View File

@ -12,6 +12,7 @@
#include "Common/FileUtil.h" #include "Common/FileUtil.h"
#include "Common/Logging/Log.h" #include "Common/Logging/Log.h"
#include "Common/MsgHandler.h" #include "Common/MsgHandler.h"
#include "Common/NandPaths.h"
#include "Common/StringUtil.h" #include "Common/StringUtil.h"
#include "Common/SysConf.h" #include "Common/SysConf.h"
@ -355,7 +356,7 @@ void SConfig::SaveSysconfSettings(IniFile& ini)
void SConfig::SaveSettingsToSysconf() void SConfig::SaveSettingsToSysconf()
{ {
SysConf sysconf; SysConf sysconf{Common::FromWhichRoot::FROM_CONFIGURED_ROOT};
sysconf.SetData<u8>("IPL.SSV", m_wii_screensaver); sysconf.SetData<u8>("IPL.SSV", m_wii_screensaver);
sysconf.SetData<u8>("IPL.LNG", m_wii_language); sysconf.SetData<u8>("IPL.LNG", m_wii_language);
@ -687,7 +688,7 @@ void SConfig::LoadSysconfSettings(IniFile& ini)
void SConfig::LoadSettingsFromSysconf() void SConfig::LoadSettingsFromSysconf()
{ {
SysConf sysconf; SysConf sysconf{Common::FromWhichRoot::FROM_CONFIGURED_ROOT};
m_wii_screensaver = sysconf.GetData<u8>("IPL.SSV"); m_wii_screensaver = sysconf.GetData<u8>("IPL.SSV");
m_wii_language = sysconf.GetData<u8>("IPL.LNG"); m_wii_language = sysconf.GetData<u8>("IPL.LNG");

View File

@ -24,7 +24,6 @@
#include "Common/Logging/LogManager.h" #include "Common/Logging/LogManager.h"
#include "Common/MathUtil.h" #include "Common/MathUtil.h"
#include "Common/MemoryUtil.h" #include "Common/MemoryUtil.h"
#include "Common/NandPaths.h"
#include "Common/StringUtil.h" #include "Common/StringUtil.h"
#include "Common/Thread.h" #include "Common/Thread.h"
#include "Common/Timer.h" #include "Common/Timer.h"
@ -65,6 +64,7 @@
#include "Core/PowerPC/JitInterface.h" #include "Core/PowerPC/JitInterface.h"
#include "Core/PowerPC/PowerPC.h" #include "Core/PowerPC/PowerPC.h"
#include "Core/State.h" #include "Core/State.h"
#include "Core/WiiRoot.h"
#ifdef USE_GDBSTUB #ifdef USE_GDBSTUB
#include "Core/PowerPC/GDBStub.h" #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 // We need to clear the cache because some parts of the JIT depend on want_determinism, e.g. use
// of FMA. // of FMA.
JitInterface::ClearCache(); JitInterface::ClearCache();
Common::InitializeWiiRoot(g_want_determinism); Core::InitializeWiiRoot(g_want_determinism);
Core::PauseAndLock(false, was_unpaused); Core::PauseAndLock(false, was_unpaused);
} }

View File

@ -263,6 +263,7 @@
<ClCompile Include="PowerPC\PPCTables.cpp" /> <ClCompile Include="PowerPC\PPCTables.cpp" />
<ClCompile Include="PowerPC\Profiler.cpp" /> <ClCompile Include="PowerPC\Profiler.cpp" />
<ClCompile Include="State.cpp" /> <ClCompile Include="State.cpp" />
<ClCompile Include="WiiRoot.cpp" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="ActionReplay.h" /> <ClInclude Include="ActionReplay.h" />
@ -464,6 +465,7 @@
<ClInclude Include="PowerPC\PPCTables.h" /> <ClInclude Include="PowerPC\PPCTables.h" />
<ClInclude Include="PowerPC\Profiler.h" /> <ClInclude Include="PowerPC\Profiler.h" />
<ClInclude Include="State.h" /> <ClInclude Include="State.h" />
<ClInclude Include="WiiRoot.h" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Text Include="CMakeLists.txt" /> <Text Include="CMakeLists.txt" />

View File

@ -156,6 +156,7 @@
<ClCompile Include="NetPlayServer.cpp" /> <ClCompile Include="NetPlayServer.cpp" />
<ClCompile Include="PatchEngine.cpp" /> <ClCompile Include="PatchEngine.cpp" />
<ClCompile Include="State.cpp" /> <ClCompile Include="State.cpp" />
<ClCompile Include="WiiRoot.cpp" />
<ClCompile Include="ActionReplay.cpp"> <ClCompile Include="ActionReplay.cpp">
<Filter>ActionReplay</Filter> <Filter>ActionReplay</Filter>
</ClCompile> </ClCompile>
@ -794,6 +795,7 @@
<ClInclude Include="NetPlayServer.h" /> <ClInclude Include="NetPlayServer.h" />
<ClInclude Include="PatchEngine.h" /> <ClInclude Include="PatchEngine.h" />
<ClInclude Include="State.h" /> <ClInclude Include="State.h" />
<ClInclude Include="WiiRoot.h" />
<ClInclude Include="ActionReplay.h"> <ClInclude Include="ActionReplay.h">
<Filter>ActionReplay</Filter> <Filter>ActionReplay</Filter>
</ClInclude> </ClInclude>

View File

@ -4,7 +4,6 @@
#include "Common/ChunkFile.h" #include "Common/ChunkFile.h"
#include "Common/CommonTypes.h" #include "Common/CommonTypes.h"
#include "Common/NandPaths.h"
#include "Core/ConfigManager.h" #include "Core/ConfigManager.h"
#include "Core/Core.h" #include "Core/Core.h"
@ -24,6 +23,7 @@
#include "Core/HW/WII_IPC.h" #include "Core/HW/WII_IPC.h"
#include "Core/IPC_HLE/WII_IPC_HLE.h" #include "Core/IPC_HLE/WII_IPC_HLE.h"
#include "Core/State.h" #include "Core/State.h"
#include "Core/WiiRoot.h"
#include "DiscIO/NANDContentLoader.h" #include "DiscIO/NANDContentLoader.h"
namespace HW namespace HW
@ -50,7 +50,7 @@ void Init()
if (SConfig::GetInstance().bWii) if (SConfig::GetInstance().bWii)
{ {
Common::InitializeWiiRoot(Core::g_want_determinism); Core::InitializeWiiRoot(Core::g_want_determinism);
DiscIO::cUIDsys::AccessInstance().UpdateLocation(); DiscIO::cUIDsys::AccessInstance().UpdateLocation();
DiscIO::CSharedContent::AccessInstance().UpdateLocation(); DiscIO::CSharedContent::AccessInstance().UpdateLocation();
WII_IPCInterface::Init(); WII_IPCInterface::Init();
@ -64,7 +64,7 @@ void Shutdown()
{ {
WII_IPC_HLE_Interface::Shutdown(); // Depends on Memory WII_IPC_HLE_Interface::Shutdown(); // Depends on Memory
WII_IPCInterface::Shutdown(); WII_IPCInterface::Shutdown();
Common::ShutdownWiiRoot(); Core::ShutdownWiiRoot();
} }
SystemTimers::Shutdown(); SystemTimers::Shutdown();

View File

@ -12,6 +12,7 @@
#include "Common/FileUtil.h" #include "Common/FileUtil.h"
#include "Common/Logging/Log.h" #include "Common/Logging/Log.h"
#include "Common/MsgHandler.h" #include "Common/MsgHandler.h"
#include "Common/NandPaths.h"
#include "Common/StringUtil.h" #include "Common/StringUtil.h"
#include "Common/SysConf.h" #include "Common/SysConf.h"
#include "Core/Core.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) u32 _DeviceID, const std::string& _rDeviceName)
: CWII_IPC_HLE_Device_usb_oh1_57e_305_base(_DeviceID, _rDeviceName) : CWII_IPC_HLE_Device_usb_oh1_57e_305_base(_DeviceID, _rDeviceName)
{ {
SysConf sysconf; SysConf sysconf{Core::g_want_determinism ? Common::FromWhichRoot::FROM_SESSION_ROOT :
if (Core::g_want_determinism) Common::FromWhichRoot::FROM_CONFIGURED_ROOT};
{ 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
{
BackUpBTInfoSection(&sysconf); BackUpBTInfoSection(&sysconf);
}
// Activate only first Wii Remote by default // Activate only first Wii Remote by default

View File

@ -0,0 +1,57 @@
// Copyright 2016 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include <string>
#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();
}
}
}

View File

@ -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();
}