Video showcasing GTA: Chinatown Wars with some replacement textures from the Android Version (courtesy of SonofUgly), running on PSPHD.
Making this method of texture replacement work required quite a lot of trial and error, as well as modifying the executable. This method uses two different PSPHD versions, a modified Echochrome emulator for dumping and the LocoRoco Midnight Carnival emulator for actually running the game with replacement textures. While this slightly complicates things, it is necessary since neither of the emulators seem to support both features.
From looking at the changes between both emulators, I believe Sony is/has been working on the texture replacement system recently. (Command line option changes, features being broken, etc.)
Also, bear in mind that both games shipped with these emulators do NOT use any texture replacement. So I'm happy this works at all.
This hopefully means that in the future we will see new PSP games released to PS Plus which use texture replacement. If that happens, we might be able to improve upon this current method of texture dumping and replacement.
From looking at the changes between both emulators, I believe Sony is/has been working on the texture replacement system recently. (Command line option changes, features being broken, etc.)
Also, bear in mind that both games shipped with these emulators do NOT use any texture replacement. So I'm happy this works at all.
This hopefully means that in the future we will see new PSP games released to PS Plus which use texture replacement. If that happens, we might be able to improve upon this current method of texture dumping and replacement.
TL;DR:
This allows you to replace original textures with new high resolution ones.
Texture dumping and replacing works surprisingly well in my experience.
Textures can either be included inside the pkg or in an external folder.
Now for the actual tutorial.
What you will need / Downloads:
- The PSP .iso you want to use
- A tool for generating PSP-fpkgs, such as Jabu's PSP-FPKG tool [1]
- A tool for extracting fpkgs, such as PS4-PKG-Tool [2]
- A tool for repacking extracted fpkgs, such as fPKG_Maker_GUI [3]
- PSPHD_Texture_Dump_Replace_v1.1.zip
Folder Dumper contains the patched and pre-configured Echochrome emulator.
Folder ReplaceFiles contains required files of the patched and pre-configured LocoRoco Midnight Carnival emulator.
Recommended Workflow:
Setup and execute Asset Dumper
- Create a fpkg of your PSP game [1]
- Extract the generated fpkg [2]
- Extract PSPHD_Texture_Dump_Replace.zip to a separate folder.
- Copy Image0/data/USER_L0.IMG from the extracted fpkg to the Dumper/ULUS99999-app/data/ folder of the asset dumper.
- Configure the asset dumper's config-title.txt to your needs. Please read the comments in the config file for extra details.
- Build the asset dumper fpkg [3]
- Install and run it on your PS4 (make sure to create all folders set in the config beforehand)
- Textures are dumped when they are loaded into memory.
This means that you will have to play the game until the texture you want to replace is loaded. You can utilize game saves or the emulator's State Saving/Loading feature for this.
For example, you could install the Asset Dumper with --texsave disabled, save states where your desired textures are loaded, and then enable --texsave and reinstall the Asset Dumper. This way you can easily load your saved states without having to worry about too much lag and countless undesired dumped textures. - Once done exporting, analyze the dump folder and identify the textures you want to replace.
- Create a replacement texture of the same size, 4x or 8x the size (other sizes might work, I have not tested them). Make sure that the filename and type of the replacement texture is IDENTICAL to the dumped one (regardless of the size of the new texture)!
- Prepare your original extracted fpkg for repacking:
Rename the folder Image0 to [title_id]-app, where you replace [title_id] with the title_id of your game (e.g. ULUS10490).
Move all files from Sc0 to the sce_sys folder inside your extracted fpkg.
You should end up with a directory structure similar to the one inside the Dumper folder.
- Copy all files from ReplaceFiles to the root of your extracted fpkg and overwrite all files.
Note: Replacing the eboot is essential! The default LocoRoco Midnight Carnival emulator has a bug which causes flaky replacement texture loading.
- Set desired settings in the config-title.txt. Please read the comments in the config file for extra details.
- Move replacement textures to the folder you specified in the config.
- Rebuild the fpkg [3] and install.
General notes:
- I highly recommend to use an external directory (like /data/texreplace) for replacement textures while testing. This allows you to change the textures without reinstalling the fpkg.
- I have personally tested this method with GTA: Chinatown Wars (ULUS10490) and Patapon (UCUS98711). New problems and issues may arise with other games.
- The emulator included in the Dumper folder should have all features and functionality of the Echochrome emulator, just with working asset dumping options.
- The emulator included in the ReplaceFiles folder should have all features and functionality of the LocoRoco Midnight Carnival emulator, with flaky replacement texture loading fixed.
However, I cannot guarantee that this is indeed the case. See spoiler below for explanation.
- If you are having trouble identifying an issue, have a look at the logs. Just check "Enable TTY Redirect" in the KLog Settings of GoldHEN 2.2.4+. Then you can listen to the log using telnet (telnet <PS4 IP> 3232).
-
After looking at the logs, I noticed the line <118>(PSP) Package: disabling --texsave, --texmissingsave, --dumpvideos, --dumpaudio.
This made me believe that the emulator dynamically disables asset dumping when detecting it's being run from a pkg.
I then used UnfSelf.exe and IDA Freeware to have a look inside the eboot. I noticed that after printing the aforementioned log message, all four option strings are being addressed by a lea instruction. Furthermore, I had previously found that this log message is not printed if we pass malformed command line options which are missing a value (such as --debug).
Using this information, I then thought about how I would implement dynamically disabling cl options and concluded that after parsing all options to a map, I would simply remove the unwanted ones afterwards based on some condition. So something like optionsMap.removeKey("--texsave").
Now, if you misspell the option string you want to remove from the map it obviously doesn't get removed...
And that's what I tried. I just shifted the address referenced by the lea instructions to an empty string (of course in the fself eboot.bin). And lo and behold, I was correct. After this slight modification those options are working as expected.
However, while the same modification seems to work for LocoRoco Midnight Carnival, the dumping feature itself just crashes the application for me.
-
While initially experimenting with texture replacement, I noticed that replacment textures had a random chance to simply not be loaded. Interestingly, it wasn't an issue where certain textures would sometimes not load. It was either all texture or no textures.
Inspecing the logs, I noticed that whenever textures were loaded, four different log messages relating to texture loading were printed. When the loading failed, none of them were printed.
As with the Echochrome patch, I had a look at the eboot in IDA Freeware and could not find anything plainly obvious which could be causing this behaviour. I then just followed the condition branches (jump instructions) leading to the texture loading code and was able to identify the single jnz instruction responsible for skipping the whole section.
I tried to follow the branches back even farther to try and identify the condition deciding whether to skip the texture loading or not. I was not able to find anything. So in the end, I just forced the texture loading branch by replacing the jnz with a bunch of nop instructions.
I was surprised to not only make texture loading work seemingly 100% reliably, but also to not notice any negative side effects.
So, while I seem to have fixed the problem, I still have no idea what the actual issue was. Therefore, I cannot with good conscience say that there are no unintended side effects yet to be discovered.
As mentioned above, this method is not perfect. Here are some things that we might be able to improve:
- Patch the emulator to enable --texswitch. This features is currently supposedly only available on Neighborhood or Windows.
- Use the same emulator for dumping and texture replacement. Maybe we can look at different PSPHD versions for that.
- Maybe using the .pak format for texture archives, which is mentioned in the emulator logs. Could potentially improve performance for large replacment texture packs.
Changelog:
Jul 4, 2023 - Removed dead link to PS4PKGViewer by theleecherman
Dec 1, 2022 - Fixed flaky texture loading + added additional details on replacement options added to config.
Changed files: ReplaceFiles/eboot.bin and ReplaceFiles/config-title.txt
Nov 29, 2022 - Initial release
Dec 1, 2022 - Fixed flaky texture loading + added additional details on replacement options added to config.
Changed files: ReplaceFiles/eboot.bin and ReplaceFiles/config-title.txt
Nov 29, 2022 - Initial release
Finally, I want to thank the community for all their prior work making this method possible.
Specifically, @Jabu for his easy-to-use fpkg converter tools, pearlxcore and TheLeecherMan for their pkg viewing and extracting tools, and codemasterv for their fpkg builder tool.
And of course the whole community, for your enthusiasm and dedication to creating such a plethora of awesome stuff!
I hope we can find uses for this texture replacement method and improve upon it.
I look forward to hearing your results and findings in the comments!
mexxpower
Last edited:
