[HLE] Added GetFirstFunctionIndex matching the start address

This commit is contained in:
Sepalani 2016-11-23 00:09:48 +00:00
parent e259b3fa76
commit 4f9e5e1141
2 changed files with 15 additions and 3 deletions

View File

@ -183,12 +183,21 @@ void Execute(u32 _CurrentPC, u32 _Instruction)
// OSPatches[pos].m_szPatchName);
}
u32 GetFunctionIndex(u32 addr)
u32 GetFunctionIndex(u32 address)
{
auto iter = s_original_instructions.find(addr);
auto iter = s_original_instructions.find(address);
return (iter != s_original_instructions.end()) ? iter->second : 0;
}
u32 GetFirstFunctionIndex(u32 address)
{
u32 index = GetFunctionIndex(address);
auto first = std::find_if(
s_original_instructions.begin(), s_original_instructions.end(),
[=](const auto& entry) { return entry.second == index && entry.first < address; });
return first == std::end(s_original_instructions) ? index : 0;
}
int GetFunctionTypeByIndex(u32 index)
{
return OSPatches[index].type;

View File

@ -34,7 +34,10 @@ u32 UnPatch(const std::string& patchName);
bool UnPatch(u32 addr, const std::string& name = {});
void Execute(u32 _CurrentPC, u32 _Instruction);
u32 GetFunctionIndex(u32 em_address);
// Returns the HLE function index if the address is located in the function
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);