Skip to content

Commit

Permalink
Merge pull request #4780 from booto/dcbz_hack
Browse files Browse the repository at this point in the history
Hack to stop dcbz/dcbi over low MEM1 trashing memory.
  • Loading branch information
Parlane committed Jan 29, 2017
2 parents ba42a88 + 2fbdf2a commit a8c51d9
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 3 deletions.
4 changes: 4 additions & 0 deletions Data/Sys/GameSettings/SCY.ini
Expand Up @@ -2,6 +2,8 @@

[Core]
# Values set here will override the main Dolphin settings.
MMU = 1
LowDCBZHack = 1

[EmuState]
# The Emulation State. 1 is worst, 5 is best, 0 is not set.
Expand All @@ -17,3 +19,5 @@ EmulationIssues =
[ActionReplay]
# Add action replay cheats here.

[Video_Settings]
SafeTextureCacheColorSamples = 2048
23 changes: 23 additions & 0 deletions Data/Sys/GameSettings/SQI.ini
@@ -0,0 +1,23 @@
# SQIE4Q, SQIP4Q - Disney Infinity

[Core]
# Values set here will override the main Dolphin settings.
MMU = 1
LowDCBZHack = 1

[EmuState]
# The Emulation State. 1 is worst, 5 is best, 0 is not set.
EmulationStateId = 3
EmulationIssues =

[OnLoad]
# Add memory patches to be loaded once on boot here.

[OnFrame]
# Add memory patches to be applied every frame here.

[ActionReplay]
# Add action replay cheats here.

[Video_Settings]
SafeTextureCacheColorSamples = 2048
3 changes: 3 additions & 0 deletions Source/Core/Core/BootManager.cpp
Expand Up @@ -73,6 +73,7 @@ struct ConfigCache
bool bAccurateNaNs;
bool bMMU;
bool bDCBZOFF;
bool bLowDCBZHack;
bool m_EnableJIT;
bool bSyncGPU;
bool bFastDiscSpeed;
Expand Down Expand Up @@ -145,6 +146,7 @@ void ConfigCache::RestoreConfig(SConfig* config)
config->bAccurateNaNs = bAccurateNaNs;
config->bMMU = bMMU;
config->bDCBZOFF = bDCBZOFF;
config->bLowDCBZHack = bLowDCBZHack;
config->m_DSPEnableJIT = m_EnableJIT;
config->bSyncGPU = bSyncGPU;
config->bFastDiscSpeed = bFastDiscSpeed;
Expand Down Expand Up @@ -248,6 +250,7 @@ bool BootCore(const std::string& _rFilename)
core_section->Get("AccurateNaNs", &StartUp.bAccurateNaNs, StartUp.bAccurateNaNs);
core_section->Get("MMU", &StartUp.bMMU, StartUp.bMMU);
core_section->Get("DCBZ", &StartUp.bDCBZOFF, StartUp.bDCBZOFF);
core_section->Get("LowDCBZHack", &StartUp.bLowDCBZHack, StartUp.bLowDCBZHack);
core_section->Get("SyncGPU", &StartUp.bSyncGPU, StartUp.bSyncGPU);
core_section->Get("FastDiscSpeed", &StartUp.bFastDiscSpeed, StartUp.bFastDiscSpeed);
core_section->Get("DSPHLE", &StartUp.bDSPHLE, StartUp.bDSPHLE);
Expand Down
2 changes: 2 additions & 0 deletions Source/Core/Core/ConfigManager.cpp
Expand Up @@ -578,6 +578,7 @@ void SConfig::LoadCoreSettings(IniFile& ini)
core->Get("SyncGpuOverclock", &fSyncGpuOverclock, 1.0f);
core->Get("FastDiscSpeed", &bFastDiscSpeed, false);
core->Get("DCBZ", &bDCBZOFF, false);
core->Get("LowDCBZHack", &bLowDCBZHack, false);
core->Get("FPRF", &bFPRF, false);
core->Get("AccurateNaNs", &bAccurateNaNs, false);
core->Get("EmulationSpeed", &m_EmulationSpeed, 1.0f);
Expand Down Expand Up @@ -725,6 +726,7 @@ void SConfig::LoadDefaults()
bAccurateNaNs = false;
bMMU = false;
bDCBZOFF = false;
bLowDCBZHack = false;
iBBDumpPort = -1;
bSyncGPU = false;
bFastDiscSpeed = false;
Expand Down
1 change: 1 addition & 0 deletions Source/Core/Core/ConfigManager.h
Expand Up @@ -106,6 +106,7 @@ struct SConfig : NonCopyable

bool bMMU = false;
bool bDCBZOFF = false;
bool bLowDCBZHack = false;
int iBBDumpPort = 0;
bool bFastDiscSpeed = false;

Expand Down
13 changes: 10 additions & 3 deletions Source/Core/Core/PowerPC/Interpreter/Interpreter_LoadStore.cpp
Expand Up @@ -362,11 +362,18 @@ void Interpreter::dcbtst(UGeckoInstruction inst)

void Interpreter::dcbz(UGeckoInstruction inst)
{
// TODO: Implement some sort of L2 emulation.
// DCBZOFF is a hack to fix certain games which would otherwise require
// accurate L2 emulation.
if (!SConfig::GetInstance().bDCBZOFF)
PowerPC::ClearCacheLine(Helper_Get_EA_X(inst) & (~31));
if (SConfig::GetInstance().bDCBZOFF)
return;

u32 dcbz_addr = Helper_Get_EA_X(inst);
// Hack to stop dcbz/dcbi over low MEM1 trashing memory.
if (SConfig::GetInstance().bLowDCBZHack && (dcbz_addr < 0x80008000) && (dcbz_addr >= 0x80000000))
return;

// TODO: Implement some sort of L2 emulation.
PowerPC::ClearCacheLine(dcbz_addr & (~31));
}

// eciwx/ecowx technically should access the specified device
Expand Down
1 change: 1 addition & 0 deletions Source/Core/Core/PowerPC/Jit64/Jit_LoadStore.cpp
Expand Up @@ -330,6 +330,7 @@ void Jit64::dcbz(UGeckoInstruction inst)
JITDISABLE(bJITLoadStoreOff);
if (SConfig::GetInstance().bDCBZOFF)
return;
FALLBACK_IF(SConfig::GetInstance().bLowDCBZHack);

int a = inst.RA;
int b = inst.RB;
Expand Down

0 comments on commit a8c51d9

Please sign in to comment.