summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authorFircrestsk8 <Fircrestsk8@gmail.com>2010-08-05 03:24:13 +0000
committerFircrestsk8 <Fircrestsk8@gmail.com>2010-08-05 03:24:13 +0000
commit040a6e1eb33ceccccf3e4c7d790e46657288c9fe (patch)
tree83b671bb2055667c393894ffd8dd97cc812088a8 /Source/Core
parent9e4ff175ec31d761613e385156c3131e09bc4578 (diff)
This commit addresses the Hyrule field slowdown issue in Zelda: Twilight Princess, as discussed in Xtreme2damax's thread: http://forums.dolphin-emu.com/thread-10638.html. It can be activated in the DX9, DX11, and OpenGL plugin GUI's. Enabling the hack while playing other games besides ZTP will likely have either an undesirable or no(more likely) effect.
The code changes disable the usual pipeline flush for certain BP Writes that occur while the minimap is being drawn in Zelda: twilight princess. This significantly increases speed while in hyrule field. The way this is accomplished is described more in depth on page 42 of Xtreme's thread. Big thanks to Xtreme for doing a great job hosting that thread, and Kiesel-stein for initial work on the hack Also, I used the resource editor in Visual studio to generate the GUI code for the DX11 plugin, and some code appeared to be removed, although the behavior of the GUI did not seem to change. Hopefully someone more experienced with resource files (forms?) can double check that no code was damaged git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6057 8ced0084-cf51-0410-be5f-012b33b47a6e
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/VideoCommon/Src/BPStructs.cpp43
-rw-r--r--Source/Core/VideoCommon/Src/VideoConfig.cpp2
-rw-r--r--Source/Core/VideoCommon/Src/VideoConfig.h1
3 files changed, 45 insertions, 1 deletions
diff --git a/Source/Core/VideoCommon/Src/BPStructs.cpp b/Source/Core/VideoCommon/Src/BPStructs.cpp
index 827e182f77..d36110494f 100644
--- a/Source/Core/VideoCommon/Src/BPStructs.cpp
+++ b/Source/Core/VideoCommon/Src/BPStructs.cpp
@@ -34,10 +34,18 @@
using namespace BPFunctions;
+u32 mapTexAddress;
+bool mapTexFound;
+int numWrites;
+
void BPInit()
{
memset(&bpmem, 0, sizeof(bpmem));
bpmem.bpMask = 0xFFFFFF;
+
+ mapTexAddress = 0;
+ numWrites = 0;
+ mapTexFound = false;
}
void RenderToXFB(const BPCmd &bp, const EFBRectangle &rc, float yScale, float xfbLines, u32 xfbAddr, const u32 dstWidth, const u32 dstHeight)
@@ -83,7 +91,40 @@ void BPWritten(const BPCmd& bp)
// FIXME: Hangs load-state, but should fix graphic-heavy games state loading
//s_bpCritical.Enter();
- FlushPipeline();
+ //BEGIN ZTP SPEEDUP HACK CHANGES
+ //This hunk of code disables the usual pipeline flush for certain BP Writes
+ //that occur while the minimap is being drawn in Zelda: twilight princess.
+ //This significantly increases speed while in hyrule field. In depth discussion
+ //on how this Hack came to be can be found at:http://forums.dolphin-emu.com/thread-10638.html
+ //-fircrestsk8
+ if (g_ActiveConfig.bZTPSpeedHack)
+ {
+ if (!mapTexFound)
+ {
+ if (bp.address == BPMEM_TEV_COLOR_ENV || bp.address == BPMEM_TEV_ALPHA_ENV)
+ {
+ numWrites++;
+ if (numWrites >= 100) //seem that if 100 consecutive BP writes are called to either of these addresses in ZTP,
+ { //then it is safe to assume the map texture address is currently loaded into the BP memory
+ mapTexAddress = (bpmem.tex[0].texImage3[0].hex << 5);
+ mapTexFound = true;
+ WARN_LOG(VIDEO, "\nZTP map texture found at address %08x\n", mapTexAddress);
+ }
+ }
+ else
+ numWrites = 0;
+ FlushPipeline();
+ }
+ else
+ {
+ if ( ((bpmem.tex[0].texImage3[0].hex << 5) != mapTexAddress) || !(bpmem.tevorders[0].getEnable(0)) || bp.address == BPMEM_TREF )
+ FlushPipeline();
+ }
+ }
+ else
+ FlushPipeline();
+ //END ZTP SPEEDUP HACK CHANGES
+
((u32*)&bpmem)[bp.address] = bp.newvalue;
switch (bp.address)
diff --git a/Source/Core/VideoCommon/Src/VideoConfig.cpp b/Source/Core/VideoCommon/Src/VideoConfig.cpp
index c45d1ea1f9..272a2217d6 100644
--- a/Source/Core/VideoCommon/Src/VideoConfig.cpp
+++ b/Source/Core/VideoCommon/Src/VideoConfig.cpp
@@ -96,6 +96,7 @@ void VideoConfig::Load(const char *ini_file)
iniFile.Get("Hacks", "EFBScaledCopy", &bCopyEFBScaled, true);
iniFile.Get("Hacks", "FIFOWatermarkTightness", &iFIFOWatermarkTightness, 50);
iniFile.Get("Hacks", "ProjectionHack", &iPhackvalue, 0);
+ iniFile.Get("Hacks", "ZTPSpeedHack", &bZTPSpeedHack, false);
iniFile.Get("Hardware", "Adapter", &iAdapter, 0);
if (iAdapter == -1)
@@ -201,6 +202,7 @@ void VideoConfig::Save(const char *ini_file)
iniFile.Set("Hacks", "EFBToTextureEnable", bCopyEFBToTexture);
iniFile.Set("Hacks", "EFBScaledCopy", bCopyEFBScaled);
iniFile.Set("Hacks", "ProjectionHack", iPhackvalue);
+ iniFile.Set("Hacks", "ZTPSpeedHack", bZTPSpeedHack);
iniFile.Set("Hardware", "Adapter", iAdapter);
diff --git a/Source/Core/VideoCommon/Src/VideoConfig.h b/Source/Core/VideoCommon/Src/VideoConfig.h
index 6b6a5f2b8f..f7ba9ac1c3 100644
--- a/Source/Core/VideoCommon/Src/VideoConfig.h
+++ b/Source/Core/VideoCommon/Src/VideoConfig.h
@@ -125,6 +125,7 @@ struct VideoConfig
float fhackvalue1, fhackvalue2;
bool bProjHack1;
float fAspectRatioHackW, fAspectRatioHackH;
+ bool bZTPSpeedHack;
int iLog; // CONF_ bits
int iSaveTargetId;