diff options
| author | Lioncash <mathew1800@gmail.com> | 2018-05-16 18:16:59 -0400 |
|---|---|---|
| committer | Lioncash <mathew1800@gmail.com> | 2018-05-16 18:56:40 -0400 |
| commit | f3c13402e80aa390a014fc767a6b80d7c91c7e7c (patch) | |
| tree | d38345a948c340c1f7e049f8890ef2862a077bac /Source/Core | |
| parent | 4b25538f2f45a61cb345b00662698846dc454f4e (diff) | |
Interpreter: Factor function hooking code out of SingleStepInner()
Diffstat (limited to 'Source/Core')
| -rw-r--r-- | Source/Core/Core/PowerPC/Interpreter/Interpreter.cpp | 33 | ||||
| -rw-r--r-- | Source/Core/Core/PowerPC/Interpreter/Interpreter.h | 2 |
2 files changed, 11 insertions, 24 deletions
diff --git a/Source/Core/Core/PowerPC/Interpreter/Interpreter.cpp b/Source/Core/Core/PowerPC/Interpreter/Interpreter.cpp index 946a3d8101..f88936654f 100644 --- a/Source/Core/Core/PowerPC/Interpreter/Interpreter.cpp +++ b/Source/Core/Core/PowerPC/Interpreter/Interpreter.cpp @@ -99,32 +99,17 @@ static void Trace(UGeckoInstruction& inst) PowerPC::ppcState.spr[8], regs.c_str(), inst.hex, ppc_inst.c_str()); } -int Interpreter::SingleStepInner() +bool Interpreter::HandleFunctionHooking(u32 address) { - u32 function = HLE::GetFirstFunctionIndex(PC); - 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::Start) - { - // Run the original. - function = 0; - } - } - else - { - function = 0; - } - } - } + return HLE::ReplaceFunctionIfPossible(address, [](u32 function, HLE::HookType type) { + HLEFunction(function); + return type != HLE::HookType::Start; + }); +} - if (function == 0) +int Interpreter::SingleStepInner() +{ + if (!HandleFunctionHooking(PC)) { #ifdef USE_GDBSTUB if (gdb_active() && gdb_bp_x(PC)) diff --git a/Source/Core/Core/PowerPC/Interpreter/Interpreter.h b/Source/Core/Core/PowerPC/Interpreter/Interpreter.h index 863dc0cb5b..dd4c88d94c 100644 --- a/Source/Core/Core/PowerPC/Interpreter/Interpreter.h +++ b/Source/Core/Core/PowerPC/Interpreter/Interpreter.h @@ -284,6 +284,8 @@ public: private: static void InitializeInstructionTables(); + static bool HandleFunctionHooking(u32 address); + // flag helper static void Helper_UpdateCR0(u32 value); static void Helper_UpdateCR1(); |
