From e18d98d4fc94830937f6011e15ad1a41a9eeb9dc Mon Sep 17 00:00:00 2001 From: iwubcode Date: Sun, 26 Jan 2025 16:37:21 -0600 Subject: [PATCH] Core: properly distinguish between ES title switches (Wii titles) and normal loading (GC, also called for Wii..); update config for ES title change, generate textures for both situations --- Source/Core/Core/Boot/Boot.cpp | 10 ++++---- Source/Core/Core/ConfigManager.cpp | 38 ++++++++++++++++++++++++++++-- Source/Core/Core/ConfigManager.h | 14 ++++++++--- Source/Core/Core/Core.cpp | 9 +------ Source/Core/Core/IOS/ES/ES.cpp | 1 + Source/Core/Core/IOS/IOS.cpp | 2 +- Source/Core/Core/IOS/MIOS.cpp | 2 +- 7 files changed, 56 insertions(+), 20 deletions(-) diff --git a/Source/Core/Core/Boot/Boot.cpp b/Source/Core/Core/Boot/Boot.cpp index 208c4d34bd..1340d19c84 100644 --- a/Source/Core/Core/Boot/Boot.cpp +++ b/Source/Core/Core/Boot/Boot.cpp @@ -550,7 +550,7 @@ bool CBoot::BootUp(Core::System& system, const Core::CPUThreadGuard& guard, if (!EmulatedBS2(system, guard, system.IsWii(), *volume, riivolution_patches)) return false; - SConfig::OnNewTitleLoad(guard); + SConfig::OnTitleDirectlyBooted(guard); return true; } @@ -601,7 +601,7 @@ bool CBoot::BootUp(Core::System& system, const Core::CPUThreadGuard& guard, return false; } - SConfig::OnNewTitleLoad(guard); + SConfig::OnTitleDirectlyBooted(guard); ppc_state.pc = executable.reader->GetEntryPoint(); @@ -621,7 +621,7 @@ bool CBoot::BootUp(Core::System& system, const Core::CPUThreadGuard& guard, if (!Boot_WiiWAD(system, wad)) return false; - SConfig::OnNewTitleLoad(guard); + SConfig::OnTitleDirectlyBooted(guard); return true; } @@ -631,7 +631,7 @@ bool CBoot::BootUp(Core::System& system, const Core::CPUThreadGuard& guard, if (!BootNANDTitle(system, nand_title.id)) return false; - SConfig::OnNewTitleLoad(guard); + SConfig::OnTitleDirectlyBooted(guard); return true; } @@ -657,7 +657,7 @@ bool CBoot::BootUp(Core::System& system, const Core::CPUThreadGuard& guard, ipl.disc->auto_disc_change_paths); } - SConfig::OnNewTitleLoad(guard); + SConfig::OnTitleDirectlyBooted(guard); return true; } diff --git a/Source/Core/Core/ConfigManager.cpp b/Source/Core/Core/ConfigManager.cpp index 5a123c87cd..9101df907a 100644 --- a/Source/Core/Core/ConfigManager.cpp +++ b/Source/Core/Core/ConfigManager.cpp @@ -44,8 +44,11 @@ #include "Core/HLE/HLE.h" #include "Core/HW/DVD/DVDInterface.h" #include "Core/HW/EXI/EXI_Device.h" +#include "Core/HW/GCKeyboard.h" +#include "Core/HW/GCPad.h" #include "Core/HW/SI/SI.h" #include "Core/HW/SI/SI_Device.h" +#include "Core/HW/Wiimote.h" #include "Core/Host.h" #include "Core/IOS/ES/ES.h" #include "Core/IOS/ES/Formats.h" @@ -239,7 +242,20 @@ void SConfig::SetRunningGameMetadata(const std::string& game_id, const std::stri DolphinAnalytics::Instance().ReportGameStart(); } -void SConfig::OnNewTitleLoad(const Core::CPUThreadGuard& guard) +void SConfig::OnESTitleChanged() +{ + auto& system = Core::System::GetInstance(); + Pad::LoadConfig(); + Keyboard::LoadConfig(); + if (system.IsWii() && !Config::Get(Config::MAIN_BLUETOOTH_PASSTHROUGH_ENABLED)) + { + Wiimote::LoadConfig(); + } + + ReloadTextures(system); +} + +void SConfig::OnTitleDirectlyBooted(const Core::CPUThreadGuard& guard) { auto& system = guard.GetSystem(); if (!Core::IsRunningOrStarting(system)) @@ -253,9 +269,27 @@ void SConfig::OnNewTitleLoad(const Core::CPUThreadGuard& guard) } CBoot::LoadMapFromFilename(guard, ppc_symbol_db); HLE::Reload(system); + PatchEngine::Reload(system); - HiresTexture::Update(); WC24PatchEngine::Reload(); + + // Note: Wii is handled by ES title change + if (!system.IsWii()) + { + ReloadTextures(system); + } +} + +void SConfig::ReloadTextures(Core::System& system) +{ + Pad::GenerateDynamicInputTextures(); + Keyboard::GenerateDynamicInputTextures(); + if (system.IsWii() && !Config::Get(Config::MAIN_BLUETOOTH_PASSTHROUGH_ENABLED)) + { + Wiimote::GenerateDynamicInputTextures(); + } + + HiresTexture::Update(); } void SConfig::LoadDefaults() diff --git a/Source/Core/Core/ConfigManager.h b/Source/Core/Core/ConfigManager.h index d21b087a51..84be081b64 100644 --- a/Source/Core/Core/ConfigManager.h +++ b/Source/Core/Core/ConfigManager.h @@ -73,9 +73,15 @@ 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(const Core::CPUThreadGuard& guard); + + // Triggered when Dolphin loads a title directly + // Reloads title-specific map files, patches, etc. + static void OnTitleDirectlyBooted(const Core::CPUThreadGuard& guard); + + // Direct title change from ES (Wii system) + // Wii titles will still hit OnTitleDirectlyBooted + // but GC titles will never see this call + static void OnESTitleChanged(); void LoadDefaults(); static std::string MakeGameID(std::string_view file_name); @@ -112,6 +118,8 @@ private: SConfig(); ~SConfig(); + static void ReloadTextures(Core::System& system); + void SetRunningGameMetadata(const std::string& game_id, const std::string& gametdb_id, u64 title_id, u16 revision, DiscIO::Region region); diff --git a/Source/Core/Core/Core.cpp b/Source/Core/Core/Core.cpp index 18dbcaa783..4823b1dca2 100644 --- a/Source/Core/Core/Core.cpp +++ b/Source/Core/Core/Core.cpp @@ -493,10 +493,8 @@ static void EmuThread(Core::System& system, std::unique_ptr boot g_controller_interface.ChangeWindow(wsi.render_window); Pad::LoadConfig(); - Pad::GenerateDynamicInputTextures(); Pad::LoadGBAConfig(); Keyboard::LoadConfig(); - Keyboard::GenerateDynamicInputTextures(); BootSessionData boot_session_data = std::move(boot->boot_session_data); const std::optional& savestate_path = boot_session_data.GetSavestatePath(); @@ -526,12 +524,7 @@ static void EmuThread(Core::System& system, std::unique_ptr boot } }}; - // Load Wiimotes - only if we are booting in Wii mode - if (system.IsWii() && !Config::Get(Config::MAIN_BLUETOOTH_PASSTHROUGH_ENABLED)) - { - Wiimote::LoadConfig(); - Wiimote::GenerateDynamicInputTextures(); - } + // Wiimote input config is loaded in OnESTitleChanged FreeLook::LoadInputConfig(); diff --git a/Source/Core/Core/IOS/ES/ES.cpp b/Source/Core/Core/IOS/ES/ES.cpp index bf388a5b67..adc07d8d39 100644 --- a/Source/Core/Core/IOS/ES/ES.cpp +++ b/Source/Core/Core/IOS/ES/ES.cpp @@ -205,6 +205,7 @@ void TitleContext::Update(const ES::TMDReader& tmd_, const ES::TicketReader& tic if (first_change) { SConfig::GetInstance().SetRunningGameMetadata(tmd, platform); + SConfig::GetInstance().OnESTitleChanged(); first_change = false; } } diff --git a/Source/Core/Core/IOS/IOS.cpp b/Source/Core/Core/IOS/IOS.cpp index fbea8dd9d7..4aa3930248 100644 --- a/Source/Core/Core/IOS/IOS.cpp +++ b/Source/Core/Core/IOS/IOS.cpp @@ -952,7 +952,7 @@ static void FinishPPCBootstrap(Core::System& system, u64 userdata, s64 cycles_la ASSERT(Core::IsCPUThread()); Core::CPUThreadGuard guard(system); - SConfig::OnNewTitleLoad(guard); + SConfig::OnTitleDirectlyBooted(guard); INFO_LOG_FMT(IOS, "Bootstrapping done."); } diff --git a/Source/Core/Core/IOS/MIOS.cpp b/Source/Core/Core/IOS/MIOS.cpp index 7722cebea5..d8829ee5cc 100644 --- a/Source/Core/Core/IOS/MIOS.cpp +++ b/Source/Core/Core/IOS/MIOS.cpp @@ -103,7 +103,7 @@ bool Load(Core::System& system) NOTICE_LOG_FMT(IOS, "IPL ready."); system.SetIsMIOS(true); system.GetDVDInterface().UpdateRunningGameMetadata(); - SConfig::OnNewTitleLoad(guard); + SConfig::OnTitleDirectlyBooted(guard); return true; } } // namespace IOS::HLE::MIOS