GS/HW: Add target check safety to FFX and Sonic Unleashed CRC hacks

This commit is contained in:
refractionpcsx2 2023-06-21 09:01:56 +01:00
parent 59b0c09443
commit ff5a9e0ea1
1 changed files with 5 additions and 2 deletions

View File

@ -814,7 +814,7 @@ bool GSHwHack::OI_FFX(GSRendererHW& r, GSTexture* rt, GSTexture* ds, GSTextureCa
const u32 ZBP = RZBUF.Block(); const u32 ZBP = RZBUF.Block();
const u32 TBP = RTEX0.TBP0; const u32 TBP = RTEX0.TBP0;
if ((FBP == 0x00d00 || FBP == 0x00000) && ZBP == 0x02100 && RPRIM->TME && TBP == 0x01a00 && RTEX0.PSM == PSMCT16S) if (ds && (FBP == 0x00d00 || FBP == 0x00000) && ZBP == 0x02100 && RPRIM->TME && TBP == 0x01a00 && RTEX0.PSM == PSMCT16S)
{ {
// random battle transition (z buffer written directly, clear it now) // random battle transition (z buffer written directly, clear it now)
GL_INS("OI_FFX ZB clear"); GL_INS("OI_FFX ZB clear");
@ -887,13 +887,16 @@ bool GSHwHack::OI_SonicUnleashed(GSRendererHW& r, GSTexture* rt, GSTexture* ds,
Frame.TBP0 = RFRAME.Block(); Frame.TBP0 = RFRAME.Block();
Frame.PSM = RFRAME.PSM; Frame.PSM = RFRAME.PSM;
if ((!RPRIM->TME) || (GSLocalMemory::m_psm[Texture.PSM].bpp != 16) || (GSLocalMemory::m_psm[Frame.PSM].bpp != 16) || (Texture.TBP0 == Frame.TBP0) || (Frame.TBW != 16 && Texture.TBW != 16)) if ((!rt) || (!RPRIM->TME) || (GSLocalMemory::m_psm[Texture.PSM].bpp != 16) || (GSLocalMemory::m_psm[Frame.PSM].bpp != 16) || (Texture.TBP0 == Frame.TBP0) || (Frame.TBW != 16 && Texture.TBW != 16))
return true; return true;
GL_INS("OI_SonicUnleashed replace draw by a copy"); GL_INS("OI_SonicUnleashed replace draw by a copy");
GSTextureCache::Target* src = g_texture_cache->LookupTarget(Texture, GSVector2i(1, 1), r.GetTextureScaleFactor(), GSTextureCache::RenderTarget); GSTextureCache::Target* src = g_texture_cache->LookupTarget(Texture, GSVector2i(1, 1), r.GetTextureScaleFactor(), GSTextureCache::RenderTarget);
if (!src)
return true;
const GSVector2i src_size(src->m_texture->GetSize()); const GSVector2i src_size(src->m_texture->GetSize());
GSVector2i rt_size(rt->GetSize()); GSVector2i rt_size(rt->GetSize());