mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2026-01-31 01:15:17 +01:00
Merge pull request #14216 from iwubcode/gameid_fifo_log
Core: add game id to fifo log header
This commit is contained in:
@@ -435,7 +435,16 @@ struct SetGameMetadata
|
|||||||
|
|
||||||
*region = DiscIO::Region::NTSC_U;
|
*region = DiscIO::Region::NTSC_U;
|
||||||
system.SetIsWii(dff_file->GetIsWii());
|
system.SetIsWii(dff_file->GetIsWii());
|
||||||
Host_TitleChanged();
|
|
||||||
|
const std::string& game_id = dff_file->GetGameId();
|
||||||
|
if (game_id == DEFAULT_GAME_ID)
|
||||||
|
{
|
||||||
|
Host_TitleChanged();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
config->SetRunningGameMetadata(game_id);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,6 +42,8 @@ class TMDReader;
|
|||||||
|
|
||||||
struct BootParameters;
|
struct BootParameters;
|
||||||
|
|
||||||
|
static constexpr std::string_view DEFAULT_GAME_ID = "00000000";
|
||||||
|
|
||||||
struct SConfig
|
struct SConfig
|
||||||
{
|
{
|
||||||
// Settings
|
// Settings
|
||||||
|
|||||||
@@ -12,11 +12,12 @@
|
|||||||
#include "Common/IOFile.h"
|
#include "Common/IOFile.h"
|
||||||
#include "Common/MsgHandler.h"
|
#include "Common/MsgHandler.h"
|
||||||
#include "Core/Config/MainSettings.h"
|
#include "Core/Config/MainSettings.h"
|
||||||
|
#include "Core/ConfigManager.h"
|
||||||
#include "Core/HW/Memmap.h"
|
#include "Core/HW/Memmap.h"
|
||||||
#include "Core/System.h"
|
#include "Core/System.h"
|
||||||
|
|
||||||
constexpr u32 FILE_ID = 0x0d01f1f0;
|
constexpr u32 FILE_ID = 0x0d01f1f0;
|
||||||
constexpr u32 VERSION_NUMBER = 5;
|
constexpr u32 VERSION_NUMBER = 6;
|
||||||
constexpr u32 MIN_LOADER_VERSION = 1;
|
constexpr u32 MIN_LOADER_VERSION = 1;
|
||||||
// This value is only used if the DFF file was created with overridden RAM sizes.
|
// This value is only used if the DFF file was created with overridden RAM sizes.
|
||||||
// If the MIN_LOADER_VERSION ever exceeds this, it's alright to remove it.
|
// If the MIN_LOADER_VERSION ever exceeds this, it's alright to remove it.
|
||||||
@@ -46,9 +47,11 @@ struct FileHeader
|
|||||||
// will crash and burn with mismatched settings. See PR #8722.
|
// will crash and burn with mismatched settings. See PR #8722.
|
||||||
u32 mem1_size;
|
u32 mem1_size;
|
||||||
u32 mem2_size;
|
u32 mem2_size;
|
||||||
u8 reserved[32];
|
char gameid[8];
|
||||||
|
u8 reserved[24];
|
||||||
};
|
};
|
||||||
static_assert(sizeof(FileHeader) == 128, "FileHeader should be 128 bytes");
|
static_assert(sizeof(FileHeader) == 128, "FileHeader should be 128 bytes");
|
||||||
|
static_assert(DEFAULT_GAME_ID.size() == sizeof(FileHeader::gameid), "Default game id size changed");
|
||||||
|
|
||||||
struct FileFrameInfo
|
struct FileFrameInfo
|
||||||
{
|
{
|
||||||
@@ -167,6 +170,17 @@ bool FifoDataFile::Save(const std::string& filename)
|
|||||||
header.mem1_size = memory.GetRamSizeReal();
|
header.mem1_size = memory.GetRamSizeReal();
|
||||||
header.mem2_size = memory.GetExRamSizeReal();
|
header.mem2_size = memory.GetExRamSizeReal();
|
||||||
|
|
||||||
|
const auto gameid = SConfig::GetInstance().GetGameID();
|
||||||
|
if (gameid.size() > DEFAULT_GAME_ID.size())
|
||||||
|
{
|
||||||
|
// Custom game id? Won't fit, just use default
|
||||||
|
std::memcpy(header.gameid, DEFAULT_GAME_ID.data(), DEFAULT_GAME_ID.size());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::strncpy(header.gameid, gameid.c_str(), DEFAULT_GAME_ID.size());
|
||||||
|
}
|
||||||
|
|
||||||
file.Seek(0, File::SeekOrigin::Begin);
|
file.Seek(0, File::SeekOrigin::Begin);
|
||||||
file.WriteBytes(&header, sizeof(FileHeader));
|
file.WriteBytes(&header, sizeof(FileHeader));
|
||||||
|
|
||||||
@@ -253,6 +267,16 @@ std::unique_ptr<FifoDataFile> FifoDataFile::Load(const std::string& filename, bo
|
|||||||
dataFile->m_Flags = header.flags;
|
dataFile->m_Flags = header.flags;
|
||||||
dataFile->m_Version = header.file_version;
|
dataFile->m_Version = header.file_version;
|
||||||
|
|
||||||
|
// Official support for game id was added in version 6
|
||||||
|
if (header.file_version < 6)
|
||||||
|
{
|
||||||
|
dataFile->m_game_id = DEFAULT_GAME_ID;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dataFile->m_game_id = std::string{header.gameid, DEFAULT_GAME_ID.size()};
|
||||||
|
}
|
||||||
|
|
||||||
if (flagsOnly)
|
if (flagsOnly)
|
||||||
{
|
{
|
||||||
// Force settings to match those used when the DFF was created. This is sort of a hack.
|
// Force settings to match those used when the DFF was created. This is sort of a hack.
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "Common/CommonTypes.h"
|
#include "Common/CommonTypes.h"
|
||||||
|
#include "Core/ConfigManager.h"
|
||||||
#include "VideoCommon/XFMemory.h"
|
#include "VideoCommon/XFMemory.h"
|
||||||
|
|
||||||
namespace File
|
namespace File
|
||||||
@@ -71,6 +72,7 @@ public:
|
|||||||
u8* GetTexMem() { return m_TexMem.data(); }
|
u8* GetTexMem() { return m_TexMem.data(); }
|
||||||
u32 GetRamSizeReal() { return m_ram_size_real; }
|
u32 GetRamSizeReal() { return m_ram_size_real; }
|
||||||
u32 GetExRamSizeReal() { return m_exram_size_real; }
|
u32 GetExRamSizeReal() { return m_exram_size_real; }
|
||||||
|
const std::string& GetGameId() const { return m_game_id; }
|
||||||
|
|
||||||
void AddFrame(const FifoFrameInfo& frameInfo);
|
void AddFrame(const FifoFrameInfo& frameInfo);
|
||||||
const FifoFrameInfo& GetFrame(u32 frame) const { return m_Frames[frame]; }
|
const FifoFrameInfo& GetFrame(u32 frame) const { return m_Frames[frame]; }
|
||||||
@@ -102,6 +104,8 @@ private:
|
|||||||
u32 m_ram_size_real = 0;
|
u32 m_ram_size_real = 0;
|
||||||
u32 m_exram_size_real = 0;
|
u32 m_exram_size_real = 0;
|
||||||
|
|
||||||
|
std::string m_game_id = std::string{DEFAULT_GAME_ID};
|
||||||
|
|
||||||
u32 m_Flags = 0;
|
u32 m_Flags = 0;
|
||||||
u32 m_Version = 0;
|
u32 m_Version = 0;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user