From 373df2a912adae2edca974c04252bd5454f2e854 Mon Sep 17 00:00:00 2001 From: zilmar Date: Thu, 22 Oct 2020 12:37:09 +1030 Subject: [PATCH] Project64: Provide ability for alternate identifier game settings --- Config/Project64.rdb | 3 +++ .../Project64-core/N64System/N64RomClass.cpp | 20 +++++++++++++++++++ Source/Project64-core/RomList/RomList.cpp | 14 ++++++++++++- Source/Project64-core/RomList/RomList.h | 1 + 4 files changed, 37 insertions(+), 1 deletion(-) diff --git a/Config/Project64.rdb b/Config/Project64.rdb index 8be597483..80aa8377d 100644 --- a/Config/Project64.rdb +++ b/Config/Project64.rdb @@ -5872,6 +5872,9 @@ SMM-TLB=0 Self Texture=1 RDRAM Size=8 +[THE LEGEND OF ZELDA-C:45] +Alt Identifier=EC7011B7-7616D72B-C:45 + [EC7011B7-7616D72B-C:45] Good Name=The Legend of Zelda - Ocarina of Time (U) (V1.0) Internal Name=THE LEGEND OF ZELDA diff --git a/Source/Project64-core/N64System/N64RomClass.cpp b/Source/Project64-core/N64System/N64RomClass.cpp index 4f612886a..e8870255f 100644 --- a/Source/Project64-core/N64System/N64RomClass.cpp +++ b/Source/Project64-core/N64System/N64RomClass.cpp @@ -16,6 +16,7 @@ #include #include #include +#include #include #ifdef _WIN32 @@ -654,6 +655,25 @@ bool CN64Rom::LoadN64Image(const char * FileLoc, bool LoadBootCodeOnly) } m_RomIdent = stdstr_f("%08X-%08X-C:%X", CRC1, CRC2, m_ROMImage[0x3D]); + { + CIniFileBase::SectionList GameIdentifiers; + CIniFile RomDatabase(g_Settings->LoadStringVal(SupportFile_RomDatabase).c_str()); + RomDatabase.GetVectorOfSections(GameIdentifiers); + + if (GameIdentifiers.find(m_RomIdent.c_str()) == GameIdentifiers.end()) + { + char InternalName[22] = { 0 }; + memcpy(InternalName, (void *)(m_ROMImage + 0x20), 20); + CN64Rom::CleanRomName(InternalName); + + std::string AltIdentifier = stdstr_f("%s-C:%X", stdstr(InternalName).Trim().ToUpper().c_str(), m_Country); + AltIdentifier = RomDatabase.GetString(AltIdentifier.c_str(), "Alt Identifier", ""); + if (!AltIdentifier.empty()) + { + m_RomIdent = AltIdentifier; + } + } + } WriteTrace(TraceN64System, TraceDebug, "Ident: %s", m_RomIdent.c_str()); if (!LoadBootCodeOnly && g_Rom == this) diff --git a/Source/Project64-core/RomList/RomList.cpp b/Source/Project64-core/RomList/RomList.cpp index 648acde81..762b326de 100644 --- a/Source/Project64-core/RomList/RomList.cpp +++ b/Source/Project64-core/RomList/RomList.cpp @@ -59,6 +59,10 @@ CRomList::CRomList() : #endif g_Settings->RegisterChangeCB(RomList_GameDir, this, (CSettings::SettingChangedFunc)RefreshSettings); } + if (m_RomIniFile) + { + m_RomIniFile->GetVectorOfSections(m_GameIdentifiers); + } WriteTrace(TraceRomList, TraceVerbose, "Done"); } @@ -582,9 +586,17 @@ void CRomList::FillRomExtensionInfo(ROM_INFO * pRomInfo) strcpy(pRomInfo->Name, "#321#"); strcpy(pRomInfo->Status, "Unknown"); - //Get File Identifier char Identifier[100]; sprintf(Identifier, "%08X-%08X-C:%X", pRomInfo->CRC1, pRomInfo->CRC2, pRomInfo->Country); + if (m_GameIdentifiers.find(Identifier) == m_GameIdentifiers.end()) + { + std::string AltIdentifier = stdstr_f("%s-C:%X", stdstr(pRomInfo->InternalName).Trim().ToUpper().c_str(), pRomInfo->Country); + AltIdentifier = m_RomIniFile->GetString(AltIdentifier.c_str(), "Alt Identifier", ""); + if (!AltIdentifier.empty()) + { + strcpy(Identifier, AltIdentifier.c_str()); + } + } //Rom Notes strncpy(pRomInfo->UserNotes, m_NotesIniFile->GetString(Identifier, "Note", "").c_str(), sizeof(pRomInfo->UserNotes) / sizeof(char)); diff --git a/Source/Project64-core/RomList/RomList.h b/Source/Project64-core/RomList/RomList.h index a1e2b759f..e79345391 100644 --- a/Source/Project64-core/RomList/RomList.h +++ b/Source/Project64-core/RomList/RomList.h @@ -95,6 +95,7 @@ private: CIniFile * m_ZipIniFile; #endif CThread m_RefreshThread; + CIniFileBase::SectionList m_GameIdentifiers; #define DISKSIZE_MAME 0x0435B0C0 #define DISKSIZE_SDK 0x03DEC800