d3d: Support the Danganronpa hack.

This commit is contained in:
Unknown W. Brackets 2014-09-13 16:47:23 -07:00
parent 1f44bf2396
commit b9d7ffe484
6 changed files with 22 additions and 20 deletions

View file

@ -20,6 +20,7 @@
#include "Core/Config.h" #include "Core/Config.h"
#include "Core/CoreParameter.h" #include "Core/CoreParameter.h"
#include "Core/Reporting.h" #include "Core/Reporting.h"
#include "Core/ELF/ParamSFO.h"
#include "Core/System.h" #include "Core/System.h"
#include "GPU/Common/FramebufferCommon.h" #include "GPU/Common/FramebufferCommon.h"
#include "GPU/GPUInterface.h" #include "GPU/GPUInterface.h"
@ -41,6 +42,21 @@ FramebufferManagerCommon::FramebufferManagerCommon() :
FramebufferManagerCommon::~FramebufferManagerCommon() { FramebufferManagerCommon::~FramebufferManagerCommon() {
} }
void FramebufferManagerCommon::Init() {
const std::string gameId = g_paramSFO.GetValueString("DISC_ID");
// This applies a hack to Dangan Ronpa, its demo, and its sequel.
// The game draws solid colors to a small framebuffer, and then reads this directly in VRAM.
// We force this framebuffer to 1x and force download it automatically.
hackForce04154000Download_ = gameId == "NPJH50631" || gameId == "NPJH50372" || gameId == "NPJH90164" || gameId == "NPJH50515";
// And an initial clear. We don't clear per frame as the games are supposed to handle that
// by themselves.
ClearBuffer();
BeginFrame();
}
void FramebufferManagerCommon::BeginFrame() { void FramebufferManagerCommon::BeginFrame() {
DecimateFBOs(); DecimateFBOs();
currentRenderVfb_ = 0; currentRenderVfb_ = 0;
@ -664,7 +680,7 @@ bool FramebufferManagerCommon::NotifyBlockTransferBefore(u32 dstBasePtr, int dst
if (srcHeight <= 0 || srcY + srcHeight > srcBuffer->bufferHeight) { if (srcHeight <= 0 || srcY + srcHeight > srcBuffer->bufferHeight) {
WARN_LOG_ONCE(btdheight, G3D, "Block transfer download %08x -> %08x skipped, %d+%d is taller than %d", srcBasePtr, dstBasePtr, srcY, srcHeight, srcBuffer->bufferHeight); WARN_LOG_ONCE(btdheight, G3D, "Block transfer download %08x -> %08x skipped, %d+%d is taller than %d", srcBasePtr, dstBasePtr, srcY, srcHeight, srcBuffer->bufferHeight);
} else { } else {
ReadFramebufferToMemory(srcBuffer, true, srcX * srcXFactor, srcY, srcWidth * srcXFactor, srcHeight); ReadFramebufferToMemory(srcBuffer, true, static_cast<int>(srcX * srcXFactor), srcY, static_cast<int>(srcWidth * srcXFactor), srcHeight);
} }
} }
return false; // Let the bit copy happen return false; // Let the bit copy happen
@ -708,7 +724,7 @@ void FramebufferManagerCommon::NotifyBlockTransferAfter(u32 dstBasePtr, int dstS
const u8 *srcBase = Memory::GetPointerUnchecked(srcBasePtr) + (srcX + srcY * srcStride) * bpp; const u8 *srcBase = Memory::GetPointerUnchecked(srcBasePtr) + (srcX + srcY * srcStride) * bpp;
int dstBpp = dstBuffer->format == GE_FORMAT_8888 ? 4 : 2; int dstBpp = dstBuffer->format == GE_FORMAT_8888 ? 4 : 2;
float dstXFactor = (float)bpp / dstBpp; float dstXFactor = (float)bpp / dstBpp;
DrawPixels(dstBuffer, dstX * dstXFactor, dstY, srcBase, dstBuffer->format, srcStride * dstXFactor, dstWidth * dstXFactor, dstHeight); DrawPixels(dstBuffer, static_cast<int>(dstX * dstXFactor), dstY, srcBase, dstBuffer->format, static_cast<int>(srcStride * dstXFactor), static_cast<int>(dstWidth * dstXFactor), dstHeight);
SetColorUpdated(dstBuffer); SetColorUpdated(dstBuffer);
RebindFramebuffer(); RebindFramebuffer();
} }

