From f5f50741727d45c3280feacc13e06b7e71118e97 Mon Sep 17 00:00:00 2001 From: "sudonim1@gmail.com" Date: Tue, 19 Jun 2012 01:12:01 +0000 Subject: [PATCH] GSDX: Put the sprite hack back in because apparently it wasn't fixed. git-svn-id: http://pcsx2.googlecode.com/svn/trunk@5312 96395faa-99c1-11dd-bbfe-3dabce05a288 --- plugins/GSdx/GSDeviceDX.h | 3 ++- plugins/GSdx/GSRendererDX.cpp | 1 + plugins/GSdx/GSSettingsDlg.cpp | 7 +++++++ plugins/GSdx/GSTextureCache.cpp | 11 +++++++++++ plugins/GSdx/GSTextureCache.h | 2 ++ plugins/GSdx/GSTextureFX11.cpp | 4 +++- plugins/GSdx/GSTextureFX9.cpp | 4 +++- plugins/GSdx/GSdx.rc | 5 +++-- plugins/GSdx/res/tfx.fx | 3 +++ plugins/GSdx/resource.h | 1 + 10 files changed, 36 insertions(+), 5 deletions(-) diff --git a/plugins/GSdx/GSDeviceDX.h b/plugins/GSdx/GSDeviceDX.h index 697bfe8398..b42c54a52a 100644 --- a/plugins/GSdx/GSDeviceDX.h +++ b/plugins/GSdx/GSDeviceDX.h @@ -174,12 +174,13 @@ public: uint32 ltf:1; uint32 colclip:2; uint32 date:2; + uint32 spritehack:1; }; uint32 key; }; - operator uint32() {return key & 0x3ffffff;} + operator uint32() {return key & 0x7ffffff;} PSSelector() : key(0) {} }; diff --git a/plugins/GSdx/GSRendererDX.cpp b/plugins/GSdx/GSRendererDX.cpp index 4592ab5956..6c75f7e06b 100644 --- a/plugins/GSdx/GSRendererDX.cpp +++ b/plugins/GSdx/GSRendererDX.cpp @@ -294,6 +294,7 @@ void GSRendererDX::DrawPrims(GSTexture* rt, GSTexture* ds, GSTextureCache::Sourc ps_sel.tcc = context->TEX0.TCC; ps_sel.ltf = bilinear && !(ps_sel.fmt <= 2 && ps_sel.wms < 3 && ps_sel.wmt < 3); ps_sel.rt = tex->m_target; + ps_sel.spritehack = tex->m_spritehack_t; int w = tex->m_texture->GetWidth(); int h = tex->m_texture->GetHeight(); diff --git a/plugins/GSdx/GSSettingsDlg.cpp b/plugins/GSdx/GSSettingsDlg.cpp index e1c8abb47a..357b3d217b 100644 --- a/plugins/GSdx/GSSettingsDlg.cpp +++ b/plugins/GSdx/GSSettingsDlg.cpp @@ -420,6 +420,7 @@ void GSHacksDlg::OnInit() CheckDlgButton(m_hWnd, IDC_ALPHAHACK, theApp.GetConfig("UserHacks_AlphaHack", 0)); CheckDlgButton(m_hWnd, IDC_OFFSETHACK, theApp.GetConfig("UserHacks_HalfPixelOffset", 0)); + CheckDlgButton(m_hWnd, IDC_SPRITEHACK, theApp.GetConfig("UserHacks_SpriteHack", 0)); CheckDlgButton(m_hWnd, IDC_WILDHACK, theApp.GetConfig("UserHacks_WildHack", 0)); CheckDlgButton(m_hWnd, IDC_AGGRESSIVECRC, theApp.GetConfig("UserHacks_AggressiveCRC", 0)); CheckDlgButton(m_hWnd, IDC_CHECK_DISABLE_ALL_HACKS, theApp.GetConfig("UserHacks_DisableCrcHacks", 0)); @@ -469,6 +470,11 @@ bool GSHacksDlg::OnMessage(UINT message, WPARAM wParam, LPARAM lParam) case IDC_OFFSETHACK: helpstr = "Halfpixel\n\nMight fix some misaligned fog, bloom, or blend effect."; break; + case IDC_SPRITEHACK: + helpstr = "Sprite Hack\n\nHelps getting rid of black inner lines in some filtered sprites." + " Half option is the preferred one. Use it for Mana Khemia or ArTonelico for example." + " Full can be used for Tales of Destiny."; + break; case IDC_WILDHACK: helpstr = "WildArms\n\nLowers the GS precision to avoid gaps between pixels when" " upscaling. Full option fixes the text on WildArms games, while Half option might improve portraits" @@ -512,6 +518,7 @@ bool GSHacksDlg::OnMessage(UINT message, WPARAM wParam, LPARAM lParam) theApp.SetConfig("UserHacks_MSAA", cb2msaa[(int)SendMessage(GetDlgItem(m_hWnd, IDC_MSAACB), CB_GETCURSEL, 0, 0)]); theApp.SetConfig("UserHacks_AlphaHack", (int)IsDlgButtonChecked(m_hWnd, IDC_ALPHAHACK)); theApp.SetConfig("UserHacks_HalfPixelOffset", (int)IsDlgButtonChecked(m_hWnd, IDC_OFFSETHACK)); + theApp.SetConfig("UserHacks_SpriteHack", (int)IsDlgButtonChecked(m_hWnd, IDC_SPRITEHACK)); theApp.SetConfig("UserHacks_SkipDraw", (int)SendMessage(GetDlgItem(m_hWnd, IDC_SKIPDRAWHACK), UDM_GETPOS, 0, 0)); theApp.SetConfig("UserHacks_WildHack", (int)IsDlgButtonChecked(m_hWnd, IDC_WILDHACK)); theApp.SetConfig("UserHacks_AggressiveCRC", (int)IsDlgButtonChecked(m_hWnd, IDC_AGGRESSIVECRC)); diff --git a/plugins/GSdx/GSTextureCache.cpp b/plugins/GSdx/GSTextureCache.cpp index 7d2561f0a3..418a9005c3 100644 --- a/plugins/GSdx/GSTextureCache.cpp +++ b/plugins/GSdx/GSTextureCache.cpp @@ -25,6 +25,7 @@ GSTextureCache::GSTextureCache(GSRenderer* r) : m_renderer(r) { + m_spritehack = !!theApp.GetConfig("UserHacks", 0) ? theApp.GetConfig("UserHacks_SpriteHack", 0) : 0; UserHacks_HalfPixelOffset = !!theApp.GetConfig("UserHacks", 0) && !!theApp.GetConfig("UserHacks_HalfPixelOffset", 0); @@ -590,6 +591,16 @@ GSTextureCache::Source* GSTextureCache::CreateSource(const GIFRegTEX0& TEX0, con bool hack = false; + if(m_spritehack && (TEX0.PSM == PSM_PSMT8 || TEX0.PSM == PSM_PSMT8H)) + { + src->m_spritehack_t = true; + + if(m_spritehack == 2 && TEX0.CPSM != PSM_PSMCT16) + src->m_spritehack_t = false; + } + else + src->m_spritehack_t = false; + if (dst) { // TODO: clean up this mess diff --git a/plugins/GSdx/GSTextureCache.h b/plugins/GSdx/GSTextureCache.h index fd53f1d1f8..904a00494c 100644 --- a/plugins/GSdx/GSTextureCache.h +++ b/plugins/GSdx/GSTextureCache.h @@ -63,6 +63,7 @@ public: bool m_target; bool m_complete; bool m_repeating; + bool m_spritehack_t; vector* m_p2t; public: @@ -106,6 +107,7 @@ protected: SourceMap m_src; list m_dst[2]; bool m_paltex; + int m_spritehack; uint8* m_temp; virtual Source* CreateSource(const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA, Target* t = NULL); diff --git a/plugins/GSdx/GSTextureFX11.cpp b/plugins/GSdx/GSTextureFX11.cpp index 5e7171b294..84189a7d85 100644 --- a/plugins/GSdx/GSTextureFX11.cpp +++ b/plugins/GSdx/GSTextureFX11.cpp @@ -177,7 +177,7 @@ void GSDevice11::SetupPS(PSSelector sel, const PSConstantBuffer* cb, PSSamplerSe if(i == m_ps.end()) { - string str[15]; + string str[16]; str[0] = format("%d", sel.fst); str[1] = format("%d", sel.wms); @@ -194,6 +194,7 @@ void GSDevice11::SetupPS(PSSelector sel, const PSConstantBuffer* cb, PSSamplerSe str[12] = format("%d", sel.ltf); str[13] = format("%d", sel.colclip); str[14] = format("%d", sel.date); + str[15] = format("%d", sel.spritehack); D3D11_SHADER_MACRO macro[] = { @@ -212,6 +213,7 @@ void GSDevice11::SetupPS(PSSelector sel, const PSConstantBuffer* cb, PSSamplerSe {"PS_LTF", str[12].c_str()}, {"PS_COLCLIP", str[13].c_str()}, {"PS_DATE", str[14].c_str()}, + {"PS_SPRITEHACK", str[15].c_str()}, {NULL, NULL}, }; diff --git a/plugins/GSdx/GSTextureFX9.cpp b/plugins/GSdx/GSTextureFX9.cpp index 6173334121..a8e0d913b3 100644 --- a/plugins/GSdx/GSTextureFX9.cpp +++ b/plugins/GSdx/GSTextureFX9.cpp @@ -135,7 +135,7 @@ void GSDevice9::SetupPS(PSSelector sel, const PSConstantBuffer* cb, PSSamplerSel if(i == m_ps.end()) { - string str[14]; + string str[15]; str[0] = format("%d", sel.fst); str[1] = format("%d", sel.wms); @@ -151,6 +151,7 @@ void GSDevice9::SetupPS(PSSelector sel, const PSConstantBuffer* cb, PSSamplerSel str[11] = format("%d", sel.ltf); str[12] = format("%d", sel.colclip); str[13] = format("%d", sel.date); + str[14] = format("%d", sel.spritehack); D3DXMACRO macro[] = { @@ -168,6 +169,7 @@ void GSDevice9::SetupPS(PSSelector sel, const PSConstantBuffer* cb, PSSamplerSel {"PS_LTF", str[11].c_str()}, {"PS_COLCLIP", str[12].c_str()}, {"PS_DATE", str[13].c_str()}, + {"PS_SPRITEHACK", str[14].c_str()}, {NULL, NULL}, }; diff --git a/plugins/GSdx/GSdx.rc b/plugins/GSdx/GSdx.rc index 289edd55d2..0b4e191fc8 100644 --- a/plugins/GSdx/GSdx.rc +++ b/plugins/GSdx/GSdx.rc @@ -88,11 +88,12 @@ BEGIN CONTROL "",IDC_SKIPDRAWHACK,"msctls_updown32",UDS_SETBUDDYINT | UDS_AUTOBUDDY | UDS_ARROWKEYS,68,35,10,14 CONTROL "Alpha",IDC_ALPHAHACK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,54,34,10 CONTROL "Half-pixel Offset",IDC_OFFSETHACK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,71,65,10 + CONTROL "Sprite",IDC_SPRITEHACK,"Button",BS_AUTO3STATE | WS_TABSTOP,14,88,35,10 LTEXT "USE AT YOUR OWN RISK!",IDC_STATIC,7,182,84,8,WS_DISABLED COMBOBOX IDC_MSAACB,35,18,44,63,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - CONTROL "WildArmsOffset",IDC_WILDHACK,"Button",BS_AUTO3STATE | WS_TABSTOP,14,88,64,10 + CONTROL "WildArmsOffset",IDC_WILDHACK,"Button",BS_AUTO3STATE | WS_TABSTOP,14,105,64,10 LTEXT "TEXT_GOES_HERE",IDC_HACK_DESCRIPTION,92,20,209,145 - CONTROL "Aggressive-CRC",IDC_AGGRESSIVECRC,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,105,66,10 + CONTROL "Aggressive-CRC",IDC_AGGRESSIVECRC,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,122,66,10 CONTROL "Disable CRCs",IDC_CHECK_DISABLE_ALL_HACKS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,157,58,10 END diff --git a/plugins/GSdx/res/tfx.fx b/plugins/GSdx/res/tfx.fx index fe6d285ea8..7ec53d56aa 100644 --- a/plugins/GSdx/res/tfx.fx +++ b/plugins/GSdx/res/tfx.fx @@ -33,6 +33,7 @@ #define PS_LTF 1 #define PS_COLCLIP 0 #define PS_DATE 0 +#define PS_SPRITEHACK 0 #endif struct VS_INPUT @@ -504,7 +505,9 @@ void atst(float4 c) } else if(PS_ATST == 2) // l { + #if PS_SPRITEHACK == 0 clip(AREF - a); + #endif } else if(PS_ATST == 3) // le { diff --git a/plugins/GSdx/resource.h b/plugins/GSdx/resource.h index c9a81b5de2..0e9646696d 100644 --- a/plugins/GSdx/resource.h +++ b/plugins/GSdx/resource.h @@ -75,6 +75,7 @@ #define IDC_SKIPDRAWHACKEDIT 2048 #define IDC_STATIC10 2049 #define IDC_HACKDISABLED 2050 +#define IDC_SPRITEHACK 2051 #define IDRESET 2052 #define IDC_SATURATION_SLIDER 2053 #define IDC_BRIGHTNESS_SLIDER 2055