GE dump loading: Try to use the correct GameID so compat.ini flags apply.

This commit is contained in:
Henrik Rydgård 2020-08-30 11:48:58 +02:00
parent b86d26da42
commit b0365bd6ee
2 changed files with 30 additions and 2 deletions

View file

@ -22,6 +22,7 @@
#include <vector> #include <vector>
#include "Common/CommonTypes.h" #include "Common/CommonTypes.h"
#include "Common/Log.h"
class ParamSFOData class ParamSFOData
{ {
@ -40,7 +41,9 @@ public:
std::string GetDiscID() { std::string GetDiscID() {
const std::string discID = GetValueString("DISC_ID"); const std::string discID = GetValueString("DISC_ID");
if (discID.empty()) { 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; return discID;
} }

View file

@ -185,6 +185,17 @@ bool CPU_HasPendingAction() {
void CPU_Shutdown(); 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() { bool CPU_Init() {
coreState = CORE_POWERUP; coreState = CORE_POWERUP;
currentMIPS = &mipsr4k; currentMIPS = &mipsr4k;
@ -216,32 +227,46 @@ bool CPU_Init() {
MIPSAnalyst::Reset(); MIPSAnalyst::Reset();
Replacement_Init(); Replacement_Init();
std::string discID;
switch (type) { switch (type) {
case IdentifiedFileType::PSP_ISO: case IdentifiedFileType::PSP_ISO:
case IdentifiedFileType::PSP_ISO_NP: case IdentifiedFileType::PSP_ISO_NP:
case IdentifiedFileType::PSP_DISC_DIRECTORY: case IdentifiedFileType::PSP_DISC_DIRECTORY:
InitMemoryForGameISO(loadedFile); InitMemoryForGameISO(loadedFile);
discID = g_paramSFO.GetDiscID();
break; break;
case IdentifiedFileType::PSP_PBP: case IdentifiedFileType::PSP_PBP:
case IdentifiedFileType::PSP_PBP_DIRECTORY: case IdentifiedFileType::PSP_PBP_DIRECTORY:
// This is normal for homebrew. // This is normal for homebrew.
// ERROR_LOG(LOADER, "PBP directory resolution failed."); // ERROR_LOG(LOADER, "PBP directory resolution failed.");
InitMemoryForGamePBP(loadedFile); InitMemoryForGamePBP(loadedFile);
discID = g_paramSFO.GetDiscID();
break; break;
case IdentifiedFileType::PSP_ELF: case IdentifiedFileType::PSP_ELF:
if (Memory::g_PSPModel != PSP_MODEL_FAT) { if (Memory::g_PSPModel != PSP_MODEL_FAT) {
INFO_LOG(LOADER, "ELF, using full PSP-2000 memory access"); INFO_LOG(LOADER, "ELF, using full PSP-2000 memory access");
Memory::g_MemorySize = Memory::RAM_DOUBLE_SIZE; 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; break;
default: default:
discID = g_paramSFO.GetDiscID();
break; break;
} }
// Here we have read the PARAM.SFO, let's see if we need any compatibility overrides. // 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 // 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. // likely to collide with any commercial ones.
std::string discID = g_paramSFO.GetDiscID();
coreParameter.compat.Load(discID); coreParameter.compat.Load(discID);
if (!Memory::Init()) { if (!Memory::Init()) {