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 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 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 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 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 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."); }