forked from dolphin-emu/dolphin
Unify the way of setting game ID, title ID, revision
The existing code from ConfigManager, ES and MIOS is merged into a new set of functions called SetRunningGameMetadata.
This commit is contained in:
@@ -21,11 +21,16 @@
|
||||
#include "Core/Boot/Boot.h"
|
||||
#include "Core/Boot/Boot_DOL.h"
|
||||
#include "Core/ConfigManager.h"
|
||||
#include "Core/Core.h" // for bWii
|
||||
#include "Core/Core.h"
|
||||
#include "Core/FifoPlayer/FifoDataFile.h"
|
||||
#include "Core/HLE/HLE.h"
|
||||
#include "Core/HW/SI/SI.h"
|
||||
#include "Core/IOS/ES/Formats.h"
|
||||
#include "Core/IOS/USB/Bluetooth/BTBase.h"
|
||||
#include "Core/PatchEngine.h"
|
||||
#include "Core/PowerPC/PPCSymbolDB.h"
|
||||
#include "Core/PowerPC/PowerPC.h"
|
||||
#include "VideoCommon/HiresTextures.h"
|
||||
|
||||
#include "DiscIO/Enums.h"
|
||||
#include "DiscIO/NANDContentLoader.h"
|
||||
@@ -726,6 +731,67 @@ void SConfig::LoadSettingsFromSysconf()
|
||||
bPAL60 = sysconf.GetData<u8>("IPL.E60") != 0;
|
||||
}
|
||||
|
||||
void SConfig::ResetRunningGameMetadata()
|
||||
{
|
||||
SetRunningGameMetadata("00000000", 0, 0);
|
||||
}
|
||||
|
||||
void SConfig::SetRunningGameMetadata(const DiscIO::IVolume& volume)
|
||||
{
|
||||
u64 title_id = 0;
|
||||
volume.GetTitleID(&title_id);
|
||||
SetRunningGameMetadata(volume.GetGameID(), title_id, volume.GetRevision());
|
||||
}
|
||||
|
||||
void SConfig::SetRunningGameMetadata(const IOS::ES::TMDReader& tmd)
|
||||
{
|
||||
const u64 title_id = tmd.GetTitleId();
|
||||
std::string game_id;
|
||||
|
||||
if (IOS::ES::IsDiscTitle(title_id))
|
||||
{
|
||||
const u32 title_identifier = Common::swap32(static_cast<u32>(title_id));
|
||||
const u16 group_id = Common::swap16(tmd.GetGroupId());
|
||||
|
||||
char ascii_game_id[6];
|
||||
std::memcpy(ascii_game_id, &title_identifier, sizeof(title_identifier));
|
||||
std::memcpy(ascii_game_id + sizeof(title_identifier), &group_id, sizeof(group_id));
|
||||
|
||||
game_id = ascii_game_id;
|
||||
}
|
||||
else
|
||||
{
|
||||
game_id = StringFromFormat("%016" PRIX64, title_id);
|
||||
}
|
||||
|
||||
SetRunningGameMetadata(game_id, title_id, tmd.GetTitleVersion());
|
||||
}
|
||||
|
||||
void SConfig::SetRunningGameMetadata(const std::string& game_id, u64 title_id, u16 revision)
|
||||
{
|
||||
const bool was_changed = m_game_id != game_id || m_title_id != title_id || m_revision != revision;
|
||||
m_game_id = game_id;
|
||||
m_title_id = title_id;
|
||||
m_revision = revision;
|
||||
|
||||
if (was_changed)
|
||||
{
|
||||
NOTICE_LOG(BOOT, "Game ID set to %s", game_id.c_str());
|
||||
|
||||
if (Core::IsRunning())
|
||||
{
|
||||
// TODO: have a callback mechanism for title changes?
|
||||
g_symbolDB.Clear();
|
||||
CBoot::LoadMapFromFilename();
|
||||
HLE::Clear();
|
||||
HLE::PatchFunctions();
|
||||
PatchEngine::Shutdown();
|
||||
PatchEngine::LoadPatches();
|
||||
HiresTexture::Update();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SConfig::LoadDefaults()
|
||||
{
|
||||
bEnableDebugging = false;
|
||||
@@ -783,9 +849,7 @@ void SConfig::LoadDefaults()
|
||||
bJITSystemRegistersOff = false;
|
||||
bJITBranchOff = false;
|
||||
|
||||
m_strGameID = "00000000";
|
||||
m_title_id = 0;
|
||||
m_revision = 0;
|
||||
ResetRunningGameMetadata();
|
||||
}
|
||||
|
||||
bool SConfig::IsUSBDeviceWhitelisted(const std::pair<u16, u16> vid_pid) const
|
||||
@@ -870,9 +934,7 @@ bool SConfig::AutoSetup(EBootBS2 _BootBS2)
|
||||
m_strFilename.c_str());
|
||||
return false;
|
||||
}
|
||||
m_strGameID = pVolume->GetGameID();
|
||||
pVolume->GetTitleID(&m_title_id);
|
||||
m_revision = pVolume->GetRevision();
|
||||
SetRunningGameMetadata(*pVolume);
|
||||
|
||||
// Check if we have a Wii disc
|
||||
bWii = pVolume->GetVolumeType() == DiscIO::Platform::WII_DISC;
|
||||
@@ -916,11 +978,11 @@ bool SConfig::AutoSetup(EBootBS2 _BootBS2)
|
||||
}
|
||||
else if (DiscIO::CNANDContentManager::Access().GetNANDLoader(m_strFilename).IsValid())
|
||||
{
|
||||
std::unique_ptr<DiscIO::IVolume> pVolume(DiscIO::CreateVolumeFromFilename(m_strFilename));
|
||||
const DiscIO::CNANDContentLoader& ContentLoader =
|
||||
const DiscIO::CNANDContentLoader& content_loader =
|
||||
DiscIO::CNANDContentManager::Access().GetNANDLoader(m_strFilename);
|
||||
const IOS::ES::TMDReader& tmd = content_loader.GetTMD();
|
||||
|
||||
if (ContentLoader.GetContentByIndex(ContentLoader.GetTMD().GetBootIndex()) == nullptr)
|
||||
if (content_loader.GetContentByIndex(tmd.GetBootIndex()) == nullptr)
|
||||
{
|
||||
// WAD is valid yet cannot be booted. Install instead.
|
||||
u64 installed = DiscIO::CNANDContentManager::Access().Install_WiiWAD(m_strFilename);
|
||||
@@ -929,33 +991,11 @@ bool SConfig::AutoSetup(EBootBS2 _BootBS2)
|
||||
return false; // do not boot
|
||||
}
|
||||
|
||||
SetRegion(ContentLoader.GetTMD().GetRegion(), &set_region_dir);
|
||||
SetRegion(tmd.GetRegion(), &set_region_dir);
|
||||
SetRunningGameMetadata(tmd);
|
||||
|
||||
bWii = true;
|
||||
m_BootType = BOOT_WII_NAND;
|
||||
|
||||
if (pVolume)
|
||||
{
|
||||
m_strGameID = pVolume->GetGameID();
|
||||
pVolume->GetTitleID(&m_title_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
// null pVolume means that we are loading from nand folder (Most Likely Wii Menu)
|
||||
// if this is the second boot we would be using the Name and id of the last title
|
||||
m_strGameID.clear();
|
||||
m_title_id = 0;
|
||||
}
|
||||
|
||||
// Use the TitleIDhex for name and/or game ID if launching
|
||||
// from nand folder or if it is not ascii characters
|
||||
// (specifically sysmenu could potentially apply to other things)
|
||||
std::string titleidstr = StringFromFormat("%016" PRIx64, m_title_id);
|
||||
|
||||
if (m_strGameID.empty())
|
||||
{
|
||||
m_strGameID = titleidstr;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user