summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
authorAnthony <Helios747@users.noreply.github.com>2018-02-07 23:36:31 -0800
committerGitHub <noreply@github.com>2018-02-07 23:36:31 -0800
commitc30ac55cf4c06cf896f0264443dfa3d5de904e69 (patch)
tree3119c1d0627ae09d7296b8bcd11b788c81813f54 /Source
parent096131c9085ff6cb358d03251f666536910d7806 (diff)
parent3deb8ce0741c07a2e511e3acf43db56a5b80dd87 (diff)
Merge pull request #6354 from leoetlino/hle
HLE: Minor cleanup
Diffstat (limited to 'Source')
-rw-r--r--Source/Core/Core/HLE/HLE.cpp64
-rw-r--r--Source/Core/Core/HLE/HLE.h22
-rw-r--r--Source/Core/Core/HLE/HLE_Misc.cpp9
-rw-r--r--Source/Core/Core/HLE/HLE_Misc.h1
-rw-r--r--Source/Core/Core/PowerPC/CachedInterpreter/CachedInterpreter.cpp8
-rw-r--r--Source/Core/Core/PowerPC/Interpreter/Interpreter.cpp8
-rw-r--r--Source/Core/Core/PowerPC/Jit64/Jit.cpp8
7 files changed, 54 insertions, 66 deletions
diff --git a/Source/Core/Core/HLE/HLE.cpp b/Source/Core/Core/HLE/HLE.cpp
index 7cc2743e8b..d3291a9a4d 100644
--- a/Source/Core/Core/HLE/HLE.cpp
+++ b/Source/Core/Core/HLE/HLE.cpp
@@ -43,41 +43,39 @@ struct SPatch
// clang-format off
static const SPatch OSPatches[] = {
// Placeholder, OSPatches[0] is the "non-existent function" index
- {"FAKE_TO_SKIP_0", HLE_Misc::UnimplementedFunction, HLE_HOOK_REPLACE, HLE_TYPE_GENERIC},
-
- {"PanicAlert", HLE_Misc::HLEPanicAlert, HLE_HOOK_REPLACE, HLE_TYPE_DEBUG},
+ {"FAKE_TO_SKIP_0", HLE_Misc::UnimplementedFunction, HookType::Replace, HookFlag::Generic},
// Name doesn't matter, installed in CBoot::BootUp()
- {"HBReload", HLE_Misc::HBReload, HLE_HOOK_REPLACE, HLE_TYPE_GENERIC},
+ {"HBReload", HLE_Misc::HBReload, HookType::Replace, HookFlag::Generic},
// Debug/OS Support
- {"OSPanic", HLE_OS::HLE_OSPanic, HLE_HOOK_REPLACE, HLE_TYPE_DEBUG},
+ {"OSPanic", HLE_OS::HLE_OSPanic, HookType::Replace, HookFlag::Debug},
// This needs to be put before vprintf (because vprintf is called indirectly by this)
- {"JUTWarningConsole_f", HLE_OS::HLE_GeneralDebugPrint, HLE_HOOK_START, HLE_TYPE_DEBUG},
-
- {"OSReport", HLE_OS::HLE_GeneralDebugPrint, HLE_HOOK_START, HLE_TYPE_DEBUG},
- {"DEBUGPrint", HLE_OS::HLE_GeneralDebugPrint, HLE_HOOK_START, HLE_TYPE_DEBUG},
- {"WUD_DEBUGPrint", HLE_OS::HLE_GeneralDebugPrint, HLE_HOOK_START, HLE_TYPE_DEBUG},
- {"vprintf", HLE_OS::HLE_GeneralDebugVPrint, HLE_HOOK_START, HLE_TYPE_DEBUG},
- {"printf", HLE_OS::HLE_GeneralDebugPrint, HLE_HOOK_START, HLE_TYPE_DEBUG},
- {"vdprintf", HLE_OS::HLE_LogVDPrint, HLE_HOOK_START, HLE_TYPE_DEBUG},
- {"dprintf", HLE_OS::HLE_LogDPrint, HLE_HOOK_START, HLE_TYPE_DEBUG},
- {"vfprintf", HLE_OS::HLE_LogVFPrint, HLE_HOOK_START, HLE_TYPE_DEBUG},
- {"fprintf", HLE_OS::HLE_LogFPrint, HLE_HOOK_START, HLE_TYPE_DEBUG},
- {"nlPrintf", HLE_OS::HLE_GeneralDebugPrint, HLE_HOOK_START, HLE_TYPE_DEBUG},
- {"DWC_Printf", HLE_OS::HLE_GeneralDebugPrint, HLE_HOOK_START, HLE_TYPE_DEBUG},
- {"puts", HLE_OS::HLE_GeneralDebugPrint, HLE_HOOK_START, HLE_TYPE_DEBUG}, // gcc-optimized printf?
- {"___blank", HLE_OS::HLE_GeneralDebugPrint, HLE_HOOK_START, HLE_TYPE_DEBUG}, // used for early init things (normally)
- {"__write_console", HLE_OS::HLE_write_console, HLE_HOOK_START, HLE_TYPE_DEBUG}, // used by sysmenu (+more?)
-
- {"GeckoCodehandler", HLE_Misc::GeckoCodeHandlerICacheFlush, HLE_HOOK_START, HLE_TYPE_FIXED},
- {"GeckoHandlerReturnTrampoline", HLE_Misc::GeckoReturnTrampoline, HLE_HOOK_REPLACE, HLE_TYPE_FIXED},
- {"AppLoaderReport", HLE_OS::HLE_GeneralDebugPrint, HLE_HOOK_REPLACE, HLE_TYPE_FIXED} // apploader needs OSReport-like function
+ {"JUTWarningConsole_f", HLE_OS::HLE_GeneralDebugPrint, HookType::Start, HookFlag::Debug},
+
+ {"OSReport", HLE_OS::HLE_GeneralDebugPrint, HookType::Start, HookFlag::Debug},
+ {"DEBUGPrint", HLE_OS::HLE_GeneralDebugPrint, HookType::Start, HookFlag::Debug},
+ {"WUD_DEBUGPrint", HLE_OS::HLE_GeneralDebugPrint, HookType::Start, HookFlag::Debug},
+ {"vprintf", HLE_OS::HLE_GeneralDebugVPrint, HookType::Start, HookFlag::Debug},
+ {"printf", HLE_OS::HLE_GeneralDebugPrint, HookType::Start, HookFlag::Debug},
+ {"vdprintf", HLE_OS::HLE_LogVDPrint, HookType::Start, HookFlag::Debug},
+ {"dprintf", HLE_OS::HLE_LogDPrint, HookType::Start, HookFlag::Debug},
+ {"vfprintf", HLE_OS::HLE_LogVFPrint, HookType::Start, HookFlag::Debug},
+ {"fprintf", HLE_OS::HLE_LogFPrint, HookType::Start, HookFlag::Debug},
+ {"nlPrintf", HLE_OS::HLE_GeneralDebugPrint, HookType::Start, HookFlag::Debug},
+ {"DWC_Printf", HLE_OS::HLE_GeneralDebugPrint, HookType::Start, HookFlag::Debug},
+ {"puts", HLE_OS::HLE_GeneralDebugPrint, HookType::Start, HookFlag::Debug}, // gcc-optimized printf?
+ {"___blank", HLE_OS::HLE_GeneralDebugPrint, HookType::Start, HookFlag::Debug}, // used for early init things (normally)
+ {"__write_console", HLE_OS::HLE_write_console, HookType::Start, HookFlag::Debug}, // used by sysmenu (+more?)
+
+ {"GeckoCodehandler", HLE_Misc::GeckoCodeHandlerICacheFlush, HookType::Start, HookFlag::Fixed},
+ {"GeckoHandlerReturnTrampoline", HLE_Misc::GeckoReturnTrampoline, HookType::Replace, HookFlag::Fixed},
+ {"AppLoaderReport", HLE_OS::HLE_GeneralDebugPrint, HookType::Replace, HookFlag::Fixed} // apploader needs OSReport-like function
};
static const SPatch OSBreakPoints[] = {
- {"FAKE_TO_SKIP_0", HLE_Misc::UnimplementedFunction, HLE_HOOK_START, HLE_TYPE_GENERIC},
+ {"FAKE_TO_SKIP_0", HLE_Misc::UnimplementedFunction, HookType::Start, HookFlag::Generic},
};
// clang-format on
@@ -117,7 +115,7 @@ void PatchFunctions()
// Remove all hooks that aren't fixed address hooks
for (auto i = s_original_instructions.begin(); i != s_original_instructions.end();)
{
- if (OSPatches[i->second].flags != HLE_TYPE_FIXED)
+ if (OSPatches[i->second].flags != HookFlag::Fixed)
{
PowerPC::ppcState.iCache.Invalidate(i->first);
i = s_original_instructions.erase(i);
@@ -131,7 +129,7 @@ void PatchFunctions()
for (u32 i = 1; i < ArraySize(OSPatches); ++i)
{
// Fixed hooks don't map to symbols
- if (OSPatches[i].flags == HLE_TYPE_FIXED)
+ if (OSPatches[i].flags == HookFlag::Fixed)
continue;
for (const auto& symbol : g_symbolDB.GetSymbolsFromName(OSPatches[i].m_szPatchName))
@@ -203,19 +201,19 @@ u32 GetFirstFunctionIndex(u32 address)
return first == std::end(s_original_instructions) ? index : 0;
}
-int GetFunctionTypeByIndex(u32 index)
+HookType GetFunctionTypeByIndex(u32 index)
{
return OSPatches[index].type;
}
-int GetFunctionFlagsByIndex(u32 index)
+HookFlag GetFunctionFlagsByIndex(u32 index)
{
return OSPatches[index].flags;
}
-bool IsEnabled(int flags)
+bool IsEnabled(HookFlag flag)
{
- return flags != HLE::HLE_TYPE_DEBUG || SConfig::GetInstance().bEnableDebugging ||
+ return flag != HLE::HookFlag::Debug || SConfig::GetInstance().bEnableDebugging ||
PowerPC::GetMode() == PowerPC::CoreMode::Interpreter;
}
@@ -226,7 +224,7 @@ u32 UnPatch(const std::string& patch_name)
if (patch == std::end(OSPatches))
return 0;
- if (patch->flags == HLE_TYPE_FIXED)
+ if (patch->flags == HookFlag::Fixed)
{
u32 patch_idx = static_cast<u32>(patch - OSPatches);
u32 addr = 0;
diff --git a/Source/Core/Core/HLE/HLE.h b/Source/Core/Core/HLE/HLE.h
index 2ea49640f9..a944c6b56c 100644
--- a/Source/Core/Core/HLE/HLE.h
+++ b/Source/Core/Core/HLE/HLE.h
@@ -10,18 +10,18 @@
namespace HLE
{
-enum HookType
+enum class HookType
{
- HLE_HOOK_START = 0, // Hook the beginning of the function and execute the function afterwards
- HLE_HOOK_REPLACE = 1, // Replace the function with the HLE version
- HLE_HOOK_NONE = 2, // Do not hook the function
+ Start, // Hook the beginning of the function and execute the function afterwards
+ Replace, // Replace the function with the HLE version
+ None, // Do not hook the function
};
-enum HookFlag
+enum class HookFlag
{
- HLE_TYPE_GENERIC = 0, // Miscellaneous function
- HLE_TYPE_DEBUG = 1, // Debug output function
- HLE_TYPE_FIXED = 2, // An arbitrary hook mapped to a fixed address instead of a symbol
+ Generic, // Miscellaneous function
+ Debug, // Debug output function
+ Fixed, // An arbitrary hook mapped to a fixed address instead of a symbol
};
void PatchFixedFunctions();
@@ -38,8 +38,8 @@ void Execute(u32 _CurrentPC, u32 _Instruction);
u32 GetFunctionIndex(u32 address);
// Returns the HLE function index if the address matches the function start
u32 GetFirstFunctionIndex(u32 address);
-int GetFunctionTypeByIndex(u32 index);
-int GetFunctionFlagsByIndex(u32 index);
+HookType GetFunctionTypeByIndex(u32 index);
+HookFlag GetFunctionFlagsByIndex(u32 index);
-bool IsEnabled(int flags);
+bool IsEnabled(HookFlag flag);
}
diff --git a/Source/Core/Core/HLE/HLE_Misc.cpp b/Source/Core/Core/HLE/HLE_Misc.cpp
index 7523836d00..9388b16a2c 100644
--- a/Source/Core/Core/HLE/HLE_Misc.cpp
+++ b/Source/Core/Core/HLE/HLE_Misc.cpp
@@ -6,7 +6,6 @@
#include "Common/CommonTypes.h"
#include "Common/Logging/Log.h"
-#include "Common/MsgHandler.h"
#include "Core/GeckoCode.h"
#include "Core/HW/CPU.h"
#include "Core/Host.h"
@@ -21,14 +20,6 @@ void UnimplementedFunction()
NPC = LR;
}
-// If you want a function to panic, you can rename it PanicAlert :p
-// Don't know if this is worth keeping.
-void HLEPanicAlert()
-{
- ::PanicAlert("HLE: PanicAlert %08x", LR);
- NPC = LR;
-}
-
void HBReload()
{
// There isn't much we can do. Just stop cleanly.
diff --git a/Source/Core/Core/HLE/HLE_Misc.h b/Source/Core/Core/HLE/HLE_Misc.h
index 7bf2d8496c..fcfc9c968e 100644
--- a/Source/Core/Core/HLE/HLE_Misc.h
+++ b/Source/Core/Core/HLE/HLE_Misc.h
@@ -6,7 +6,6 @@
namespace HLE_Misc
{
-void HLEPanicAlert();
void UnimplementedFunction();
void HBReload();
void GeckoCodeHandlerICacheFlush();
diff --git a/Source/Core/Core/PowerPC/CachedInterpreter/CachedInterpreter.cpp b/Source/Core/Core/PowerPC/CachedInterpreter/CachedInterpreter.cpp
index ff7739905c..50823cf4d7 100644
--- a/Source/Core/Core/PowerPC/CachedInterpreter/CachedInterpreter.cpp
+++ b/Source/Core/Core/PowerPC/CachedInterpreter/CachedInterpreter.cpp
@@ -208,15 +208,15 @@ void CachedInterpreter::Jit(u32 address)
u32 function = HLE::GetFirstFunctionIndex(ops[i].address);
if (function != 0)
{
- int type = HLE::GetFunctionTypeByIndex(function);
- if (type == HLE::HLE_HOOK_START || type == HLE::HLE_HOOK_REPLACE)
+ HLE::HookType type = HLE::GetFunctionTypeByIndex(function);
+ if (type == HLE::HookType::Start || type == HLE::HookType::Replace)
{
- int flags = HLE::GetFunctionFlagsByIndex(function);
+ HLE::HookFlag flags = HLE::GetFunctionFlagsByIndex(function);
if (HLE::IsEnabled(flags))
{
m_code.emplace_back(WritePC, ops[i].address);
m_code.emplace_back(Interpreter::HLEFunction, function);
- if (type == HLE::HLE_HOOK_REPLACE)
+ if (type == HLE::HookType::Replace)
{
m_code.emplace_back(EndBlock, js.downcountAmount);
m_code.emplace_back();
diff --git a/Source/Core/Core/PowerPC/Interpreter/Interpreter.cpp b/Source/Core/Core/PowerPC/Interpreter/Interpreter.cpp
index 8d2216aff7..928ec241b9 100644
--- a/Source/Core/Core/PowerPC/Interpreter/Interpreter.cpp
+++ b/Source/Core/Core/PowerPC/Interpreter/Interpreter.cpp
@@ -105,14 +105,14 @@ int Interpreter::SingleStepInner()
u32 function = HLE::GetFirstFunctionIndex(PC);
if (function != 0)
{
- int type = HLE::GetFunctionTypeByIndex(function);
- if (type == HLE::HLE_HOOK_START || type == HLE::HLE_HOOK_REPLACE)
+ HLE::HookType type = HLE::GetFunctionTypeByIndex(function);
+ if (type == HLE::HookType::Start || type == HLE::HookType::Replace)
{
- int flags = HLE::GetFunctionFlagsByIndex(function);
+ HLE::HookFlag flags = HLE::GetFunctionFlagsByIndex(function);
if (HLE::IsEnabled(flags))
{
HLEFunction(function);
- if (type == HLE::HLE_HOOK_START)
+ if (type == HLE::HookType::Start)
{
// Run the original.
function = 0;
diff --git a/Source/Core/Core/PowerPC/Jit64/Jit.cpp b/Source/Core/Core/PowerPC/Jit64/Jit.cpp
index facfe820e5..ffaea8b8de 100644
--- a/Source/Core/Core/PowerPC/Jit64/Jit.cpp
+++ b/Source/Core/Core/PowerPC/Jit64/Jit.cpp
@@ -803,14 +803,14 @@ const u8* Jit64::DoJit(u32 em_address, PPCAnalyst::CodeBuffer* code_buf, JitBloc
u32 function = HLE::GetFirstFunctionIndex(ops[i].address);
if (function != 0)
{
- int type = HLE::GetFunctionTypeByIndex(function);
- if (type == HLE::HLE_HOOK_START || type == HLE::HLE_HOOK_REPLACE)
+ HLE::HookType type = HLE::GetFunctionTypeByIndex(function);
+ if (type == HLE::HookType::Start || type == HLE::HookType::Replace)
{
- int flags = HLE::GetFunctionFlagsByIndex(function);
+ HLE::HookFlag flags = HLE::GetFunctionFlagsByIndex(function);
if (HLE::IsEnabled(flags))
{
HLEFunction(function);
- if (type == HLE::HLE_HOOK_REPLACE)
+ if (type == HLE::HookType::Replace)
{
MOV(32, R(RSCRATCH), PPCSTATE(npc));
js.downcountAmount += js.st.numCycles;