Darkstalkers: Gross hack to avoid the game's own stretch, and present the raw buffer instead for a sharper image.

This commit is contained in:
Henrik Rydgård 2019-10-24 00:10:39 +02:00
parent 2dd7a9aa12
commit 9099441973
5 changed files with 37 additions and 4 deletions

View File

@ -68,6 +68,7 @@ void Compatibility::CheckSettings(IniFile &iniFile, const std::string &gameID) {
CheckSetting(iniFile, gameID, "HideISOFiles", &flags_.HideISOFiles); CheckSetting(iniFile, gameID, "HideISOFiles", &flags_.HideISOFiles);
CheckSetting(iniFile, gameID, "MoreAccurateVMMUL", &flags_.MoreAccurateVMMUL); CheckSetting(iniFile, gameID, "MoreAccurateVMMUL", &flags_.MoreAccurateVMMUL);
CheckSetting(iniFile, gameID, "ForceSoftwareRenderer", &flags_.ForceSoftwareRenderer); 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) { void Compatibility::CheckSetting(IniFile &iniFile, const std::string &gameID, const char *option, bool *flag) {

View File

@ -68,6 +68,7 @@ struct CompatFlags {
bool HideISOFiles; bool HideISOFiles;
bool MoreAccurateVMMUL; bool MoreAccurateVMMUL;
bool ForceSoftwareRenderer; bool ForceSoftwareRenderer;
bool DarkStalkersPresentHack;
}; };
class IniFile; class IniFile;

View File

@ -17,6 +17,8 @@
#include <algorithm> #include <algorithm>
#include "Core/System.h"
#include "GPU/GPUState.h" #include "GPU/GPUState.h"
#include "GPU/Software/Clipper.h" #include "GPU/Software/Clipper.h"
@ -24,6 +26,9 @@
#include "profiler/profiler.h" #include "profiler/profiler.h"
extern bool g_DarkStalkerStretch;
namespace Clipper { namespace Clipper {
enum { enum {
@ -207,6 +212,13 @@ void ProcessRect(const VertexData& v0, const VertexData& v1)
return; 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]; VertexData buf[4];
buf[0].screenpos = ScreenCoords(v0.screenpos.x, v0.screenpos.y, v1.screenpos.z); buf[0].screenpos = ScreenCoords(v0.screenpos.x, v0.screenpos.y, v1.screenpos.z);
buf[0].texturecoords = v0.texturecoords; buf[0].texturecoords = v0.texturecoords;

View File

@ -148,12 +148,16 @@ void SoftGPU::SetDisplayFramebuffer(u32 framebuf, u32 stride, GEBufferFormat for
GPURecord::NotifyDisplay(framebuf, stride, format); GPURecord::NotifyDisplay(framebuf, stride, format);
} }
bool g_DarkStalkerStretch;
// Copies RGBA8 data from RAM to the currently bound render target. // Copies RGBA8 data from RAM to the currently bound render target.
void SoftGPU::CopyToCurrentFboFromDisplayRam(int srcwidth, int srcheight) { void SoftGPU::CopyToCurrentFboFromDisplayRam(int srcwidth, int srcheight) {
if (!draw_) if (!draw_)
return; return;
float u0 = 0.0f; float u0 = 0.0f;
float u1; float u1;
float v0 = 1.0f;
float v1 = 0.0f;
if (fbTex) { if (fbTex) {
fbTex->Release(); fbTex->Release();
@ -175,7 +179,19 @@ void SoftGPU::CopyToCurrentFboFromDisplayRam(int srcwidth, int srcheight) {
desc.mipLevels = 1; desc.mipLevels = 1;
desc.tag = "SoftGPU"; desc.tag = "SoftGPU";
bool hasImage = true; 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; hasImage = false;
u1 = 1.0f; u1 = 1.0f;
} else if (displayFormat_ == GE_FORMAT_8888) { } else if (displayFormat_ == GE_FORMAT_8888) {
@ -252,12 +268,10 @@ void SoftGPU::CopyToCurrentFboFromDisplayRam(int srcwidth, int srcheight) {
x2 -= 1.0f; x2 -= 1.0f;
y2 -= 1.0f; y2 -= 1.0f;
float v0 = 1.0f;
float v1 = 0.0f;
if (GetGPUBackend() == GPUBackend::VULKAN) { if (GetGPUBackend() == GPUBackend::VULKAN) {
std::swap(v0, v1); std::swap(v0, v1);
} }
draw_->BindFramebufferAsRenderTarget(nullptr, { Draw::RPAction::CLEAR, Draw::RPAction::DONT_CARE, Draw::RPAction::DONT_CARE }); 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::Viewport viewport = { 0.0f, 0.0f, dstwidth, dstheight, 0.0f, 1.0f };
draw_->SetViewports(1, &viewport); draw_->SetViewports(1, &viewport);

View File

@ -688,3 +688,8 @@ UCUS98713 = true
# Darkstalkers # Darkstalkers
ULES00016 = true ULES00016 = true
ULUS10005 = true ULUS10005 = true
[DarkStalkersPresentHack]
# Darkstalkers
ULES00016 = true
ULUS10005 = true