Add cvar for Unreal Engine 3 workaround

This commit is contained in:
illusion98 2019-10-26 05:18:05 -05:00 committed by illusion
parent 07afd9a377
commit c266b17898
1 changed files with 14 additions and 4 deletions

View File

@ -8,12 +8,16 @@
*/
#include "xenia/cpu/ppc/ppc_emit-private.h"
#include "xenia/base/cvar.h"
#include <stddef.h>
#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_CONTROL_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_CONTROL_TYPE_DATA_STORE_AND_FLUSH);
}
return 0;
}