mirror of
https://github.com/hedge-dev/XenonRecomp.git
synced 2025-06-06 09:12:08 +00:00
Add support for placing midasm hooks after instructions.
This commit is contained in:
parent
87e350906b
commit
3280a7cf9f
@ -333,7 +333,8 @@ bool Recompiler::Recompile(
|
||||
};
|
||||
|
||||
auto midAsmHook = config.midAsmHooks.find(base);
|
||||
if (midAsmHook != config.midAsmHooks.end())
|
||||
|
||||
auto printMidAsmHook = [&]()
|
||||
{
|
||||
bool returnsBool = midAsmHook->second.returnOnFalse || midAsmHook->second.returnOnTrue ||
|
||||
midAsmHook->second.jumpAddressOnFalse != NULL || midAsmHook->second.jumpAddressOnTrue != NULL;
|
||||
@ -410,7 +411,10 @@ bool Recompiler::Recompile(
|
||||
else if (midAsmHook->second.jumpAddress != NULL)
|
||||
println("\tgoto loc_{:X};", midAsmHook->second.jumpAddress);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
if (midAsmHook != config.midAsmHooks.end() && !midAsmHook->second.afterInstruction)
|
||||
printMidAsmHook();
|
||||
|
||||
int id = insn.opcode->id;
|
||||
|
||||
@ -2149,6 +2153,9 @@ bool Recompiler::Recompile(
|
||||
}
|
||||
#endif
|
||||
|
||||
if (midAsmHook != config.midAsmHooks.end() && midAsmHook->second.afterInstruction)
|
||||
printMidAsmHook();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -118,6 +118,8 @@ void RecompilerConfig::Load(const std::string_view& configFilePath)
|
||||
fmt::println("{}: can't mix direct and conditional return/jump", midAsmHook.name);
|
||||
}
|
||||
|
||||
midAsmHook.afterInstruction = table["after_instruction"].value_or(false);
|
||||
|
||||
midAsmHooks.emplace(*table["address"].value<uint32_t>(), std::move(midAsmHook));
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,8 @@ struct RecompilerMidAsmHook
|
||||
uint32_t jumpAddress = 0;
|
||||
uint32_t jumpAddressOnTrue = 0;
|
||||
uint32_t jumpAddressOnFalse = 0;
|
||||
|
||||
bool afterInstruction = false;
|
||||
};
|
||||
|
||||
struct RecompilerConfig
|
||||
|
Loading…
x
Reference in New Issue
Block a user