summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authorLéo Lam <leo@leolam.fr>2021-02-26 16:20:24 +0100
committerLéo Lam <leo@leolam.fr>2021-03-04 18:41:13 +0100
commit19667cb801f032723095100b6c97fa1d43d279fa (patch)
treeeda160c33691d85d701584b07d78bf8063ee697e /Source/Core
parenta658cbce167d39a30005deb6208a3dcf798a1691 (diff)
Fix symbol map being loaded too early during title changes
We should only try to load a symbol map for the new title *after* it has been loaded into memory, not before. Likewise for applying HLE patches and loading new custom textures. In practice, loading/repatching too early was only a problem for titles that are launched via ES_Launch. This commit fixes that.
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/Core/Boot/Boot.cpp28
-rw-r--r--Source/Core/Core/ConfigManager.cpp26
-rw-r--r--Source/Core/Core/ConfigManager.h4
-rw-r--r--Source/Core/Core/IOS/IOS.cpp1
4 files changed, 35 insertions, 24 deletions
diff --git a/Source/Core/Core/Boot/Boot.cpp b/Source/Core/Core/Boot/Boot.cpp
index b56d7981cf..8dc65b1090 100644
--- a/Source/Core/Core/Boot/Boot.cpp
+++ b/Source/Core/Core/Boot/Boot.cpp
@@ -436,11 +436,7 @@ bool CBoot::BootUp(std::unique_ptr<BootParameters> boot)
if (!EmulatedBS2(config.bWii, *volume))
return false;
- // Try to load the symbol map if there is one, and then scan it for
- // and eventually replace code
- if (LoadMapFromFilename())
- HLE::PatchFunctions();
-
+ SConfig::OnNewTitleLoad();
return true;
}
@@ -482,9 +478,11 @@ bool CBoot::BootUp(std::unique_ptr<BootParameters> boot)
SetupGCMemory();
}
+ SConfig::OnNewTitleLoad();
+
PC = executable.reader->GetEntryPoint();
- if (executable.reader->LoadSymbols() || LoadMapFromFilename())
+ if (executable.reader->LoadSymbols())
{
UpdateDebugger_MapLoaded();
HLE::PatchFunctions();
@@ -495,13 +493,21 @@ bool CBoot::BootUp(std::unique_ptr<BootParameters> boot)
bool operator()(const DiscIO::VolumeWAD& wad) const
{
SetDefaultDisc();
- return Boot_WiiWAD(wad);
+ if (!Boot_WiiWAD(wad))
+ return false;
+
+ SConfig::OnNewTitleLoad();
+ return true;
}
bool operator()(const BootParameters::NANDTitle& nand_title) const
{
SetDefaultDisc();
- return BootNANDTitle(nand_title.id);
+ if (!BootNANDTitle(nand_title.id))
+ return false;
+
+ SConfig::OnNewTitleLoad();
+ return true;
}
bool operator()(const BootParameters::IPL& ipl) const
@@ -525,9 +531,7 @@ bool CBoot::BootUp(std::unique_ptr<BootParameters> boot)
SetDisc(DiscIO::CreateDisc(ipl.disc->path), ipl.disc->auto_disc_change_paths);
}
- if (LoadMapFromFilename())
- HLE::PatchFunctions();
-
+ SConfig::OnNewTitleLoad();
return true;
}
@@ -544,8 +548,6 @@ bool CBoot::BootUp(std::unique_ptr<BootParameters> boot)
if (!std::visit(BootTitle(), boot->parameters))
return false;
- PatchEngine::LoadPatches();
- HLE::PatchFixedFunctions();
return true;
}
diff --git a/Source/Core/Core/ConfigManager.cpp b/Source/Core/Core/ConfigManager.cpp
index accc958615..d4ec804b3a 100644
--- a/Source/Core/Core/ConfigManager.cpp
+++ b/Source/Core/Core/ConfigManager.cpp
@@ -706,19 +706,23 @@ void SConfig::SetRunningGameMetadata(const std::string& game_id, const std::stri
Config::AddLayer(ConfigLoaders::GenerateLocalGameConfigLoader(game_id, revision));
if (Core::IsRunning())
- {
- // TODO: have a callback mechanism for title changes?
- if (!g_symbolDB.IsEmpty())
- {
- g_symbolDB.Clear();
- Host_NotifyMapLoaded();
- }
- CBoot::LoadMapFromFilename();
- HLE::Reload();
- PatchEngine::Reload();
- HiresTexture::Update();
DolphinAnalytics::Instance().ReportGameStart();
+}
+
+void SConfig::OnNewTitleLoad()
+{
+ if (!Core::IsRunning())
+ return;
+
+ if (!g_symbolDB.IsEmpty())
+ {
+ g_symbolDB.Clear();
+ Host_NotifyMapLoaded();
}
+ CBoot::LoadMapFromFilename();
+ HLE::Reload();
+ PatchEngine::Reload();
+ HiresTexture::Update();
}
void SConfig::LoadDefaults()
diff --git a/Source/Core/Core/ConfigManager.h b/Source/Core/Core/ConfigManager.h
index d1de769706..8d67d35ffd 100644
--- a/Source/Core/Core/ConfigManager.h
+++ b/Source/Core/Core/ConfigManager.h
@@ -197,6 +197,10 @@ struct SConfig
void SetRunningGameMetadata(const DiscIO::Volume& volume, const DiscIO::Partition& partition);
void SetRunningGameMetadata(const IOS::ES::TMDReader& tmd, DiscIO::Platform platform);
void SetRunningGameMetadata(const std::string& game_id);
+ // Reloads title-specific map files, patches, custom textures, etc.
+ // This should only be called after the new title has been loaded into memory.
+ static void OnNewTitleLoad();
+
void LoadDefaults();
static std::string MakeGameID(std::string_view file_name);
// Replaces NTSC-K with some other region, and doesn't replace non-NTSC-K regions
diff --git a/Source/Core/Core/IOS/IOS.cpp b/Source/Core/Core/IOS/IOS.cpp
index d5a26a06e1..b7b5a34e15 100644
--- a/Source/Core/Core/IOS/IOS.cpp
+++ b/Source/Core/Core/IOS/IOS.cpp
@@ -856,6 +856,7 @@ IOSC& Kernel::GetIOSC()
static void FinishPPCBootstrap(u64 userdata, s64 cycles_late)
{
ReleasePPC();
+ SConfig::OnNewTitleLoad();
INFO_LOG_FMT(IOS, "Bootstrapping done.");
}