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.
This commit is contained in:
Léo Lam 2021-02-26 16:20:24 +01:00
parent a658cbce16
commit 19667cb801
No known key found for this signature in database
GPG Key ID: 0DF30F9081000741
4 changed files with 35 additions and 24 deletions

View File

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

View File

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

View File

@ -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

View File

@ -856,6 +856,7 @@ IOSC& Kernel::GetIOSC()
static void FinishPPCBootstrap(u64 userdata, s64 cycles_late)
{
ReleasePPC();
SConfig::OnNewTitleLoad();
INFO_LOG_FMT(IOS, "Bootstrapping done.");
}