Implement optional dumping of NPDRM isos (PBP demos) on game startup

This commit is contained in:
Henrik Rydgård committed 2026-03-19 16:07:24 +01:00
1 parent 0e55129fab
commit 6377c0bb06
6 files changed
+69 -5

No files matched your search

+41 -1
View File
@@ -15,6 +15,8 @@
// Official git repository and contact information can be found at
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
#include <thread>
#include "Core/Core.h"
#include "Common/System/Request.h"
@@ -24,6 +26,7 @@
#ifdef _WIN32
#include "Common/CommonWindows.h"
#endif
#include "Common/System/OSD.h"
#include "Core/ELF/ParamSFO.h"
#include "Core/ELF/PBPReader.h"
@@ -38,7 +41,7 @@
#include "Core/Loaders.h"
#include "Core/MemMap.h"
#include "Core/HDRemaster.h"
#include "Core/Util/PathUtil.h"
#include "Core/Config.h"
#include "Core/ConfigValues.h"
@@ -60,6 +63,43 @@ static void UseLargeMem(int memsize) {
}
}
void DumpBlockDeviceAsync(std::shared_ptr<BlockDevice> bd, Path destPath, std::string title) {
NPDRMDemoBlockDevice *npdrmDemoBD = dynamic_cast<NPDRMDemoBlockDevice *>(bd.get());
if (npdrmDemoBD) {
INFO_LOG(Log::System, "Dumping NPDRM demo ISO... (%s)", destPath.c_str());
std::thread dumpThread([bd, title, destPath]() {
File::CreateFullPath(destPath.NavigateUp());
if (File::Exists(destPath)) {
INFO_LOG(Log::System, "Dump file already exists, skipping: %s", destPath.c_str());
return;
}
FILE *dest = File::OpenCFile(destPath, "wb");
if (!dest) {
ERROR_LOG(Log::System, "Failed to open destination for NPDRM demo ISO dump: %s", destPath.c_str());
return;
}
g_OSD.SetProgressBar("npdrm_dump", title, 0.0f, 1.0f, 0.0f, 0.0f);
int blocks = bd->GetNumBlocks();
std::vector<u8> blockBuf(bd->GetBlockSize());
for (int i = 0; i < blocks; i++) {
bd->ReadBlock(i, blockBuf.data());
fwrite(blockBuf.data(), 1, blockBuf.size(), dest);
g_OSD.SetProgressBar("npdrm_dump", title, 0.0f, 1.0f, (float)(i + 1) / blocks, 0.0f);
}
fclose(dest);
g_OSD.RemoveProgressBar("npdrm_dump", true, 1.0f);
g_OSD.Show(OSDType::MESSAGE_SUCCESS, title, GetFriendlyPath(destPath), 5.0f, "npdrm_finished");
if (System_GetPropertyBool(SYSPROP_CAN_SHOW_FILE)) {
g_OSD.SetClickCallback("npdrm_finished", [destPath]() {
System_ShowFileInFolder(destPath);
});
}
INFO_LOG(Log::System, "Finished dumping NPDRM demo ISO... (%s)", title.c_str());
});
dumpThread.detach();
}
}
bool MountGameISO(FileLoader *fileLoader, std::string *errorString) {
std::shared_ptr<IFileSystem> fileSystem;
std::shared_ptr<IFileSystem> blockSystem;