diff --git a/src/xenia/cpu/ppc/ppc_emit_memory.cc b/src/xenia/cpu/ppc/ppc_emit_memory.cc index b24172579..36fb1d392 100644 --- a/src/xenia/cpu/ppc/ppc_emit_memory.cc +++ b/src/xenia/cpu/ppc/ppc_emit_memory.cc @@ -8,12 +8,16 @@ */ #include "xenia/cpu/ppc/ppc_emit-private.h" - +#include "xenia/base/cvar.h" #include #include "xenia/base/assert.h" #include "xenia/cpu/ppc/ppc_context.h" #include "xenia/cpu/ppc/ppc_hir_builder.h" +DEFINE_bool(UE_Workaround, true, + "Workaround for Unreal Engine 3 titles to run, try disabling if other games have problems", + "CPU"); + namespace xe { namespace cpu { namespace ppc { @@ -1080,9 +1084,15 @@ int InstrEmit_stfsx(PPCHIRBuilder& f, const InstrData& i) { // https://randomascii.wordpress.com/2018/01/07/finding-a-cpu-design-bug-in-the-xbox-360/ int InstrEmit_dcbf(PPCHIRBuilder& f, const InstrData& i) { - Value* ea = CalculateEA_0(f, i.X.RA, i.X.RB); - f.CacheControl(ea, 128, - CacheControlType::CACHE_CONTOROL_TYPE_DATA_STORE_AND_FLUSH); + //UE Hack + if ((i.X.RB == 11) && (cvars::UE_Workaround) && (f.CompareEQ(f.LoadGPR(i.X.RB), f.LoadConstantUint16(0xFEED)))) { + Value* val = f.Sub(f.LoadGPR(i.X.RB), f.LoadConstantUint64(0x0004)); + f.StoreGPR(i.X.RB, val); + } else { + Value* ea = CalculateEA_0(f, i.X.RA, i.X.RB); + f.CacheControl(ea, 128, + CacheControlType::CACHE_CONTOROL_TYPE_DATA_STORE_AND_FLUSH); + } return 0; }