Config: Fix Movie config loading/saving
* Add missing Language setting loading/saving. This was added after the original OnionConfig PR, which is why support for it was missing. * Change MovieConfigLoader to reuse ConfigInfos. Less duplication. * Extract MovieConfigLoader::Save into SaveToDTM. The DTM should use the current config and not just the movie layer. This makes more sense than just saving the movie layer, which may not always exist, and also fixes a crash that would happen when creating a new recording because the movie layer wouldn't exist in that case. (Plus, having to get the loader from the layer and call ChangeDTM on it manually is not very pretty.)
This commit is contained in:
parent
fa7e3e55d2
commit
940cc843ed
|
@ -109,11 +109,6 @@ const LayerMap& Layer::GetLayerMap() const
|
|||
return m_sections;
|
||||
}
|
||||
|
||||
ConfigLayerLoader* Layer::GetLoader() const
|
||||
{
|
||||
return m_loader.get();
|
||||
}
|
||||
|
||||
bool Layer::IsDirty() const
|
||||
{
|
||||
return std::any_of(m_sections.begin(), m_sections.end(), [](const auto& system) {
|
||||
|
|
|
@ -75,8 +75,6 @@ public:
|
|||
|
||||
LayerType GetLayer() const;
|
||||
const LayerMap& GetLayerMap() const;
|
||||
// Stay away from this routine as much as possible
|
||||
ConfigLayerLoader* GetLoader() const;
|
||||
|
||||
protected:
|
||||
bool IsDirty() const;
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
|
||||
#include "Common/Config/Config.h"
|
||||
#include "Core/Boot/Boot.h"
|
||||
#include "Core/Config/MainSettings.h"
|
||||
#include "Core/Config/SYSCONFSettings.h"
|
||||
#include "Core/ConfigLoaders/BaseConfigLoader.h"
|
||||
#include "Core/ConfigLoaders/GameConfigLoader.h"
|
||||
|
@ -312,13 +313,14 @@ bool BootCore(std::unique_ptr<BootParameters> boot)
|
|||
// Movie settings
|
||||
if (Movie::IsPlayingInput() && Movie::IsConfigSaved())
|
||||
{
|
||||
StartUp.bCPUThread = Movie::IsDualCore();
|
||||
StartUp.bDSPHLE = Movie::IsDSPHLE();
|
||||
StartUp.bFastDiscSpeed = Movie::IsFastDiscSpeed();
|
||||
StartUp.iCPUCore = Movie::GetCPUMode();
|
||||
StartUp.bSyncGPU = Movie::IsSyncGPU();
|
||||
// TODO: remove this once ConfigManager starts using OnionConfig.
|
||||
StartUp.bCPUThread = Config::Get(Config::MAIN_CPU_THREAD);
|
||||
StartUp.bDSPHLE = Config::Get(Config::MAIN_DSP_HLE);
|
||||
StartUp.bFastDiscSpeed = Config::Get(Config::MAIN_FAST_DISC_SPEED);
|
||||
StartUp.iCPUCore = Config::Get(Config::MAIN_CPU_CORE);
|
||||
StartUp.bSyncGPU = Config::Get(Config::MAIN_SYNC_GPU);
|
||||
if (!StartUp.bWii)
|
||||
StartUp.SelectedLanguage = Movie::GetLanguage();
|
||||
StartUp.SelectedLanguage = Config::Get(Config::MAIN_GC_LANGUAGE);
|
||||
for (int i = 0; i < 2; ++i)
|
||||
{
|
||||
if (Movie::IsUsingMemcard(i) && Movie::IsStartingFromClearSave() && !StartUp.bWii)
|
||||
|
|
|
@ -13,73 +13,79 @@
|
|||
#include "Common/Config/Config.h"
|
||||
#include "Common/FileUtil.h"
|
||||
|
||||
#include "Core/Config/GraphicsSettings.h"
|
||||
#include "Core/Config/MainSettings.h"
|
||||
#include "Core/Config/SYSCONFSettings.h"
|
||||
#include "Core/ConfigManager.h"
|
||||
#include "Core/Movie.h"
|
||||
#include "VideoCommon/VideoConfig.h"
|
||||
|
||||
namespace ConfigLoaders
|
||||
{
|
||||
static void LoadFromDTM(Config::Layer* config_layer, Movie::DTMHeader* dtm)
|
||||
{
|
||||
config_layer->Set(Config::MAIN_CPU_THREAD, dtm->bDualCore);
|
||||
config_layer->Set(Config::MAIN_DSP_HLE, dtm->bDSPHLE);
|
||||
config_layer->Set(Config::MAIN_FAST_DISC_SPEED, dtm->bFastDiscSpeed);
|
||||
config_layer->Set(Config::MAIN_CPU_CORE, static_cast<int>(dtm->CPUCore));
|
||||
config_layer->Set(Config::MAIN_SYNC_GPU, dtm->bSyncGPU);
|
||||
config_layer->Set(Config::MAIN_GFX_BACKEND,
|
||||
std::string(reinterpret_cast<char*>(dtm->videoBackend)));
|
||||
|
||||
config_layer->Set(Config::SYSCONF_PROGRESSIVE_SCAN, dtm->bProgressive);
|
||||
config_layer->Set(Config::SYSCONF_PAL60, dtm->bPAL60);
|
||||
if (dtm->bWii)
|
||||
config_layer->Set(Config::SYSCONF_LANGUAGE, static_cast<u32>(dtm->language));
|
||||
else
|
||||
config_layer->Set(Config::MAIN_GC_LANGUAGE, static_cast<int>(dtm->language));
|
||||
|
||||
config_layer->Set(Config::GFX_USE_XFB, dtm->bUseXFB);
|
||||
config_layer->Set(Config::GFX_USE_REAL_XFB, dtm->bUseRealXFB);
|
||||
config_layer->Set(Config::GFX_HACK_EFB_ACCESS_ENABLE, dtm->bEFBAccessEnable);
|
||||
config_layer->Set(Config::GFX_HACK_SKIP_EFB_COPY_TO_RAM, dtm->bSkipEFBCopyToRam);
|
||||
config_layer->Set(Config::GFX_HACK_EFB_EMULATE_FORMAT_CHANGES, dtm->bEFBEmulateFormatChanges);
|
||||
}
|
||||
|
||||
void SaveToDTM(Config::Layer* config_layer, Movie::DTMHeader* dtm)
|
||||
{
|
||||
dtm->bDualCore = config_layer->Get(Config::MAIN_CPU_THREAD);
|
||||
dtm->bDSPHLE = config_layer->Get(Config::MAIN_DSP_HLE);
|
||||
dtm->bFastDiscSpeed = config_layer->Get(Config::MAIN_FAST_DISC_SPEED);
|
||||
dtm->CPUCore = config_layer->Get(Config::MAIN_CPU_CORE);
|
||||
dtm->bSyncGPU = config_layer->Get(Config::MAIN_SYNC_GPU);
|
||||
const std::string video_backend = config_layer->Get(Config::MAIN_GFX_BACKEND);
|
||||
|
||||
dtm->bProgressive = config_layer->Get(Config::SYSCONF_PROGRESSIVE_SCAN);
|
||||
dtm->bPAL60 = config_layer->Get(Config::SYSCONF_PAL60);
|
||||
if (dtm->bWii)
|
||||
dtm->language = config_layer->Get(Config::SYSCONF_LANGUAGE);
|
||||
else
|
||||
dtm->language = config_layer->Get(Config::MAIN_GC_LANGUAGE);
|
||||
|
||||
dtm->bUseXFB = config_layer->Get(Config::GFX_USE_XFB);
|
||||
dtm->bUseRealXFB = config_layer->Get(Config::GFX_USE_REAL_XFB);
|
||||
dtm->bEFBAccessEnable = config_layer->Get(Config::GFX_HACK_EFB_ACCESS_ENABLE);
|
||||
dtm->bSkipEFBCopyToRam = config_layer->Get(Config::GFX_HACK_SKIP_EFB_COPY_TO_RAM);
|
||||
dtm->bEFBEmulateFormatChanges = config_layer->Get(Config::GFX_HACK_EFB_EMULATE_FORMAT_CHANGES);
|
||||
|
||||
// This never used the regular config
|
||||
dtm->bSkipIdle = true;
|
||||
dtm->bEFBCopyEnable = true;
|
||||
dtm->bEFBCopyCacheEnable = false;
|
||||
|
||||
strncpy(reinterpret_cast<char*>(dtm->videoBackend), video_backend.c_str(),
|
||||
ArraySize(dtm->videoBackend));
|
||||
}
|
||||
|
||||
// TODO: Future project, let this support all the configuration options.
|
||||
// This will require a large break to the DTM format
|
||||
void MovieConfigLayerLoader::Load(Config::Layer* config_layer)
|
||||
{
|
||||
Config::Section* core = config_layer->GetOrCreateSection(Config::System::Main, "Core");
|
||||
Config::Section* video_settings = Config::GetOrCreateSection(Config::System::GFX, "Settings");
|
||||
Config::Section* video_hacks = Config::GetOrCreateSection(Config::System::GFX, "Hacks");
|
||||
|
||||
core->Set("SkipIdle", m_header->bSkipIdle);
|
||||
core->Set("CPUThread", m_header->bDualCore);
|
||||
core->Set("DSPHLE", m_header->bDSPHLE);
|
||||
core->Set("FastDiscSpeed", m_header->bFastDiscSpeed);
|
||||
core->Set("CPUCore", m_header->CPUCore);
|
||||
core->Set("SyncGPU", m_header->bSyncGPU);
|
||||
core->Set("GFXBackend", std::string(reinterpret_cast<char*>(m_header->videoBackend)));
|
||||
|
||||
config_layer->Set(Config::SYSCONF_PROGRESSIVE_SCAN, m_header->bProgressive);
|
||||
config_layer->Set(Config::SYSCONF_PAL60, m_header->bPAL60);
|
||||
if (m_header->bWii)
|
||||
config_layer->Set(Config::SYSCONF_LANGUAGE, static_cast<u32>(m_header->language));
|
||||
|
||||
video_settings->Set("UseXFB", m_header->bUseXFB);
|
||||
video_settings->Set("UseRealXFB", m_header->bUseRealXFB);
|
||||
video_hacks->Set("EFBAccessEnable", m_header->bEFBAccessEnable);
|
||||
video_hacks->Set("EFBToTextureEnable", m_header->bSkipEFBCopyToRam);
|
||||
video_hacks->Set("EFBEmulateFormatChanges", m_header->bEFBEmulateFormatChanges);
|
||||
LoadFromDTM(config_layer, m_header);
|
||||
}
|
||||
|
||||
void MovieConfigLayerLoader::Save(Config::Layer* config_layer)
|
||||
{
|
||||
Config::Section* core = config_layer->GetOrCreateSection(Config::System::Main, "Core");
|
||||
Config::Section* video_settings = Config::GetOrCreateSection(Config::System::GFX, "Settings");
|
||||
Config::Section* video_hacks = Config::GetOrCreateSection(Config::System::GFX, "Hacks");
|
||||
|
||||
std::string video_backend;
|
||||
u32 cpu_core;
|
||||
|
||||
core->Get("SkipIdle", &m_header->bSkipIdle);
|
||||
core->Get("CPUThread", &m_header->bDualCore);
|
||||
core->Get("DSPHLE", &m_header->bDSPHLE);
|
||||
core->Get("FastDiscSpeed", &m_header->bFastDiscSpeed);
|
||||
core->Get("CPUCore", &cpu_core);
|
||||
core->Get("SyncGPU", &m_header->bSyncGPU);
|
||||
core->Get("GFXBackend", &video_backend);
|
||||
m_header->bProgressive = config_layer->Get(Config::SYSCONF_PROGRESSIVE_SCAN);
|
||||
m_header->bPAL60 = config_layer->Get(Config::SYSCONF_PAL60);
|
||||
if (m_header->bWii)
|
||||
m_header->language = config_layer->Get(Config::SYSCONF_LANGUAGE);
|
||||
|
||||
video_settings->Get("UseXFB", &m_header->bUseXFB);
|
||||
video_settings->Get("UseRealXFB", &m_header->bUseRealXFB);
|
||||
video_hacks->Get("EFBAccessEnable", &m_header->bEFBAccessEnable);
|
||||
video_hacks->Get("EFBToTextureEnable", &m_header->bSkipEFBCopyToRam);
|
||||
video_hacks->Get("EFBEmulateFormatChanges", &m_header->bEFBEmulateFormatChanges);
|
||||
|
||||
// This never used the regular config
|
||||
m_header->bEFBCopyEnable = true;
|
||||
m_header->bEFBCopyCacheEnable = false;
|
||||
|
||||
m_header->CPUCore = cpu_core;
|
||||
strncpy(reinterpret_cast<char*>(m_header->videoBackend), video_backend.c_str(),
|
||||
ArraySize(m_header->videoBackend));
|
||||
}
|
||||
|
||||
// Loader generation
|
||||
|
|
|
@ -26,10 +26,10 @@ public:
|
|||
void Load(Config::Layer* config_layer) override;
|
||||
void Save(Config::Layer* config_layer) override;
|
||||
|
||||
void ChangeDTMHeader(Movie::DTMHeader* header) { m_header = header; }
|
||||
private:
|
||||
Movie::DTMHeader* m_header;
|
||||
};
|
||||
|
||||
void SaveToDTM(Config::Layer* layer, Movie::DTMHeader* header);
|
||||
std::unique_ptr<Config::ConfigLayerLoader> GenerateMovieConfigLoader(Movie::DTMHeader* header);
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include "Common/Timer.h"
|
||||
|
||||
#include "Core/Boot/Boot.h"
|
||||
#include "Core/Config/MainSettings.h"
|
||||
#include "Core/Config/SYSCONFSettings.h"
|
||||
#include "Core/ConfigLoaders/MovieConfigLoader.h"
|
||||
#include "Core/ConfigManager.h"
|
||||
|
@ -77,11 +78,7 @@ static u64 s_totalLagCount = 0; // just stats
|
|||
static u64 s_currentInputCount = 0, s_totalInputCount = 0; // just stats
|
||||
static u64 s_totalTickCount = 0, s_tickCountAtLastInput = 0; // just stats
|
||||
static u64 s_recordingStartTime; // seconds since 1970 that recording started
|
||||
static bool s_bSaveConfig = false, s_bDualCore = false;
|
||||
static bool s_bDSPHLE = false, s_bFastDiscSpeed = false;
|
||||
static bool s_bSyncGPU = false, s_bNetPlay = false;
|
||||
static std::string s_videoBackend = "unknown";
|
||||
static int s_iCPUCore = 1;
|
||||
static bool s_bSaveConfig = false, s_bNetPlay = false;
|
||||
static bool s_bClearSave = false;
|
||||
static bool s_bDiscChange = false;
|
||||
static bool s_bReset = false;
|
||||
|
@ -92,7 +89,6 @@ static u8 s_bongos, s_memcards;
|
|||
static u8 s_revision[20];
|
||||
static u32 s_DSPiromHash = 0;
|
||||
static u32 s_DSPcoefHash = 0;
|
||||
static u8 s_language = static_cast<u8>(DiscIO::Language::LANGUAGE_UNKNOWN);
|
||||
|
||||
static bool s_bRecordingFromSaveState = false;
|
||||
static bool s_bPolled = false;
|
||||
|
@ -106,6 +102,7 @@ static WiiManipFunction s_wii_manip_func;
|
|||
|
||||
static std::string s_current_file_name;
|
||||
|
||||
static void GetSettings();
|
||||
static bool IsMovieHeader(u8 magic[4])
|
||||
{
|
||||
return magic[0] == 'D' && magic[1] == 'T' && magic[2] == 'M' && magic[3] == 0x1A;
|
||||
|
@ -219,7 +216,6 @@ void Init(const BootParameters& boot)
|
|||
s_bPolled = false;
|
||||
s_bFrameStep = false;
|
||||
s_bSaveConfig = false;
|
||||
s_iCPUCore = SConfig::GetInstance().iCPUCore;
|
||||
if (IsPlayingInput())
|
||||
{
|
||||
ReadHeader();
|
||||
|
@ -420,30 +416,6 @@ bool IsConfigSaved()
|
|||
{
|
||||
return s_bSaveConfig;
|
||||
}
|
||||
bool IsDualCore()
|
||||
{
|
||||
return s_bDualCore;
|
||||
}
|
||||
|
||||
bool IsDSPHLE()
|
||||
{
|
||||
return s_bDSPHLE;
|
||||
}
|
||||
|
||||
bool IsFastDiscSpeed()
|
||||
{
|
||||
return s_bFastDiscSpeed;
|
||||
}
|
||||
|
||||
int GetCPUMode()
|
||||
{
|
||||
return s_iCPUCore;
|
||||
}
|
||||
|
||||
u8 GetLanguage()
|
||||
{
|
||||
return s_language;
|
||||
}
|
||||
|
||||
bool IsStartingFromClearSave()
|
||||
{
|
||||
|
@ -455,11 +427,6 @@ bool IsUsingMemcard(int memcard)
|
|||
return (s_memcards & (1 << memcard)) != 0;
|
||||
}
|
||||
|
||||
bool IsSyncGPU()
|
||||
{
|
||||
return s_bSyncGPU;
|
||||
}
|
||||
|
||||
bool IsNetPlayRecording()
|
||||
{
|
||||
return s_bNetPlay;
|
||||
|
@ -893,16 +860,10 @@ void ReadHeader()
|
|||
{
|
||||
s_bSaveConfig = true;
|
||||
Config::AddLayer(ConfigLoaders::GenerateMovieConfigLoader(&tmpHeader));
|
||||
s_bDualCore = tmpHeader.bDualCore;
|
||||
s_bDSPHLE = tmpHeader.bDSPHLE;
|
||||
s_bFastDiscSpeed = tmpHeader.bFastDiscSpeed;
|
||||
s_iCPUCore = tmpHeader.CPUCore;
|
||||
s_bClearSave = tmpHeader.bClearSave;
|
||||
s_memcards = tmpHeader.memcards;
|
||||
s_bongos = tmpHeader.bongos;
|
||||
s_bSyncGPU = tmpHeader.bSyncGPU;
|
||||
s_bNetPlay = tmpHeader.bNetPlay;
|
||||
s_language = tmpHeader.language;
|
||||
memcpy(s_revision, tmpHeader.revision, ArraySize(s_revision));
|
||||
}
|
||||
else
|
||||
|
@ -910,7 +871,6 @@ void ReadHeader()
|
|||
GetSettings();
|
||||
}
|
||||
|
||||
s_videoBackend = (char*)tmpHeader.videoBackend;
|
||||
s_discChange = (char*)tmpHeader.discChange;
|
||||
s_author = (char*)tmpHeader.author;
|
||||
memcpy(s_MD5, tmpHeader.md5, 16);
|
||||
|
@ -1369,26 +1329,9 @@ void SaveRecording(const std::string& filename)
|
|||
header.recordingStartTime = s_recordingStartTime;
|
||||
|
||||
header.bSaveConfig = true;
|
||||
auto* movie_layer = Config::GetLayer(Config::LayerType::Movie);
|
||||
auto* loader = static_cast<ConfigLoaders::MovieConfigLayerLoader*>(movie_layer->GetLoader());
|
||||
loader->ChangeDTMHeader(&header);
|
||||
movie_layer->Save();
|
||||
header.bSkipIdle = true;
|
||||
header.bDualCore = s_bDualCore;
|
||||
header.bDSPHLE = s_bDSPHLE;
|
||||
header.bFastDiscSpeed = s_bFastDiscSpeed;
|
||||
strncpy((char*)header.videoBackend, s_videoBackend.c_str(), ArraySize(header.videoBackend));
|
||||
header.CPUCore = s_iCPUCore;
|
||||
header.bEFBAccessEnable = g_ActiveConfig.bEFBAccessEnable;
|
||||
header.bEFBCopyEnable = true;
|
||||
header.bSkipEFBCopyToRam = g_ActiveConfig.bSkipEFBCopyToRam;
|
||||
header.bEFBCopyCacheEnable = false;
|
||||
header.bEFBEmulateFormatChanges = g_ActiveConfig.bEFBEmulateFormatChanges;
|
||||
header.bUseXFB = g_ActiveConfig.bUseXFB;
|
||||
header.bUseRealXFB = g_ActiveConfig.bUseRealXFB;
|
||||
ConfigLoaders::SaveToDTM(Config::GetLayer(Config::LayerType::Meta), &header);
|
||||
header.memcards = s_memcards;
|
||||
header.bClearSave = s_bClearSave;
|
||||
header.bSyncGPU = s_bSyncGPU;
|
||||
header.bNetPlay = s_bNetPlay;
|
||||
strncpy((char*)header.discChange, s_discChange.c_str(), ArraySize(header.discChange));
|
||||
strncpy((char*)header.author, s_author.c_str(), ArraySize(header.author));
|
||||
|
@ -1398,7 +1341,6 @@ void SaveRecording(const std::string& filename)
|
|||
header.DSPiromHash = s_DSPiromHash;
|
||||
header.DSPcoefHash = s_DSPcoefHash;
|
||||
header.tickCount = s_totalTickCount;
|
||||
header.language = s_language;
|
||||
|
||||
// TODO
|
||||
header.uniqueID = 0;
|
||||
|
@ -1457,24 +1399,16 @@ void SetGraphicsConfig()
|
|||
void GetSettings()
|
||||
{
|
||||
s_bSaveConfig = true;
|
||||
s_bDualCore = SConfig::GetInstance().bCPUThread;
|
||||
s_bDSPHLE = SConfig::GetInstance().bDSPHLE;
|
||||
s_bFastDiscSpeed = SConfig::GetInstance().bFastDiscSpeed;
|
||||
s_videoBackend = g_video_backend->GetName();
|
||||
s_bSyncGPU = SConfig::GetInstance().bSyncGPU;
|
||||
s_iCPUCore = SConfig::GetInstance().iCPUCore;
|
||||
s_bNetPlay = NetPlay::IsNetPlayRunning();
|
||||
if (SConfig::GetInstance().bWii)
|
||||
{
|
||||
u64 title_id = SConfig::GetInstance().GetTitleID();
|
||||
s_bClearSave =
|
||||
!File::Exists(Common::GetTitleDataPath(title_id, Common::FROM_SESSION_ROOT) + "banner.bin");
|
||||
s_language = Config::Get(Config::SYSCONF_LANGUAGE);
|
||||
}
|
||||
else
|
||||
{
|
||||
s_bClearSave = !File::Exists(SConfig::GetInstance().m_strMemoryCardA);
|
||||
s_language = SConfig::GetInstance().SelectedLanguage;
|
||||
}
|
||||
s_memcards |=
|
||||
(SConfig::GetInstance().m_EXIDevice[0] == ExpansionInterface::EXIDEVICE_MEMORYCARD ||
|
||||
|
@ -1488,7 +1422,7 @@ void GetSettings()
|
|||
std::array<u8, 20> revision = ConvertGitRevisionToBytes(scm_rev_git_str);
|
||||
std::copy(std::begin(revision), std::end(revision), std::begin(s_revision));
|
||||
|
||||
if (!s_bDSPHLE)
|
||||
if (!Config::Get(Config::MAIN_DSP_HLE))
|
||||
{
|
||||
std::string irom_file = File::GetUserPath(D_GCUSER_IDX) + DSP_IROM;
|
||||
std::string coef_file = File::GetUserPath(D_GCUSER_IDX) + DSP_COEF;
|
||||
|
|
|
@ -137,16 +137,9 @@ void SignalDiscChange(const std::string& new_path);
|
|||
void SetReset(bool reset);
|
||||
|
||||
bool IsConfigSaved();
|
||||
bool IsDualCore();
|
||||
bool IsDSPHLE();
|
||||
bool IsFastDiscSpeed();
|
||||
int GetCPUMode();
|
||||
u8 GetLanguage();
|
||||
bool IsStartingFromClearSave();
|
||||
bool IsUsingMemcard(int memcard);
|
||||
bool IsSyncGPU();
|
||||
void SetGraphicsConfig();
|
||||
void GetSettings();
|
||||
bool IsNetPlayRecording();
|
||||
|
||||
bool IsUsingPad(int controller);
|
||||
|
|
Loading…
Reference in New Issue