-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Patches/PPU: Implement HLE/LLE/With-TOC function call patches #10859
Conversation
32d92be
to
975b0a8
Compare
975b0a8
to
9c7eb19
Compare
my personal opinion is that it should be |
9c7eb19
to
f939e1f
Compare
Okay, note that this is the opposite from what's used in the PPU disassembler by the debugger. (was replaced so function name appears without widening view much) |
f939e1f
to
e5e8aef
Compare
34e12bd
to
81e647d
Compare
|
0e89fc2
to
c5c45e3
Compare
PR is ready. |
rpcs3/Emu/Cell/PPUThread.cpp
Outdated
|
||
if (all_info.return_and_restore) | ||
{ | ||
// Save LR and R2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aren't you supposed to save them in PPU context of current thread?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
5cc38f3
to
71e4455
Compare
71e4455
to
9252ad6
Compare
Fresh from the oven, function calls with TOC: You can specify direct address of function OPD for calls with TOC by only specifying its addres, example: Notes:
|
d514b36
to
54c1ad2
Compare
rpcs3/Emu/Cell/PPUThread.cpp
Outdated
if (ppu) | ||
{ | ||
// This check checks if we need to either branch and save modified registers | ||
// *** Notice how this check is not compatible with using the same call twice without any other in between! *** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm. Can you elaborate on why call to next is handled in a special manner and what does this comment mean, that simple recursion is not allowed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Recursion is not recommended but there are cases in which it's valid here such as if the HLE calls history stack looks like this:
- [caller CIA] jumpf funcA
- [funcA + 0x10] jumpf funcA // funcA + 0x10 != caller CIA (comparing 1.CIA and 2.CIA)
// 3. [funcA + 0x10] jumpf funcA // Invalid, funcA + 0x10 == funcA + 0x10 (comparing 2.CIA and 3.CIA) - [caller CIA] jumpf funcA // Same (comparing 2.CIA and 3.CIA)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about using PPU stack with artificial call frames? It seems it could look more simple in the end, and easier to track the callstack.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is a callstack, that's not the issue. Ok I think I need to reserve a special address for registers restoration callback, its address will be passed in LR. Using the same address for registers restoration was probably a mistake.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
54c1ad2
to
f71b88b
Compare
Example patches: [ jumpf, 0x12340, "cellGcmSys:cellGcmSetFlip"] // Places a call to cellGcmSetFlip at 0x12340 [ jumpf, 0x12340, "cellGcmSys:0xDC09357E"] // Same, using FNID [ jumpf, 0x12340, 0x2345678 ] # Function OPD based call eading OPD at 0x2345678
f71b88b
to
708eed1
Compare
This new patch type allows to insert function calls to exported functions and custom HLE functions. Not only this extends greatly the potential of functionality patches can do by itself by providing access to all PS3 firmware functions and custom PRX ones - you can register custom HLE functions in RPCS3 code with custom module name and use that in patches. In other words you can inject real C++ code into games! The downside of that is that you need to use a custom RPCS3 build which those functions exist in it, but @isJuhn had an idea a while ago that real DLL files can be used to inject such code without the need to use custom RPCS3 builds. So in the future we might see an "HLE" function loading DLL functions and injecting to games. Potential is basically endless here.
Ideas for such C++ patches for example:
Example patches:
In addition, you can specify direct address of function OPD for calls with TOC by only specifying its addres, example:
Not to be confused with jumpl, even if changing R2 is not needed do not use it as jumpl.
Notes: