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

This commit is contained in:
iwubcode 2025-01-26 16:37:21 -06:00
parent d03f9032c1
commit e18d98d4fc
7 changed files with 56 additions and 20 deletions

View File

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

View File

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

View File

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

View File

@ -493,10 +493,8 @@ static void EmuThread(Core::System& system, std::unique_ptr<BootParameters> 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<std::string>& savestate_path = boot_session_data.GetSavestatePath();
@ -526,12 +524,7 @@ static void EmuThread(Core::System& system, std::unique_ptr<BootParameters> 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();

View File

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

View File

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

View File

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