View file

@ -94,6 +94,7 @@ public:
FramebufferManagerCommon(); FramebufferManagerCommon();
virtual ~FramebufferManagerCommon(); virtual ~FramebufferManagerCommon();
virtual void Init();
void BeginFrame(); void BeginFrame();
void SetDisplayFramebuffer(u32 framebuf, u32 stride, GEBufferFormat format); void SetDisplayFramebuffer(u32 framebuf, u32 stride, GEBufferFormat format);

View file

@ -126,9 +126,6 @@ namespace DX9 {
convBuf(0), convBuf(0),
gameUsesSequentialCopies_(false) gameUsesSequentialCopies_(false)
{ {
// And an initial clear. We don't clear per frame as the games are supposed to handle that
// by themselves.
ClearBuffer();
// TODO: Check / use D3DCAPS2_DYNAMICTEXTURES? // TODO: Check / use D3DCAPS2_DYNAMICTEXTURES?
int usage = 0; int usage = 0;
D3DPOOL pool = D3DPOOL_MANAGED; D3DPOOL pool = D3DPOOL_MANAGED;
@ -141,7 +138,6 @@ namespace DX9 {
drawPixelsTex_ = nullptr; drawPixelsTex_ = nullptr;
ERROR_LOG(G3D, "Failed to create drawpixels texture"); ERROR_LOG(G3D, "Failed to create drawpixels texture");
} }
BeginFrame();
} }
FramebufferManagerDX9::~FramebufferManagerDX9() { FramebufferManagerDX9::~FramebufferManagerDX9() {

View file

@ -396,6 +396,7 @@ DIRECTX9_GPU::DIRECTX9_GPU()
transformDraw_.SetShaderManager(shaderManager_); transformDraw_.SetShaderManager(shaderManager_);
transformDraw_.SetTextureCache(&textureCache_); transformDraw_.SetTextureCache(&textureCache_);
transformDraw_.SetFramebufferManager(&framebufferManager_); transformDraw_.SetFramebufferManager(&framebufferManager_);
framebufferManager_.Init();
framebufferManager_.SetTextureCache(&textureCache_); framebufferManager_.SetTextureCache(&textureCache_);
framebufferManager_.SetShaderManager(shaderManager_); framebufferManager_.SetShaderManager(shaderManager_);
framebufferManager_.SetTransformDrawEngine(&transformDraw_); framebufferManager_.SetTransformDrawEngine(&transformDraw_);

View file

@ -30,7 +30,6 @@
#include "Core/Config.h" #include "Core/Config.h"
#include "Core/System.h" #include "Core/System.h"
#include "Core/Reporting.h" #include "Core/Reporting.h"
#include "Core/ELF/ParamSFO.h"
#include "Core/HLE/sceDisplay.h" #include "Core/HLE/sceDisplay.h"
#include "GPU/ge_constants.h" #include "GPU/ge_constants.h"
#include "GPU/GPUState.h" #include "GPU/GPUState.h"
@ -353,20 +352,9 @@ FramebufferManager::FramebufferManager() :
} }
void FramebufferManager::Init() { void FramebufferManager::Init() {
FramebufferManagerCommon::Init();
CompileDraw2DProgram(); CompileDraw2DProgram();
const std::string gameId = g_paramSFO.GetValueString("DISC_ID");
// This applies a hack to Dangan Ronpa, its demo, and its sequel.
// The game draws solid colors to a small framebuffer, and then reads this directly in VRAM.
// We force this framebuffer to 1x and force download it automatically.
hackForce04154000Download_ = gameId == "NPJH50631" || gameId == "NPJH50372" || gameId == "NPJH90164" || gameId == "NPJH50515";
// And an initial clear. We don't clear per frame as the games are supposed to handle that
// by themselves.
ClearBuffer();
SetLineWidth(); SetLineWidth();
BeginFrame();
} }
FramebufferManager::~FramebufferManager() { FramebufferManager::~FramebufferManager() {

View file

@ -83,7 +83,7 @@ public:
void DestroyAllFBOs(); void DestroyAllFBOs();
void Init(); virtual void Init() override;
void EndFrame(); void EndFrame();
void Resized(); void Resized();
void DeviceLost(); void DeviceLost();