diff --git a/Source/Core/Core/PowerPC/Jit64/Jit.cpp b/Source/Core/Core/PowerPC/Jit64/Jit.cpp index b266962324..9f45027415 100644 --- a/Source/Core/Core/PowerPC/Jit64/Jit.cpp +++ b/Source/Core/Core/PowerPC/Jit64/Jit.cpp @@ -806,26 +806,8 @@ const u8* Jit64::DoJit(u32 em_address, PPCAnalyst::CodeBuffer* code_buf, JitBloc SetJumpTarget(noExtIntEnable); } - u32 function = HLE::GetFirstFunctionIndex(op.address); - if (function != 0) - { - HLE::HookType type = HLE::GetFunctionTypeByIndex(function); - if (type == HLE::HookType::Start || type == HLE::HookType::Replace) - { - HLE::HookFlag flags = HLE::GetFunctionFlagsByIndex(function); - if (HLE::IsEnabled(flags)) - { - HLEFunction(function); - if (type == HLE::HookType::Replace) - { - MOV(32, R(RSCRATCH), PPCSTATE(npc)); - js.downcountAmount += js.st.numCycles; - WriteExitDestInRSCRATCH(); - break; - } - } - } - } + if (HandleFunctionHooking(op.address)) + break; if (!op.skip) { @@ -1042,3 +1024,18 @@ void Jit64::IntializeSpeculativeConstants() } } } + +bool Jit64::HandleFunctionHooking(u32 address) +{ + return HLE::ReplaceFunctionIfPossible(address, [&](u32 function, HLE::HookType type) { + HLEFunction(function); + + if (type != HLE::HookType::Replace) + return false; + + MOV(32, R(RSCRATCH), PPCSTATE(npc)); + js.downcountAmount += js.st.numCycles; + WriteExitDestInRSCRATCH(); + return true; + }); +} diff --git a/Source/Core/Core/PowerPC/Jit64/Jit.h b/Source/Core/Core/PowerPC/Jit64/Jit.h index 634eb68b6c..ce8de7509b 100644 --- a/Source/Core/Core/PowerPC/Jit64/Jit.h +++ b/Source/Core/Core/PowerPC/Jit64/Jit.h @@ -234,6 +234,8 @@ private: static void InitializeInstructionTables(); void CompileInstruction(PPCAnalyst::CodeOp& op); + bool HandleFunctionHooking(u32 address); + void AllocStack(); void FreeStack();