From b0365bd6ee3dc0b755edbc215f1e91e2c85de1e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sun, 30 Aug 2020 11:48:58 +0200 Subject: [PATCH] GE dump loading: Try to use the correct GameID so compat.ini flags apply. --- Core/ELF/ParamSFO.h | 5 ++++- Core/System.cpp | 27 ++++++++++++++++++++++++++- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/Core/ELF/ParamSFO.h b/Core/ELF/ParamSFO.h index dca5d1b23e..aac91f12e7 100644 --- a/Core/ELF/ParamSFO.h +++ b/Core/ELF/ParamSFO.h @@ -22,6 +22,7 @@ #include #include "Common/CommonTypes.h" +#include "Common/Log.h" class ParamSFOData { @@ -40,7 +41,9 @@ public: std::string GetDiscID() { const std::string discID = GetValueString("DISC_ID"); if (discID.empty()) { - return GenerateFakeID(); + std::string fakeID = GenerateFakeID(); + WARN_LOG(LOADER, "No DiscID found - generating a fake one: %s", fakeID.c_str()); + return fakeID; } return discID; } diff --git a/Core/System.cpp b/Core/System.cpp index 6f9b58ad7b..cc77f58f97 100644 --- a/Core/System.cpp +++ b/Core/System.cpp @@ -185,6 +185,17 @@ bool CPU_HasPendingAction() { void CPU_Shutdown(); +bool DiscIDFromGEDumpPath(const std::string &path, std::string *id) { + std::string filename = File::GetFilename(path); + // Could be more discerning, but hey.. + if (filename.size() > 10 && filename[0] == 'U' && filename[9] == '_') { + *id = filename.substr(0, 9); + return true; + } else { + return false; + } +} + bool CPU_Init() { coreState = CORE_POWERUP; currentMIPS = &mipsr4k; @@ -216,32 +227,46 @@ bool CPU_Init() { MIPSAnalyst::Reset(); Replacement_Init(); + std::string discID; + switch (type) { case IdentifiedFileType::PSP_ISO: case IdentifiedFileType::PSP_ISO_NP: case IdentifiedFileType::PSP_DISC_DIRECTORY: InitMemoryForGameISO(loadedFile); + discID = g_paramSFO.GetDiscID(); break; case IdentifiedFileType::PSP_PBP: case IdentifiedFileType::PSP_PBP_DIRECTORY: // This is normal for homebrew. // ERROR_LOG(LOADER, "PBP directory resolution failed."); InitMemoryForGamePBP(loadedFile); + discID = g_paramSFO.GetDiscID(); break; case IdentifiedFileType::PSP_ELF: if (Memory::g_PSPModel != PSP_MODEL_FAT) { INFO_LOG(LOADER, "ELF, using full PSP-2000 memory access"); Memory::g_MemorySize = Memory::RAM_DOUBLE_SIZE; } + discID = g_paramSFO.GetDiscID(); + break; + case IdentifiedFileType::PPSSPP_GE_DUMP: + // Try to grab the disc ID from the filename, since unfortunately, we don't store + // it in the GE dump. This should probably be fixed, but as long as you don't rename the dumps, + // this will do the trick. + if (!DiscIDFromGEDumpPath(filename, &discID)) { + // Failed? Let the param SFO autogen a fake disc ID. + discID = g_paramSFO.GetDiscID(); + } break; default: + discID = g_paramSFO.GetDiscID(); break; } // Here we have read the PARAM.SFO, let's see if we need any compatibility overrides. // Homebrew usually has an empty discID, and even if they do have a disc id, it's not // likely to collide with any commercial ones. - std::string discID = g_paramSFO.GetDiscID(); coreParameter.compat.Load(discID); if (!Memory::Init()) {