Skip to content
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

Add .pat support #15656

Open
2 tasks done
IncognitoMan opened this issue Jul 6, 2022 · 5 comments
Open
2 tasks done

Add .pat support #15656

IncognitoMan opened this issue Jul 6, 2022 · 5 comments
Labels
Cheats User Interface PPSSPP's own user interface / UX
Milestone

Comments

@IncognitoMan
Copy link
Contributor

IncognitoMan commented Jul 6, 2022

What should happen

Various cheat engines on psp (FreeCheat and TempAR for example) let you apply memory patches in the form of .pat files.

These .pat files get applied at the users choice... an example being with Monster Hunter Freedom Unite where you would swap quests out with custom quests in guildhall by applying these at quest counter.

.pat structure is also pretty straight forward.

  • First 4 bytes are the address to start writing at... so if the address was 0x0937D150 it would be 50 D1 37 09
  • After the first 4 bytes is the data

Who would this benefit

People either rewriting large chunks of data in memory or testing code injections.

I could also see this being used for generating a randomizer by chain loading .pat files in a folder... though unsure how to go about that... Maybe something similar to textures where it'll check for an ini like PSP/PATCHES/GAMEID/patches.ini and apply that at boot/users chioce (like at a games menu)?

Platform (if relevant)

No response

Games this would be useful in

Monster Hunter Freedom Unite, Monster Hunter Portable 2nd G, Monster Hunter Portable 3rd

Other emulators or software with a similar feature

No response

Checklist

@hrydgard
Copy link
Owner

hrydgard commented Jul 6, 2022

What would be the user interface for applying this? Would these files show up in cheats, or does something new need to be built?

File format indeed sounds very easy to patch.

There's a further issue, sometimes things end up at different addresses on PPSSPP vs the real hardware, due to us not quite tuning in how much RAM various system libraries should take up, which can also make this kind of patch iffy.

@hrydgard hrydgard added User Interface PPSSPP's own user interface / UX Cheats labels Jul 6, 2022
@hrydgard hrydgard added this to the Future milestone Jul 6, 2022
@anr2me
Copy link
Collaborator

anr2me commented Jul 7, 2022

it'll check for an ini like PSP/PATCHES/GAMEID/patches.ini and apply that at boot/users chioce (like at a games menu)

You mean the patches.ini will have options like, ApplyAt = boot / menu / quest counter, etc like that and PPSSPP will detects the current scene and automatically apply it? instead of users manually applying it? O.o
If it's, how does PPSSPP know which scene is currently running if it's automatic?

@LunaMoo
Copy link
Collaborator

LunaMoo commented Jul 7, 2022

I think he ment that at boot a random selection from provided list would be loaded, this feels like a non-universal feature aiming at Monster Hunter quests that can be easily generated since they're just different map and selection of monsters, but those can also be loaded easily with custom made DLC's which third party software like quest editors doing exactly that, so it's whatever.

If the game suffers from different ram structure(as it often does in our case), loading pat files can do anything from glitching or crashing the game to breaking savedata stored in ram(that can later corrupt savedata stored on disc) as they're usually used to inject a large portion of modified data stored in RAM and the system has no means of checking what it's patching compared to CWCheats for example.

@IncognitoMan
Copy link
Contributor Author

What would be the user interface for applying this? Would these files show up in cheats, or does something new need to be built?

File format indeed sounds very easy to patch.

There's a further issue, sometimes things end up at different addresses on PPSSPP vs the real hardware, due to us not quite tuning in how much RAM various system libraries should take up, which can also make this kind of patch iffy.

I started brainstorming it for how a user may interact with it and i think the best way would be either a option called "Apply PAT" or something under the game menu (the one with the savestate selection screen) or nested inside the "Cheats" option that takes you to a menu similar to the cheat menu where you can toggle which pat's to apply, and then a button to press to apply them (it would be a one time thing as you aren't constantly writing them)

it'll check for an ini like PSP/PATCHES/GAMEID/patches.ini and apply that at boot/users chioce (like at a games menu)

You mean the patches.ini will have options like, ApplyAt = boot / menu / quest counter, etc like that and PPSSPP will detects the current scene and automatically apply it? instead of users manually applying it? O.o If it's, how does PPSSPP know which scene is currently running if it's automatic?

I originally thought a ini that basically lists which pats to apply and a option to apply based on an ini would be nice but after thinking about it for a bit I realized maybe the ini solution wouldn't be good nor useful on other platforms... in the end i think a menu like the cheats menu as stated above would probably be better and you toggle on/off individual pats

I think he ment that at boot a random selection from provided list would be loaded, this feels like a non-universal feature aiming at Monster Hunter quests that can be easily generated since they're just different map and selection of monsters, but those can also be loaded easily with custom made DLC's which third party software like quest editors doing exactly that, so it's whatever.

If the game suffers from different ram structure(as it often does in our case), loading pat files can do anything from glitching or crashing the game to breaking savedata stored in ram(that can later corrupt savedata stored on disc) as they're usually used to inject a large portion of modified data stored in RAM and the system has no means of checking what it's patching compared to CWCheats for example.

Actually meant that the ini would be used as a way to chainload a specific set of pats at the users choice or at boot....I'im thinking about it outside of monster hunter quests and more along the lines of a randomizer for monster hunter in general... It could also be used for other games where you may want/need to change something that's a bit larger than what would be sane in the form of a cwcheat code.

In the end the ini idea might not work well and maybe need something like the cheats menu to toggle on/off specific pats you want and then an apply button to apply them as mentioned above.

I'm also aware of the memory addressing differences... a code I wrote ended up only working on ppsspp and not real hardware... and I've had the same happen vice versa. So yes special care would have to be made to make sure pats are doing whats intended and may/may not work when tested on real hardware.

@LunaMoo
Copy link
Collaborator

LunaMoo commented Jul 7, 2022

The problem with that is that no checks existed in those patches, so existing patches would be dangerous for potential users that could pretty easily corrupt their savedata by overwriting it in ram with some patches and then having their 1000h savedata overwritten.

I'd say it's better to just dump the idea of supporting pat format completely, since they never will be safe due to their PSP legacy and allocation differences and just concentrate on what's discussed in #15626 and #13804 (external scripting support) which would make such memory patches just as easy, but require them to be made for PPSSPP with some additional safety checks as well and on top of that it would be way more powerful and wouldn't need any weird systems via ini files as the randomized elements could simply be programmed into such patch.

I assume "code I wrote" wasn't refering to programming as for the cheats, as long as you write your own code(in mips) patching the game code it should work same on emulators and real hardware even in games affected by the allocation differences.
Rare, but PPSSPP can have differences in allocation even between versions so in general I'd recommend to only create cheats in assembly. It'll avoid having to keep them updated, in many games it's also much easier to create cheats by changing the game code than modifying variables.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Cheats User Interface PPSSPP's own user interface / UX
Projects
None yet
Development

No branches or pull requests

4 participants