diff --git a/Core/CoreParameter.h b/Core/CoreParameter.h index 3ca526b46a..13deda4162 100644 --- a/Core/CoreParameter.h +++ b/Core/CoreParameter.h @@ -21,6 +21,7 @@ #include "Common/File/Path.h" #include "Core/Compatibility.h" +#include "Core/Loaders.h" enum GPUCore { GPUCORE_GLES, @@ -86,6 +87,7 @@ struct CoreParameter { bool frozen = false; FileLoader *mountIsoLoader = nullptr; + IdentifiedFileType fileType = IdentifiedFileType::UNKNOWN; Compatibility compat; }; diff --git a/Core/ELF/PBPReader.cpp b/Core/ELF/PBPReader.cpp index 72cab6df8d..9306585f12 100644 --- a/Core/ELF/PBPReader.cpp +++ b/Core/ELF/PBPReader.cpp @@ -23,7 +23,7 @@ #include "Core/Loaders.h" #include "Core/ELF/PBPReader.h" -PBPReader::PBPReader(FileLoader *fileLoader) : file_(nullptr), header_(), isELF_(false) { +PBPReader::PBPReader(FileLoader *fileLoader) { if (!fileLoader->Exists()) { ERROR_LOG(Log::Loader, "Failed to open PBP file %s", fileLoader->GetPath().c_str()); return; @@ -48,12 +48,19 @@ PBPReader::PBPReader(FileLoader *fileLoader) : file_(nullptr), header_(), isELF_ file_ = fileLoader; } -bool PBPReader::GetSubFile(PBPSubFile file, std::vector *out) { +bool PBPReader::GetSubFile(PBPSubFile file, std::vector *out) const { if (!file_) { return false; } const size_t expected = GetSubFileSize(file); + + // This is only used to get the PARAM.SFO, so let's have a strict 256MB file size limit for sanity. + if (expected > 256 * 1024 * 1024) { + ERROR_LOG(Log::Loader, "Bad subfile size: %d", (int)expected); + return false; + } + const u32 off = header_.offsets[(int)file]; out->resize(expected); @@ -67,13 +74,19 @@ bool PBPReader::GetSubFile(PBPSubFile file, std::vector *out) { return true; } -void PBPReader::GetSubFileAsString(PBPSubFile file, std::string *out) { +bool PBPReader::GetSubFileAsString(PBPSubFile file, std::string *out) const { if (!file_) { out->clear(); - return; + return false; } const size_t expected = GetSubFileSize(file); + + // This is only used to get the PNG, AT3 etc, so let's have a strict 256MB file size limit for sanity. + if (expected > 256 * 1024 * 1024) { + ERROR_LOG(Log::Loader, "Bad subfile size: %d", (int)expected); + return false; + } const u32 off = header_.offsets[(int)file]; out->resize(expected); diff --git a/Core/ELF/PBPReader.h b/Core/ELF/PBPReader.h index af322deb74..572f215ad5 100644 --- a/Core/ELF/PBPReader.h +++ b/Core/ELF/PBPReader.h @@ -50,10 +50,10 @@ public: bool IsValid() const { return file_ != nullptr; } bool IsELF() const { return file_ == nullptr && isELF_; } - bool GetSubFile(PBPSubFile file, std::vector *out); - void GetSubFileAsString(PBPSubFile file, std::string *out); + bool GetSubFile(PBPSubFile file, std::vector *out) const; + bool GetSubFileAsString(PBPSubFile file, std::string *out) const; - size_t GetSubFileSize(PBPSubFile file) { + size_t GetSubFileSize(PBPSubFile file) const { int num = (int)file; if (num < 7) { return header_.offsets[file + 1] - header_.offsets[file]; @@ -63,8 +63,8 @@ public: } private: - FileLoader *file_; - size_t fileSize_; - const PBPHeader header_; - bool isELF_; + FileLoader *file_ = nullptr; + size_t fileSize_ = 0; + const PBPHeader header_{}; + bool isELF_ = false; }; diff --git a/Core/FileSystems/BlockDevices.cpp b/Core/FileSystems/BlockDevices.cpp index 4b968722d7..8a7f55be88 100644 --- a/Core/FileSystems/BlockDevices.cpp +++ b/Core/FileSystems/BlockDevices.cpp @@ -428,10 +428,12 @@ NPDRMDemoBlockDevice::NPDRMDemoBlockDevice(FileLoader *fileLoader) memcpy(psarStr, &psar_id, 4); // Protect against a badly decrypted header, and send information through the assert about what's being played (implicitly). - _assert_msg_(blockLBAs_ <= 4096, "Bad blockLBAs in header: %08x (%s) psar: %s", blockLBAs_, fileLoader->GetPath().ToVisualString().c_str(), psarStr); + _dbg_assert_msg_(blockLBAs_ <= 4096, "Bad blockLBAs in header: %08x (%s) psar: %s", blockLBAs_, fileLoader->GetPath().ToVisualString().c_str(), psarStr); // When we remove the above assert, let's just try to survive. if (blockLBAs_ > 4096) { + ERROR_LOG(Log::Loader, "Bad blockLBAs in header: %08x (%s) psar: %s", blockLBAs_, fileLoader->GetPath().ToVisualString().c_str(), psarStr); + // We'll end up displaying an error message since ReadBlock will fail. return; } @@ -447,7 +449,7 @@ NPDRMDemoBlockDevice::NPDRMDemoBlockDevice(FileLoader *fileLoader) table_ = new table_info[numBlocks_]; readSize = fileLoader_->ReadAt(psarOffset + tableOffset_, 1, tableSize_, table_); - if (readSize!=tableSize_){ + if (readSize != tableSize_){ ERROR_LOG(Log::Loader, "Invalid NPUMDIMG table!"); } diff --git a/Core/HLE/scePspNpDrm_user.cpp b/Core/HLE/scePspNpDrm_user.cpp index b81d92a601..d8194c8904 100644 --- a/Core/HLE/scePspNpDrm_user.cpp +++ b/Core/HLE/scePspNpDrm_user.cpp @@ -4,27 +4,23 @@ #include "Core/HLE/FunctionWrappers.h" #include "Core/HLE/sceIo.h" -static int sceNpDrmSetLicenseeKey(u32 npDrmKeyAddr) -{ - INFO_LOG(Log::HLE, "call sceNpDrmSetLicenseeKey(%08x)", npDrmKeyAddr); +static int sceNpDrmSetLicenseeKey(u32 npDrmKeyAddr) { + WARN_LOG(Log::HLE, "UNIMPL: sceNpDrmSetLicenseeKey(%08x)", npDrmKeyAddr); return 0; } -static int sceNpDrmClearLicenseeKey() -{ - INFO_LOG(Log::HLE, "call sceNpDrmClearLicenseeKey()"); +static int sceNpDrmClearLicenseeKey() { + WARN_LOG(Log::HLE, "UNIMPL: sceNpDrmClearLicenseeKey()"); return 0; } -static int sceNpDrmRenameCheck(const char *filename) -{ - INFO_LOG(Log::HLE, "call sceNpDrmRenameCheck(%s)", filename); +static int sceNpDrmRenameCheck(const char *filename) { + WARN_LOG(Log::HLE, "UNIMPL: sceNpDrmRenameCheck(%s)", filename); return 0; } -static int sceNpDrmEdataSetupKey(u32 edataFd) -{ - INFO_LOG(Log::HLE, "call sceNpDrmEdataSetupKey %x", edataFd); +static int sceNpDrmEdataSetupKey(u32 edataFd) { + INFO_LOG(Log::HLE, "sceNpDrmEdataSetupKey(%x)", edataFd); int usec = 0; // set PGD offset int retval = __IoIoctl(edataFd, 0x04100002, 0x90, 0, 0, 0, usec); @@ -37,20 +33,17 @@ static int sceNpDrmEdataSetupKey(u32 edataFd) return hleDelayResult(retval, "io ctrl command", usec); } -static int sceNpDrmEdataGetDataSize(u32 edataFd) -{ - INFO_LOG(Log::HLE, "call sceNpDrmEdataGetDataSize %x", edataFd); +static int sceNpDrmEdataGetDataSize(u32 edataFd) { + INFO_LOG(Log::HLE, "sceNpDrmEdataGetDataSize %x", edataFd); return sceIoIoctl(edataFd, 0x04100010, 0, 0, 0, 0); } -static int sceNpDrmOpen() -{ - ERROR_LOG(Log::HLE, "UNIMPL sceNpDrmOpen"); +static int sceNpDrmOpen() { + ERROR_LOG(Log::HLE, "UNIMPL: sceNpDrmOpen()"); return 0; } -const HLEFunction sceNpDrm[] = -{ +const HLEFunction sceNpDrm[] = { {0XA1336091, &WrapI_U, "sceNpDrmSetLicenseeKey", 'i', "x"}, {0X9B745542, &WrapI_V, "sceNpDrmClearLicenseeKey", 'i', "" }, {0X275987D1, &WrapI_C, "sceNpDrmRenameCheck", 'i', "s"}, @@ -59,8 +52,7 @@ const HLEFunction sceNpDrm[] = {0X2BAA4294, &WrapI_V, "sceNpDrmOpen", 'i', "" }, }; -void Register_sceNpDrm() -{ +void Register_sceNpDrm() { RegisterModule("sceNpDrm", ARRAY_SIZE(sceNpDrm), sceNpDrm); RegisterModule("scePspNpDrm_user", ARRAY_SIZE(sceNpDrm), sceNpDrm); } diff --git a/Core/System.cpp b/Core/System.cpp index 2cf51d96c4..69e92f0fb2 100644 --- a/Core/System.cpp +++ b/Core/System.cpp @@ -254,6 +254,7 @@ bool CPU_Init(std::string *errorString, FileLoader *loadedFile) { if (!g_CoreParameter.mountIso.empty()) { g_CoreParameter.mountIsoLoader = ConstructFileLoader(g_CoreParameter.mountIso); } + g_CoreParameter.fileType = type; MIPSAnalyst::Reset(); Replacement_Init(); diff --git a/GPU/Debugger/Record.cpp b/GPU/Debugger/Record.cpp index 88ee8353ea..d9e17c7550 100644 --- a/GPU/Debugger/Record.cpp +++ b/GPU/Debugger/Record.cpp @@ -151,7 +151,12 @@ static void DirtyDrawnVRAM() { DirtyVRAM(gstate.getFrameBufAddress(), bytes, DirtyVRAMFlag::DRAWN); } -static void BeginRecording() { +static bool BeginRecording() { + if (PSP_CoreParameter().fileType == IdentifiedFileType::PPSSPP_GE_DUMP) { + // Can't record a GE dump. + return false; + } + active = true; nextFrame = false; lastTextures.clear(); @@ -178,6 +183,7 @@ static void BeginRecording() { } DirtyAllVRAM(DirtyVRAMFlag::DIRTY); + return true; } static void WriteCompressed(FILE *fp, const void *p, size_t sz) { @@ -619,6 +625,10 @@ void ClearCallback() { static void FinishRecording() { // We're done - this was just to write the result out. + if (!active) { + return; + } + Path filename = WriteRecording(); commands.clear(); pushbuf.clear(); @@ -785,7 +795,7 @@ void NotifyDisplay(u32 framebuf, int stride, int fmt) { } if (!active && nextFrame && (gstate_c.skipDrawReason & SKIPDRAW_SKIPFRAME) == 0) { NOTICE_LOG(Log::System, "Recording starting on display..."); - BeginRecording(); + BeginRecording(); // TODO: Handle return value. } if (!active) { return; diff --git a/UI/EmuScreen.cpp b/UI/EmuScreen.cpp index b396f2157f..8b30ccf01c 100644 --- a/UI/EmuScreen.cpp +++ b/UI/EmuScreen.cpp @@ -1398,7 +1398,7 @@ ScreenRenderFlags EmuScreen::render(ScreenRenderMode mode) { Draw::BackendState state = draw->GetCurrentBackendState(); if (state.valid) { - _dbg_assert_msg_(state.passes >= 1, "skipB: %d sw: %d mode: %d back: %d tag: %s", (int)skipBufferEffects, (int)g_Config.bSoftwareRendering, (int)mode, (int)g_Config.iGPUBackend, screenManager()->topScreen()->tag()); + _dbg_assert_msg_(state.passes >= 1, "skipB: %d sw: %d mode: %d back: %d tag: %s behi: %d", (int)skipBufferEffects, (int)g_Config.bSoftwareRendering, (int)mode, (int)g_Config.iGPUBackend, screenManager()->topScreen()->tag(), (int)g_Config.bRunBehindPauseMenu); // Workaround any remaining bugs like this. if (state.passes == 0) { draw->BindFramebufferAsRenderTarget(nullptr, { RPAction::CLEAR, RPAction::CLEAR, RPAction::CLEAR, }, "EmuScreen_SafeFallback"); diff --git a/assets/compat.ini b/assets/compat.ini index c86e513f86..7e446b9db7 100644 --- a/assets/compat.ini +++ b/assets/compat.ini @@ -831,6 +831,12 @@ ULJS00188 = true UCES00018 = true UCUS98601 = true +# PlayStation Network Collection: Power Pack (#19571) +UCES01160 = true + +# PlayStation Network Collection: Puzzle Pack +UCES01159 = true + [GoWFramerateHack60] # Replaces ForceMax60FPS for GOW games, should provide smoother experience # Also works around softlock in GOW:GOS , see #8299