Skip to content
Permalink
Browse files

gsdx-hw: Add an OI hack for Sonic Unleashed.

It will allow to render the shadows properly.

Rendering pattern is:
Save RG channel with a kind of a TS (replaced by a copy in this hack),
compute shadow in RG,
save result in alpha with a TS,
Restore RG channel that we previously copied to render shadows.
  • Loading branch information...
lightningterror committed May 14, 2019
1 parent 40929a4 commit b19804190e427a56d010457949051823256f98b6
Showing with 34 additions and 0 deletions.
  1. +33 −0 plugins/GSdx/Renderers/HW/GSRendererHW.cpp
  2. +1 −0 plugins/GSdx/Renderers/HW/GSRendererHW.h
@@ -1273,6 +1273,7 @@ GSRendererHW::Hacks::Hacks()
m_oi_list.push_back(HackEntry<OI_Ptr>(CRC::FFX, CRC::RegionCount, &GSRendererHW::OI_FFX));
m_oi_list.push_back(HackEntry<OI_Ptr>(CRC::MetalSlug6, CRC::RegionCount, &GSRendererHW::OI_MetalSlug6));
m_oi_list.push_back(HackEntry<OI_Ptr>(CRC::RozenMaidenGebetGarden, CRC::RegionCount, &GSRendererHW::OI_RozenMaidenGebetGarden));
m_oi_list.push_back(HackEntry<OI_Ptr>(CRC::SonicUnleashed, CRC::RegionCount, &GSRendererHW::OI_SonicUnleashed));
m_oi_list.push_back(HackEntry<OI_Ptr>(CRC::StarWarsForceUnleashed, CRC::RegionCount, &GSRendererHW::OI_StarWarsForceUnleashed));
m_oi_list.push_back(HackEntry<OI_Ptr>(CRC::SuperManReturns, CRC::RegionCount, &GSRendererHW::OI_SuperManReturns));
m_oi_list.push_back(HackEntry<OI_Ptr>(CRC::ArTonelico2, CRC::RegionCount, &GSRendererHW::OI_ArTonelico2));
@@ -1665,6 +1666,38 @@ bool GSRendererHW::OI_RozenMaidenGebetGarden(GSTexture* rt, GSTexture* ds, GSTex
return true;
}

bool GSRendererHW::OI_SonicUnleashed(GSTexture* rt, GSTexture* ds, GSTextureCache::Source* t)
{
// Rendering pattern is:
// Save RG channel with a kind of a TS (replaced by a copy in this hack),
// compute shadow in RG,
// save result in alpha with a TS,
// Restore RG channel that we previously copied to render shadows.

GIFRegTEX0 Texture = m_context->TEX0;

GIFRegTEX0 Frame;
Frame.TBW = m_context->FRAME.FBW;
Frame.TBP0 = m_context->FRAME.FBP;
Frame.TBP0 = m_context->FRAME.Block();
Frame.PSM = m_context->FRAME.PSM;

if ((!PRIM->TME) || (GSLocalMemory::m_psm[Texture.PSM].bpp != 16) || (GSLocalMemory::m_psm[Frame.PSM].bpp != 16))
return true;

if ((Texture.TBP0 == Frame.TBP0) || (Frame.TBW != 16 && Texture.TBW != 16))
return true;

GSTextureCache::Target* src = m_tc->LookupTarget(Texture, m_width, m_height, GSTextureCache::RenderTarget, true);
GSVector4 sRect(0, 0, 1, 1);
GSVector4 dRect(0, 0, m_width, m_height);

m_dev->StretchRect(src->m_texture, sRect, rt, dRect, true, true, true, false);
GL_INS("OI_SonicUnleashed replace draw by a copy");

return false;
}

bool GSRendererHW::OI_StarWarsForceUnleashed(GSTexture* rt, GSTexture* ds, GSTextureCache::Source* t)
{
uint32 FBP = m_context->FRAME.Block();
@@ -56,6 +56,7 @@ class GSRendererHW : public GSRenderer
bool OI_FFX(GSTexture* rt, GSTexture* ds, GSTextureCache::Source* t);
bool OI_MetalSlug6(GSTexture* rt, GSTexture* ds, GSTextureCache::Source* t);
bool OI_RozenMaidenGebetGarden(GSTexture* rt, GSTexture* ds, GSTextureCache::Source* t);
bool OI_SonicUnleashed(GSTexture* rt, GSTexture* ds, GSTextureCache::Source* t);
bool OI_StarWarsForceUnleashed(GSTexture* rt, GSTexture* ds, GSTextureCache::Source* t);
bool OI_PointListPalette(GSTexture* rt, GSTexture* ds, GSTextureCache::Source* t);
bool OI_SuperManReturns(GSTexture* rt, GSTexture* ds, GSTextureCache::Source* t);

0 comments on commit b198041

Please sign in to comment.
You can’t perform that action at this time.