MIPSHooks for the Interpreter core #18848
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR doesn't add any new debugging features, but introduces the API that can be utilized for PPSSPP customization.
That interface allows easily overriding the standard behaviors of the assembly instructions. That's what I decided to call "hooking".
I have seen a few PPSSPP mods (and made one too), and I have realized it's fairly hard to implement some advanced debugging/logging in the emulator without harming the performance of the execution. See, modding the JIT requires godlike skills, and the IR interpreter is not fit for that. We're left with the Interpreter, which calls
Interpret(instr, op);
for all instructions that it sees. It's a wrapper aroundinstr->interpret(op);
and theinstr
is acquired throughconst MIPSInstruction *MIPSGetInstruction(MIPSOpcode op)
. The system is slightly complex: there are 28 big tables with predefined MIPS instructions and their handlers. I have removed the constness from these tables to allow the replacing of the standard interpreter functions. It would be way easier than making new CPU cores and copy-pasting all the old code just to make small changes.The example usage can be found in my other branch that I've created from this one.
As simple as that.
The tool is for accumulating the destinations of
jr t9
andjalr t9
calls.The name lookup table is initialized when any game is loaded so I thought it'd be a nice demo of what happens when it can't find the names.
One last note: this API needs to be used correctly. I can't enforce it, of course, but if there are multiple possible hook setups, it's necessary to call
MIPSHooks::Reset();
before setting up the new ones or else the emu will forget the original handlers.