From f24be5c3528d520879fc4c825a05e0427af94440 Mon Sep 17 00:00:00 2001 From: gabest11 Date: Sun, 5 Jul 2009 12:58:59 +0000 Subject: [PATCH] GSdx: a few games fixes (one piece grand battle, xenosaga 1, chikyuu boueigun 2) git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1469 96395faa-99c1-11dd-bbfe-3dabce05a288 --- plugins/GSdx/GSRenderer.cpp | 1 + plugins/GSdx/GSRenderer.h | 1 + plugins/GSdx/GSRendererDX.h | 58 +++++++++++++++++++++++++---------- plugins/GSdx/GSRendererHW.h | 12 ++++---- plugins/GSdx/GSRendererSW.cpp | 12 ++++---- plugins/GSdx/GSState.cpp | 14 +++++++++ plugins/GSdx/res/tfx.fx | 4 +-- 7 files changed, 72 insertions(+), 30 deletions(-) diff --git a/plugins/GSdx/GSRenderer.cpp b/plugins/GSdx/GSRenderer.cpp index 38ee242b1e..09fbef3acb 100644 --- a/plugins/GSdx/GSRenderer.cpp +++ b/plugins/GSdx/GSRenderer.cpp @@ -41,6 +41,7 @@ GSRenderer::GSRenderer(uint8* base, bool mt, void (*irq)(), GSDevice* dev) s_dump = !!theApp.GetConfig("dump", 0); s_save = !!theApp.GetConfig("save", 0); s_savez = !!theApp.GetConfig("savez", 0); + s_saven = theApp.GetConfig("saven", 0); } GSRenderer::~GSRenderer() diff --git a/plugins/GSdx/GSRenderer.h b/plugins/GSdx/GSRenderer.h index e52e16d357..e78f762e2b 100644 --- a/plugins/GSdx/GSRenderer.h +++ b/plugins/GSdx/GSRenderer.h @@ -67,6 +67,7 @@ public: bool s_dump; bool s_save; bool s_savez; + int s_saven; public: GSRenderer(uint8* base, bool mt, void (*irq)(), GSDevice* dev); diff --git a/plugins/GSdx/GSRendererDX.h b/plugins/GSdx/GSRendererDX.h index 96bfe7fe40..02eace9673 100644 --- a/plugins/GSdx/GSRendererDX.h +++ b/plugins/GSdx/GSRendererDX.h @@ -91,10 +91,30 @@ public: GSTextureFX::OMBlendSelector om_bsel; om_bsel.abe = !IsOpaque(); - om_bsel.a = context->ALPHA.A; - om_bsel.b = context->ALPHA.B; - om_bsel.c = context->ALPHA.C; - om_bsel.d = context->ALPHA.D; + + if(om_bsel.abe) + { + om_bsel.a = context->ALPHA.A; + om_bsel.b = context->ALPHA.B; + om_bsel.c = context->ALPHA.C; + om_bsel.d = context->ALPHA.D; + + if(env.PABE.PABE) + { + if(om_bsel.a == 0 && om_bsel.b == 1 && om_bsel.c == 0 && om_bsel.d == 1) + { + // this works because with PABE alpha blending is on when alpha >= 0x80, but since the pixel shader + // cannot output anything over 0x80 (== 1.0) blending with 0x80 or turning it off gives the same result + + om_bsel.abe = 0; + } + else + { + ASSERT(0); + } + } + } + om_bsel.wr = (context->FRAME.FBMSK & 0x000000ff) != 0x000000ff; om_bsel.wg = (context->FRAME.FBMSK & 0x0000ff00) != 0x0000ff00; om_bsel.wb = (context->FRAME.FBMSK & 0x00ff0000) != 0x00ff0000; @@ -193,19 +213,25 @@ public: GSTextureFX::PSConstantBuffer ps_cb; - ps_cb.FogColor_AREF = GSVector4((int)env.FOGCOL.FCR, (int)env.FOGCOL.FCG, (int)env.FOGCOL.FCB, 0) / 255; - - switch(ps_sel.atst) + if(ps_sel.fog) { - case ATST_LESS: - ps_cb.FogColor_AREF.a = (float)((int)context->TEST.AREF - 1); - break; - case ATST_GREATER: - ps_cb.FogColor_AREF.a = (float)((int)context->TEST.AREF + 1); - break; - default: - ps_cb.FogColor_AREF.a = (float)(int)context->TEST.AREF; - break; + ps_cb.FogColor_AREF = GSVector4((int)env.FOGCOL.FCR, (int)env.FOGCOL.FCG, (int)env.FOGCOL.FCB, 0) / 255; + } + + if(ps_sel.ate) + { + switch(ps_sel.atst) + { + case ATST_LESS: + ps_cb.FogColor_AREF.a = (float)((int)context->TEST.AREF - 1); + break; + case ATST_GREATER: + ps_cb.FogColor_AREF.a = (float)((int)context->TEST.AREF + 1); + break; + default: + ps_cb.FogColor_AREF.a = (float)(int)context->TEST.AREF; + break; + } } if(tex) diff --git a/plugins/GSdx/GSRendererHW.h b/plugins/GSdx/GSRendererHW.h index 536755108d..d55a7f4d72 100644 --- a/plugins/GSdx/GSRendererHW.h +++ b/plugins/GSdx/GSRendererHW.h @@ -87,7 +87,7 @@ protected: if(s_dump) { - if(s_save) + if(s_save && s_n >= s_saven) { t->Save(format("c:\\temp2\\_%05d_f%I64d_fr%d_%05x_%d.bmp", s_n, m_perfmon.GetFrame(), i, (int)TEX0.TBP0, (int)TEX0.PSM)); } @@ -157,7 +157,7 @@ protected: string s; - if(s_save && tex) + if(s_save && s_n >= s_saven && tex) { s = format("c:\\temp2\\_%05d_f%I64d_tex_%05x_%d_%d%d_%02x_%02x_%02x_%02x.dds", s_n, frame, (int)context->TEX0.TBP0, (int)context->TEX0.PSM, @@ -177,14 +177,14 @@ protected: s_n++; - if(s_save) + if(s_save && s_n >= s_saven) { s = format("c:\\temp2\\_%05d_f%I64d_rt0_%05x_%d.bmp", s_n, frame, context->FRAME.Block(), context->FRAME.PSM); rt->m_texture->Save(s); } - if(s_savez) + if(s_savez && s_n >= s_saven) { s = format("c:\\temp2\\_%05d_f%I64d_rz0_%05x_%d.bmp", s_n, frame, context->ZBUF.Block(), context->ZBUF.PSM); @@ -265,14 +265,14 @@ protected: string s; - if(s_save) + if(s_save && s_n >= s_saven) { s = format("c:\\temp2\\_%05d_f%I64d_rt1_%05x_%d.bmp", s_n, frame, context->FRAME.Block(), context->FRAME.PSM); rt->m_texture->Save(s); } - if(s_savez) + if(s_savez && s_n >= s_saven) { s = format("c:\\temp2\\_%05d_f%I64d_rz1_%05x_%d.bmp", s_n, frame, context->ZBUF.Block(), context->ZBUF.PSM); diff --git a/plugins/GSdx/GSRendererSW.cpp b/plugins/GSdx/GSRendererSW.cpp index 2a5213250e..0302b866de 100644 --- a/plugins/GSdx/GSRendererSW.cpp +++ b/plugins/GSdx/GSRendererSW.cpp @@ -111,7 +111,7 @@ GSTexture* GSRendererSW::GetOutput(int i) if(s_dump) { - if(s_save) + if(s_save && s_n >= s_saven) { m_texture[i]->Save(format("c:\\temp1\\_%05d_f%I64d_fr%d_%05x_%d.bmp", s_n, m_perfmon.GetFrame(), i, (int)TEX0.TBP0, (int)TEX0.PSM)); } @@ -149,7 +149,7 @@ void GSRendererSW::Draw() string s; - if(s_save && PRIM->TME) + if(s_save && s_n >= s_saven && PRIM->TME) { s = format("c:\\temp1\\_%05d_f%I64d_tex_%05x_%d.bmp", s_n, frame, (int)m_context->TEX0.TBP0, (int)m_context->TEX0.PSM); @@ -158,14 +158,14 @@ void GSRendererSW::Draw() s_n++; - if(s_save) + if(s_save && s_n >= s_saven) { s = format("c:\\temp1\\_%05d_f%I64d_rt0_%05x_%d.bmp", s_n, frame, m_context->FRAME.Block(), m_context->FRAME.PSM); m_mem.SaveBMP(s, m_context->FRAME.Block(), m_context->FRAME.FBW, m_context->FRAME.PSM, GetFrameRect().width(), 512);//GetFrameSize(1).cy); } - if(s_savez) + if(s_savez && s_n >= s_saven) { s = format("c:\\temp1\\_%05d_f%I64d_rz0_%05x_%d.bmp", s_n, frame, m_context->ZBUF.Block(), m_context->ZBUF.PSM); @@ -222,14 +222,14 @@ void GSRendererSW::Draw() string s; - if(s_save) + if(s_save && s_n >= s_saven) { s = format("c:\\temp1\\_%05d_f%I64d_rt1_%05x_%d.bmp", s_n, frame, m_context->FRAME.Block(), m_context->FRAME.PSM); m_mem.SaveBMP(s, m_context->FRAME.Block(), m_context->FRAME.FBW, m_context->FRAME.PSM, GetFrameRect().width(), 512);//GetFrameSize(1).cy); } - if(s_savez) + if(s_savez && s_n >= s_saven) { s = format("c:\\temp1\\_%05d_f%I64d_rz1_%05x_%d.bmp", s_n, frame, m_context->ZBUF.Block(), m_context->ZBUF.PSM); diff --git a/plugins/GSdx/GSState.cpp b/plugins/GSdx/GSState.cpp index 62b51bd95e..fc33fec581 100644 --- a/plugins/GSdx/GSState.cpp +++ b/plugins/GSdx/GSState.cpp @@ -1881,6 +1881,19 @@ bool GSC_OnePieceGrandAdventure(const GSFrameInfo& fi, int& skip) return true; } +bool GSC_OnePieceGrandBattle(const GSFrameInfo& fi, int& skip) +{ + if(skip == 0) + { + if(fi.TME && fi.FBP == 0x02d00 && fi.FPSM == PSM_PSMCT16 && (fi.TBP0 == 0x00000 || fi.TBP0 == 0x00f00) && fi.TPSM == PSM_PSMCT16) + { + skip = 4; + } + } + + return true; +} + bool GSC_ICO(const GSFrameInfo& fi, int& skip) { if(skip == 0) @@ -2301,6 +2314,7 @@ bool GSState::IsBadFrame(int& skip) map[CRC::BullyCC] = GSC_BullyCC; map[CRC::SoTC] = GSC_SoTC; map[CRC::OnePieceGrandAdventure] = GSC_OnePieceGrandAdventure; + map[CRC::OnePieceGrandBattle] = GSC_OnePieceGrandBattle; map[CRC::ICO] = GSC_ICO; map[CRC::GT4] = GSC_GT4; map[CRC::WildArms5] = GSC_WildArms5; diff --git a/plugins/GSdx/res/tfx.fx b/plugins/GSdx/res/tfx.fx index 1ae604a790..3c8b46f27c 100644 --- a/plugins/GSdx/res/tfx.fx +++ b/plugins/GSdx/res/tfx.fx @@ -198,7 +198,7 @@ float4 wrapuv(float4 uv) else if(PS_WMS == 3) { #if SHADER_MODEL >= 0x400 - uv.xz = (float2)(((int2)(uv * WH.xyxy).xz & MskFix.xx) | MskFix.zz) / WH.xy; + uv.xz = (float2)(((int2)(uv.xz * WH.xx) & MskFix.xx) | MskFix.zz) / WH.xx; #elif SHADER_MODEL <= 0x300 uv.x = tex1D(UMSKFIX, uv.x); uv.z = tex1D(UMSKFIX, uv.z); @@ -220,7 +220,7 @@ float4 wrapuv(float4 uv) else if(PS_WMT == 3) { #if SHADER_MODEL >= 0x400 - uv.yw = (float2)(((int2)(uv * WH.xyxy).yw & MskFix.yy) | MskFix.ww) / WH.xy; + uv.yw = (float2)(((int2)(uv.yw * WH.yy) & MskFix.yy) | MskFix.ww) / WH.yy; #elif SHADER_MODEL <= 0x300 uv.y = tex1D(VMSKFIX, uv.y); uv.w = tex1D(VMSKFIX, uv.w);