From 08f7bd2dc3c741ecc88f105c4679eed83b9291cc Mon Sep 17 00:00:00 2001 From: Gregory Hainaut Date: Mon, 16 May 2016 10:55:02 +0200 Subject: [PATCH] gsdx: add crc hack for Ar tonelico 2 It would requires some texture dynamic width convert shaders. So as a quick solution, let's add a new CRC hack. For issue #1362 (granted the CRC is correct) --- plugins/GSdx/GSCrc.cpp | 1 + plugins/GSdx/GSCrc.h | 1 + plugins/GSdx/GSRendererHW.cpp | 33 +++++++++++++++++++++++++++++++++ plugins/GSdx/GSRendererHW.h | 1 + 4 files changed, 36 insertions(+) diff --git a/plugins/GSdx/GSCrc.cpp b/plugins/GSdx/GSCrc.cpp index f737194879..9f5a73d5fc 100644 --- a/plugins/GSdx/GSCrc.cpp +++ b/plugins/GSdx/GSCrc.cpp @@ -26,6 +26,7 @@ CRC::Game CRC::m_games[] = { {0x00000000, NoTitle, NoRegion, 0}, + {0xF46142D3, ArTonelico2, NoRegion, 0}, {0x2113EA2E, MetalSlug6, JP, 0}, {0x42E05BAF, TomoyoAfter, JP, PointListPalette}, {0x7800DC84, Clannad, JP, PointListPalette}, diff --git a/plugins/GSdx/GSCrc.h b/plugins/GSdx/GSCrc.h index c47f8ec6f2..6a36da9f92 100644 --- a/plugins/GSdx/GSCrc.h +++ b/plugins/GSdx/GSCrc.h @@ -27,6 +27,7 @@ public: enum Title { NoTitle, + ArTonelico2, MetalSlug6, TomoyoAfter, Clannad, diff --git a/plugins/GSdx/GSRendererHW.cpp b/plugins/GSdx/GSRendererHW.cpp index 950c78b465..af05eaf327 100644 --- a/plugins/GSdx/GSRendererHW.cpp +++ b/plugins/GSdx/GSRendererHW.cpp @@ -745,6 +745,7 @@ GSRendererHW::Hacks::Hacks() m_oi_list.push_back(HackEntry(CRC::SpyroEternalNight, CRC::RegionCount, &GSRendererHW::OI_SpyroEternalNight)); m_oi_list.push_back(HackEntry(CRC::TalesOfLegendia, CRC::RegionCount, &GSRendererHW::OI_TalesOfLegendia)); m_oi_list.push_back(HackEntry(CRC::SuperManReturns, CRC::RegionCount, &GSRendererHW::OI_SuperManReturns)); + m_oi_list.push_back(HackEntry(CRC::ArTonelico2, CRC::RegionCount, &GSRendererHW::OI_ArTonelico2)); if (!can_handle_depth) m_oi_list.push_back(HackEntry(CRC::SMTNocturne, CRC::RegionCount, &GSRendererHW::OI_SMTNocturne)); @@ -1462,6 +1463,38 @@ bool GSRendererHW::OI_SuperManReturns(GSTexture* rt, GSTexture* ds, GSTextureCac return false; } +bool GSRendererHW::OI_ArTonelico2(GSTexture* rt, GSTexture* ds, GSTextureCache::Source* t) +{ + // world map clipping + // + // The bad draw call is a sprite rendering to clear the z buffer + + /* + Depth buffer description + * width is 10 pages + * texture/scissor size is 640x448 + * depth is 16 bits so it writes 70 (10w * 7h) pages of data. + + following draw calls will use the buffer as 6 pages width with a scissor + test of 384x672. So the above texture can be seen as a + + * texture width: 6 pages * 64 pixels/page = 384 + * texture height: 70/6 pages * 64 pixels/page =746 + + So as you can see the GS issue a write of 640x448 but actually it + expects to clean a 384x746 area. Ideally the fix will transform the + buffer to adapt the page width properly. + */ + + GSVertex* v = &m_vertex.buff[0]; + + if (m_vertex.next == 2 && !PRIM->TME && m_context->FRAME.FBW == 10 && v->XYZ.Z == 0 && m_context->TEST.ZTST == ZTST_ALWAYS) { + GL_INS("OI_ArTonelico2"); + m_dev->ClearDepth(ds, 0); + } + + return true; +} // OO (others output?) hacks: invalidate extra local memory after the draw call diff --git a/plugins/GSdx/GSRendererHW.h b/plugins/GSdx/GSRendererHW.h index fa2454c7ba..4f0c07dfd8 100644 --- a/plugins/GSdx/GSRendererHW.h +++ b/plugins/GSdx/GSRendererHW.h @@ -68,6 +68,7 @@ private: bool OI_SMTNocturne(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); + bool OI_ArTonelico2(GSTexture* rt, GSTexture* ds, GSTextureCache::Source* t); void OO_DBZBT2(); void OO_MajokkoALaMode2();