diff --git a/Core/Compatibility.cpp b/Core/Compatibility.cpp index e4b35d2ee6..b006447072 100644 --- a/Core/Compatibility.cpp +++ b/Core/Compatibility.cpp @@ -68,6 +68,7 @@ void Compatibility::CheckSettings(IniFile &iniFile, const std::string &gameID) { CheckSetting(iniFile, gameID, "HideISOFiles", &flags_.HideISOFiles); CheckSetting(iniFile, gameID, "MoreAccurateVMMUL", &flags_.MoreAccurateVMMUL); CheckSetting(iniFile, gameID, "ForceSoftwareRenderer", &flags_.ForceSoftwareRenderer); + CheckSetting(iniFile, gameID, "DarkStalkersPresentHack", &flags_.DarkStalkersPresentHack); } void Compatibility::CheckSetting(IniFile &iniFile, const std::string &gameID, const char *option, bool *flag) { diff --git a/Core/Compatibility.h b/Core/Compatibility.h index a3f35ec3fb..0baf9db5fa 100644 --- a/Core/Compatibility.h +++ b/Core/Compatibility.h @@ -68,6 +68,7 @@ struct CompatFlags { bool HideISOFiles; bool MoreAccurateVMMUL; bool ForceSoftwareRenderer; + bool DarkStalkersPresentHack; }; class IniFile; diff --git a/GPU/Software/Clipper.cpp b/GPU/Software/Clipper.cpp index 5f4f76d3a3..be9acb8c19 100644 --- a/GPU/Software/Clipper.cpp +++ b/GPU/Software/Clipper.cpp @@ -17,6 +17,8 @@ #include +#include "Core/System.h" + #include "GPU/GPUState.h" #include "GPU/Software/Clipper.h" @@ -24,6 +26,9 @@ #include "profiler/profiler.h" + +extern bool g_DarkStalkerStretch; + namespace Clipper { enum { @@ -207,6 +212,13 @@ void ProcessRect(const VertexData& v0, const VertexData& v1) return; } + // Eliminate the stretch blit in DarkStalkers. + // We compensate for that when blitting the framebuffer in SoftGpu.cpp. + if (PSP_CoreParameter().compat.flags().DarkStalkersPresentHack && v0.texturecoords.x == 64.0f && v0.texturecoords.y == 16.0f && v1.texturecoords.x == 448.0f && v1.texturecoords.y == 240.0f) { + g_DarkStalkerStretch = true; + return; + } + VertexData buf[4]; buf[0].screenpos = ScreenCoords(v0.screenpos.x, v0.screenpos.y, v1.screenpos.z); buf[0].texturecoords = v0.texturecoords; diff --git a/GPU/Software/SoftGpu.cpp b/GPU/Software/SoftGpu.cpp index 00a240e9bd..6b13a34f2e 100644 --- a/GPU/Software/SoftGpu.cpp +++ b/GPU/Software/SoftGpu.cpp @@ -148,12 +148,16 @@ void SoftGPU::SetDisplayFramebuffer(u32 framebuf, u32 stride, GEBufferFormat for GPURecord::NotifyDisplay(framebuf, stride, format); } +bool g_DarkStalkerStretch; + // Copies RGBA8 data from RAM to the currently bound render target. void SoftGPU::CopyToCurrentFboFromDisplayRam(int srcwidth, int srcheight) { if (!draw_) return; float u0 = 0.0f; float u1; + float v0 = 1.0f; + float v1 = 0.0f; if (fbTex) { fbTex->Release(); @@ -175,7 +179,19 @@ void SoftGPU::CopyToCurrentFboFromDisplayRam(int srcwidth, int srcheight) { desc.mipLevels = 1; desc.tag = "SoftGPU"; bool hasImage = true; - if (!Memory::IsValidAddress(displayFramebuf_) || srcwidth == 0 || srcheight == 0) { + if (PSP_CoreParameter().compat.flags().DarkStalkersPresentHack && displayFormat_ == GE_FORMAT_5551 && g_DarkStalkerStretch) { + u8 *data = Memory::GetPointer(0x04088000); + desc.swizzle = Draw::TextureSwizzle::BGRA; + desc.format = Draw::DataFormat::A1R5G5B5_UNORM_PACK16; + desc.width = displayStride_ == 0 ? srcwidth : displayStride_; + desc.height = srcheight; + desc.initData.push_back(data); + u0 = 64.0f / 512.0f; + u1 = 448.0f / 512.0f; + v1 = 16.0f / 272.0f; + v0 = 240.0f / 272.0f; + g_DarkStalkerStretch = false; + } else if (!Memory::IsValidAddress(displayFramebuf_) || srcwidth == 0 || srcheight == 0) { hasImage = false; u1 = 1.0f; } else if (displayFormat_ == GE_FORMAT_8888) { @@ -252,12 +268,10 @@ void SoftGPU::CopyToCurrentFboFromDisplayRam(int srcwidth, int srcheight) { x2 -= 1.0f; y2 -= 1.0f; - float v0 = 1.0f; - float v1 = 0.0f; - if (GetGPUBackend() == GPUBackend::VULKAN) { std::swap(v0, v1); } + draw_->BindFramebufferAsRenderTarget(nullptr, { Draw::RPAction::CLEAR, Draw::RPAction::DONT_CARE, Draw::RPAction::DONT_CARE }); Draw::Viewport viewport = { 0.0f, 0.0f, dstwidth, dstheight, 0.0f, 1.0f }; draw_->SetViewports(1, &viewport); diff --git a/assets/compat.ini b/assets/compat.ini index 4d41fa0665..c67f0b8360 100644 --- a/assets/compat.ini +++ b/assets/compat.ini @@ -688,3 +688,8 @@ UCUS98713 = true # Darkstalkers ULES00016 = true ULUS10005 = true + +[DarkStalkersPresentHack] +# Darkstalkers +ULES00016 = true +ULUS10005 = true