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)) { char title[1024]; sprintf(title, "%s : %s", g_paramSFO.GetValueString("DISC_ID").c_str(), g_paramSFO.GetValueString("TITLE").c_str()); INFO_LOG(LOADER, "%s", title); host->SetWindowTitle(title); } } std::string bootpath("disc0:/PSP_GAME/SYSDIR/EBOOT.BIN"); // Bypass Chinese translation patches, see comment above. for (size_t i = 0; i < ARRAY_SIZE(altBootNames); i++) { if (pspFileSystem.GetFileInfo(altBootNames[i]).exists) { bootpath = altBootNames[i]; } } // Bypass another more dangerous one where the file is in USRDIR - this could collide with files in some game. std::string id = g_paramSFO.GetValueString("DISC_ID"); if (id == "NPJH50624" && pspFileSystem.GetFileInfo("disc0:/PSP_GAME/USRDIR/PAKFILE2.BIN").exists) { bootpath = "disc0:/PSP_GAME/USRDIR/PAKFILE2.BIN"; } if (id == "NPJH00100" && pspFileSystem.GetFileInfo("disc0:/PSP_GAME/USRDIR/DATA/GIM/GBL").exists) { bootpath = "disc0:/PSP_GAME/USRDIR/DATA/GIM/GBL"; } bool hasEncrypted = false; u32 fd; if ((fd = pspFileSystem.OpenFile(bootpath, FILEACCESS_READ)) != 0) { u8 head[4]; pspFileSystem.ReadFile(fd, head, 4); if (memcmp(head, "~PSP", 4) == 0 || memcmp(head, "\x7F""ELF", 4) == 0) { hasEncrypted = true; } pspFileSystem.CloseFile(fd); } if (!hasEncrypted) { // try unencrypted BOOT.BIN bootpath = "disc0:/PSP_GAME/SYSDIR/BOOT.BIN"; } INFO_LOG(LOADER,"Loading %s...", bootpath.c_str()); return __KernelLoadExec(bootpath.c_str(), 0, error_string); }
// 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(std::string fileToStart) { IFileSystem* umd2; // check if it's a disc directory FileInfo info; if (!getFileInfo(fileToStart.c_str(), &info)) return; if (info.isDirectory) { umd2 = new VirtualDiscFileSystem(&pspFileSystem, fileToStart); } else { auto bd = constructBlockDevice(fileToStart.c_str()); // Can't init anything without a block device... if (!bd) return; umd2 = new ISOFileSystem(&pspFileSystem, bd); } // Parse PARAM.SFO //pspFileSystem.Mount("host0:",umd2); pspFileSystem.Mount("umd0:", umd2); pspFileSystem.Mount("umd1:", umd2); pspFileSystem.Mount("disc0:", umd2); pspFileSystem.Mount("umd:", umd2); std::string gameID; std::string sfoPath("disc0:/PSP_GAME/PARAM.SFO"); PSPFileInfo fileInfo = pspFileSystem.GetFileInfo(sfoPath.c_str()); if (fileInfo.exists) { u8 *paramsfo = new u8[(size_t)fileInfo.size]; u32 fd = pspFileSystem.OpenFile(sfoPath, FILEACCESS_READ); pspFileSystem.ReadFile(fd, paramsfo, fileInfo.size); pspFileSystem.CloseFile(fd); if (g_paramSFO.ReadSFO(paramsfo, (size_t)fileInfo.size)) { gameID = g_paramSFO.GetValueString("DISC_ID"); for (size_t i = 0; i < ARRAY_SIZE(g_HDRemasters); i++) { if(g_HDRemasters[i].gameID == gameID) { g_RemasterMode = true; Memory::g_MemorySize = g_HDRemasters[i].MemorySize; if(g_HDRemasters[i].DoubleTextureCoordinates) g_DoubleTextureCoordinates = true; break; } } DEBUG_LOG(LOADER, "HDRemaster mode is %s", g_RemasterMode? "true": "false"); } delete [] paramsfo; } }
bool Load_PSP_ISO(const char *filename, std::string *error_string) { ISOFileSystem *umd2 = new ISOFileSystem(&pspFileSystem, constructBlockDevice(filename)); // Parse PARAM.SFO //pspFileSystem.Mount("host0:",umd2); pspFileSystem.Mount("umd0:", umd2); pspFileSystem.Mount("umd1:", umd2); pspFileSystem.Mount("disc0:", umd2); pspFileSystem.Mount("umd:", umd2); std::string sfoPath("disc0:/PSP_GAME/PARAM.SFO"); PSPFileInfo fileInfo = pspFileSystem.GetFileInfo(sfoPath.c_str()); if (fileInfo.exists) { u8 *paramsfo = new u8[(size_t)fileInfo.size]; u32 fd = pspFileSystem.OpenFile(sfoPath, FILEACCESS_READ); pspFileSystem.ReadFile(fd, paramsfo, fileInfo.size); pspFileSystem.CloseFile(fd); if (g_paramSFO.ReadSFO(paramsfo, (size_t)fileInfo.size)) { char title[1024]; sprintf(title, "%s : %s", g_paramSFO.GetValueString("DISC_ID").c_str(), g_paramSFO.GetValueString("TITLE").c_str()); INFO_LOG(LOADER, "%s", title); host->SetWindowTitle(title); } delete [] paramsfo; } std::string bootpath("disc0:/PSP_GAME/SYSDIR/EBOOT.BIN"); // bypass patchers if (pspFileSystem.GetFileInfo("disc0:/PSP_GAME/SYSDIR/EBOOT.OLD").exists) { bootpath = "disc0:/PSP_GAME/SYSDIR/EBOOT.OLD"; } bool hasEncrypted = false; u32 fd; if ((fd = pspFileSystem.OpenFile(bootpath, FILEACCESS_READ)) != 0) { u8 head[4]; pspFileSystem.ReadFile(fd, head, 4); if (memcmp(head, "~PSP", 4) == 0 || memcmp(head, "\x7F""ELF", 4) == 0) { hasEncrypted = true; } pspFileSystem.CloseFile(fd); } if (!hasEncrypted) { // try unencrypted BOOT.BIN bootpath = "disc0:/PSP_GAME/SYSDIR/BOOT.BIN"; } INFO_LOG(LOADER,"Loading %s...", bootpath.c_str()); return __KernelLoadExec(bootpath.c_str(), 0, error_string); }
// 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) { IFileSystem* umd2; if (!fileLoader->Exists()) { return; } bool actualIso = false; if (fileLoader->IsDirectory()) { umd2 = new VirtualDiscFileSystem(&pspFileSystem, fileLoader->Path()); } else { auto bd = constructBlockDevice(fileLoader); // Can't init anything without a block device... if (!bd) return; #ifdef _M_X64 if (g_Config.bCacheFullIsoInRam) { // The constructor destroys the original block device object after reading it. bd = new RAMBlockDevice(bd); } #endif umd2 = new ISOFileSystem(&pspFileSystem, bd); actualIso = true; } // Parse PARAM.SFO //pspFileSystem.Mount("host0:",umd2); IFileSystem *entireIso = 0; if (actualIso) { entireIso = new ISOBlockSystem(static_cast<ISOFileSystem *>(umd2)); } else { entireIso = umd2; } pspFileSystem.Mount("umd0:", entireIso); pspFileSystem.Mount("umd1:", entireIso); pspFileSystem.Mount("disc0:", umd2); pspFileSystem.Mount("umd:", entireIso); std::string gameID; 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)) { gameID = g_paramSFO.GetValueString("DISC_ID"); for (size_t i = 0; i < ARRAY_SIZE(g_HDRemasters); i++) { if(g_HDRemasters[i].gameID == gameID) { g_RemasterMode = true; Memory::g_MemorySize = g_HDRemasters[i].MemorySize; if(g_HDRemasters[i].DoubleTextureCoordinates) g_DoubleTextureCoordinates = true; break; } } DEBUG_LOG(LOADER, "HDRemaster mode is %s", g_RemasterMode? "true": "false"); } } }
bool Load_PSP_ISO(const char *filename, 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) { u8 *paramsfo = new u8[(size_t)fileInfo.size]; u32 fd = pspFileSystem.OpenFile(sfoPath, FILEACCESS_READ); pspFileSystem.ReadFile(fd, paramsfo, fileInfo.size); pspFileSystem.CloseFile(fd); if (g_paramSFO.ReadSFO(paramsfo, (size_t)fileInfo.size)) { char title[1024]; sprintf(title, "%s : %s", g_paramSFO.GetValueString("DISC_ID").c_str(), g_paramSFO.GetValueString("TITLE").c_str()); INFO_LOG(LOADER, "%s", title); host->SetWindowTitle(title); } delete [] paramsfo; } std::string bootpath("disc0:/PSP_GAME/SYSDIR/EBOOT.BIN"); // bypass patchers if (pspFileSystem.GetFileInfo("disc0:/PSP_GAME/SYSDIR/EBOOT.OLD").exists) { bootpath = "disc0:/PSP_GAME/SYSDIR/EBOOT.OLD"; } // bypass another patchers if (pspFileSystem.GetFileInfo("disc0:/PSP_GAME/SYSDIR/EBOOT.DAT").exists) { bootpath = "disc0:/PSP_GAME/SYSDIR/EBOOT.DAT"; } // bypass more patchers if (pspFileSystem.GetFileInfo("disc0:/PSP_GAME/SYSDIR/EBOOT.BI").exists) { bootpath = "disc0:/PSP_GAME/SYSDIR/EBOOT.BI"; } if (pspFileSystem.GetFileInfo("disc0:/PSP_GAME/SYSDIR/EBOOT.LLD").exists) { bootpath = "disc0:/PSP_GAME/SYSDIR/EBOOT.LLD"; } if (pspFileSystem.GetFileInfo("disc0:/PSP_GAME/SYSDIR/OLD_EBOOT.BIN").exists) { bootpath = "disc0:/PSP_GAME/SYSDIR/OLD_EBOOT.BIN"; } if (pspFileSystem.GetFileInfo("disc0:/PSP_GAME/SYSDIR/EBOOT.123").exists) { bootpath = "disc0:/PSP_GAME/SYSDIR/EBOOT.123"; } if (pspFileSystem.GetFileInfo("disc0:/PSP_GAME/SYSDIR/EBOOT_LRC_CH.BIN").exists) { bootpath = "disc0:/PSP_GAME/SYSDIR/EBOOT_LRC_CH.BIN"; } if (pspFileSystem.GetFileInfo("disc0:/PSP_GAME/SYSDIR/BOOT0.OLD").exists) { bootpath = "disc0:/PSP_GAME/SYSDIR/BOOT0.OLD"; } if (pspFileSystem.GetFileInfo("disc0:/PSP_GAME/SYSDIR/BOOT1.OLD").exists) { bootpath = "disc0:/PSP_GAME/SYSDIR/BOOT1.OLD"; } if (pspFileSystem.GetFileInfo("disc0:/PSP_GAME/SYSDIR/BINOT.BIN").exists) { bootpath = "disc0:/PSP_GAME/SYSDIR/BINOT.BIN"; } if (pspFileSystem.GetFileInfo("disc0:/PSP_GAME/SYSDIR/EBOOT.FRY").exists) { bootpath = "disc0:/PSP_GAME/SYSDIR/EBOOT.FRY"; } if (pspFileSystem.GetFileInfo("disc0:/PSP_GAME/SYSDIR/EBOOT.Z.Y").exists) { bootpath = "disc0:/PSP_GAME/SYSDIR/EBOOT.Z.Y"; } bool hasEncrypted = false; u32 fd; if ((fd = pspFileSystem.OpenFile(bootpath, FILEACCESS_READ)) != 0) { u8 head[4]; pspFileSystem.ReadFile(fd, head, 4); if (memcmp(head, "~PSP", 4) == 0 || memcmp(head, "\x7F""ELF", 4) == 0) { hasEncrypted = true; } pspFileSystem.CloseFile(fd); } if (!hasEncrypted) { // try unencrypted BOOT.BIN bootpath = "disc0:/PSP_GAME/SYSDIR/BOOT.BIN"; } INFO_LOG(LOADER,"Loading %s...", bootpath.c_str()); return __KernelLoadExec(bootpath.c_str(), 0, error_string); }