diff --git a/Core/HLE/sceKernelModule.cpp b/Core/HLE/sceKernelModule.cpp index b27fd27da5..551e8e2143 100644 --- a/Core/HLE/sceKernelModule.cpp +++ b/Core/HLE/sceKernelModule.cpp @@ -483,7 +483,7 @@ void PSPModule::GetLongInfo(char *ptr, int bufSize) const { StringWriter w(ptr, bufSize); w.F("%s: Version %d.%d. %d segments", nm.name, nm.version[1], nm.version[0], nm.nsegment).endl(); w.F("Memory block: %08x (%08x/%d bytes)", memoryBlockAddr, memoryBlockSize, memoryBlockSize).endl(); - for (int i = 0; i < nm.nsegment; i++) { + for (int i = 0; i < (int)nm.nsegment; i++) { w.F(" %08x (%08x bytes)\n", nm.segmentaddr[i], nm.segmentsize[i]); } w.F("Text: %08x (%08x bytes)\n", nm.text_addr, nm.text_size); diff --git a/Core/SaveState.cpp b/Core/SaveState.cpp index 4232ad56f3..50e07d2273 100644 --- a/Core/SaveState.cpp +++ b/Core/SaveState.cpp @@ -1094,7 +1094,7 @@ double g_lastSaveTime = -1.0; case SAVESTATE_SAVE_SCREENSHOT: { int maxResMultiplier = 2; - tempResult = TakeGameScreenshot(nullptr, op.filename, ScreenshotFormat::JPG, SCREENSHOT_DISPLAY, nullptr, nullptr, maxResMultiplier); + tempResult = TakeGameScreenshot(nullptr, op.filename, ScreenshotFormat::JPG, SCREENSHOT_DISPLAY, maxResMultiplier); callbackResult = tempResult ? Status::SUCCESS : Status::FAILURE; if (!tempResult) { WARN_LOG(Log::SaveState, "Failed to take a screenshot for the savestate! (%s) The savestate will lack an icon.", op.filename.c_str()); diff --git a/Core/Screenshot.cpp b/Core/Screenshot.cpp index 72838eb7ec..aaa17e41ac 100644 --- a/Core/Screenshot.cpp +++ b/Core/Screenshot.cpp @@ -328,9 +328,8 @@ static GPUDebugBuffer ApplyRotation(const GPUDebugBuffer &buf, DisplayRotation r return rotated; } -bool TakeGameScreenshot(Draw::DrawContext *draw, const Path &filename, ScreenshotFormat fmt, ScreenshotType type, int *width, int *height, int maxRes) { +bool TakeGameScreenshot(Draw::DrawContext *draw, const Path &filename, ScreenshotFormat fmt, ScreenshotType type, int maxRes) { GPUDebugBuffer buf; - bool success = false; u32 w = (u32)-1; u32 h = (u32)-1; @@ -339,45 +338,34 @@ bool TakeGameScreenshot(Draw::DrawContext *draw, const Path &filename, Screensho ERROR_LOG(Log::System, "Can't take screenshots when GPU not running"); return false; } - success = gpuDebug->GetCurrentFramebuffer(buf, type == SCREENSHOT_RENDER ? GPU_DBG_FRAMEBUF_RENDER : GPU_DBG_FRAMEBUF_DISPLAY, maxRes); + if (!gpuDebug->GetCurrentFramebuffer(buf, type == SCREENSHOT_RENDER ? GPU_DBG_FRAMEBUF_RENDER : GPU_DBG_FRAMEBUF_DISPLAY, maxRes)) { + return false; + } w = maxRes > 0 ? 480 * maxRes : PSP_CoreParameter().renderWidth; h = maxRes > 0 ? 272 * maxRes : PSP_CoreParameter().renderHeight; } else if (g_display.rotation != DisplayRotation::ROTATE_0) { _dbg_assert_(draw); GPUDebugBuffer temp; - success = ::GetOutputFramebuffer(draw, temp); - if (success) { - buf = ApplyRotation(temp, g_display.rotation); + if (!::GetOutputFramebuffer(draw, temp)) { + return false; } + buf = ApplyRotation(temp, g_display.rotation); } else { _dbg_assert_(draw); - success = ::GetOutputFramebuffer(draw, buf); + if (!GetOutputFramebuffer(draw, buf)) { + return false; + } } - if (!success) { + u8 *flipbuffer = nullptr; + const u8 *buffer = ConvertBufferToScreenshot(buf, false, flipbuffer, w, h); + if (!buffer) { return false; } - if (success) { - u8 *flipbuffer = nullptr; - const u8 *buffer = ConvertBufferToScreenshot(buf, false, flipbuffer, w, h); - success = buffer != nullptr; - if (success) { - if (width) - *width = w; - if (height) - *height = h; - - success = Save888RGBScreenshot(filename, fmt, buffer, w, h); - } - delete[] flipbuffer; - } - - if (!success) { - ERROR_LOG(Log::IO, "Failed to write screenshot."); - } - - return success; + bool success = Save888RGBScreenshot(filename, fmt, buffer, w, h); + delete[] flipbuffer; + return true; } bool Save888RGBScreenshot(const Path &filename, ScreenshotFormat fmt, const u8 *bufferRGB888, int w, int h) { diff --git a/Core/Screenshot.h b/Core/Screenshot.h index 69794bb6de..6e15c0bba2 100644 --- a/Core/Screenshot.h +++ b/Core/Screenshot.h @@ -41,7 +41,7 @@ enum ScreenshotType { const u8 *ConvertBufferToScreenshot(const GPUDebugBuffer &buf, bool alpha, u8 *&temp, u32 &w, u32 &h); // Can only be used while in game. -bool TakeGameScreenshot(Draw::DrawContext *draw, const Path &filename, ScreenshotFormat fmt, ScreenshotType type, int *width = nullptr, int *height = nullptr, int maxRes = -1); +bool TakeGameScreenshot(Draw::DrawContext *draw, const Path &filename, ScreenshotFormat fmt, ScreenshotType type, int maxRes = -1); bool Save888RGBScreenshot(const Path &filename, ScreenshotFormat fmt, const u8 *bufferRGB888, int w, int h); bool Save8888RGBAScreenshot(const Path &filename, const u8 *bufferRGBA8888, int w, int h); diff --git a/GPU/Common/GPUDebugInterface.h b/GPU/Common/GPUDebugInterface.h index 378ac361f4..2b3e437cfa 100644 --- a/GPU/Common/GPUDebugInterface.h +++ b/GPU/Common/GPUDebugInterface.h @@ -153,13 +153,13 @@ struct GPUDebugBuffer { void ZeroBytes(); - u8 *GetData() { - return data_; - } - u32 GetRawPixel(int x, int y) const; void SetRawPixel(int x, int y, u32 c); + u8 *GetDataWrite() { + return data_; + } + const u8 *GetData() const { return data_; } diff --git a/GPU/Software/SoftGpu.cpp b/GPU/Software/SoftGpu.cpp index fc6c1bb036..64f8d2f905 100644 --- a/GPU/Software/SoftGpu.cpp +++ b/GPU/Software/SoftGpu.cpp @@ -1384,7 +1384,7 @@ bool SoftGPU::GetCurrentFramebuffer(GPUDebugBuffer &buffer, GPUDebugFramebufferT buffer.Allocate(size.x, size.y, fmt); const int depth = fmt == GE_FORMAT_8888 ? 4 : 2; - u8 *dst = buffer.GetData(); + u8 *dst = buffer.GetDataWrite(); const int byteWidth = size.x * depth; for (int16_t y = 0; y < size.y; ++y) { memcpy(dst, src, byteWidth); @@ -1404,7 +1404,7 @@ bool SoftGPU::GetCurrentDepthbuffer(GPUDebugBuffer &buffer) { const int depth = 2; const u8 *src = depthbuf.data; - u8 *dst = buffer.GetData(); + u8 *dst = buffer.GetDataWrite(); for (int16_t y = 0; y < size.y; ++y) { memcpy(dst, src, size.x * depth); dst += size.x * depth; @@ -1430,7 +1430,7 @@ bool SoftGPU::GetCurrentStencilbuffer(GPUDebugBuffer &buffer) { DrawingCoords size = GetTargetSize(gstate.FrameBufStride()); buffer.Allocate(size.x, size.y, GPU_DBG_FORMAT_8BIT); - u8 *row = buffer.GetData(); + u8 *row = buffer.GetDataWrite(); for (int16_t y = 0; y < size.y; ++y) { for (int16_t x = 0; x < size.x; ++x) { row[x] = GetPixelStencil(gstate.FrameBufFormat(), gstate.FrameBufStride(), x, y); @@ -1451,7 +1451,7 @@ bool SoftGPU::GetCurrentClut(GPUDebugBuffer &buffer) const u32 pixels = 1024 / bpp; buffer.Allocate(pixels, 1, (GEBufferFormat)gstate.getClutPaletteFormat()); - memcpy(buffer.GetData(), clut, 1024); + memcpy(buffer.GetDataWrite(), clut, 1024); return true; } diff --git a/UI/ReportScreen.cpp b/UI/ReportScreen.cpp index 238c057174..425dc0ce2e 100644 --- a/UI/ReportScreen.cpp +++ b/UI/ReportScreen.cpp @@ -182,7 +182,7 @@ ScreenRenderFlags ReportScreen::render(ScreenRenderMode mode) { File::CreateDir(path); } screenshotFilename_ = path / ".reporting.jpg"; - if (TakeGameScreenshot(screenManager()->getDrawContext(), screenshotFilename_, ScreenshotFormat::JPG, SCREENSHOT_DISPLAY, nullptr, nullptr, 4)) { + if (TakeGameScreenshot(screenManager()->getDrawContext(), screenshotFilename_, ScreenshotFormat::JPG, SCREENSHOT_DISPLAY, 4)) { // Redo the views already, now with a screenshot included. RecreateViews(); } else {