mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-07-11 01:25:07 +02:00
Only load PARAM.SFO once during startup
This commit is contained in:
@@ -59,6 +59,7 @@ public:
|
||||
// If not found, returns a negative value.
|
||||
int GetDataOffset(const u8 *paramsfo, const char *dataName);
|
||||
|
||||
bool IsValid() const { return !values.empty(); }
|
||||
void Clear();
|
||||
|
||||
private:
|
||||
|
||||
+3
-1
@@ -261,7 +261,9 @@ bool LoadFile(FileLoader **fileLoaderPtr, std::string *error_string) {
|
||||
IdentifiedFileType ebootType = Identify_File(fileLoader, error_string);
|
||||
if (ebootType == IdentifiedFileType::PSP_ISO_NP) {
|
||||
MountGameISO(fileLoader);
|
||||
InitMemoryForGameISO(fileLoader);
|
||||
if (LoadParamSFOFromDisc()) {
|
||||
InitMemorySizeForGame();
|
||||
}
|
||||
pspFileSystem.SetStartingDirectory("disc0:/PSP_GAME/USRDIR");
|
||||
return Load_PSP_ISO(fileLoader, error_string);
|
||||
}
|
||||
|
||||
+34
-33
@@ -91,28 +91,29 @@ bool MountGameISO(FileLoader *fileLoader) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// We gather the game info before actually loading/booting the ISO
|
||||
// to determine if the emulator should enable extra memory and
|
||||
// double-sized texture coordinates.
|
||||
void InitMemoryForGameISO(FileLoader *fileLoader) {
|
||||
std::string gameID;
|
||||
std::string umdData;
|
||||
|
||||
bool LoadParamSFOFromDisc() {
|
||||
std::string sfoPath("disc0:/PSP_GAME/PARAM.SFO");
|
||||
PSPFileInfo fileInfo = pspFileSystem.GetFileInfo(sfoPath.c_str());
|
||||
|
||||
if (fileInfo.exists) {
|
||||
std::vector<u8> paramsfo;
|
||||
pspFileSystem.ReadEntireFile(sfoPath, paramsfo);
|
||||
if (g_paramSFO.ReadSFO(paramsfo)) {
|
||||
UseLargeMem(g_paramSFO.GetValueInt("MEMSIZE"));
|
||||
gameID = g_paramSFO.GetValueString("DISC_ID");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector<u8> umdDataBin;
|
||||
if (pspFileSystem.ReadEntireFile("disc0:/UMD_DATA.BIN", umdDataBin) >= 0) {
|
||||
umdData = std::string((const char *)&umdDataBin[0], umdDataBin.size());
|
||||
}
|
||||
// We gather the game info before actually loading/booting the ISO
|
||||
// to determine if the emulator should enable extra memory and
|
||||
// double-sized texture coordinates.
|
||||
void InitMemorySizeForGame() {
|
||||
std::string gameID;
|
||||
std::string umdData;
|
||||
|
||||
if (g_paramSFO.IsValid()) {
|
||||
UseLargeMem(g_paramSFO.GetValueInt("MEMSIZE"));
|
||||
gameID = g_paramSFO.GetValueString("DISC_ID");
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < g_HDRemastersCount; i++) {
|
||||
@@ -120,6 +121,14 @@ void InitMemoryForGameISO(FileLoader *fileLoader) {
|
||||
if (entry.gameID != gameID) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (umdData.empty()) {
|
||||
std::vector<u8> umdDataBin;
|
||||
if (pspFileSystem.ReadEntireFile("disc0:/UMD_DATA.BIN", umdDataBin) >= 0) {
|
||||
umdData = std::string((const char *)&umdDataBin[0], umdDataBin.size());
|
||||
}
|
||||
}
|
||||
|
||||
if (entry.umdDataValue && umdData.find(entry.umdDataValue) == umdData.npos) {
|
||||
continue;
|
||||
}
|
||||
@@ -134,21 +143,14 @@ void InitMemoryForGameISO(FileLoader *fileLoader) {
|
||||
}
|
||||
}
|
||||
|
||||
void InitMemoryForGamePBP(FileLoader *fileLoader) {
|
||||
if (!fileLoader->Exists()) {
|
||||
return;
|
||||
}
|
||||
|
||||
bool LoadParamSFOFromPBP(FileLoader *fileLoader) {
|
||||
PBPReader pbp(fileLoader);
|
||||
if (pbp.IsValid() && !pbp.IsELF()) {
|
||||
std::vector<u8> sfoData;
|
||||
if (pbp.GetSubFile(PBP_PARAM_SFO, &sfoData)) {
|
||||
// Carefully parse param SFO for PBP files.
|
||||
ParamSFOData paramSFO;
|
||||
if (paramSFO.ReadSFO(sfoData)) {
|
||||
// This is the parameter CFW uses to determine homebrew wants the full 64MB.
|
||||
UseLargeMem(paramSFO.GetValueInt("MEMSIZE"));
|
||||
|
||||
// Take this moment to bring over the title, if set.
|
||||
std::string title = paramSFO.GetValueString("TITLE");
|
||||
if (g_paramSFO.GetValueString("TITLE").empty() && !title.empty()) {
|
||||
g_paramSFO.SetValue("TITLE", title, (int)title.size());
|
||||
@@ -170,9 +172,11 @@ void InitMemoryForGamePBP(FileLoader *fileLoader) {
|
||||
ver = "1.00";
|
||||
g_paramSFO.SetValue("DISC_VERSION", ver, (int)ver.size());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -202,16 +206,13 @@ static const char * const altBootNames[] = {
|
||||
bool Load_PSP_ISO(FileLoader *fileLoader, std::string *error_string) {
|
||||
// Mounting stuff relocated to InitMemoryForGameISO due to HD Remaster restructuring of code.
|
||||
|
||||
std::string sfoPath("disc0:/PSP_GAME/PARAM.SFO");
|
||||
PSPFileInfo fileInfo = pspFileSystem.GetFileInfo(sfoPath.c_str());
|
||||
if (fileInfo.exists) {
|
||||
std::vector<u8> paramsfo;
|
||||
pspFileSystem.ReadEntireFile(sfoPath, paramsfo);
|
||||
if (g_paramSFO.ReadSFO(paramsfo)) {
|
||||
std::string title = StringFromFormat("%s : %s", g_paramSFO.GetValueString("DISC_ID").c_str(), g_paramSFO.GetValueString("TITLE").c_str());
|
||||
INFO_LOG(Log::Loader, "%s", title.c_str());
|
||||
System_SetWindowTitle(title);
|
||||
}
|
||||
if (g_paramSFO.IsValid()) {
|
||||
std::string title = StringFromFormat("%s : %s", g_paramSFO.GetValueString("DISC_ID").c_str(), g_paramSFO.GetValueString("TITLE").c_str());
|
||||
INFO_LOG(Log::Loader, "%s", title.c_str());
|
||||
System_SetWindowTitle(title);
|
||||
} else {
|
||||
// Should have been loaded earlier in the process.
|
||||
_dbg_assert_(false);
|
||||
}
|
||||
|
||||
std::string bootpath("disc0:/PSP_GAME/SYSDIR/EBOOT.BIN");
|
||||
|
||||
+5
-2
@@ -24,7 +24,10 @@ class FileLoader;
|
||||
bool Load_PSP_ISO(FileLoader *fileLoader, std::string *error_string);
|
||||
bool Load_PSP_ELF_PBP(FileLoader *fileLoader, std::string *error_string);
|
||||
bool Load_PSP_GE_Dump(FileLoader *fileLoader, std::string *error_string);
|
||||
void InitMemoryForGameISO(FileLoader *fileLoader);
|
||||
|
||||
bool MountGameISO(FileLoader *fileLoader);
|
||||
void InitMemoryForGamePBP(FileLoader *fileLoader);
|
||||
bool LoadParamSFOFromDisc();
|
||||
bool LoadParamSFOFromPBP(FileLoader *fileLoader);
|
||||
void InitMemorySizeForGame();
|
||||
|
||||
void PSPLoaders_Shutdown();
|
||||
|
||||
+6
-2
@@ -244,13 +244,17 @@ bool CPU_Init(std::string *errorString, FileLoader *loadedFile, IdentifiedFileTy
|
||||
case IdentifiedFileType::PSP_ISO_NP:
|
||||
case IdentifiedFileType::PSP_DISC_DIRECTORY:
|
||||
MountGameISO(loadedFile);
|
||||
InitMemoryForGameISO(loadedFile);
|
||||
if (LoadParamSFOFromDisc()) {
|
||||
InitMemorySizeForGame();
|
||||
}
|
||||
break;
|
||||
case IdentifiedFileType::PSP_PBP:
|
||||
case IdentifiedFileType::PSP_PBP_DIRECTORY:
|
||||
// This is normal for homebrew.
|
||||
// ERROR_LOG(Log::Loader, "PBP directory resolution failed.");
|
||||
InitMemoryForGamePBP(loadedFile);
|
||||
if (LoadParamSFOFromPBP(loadedFile)) {
|
||||
InitMemorySizeForGame();
|
||||
}
|
||||
break;
|
||||
case IdentifiedFileType::PSP_ELF:
|
||||
if (Memory::g_PSPModel != PSP_MODEL_FAT) {
|
||||
|
||||
Reference in New Issue
Block a user