few notes before starting:

-if you don’t care about reading all of this, the value to edit is at address 0x4089

-this is pretty much my first time writing about something like this, if the writing is trash, please do forgive

-i played this game on a (homebrewed) switch, around 6 months ago, so the details are a bit hazy

-i didn’t link to DBI installer as last time i checked on it, it was in a bit of hot water, if you care enough, look it up yourself cause i sure dont

Intro or smth idk

Persona 5 Royal, one of my favorite games of all times, from the great gameplay to the touching story, very well made, except that one part in the casino palace where you have to collect the stupid blue casino coins and need to reach 10,000 coins. Conviniently, the game gives you that specific amount after winning a certain battle, so no problem right? WRONG, there’s a shop that you can access in the area leading up to where you have to spend your hard earned casino cash, if you buy the shop’s goods before spending your fortune, you will be stuck with around ~9000 (specifically 9205 for me) and the only way to get back 10,000 is to slowly farm coins 25 at a time at the casino’s table, which as you might have guessed, takes ages, you arent guarentee winning either so you’ll have to (statistically) spend double that long period of time, horray!.

“But im a self proclaimed programmer, surely i can solve this problem like one!” i thought to myself, and with that began my journey of trying to get my hard earned cash back by editing the save file of the game

Getting the save files from my (homebrewed) switch

The first logical step to edit a save file, is of course to get hold of said save file, easy enough, launch JKSV, back up the save, plug in my switch to my pc, copy it over, launch ImHex to start looking for the needed data aaaaaaaand it’s encrypted, of course… at first i tried uploading it to sites such as this online save editor, but to no avail, then i tried decrypting them using this script i found online, but also to no avail.

I almost gave up (not the first time this will happen in this project) but then i stupidly thought to myself “let’s try another way of backing up the saves instead of JKSV maybe it won’t be encrypted that way..”, i tried ‘DBI installer’, and to my surprise, it worked, it gave me saves that were decrypt-bale, im unsure why JKSV gave me ones that didn’t work with the script mentioned earlier in the first place but hey, everything worked out in the end (i wrote this in a few lines, but it actually took me ages to try an alternative for JKSV lol)

Now that we have the (decrypted) save files, we can finally start looking at them using ImHex, we’ll start by looking for either values that resemble the amount of casino coins i have right now, or hex values that translate to “coins” or “chips” or “casino” with ASCII, ImHex makes this much easier Picture inside ImHex editing the save file.

Finding the values for the casino coins

Unfortunetely, i don’t find anything that resembles the values im looking for (subtle forshadowing)

searching for "casino" in the save file

(before you ask, yes i did search for other keywords, and for the hex value of exactly how many coins i had, coins -1, in both big and small endien)

at first this made be panic, as i thought maybe the amount of casino coins i had was stored in the game somehow? maybe there another file which is resposible for saving coins and money and what not? before revealing the answer, lets go on a little detour, the same detour i went on before actually finding the values i needed to edit:) (skip to part where i find the hex values if you don’t wanna go into my little detour)

Why do the hard work when someone has already done it before

Maybe i shouldn’t reinvent the wheel, surely someone somewhere on this vast world wide web has already gone through my same hiccup and fixed it programmatically without doing the manual labor, right? turns out i was wrong, no one has.

I found a few save editors specific to Persona 5 Royal, but they didn’t have a feature to edit the amount of casino coins, so it’s useless in this usecase

I also found a Cheat Engine table for the game, that does support increasing casino coins, but of course it’s Cheat Engine, so i need to own the game on pc, which i don’t :p

And everyone who made the same mistake as i did was recommended to either load up an older save file, or grind the coins manually, as a programmer, i simply cannot accept doing anything manually when it can be automated or cheated, and i didn’t have a save file that wasn’t too old (most recent at that time was around ~6hrs or so behind)

Took me quite a while to accept the fact that, in fact, no one has solved this issue by editing the save file before (at least on switch), then after some time, and almost giving up, it hit me….

Singling out the hex value i needed to change

As a last ditch effort, i thought to myself id backup my save, get exactly 25 coins from the gambling on the table method i mentioned earlier, then back up the save again and compare the two saves, and look for changes that resemble the number of coins before and after getting 25 coins, ImHex made this super easy as it has this feature built-in! amazing! i have finally found the value i need to change! i don’t have to grind the coins little by little! image of the diffrences between the 2 save files

You really thought it was gonna be that easy? nope, it wasn’t…. well im exaggerating, it was easy, aside from the small fact that i found 15 diffrences between the saves, i tried figuring out which one it was with my limited intelligance, but i wasn’t able to, so i simple maxed out every value that was different between the 2 save files and tested each changed save file on it’s own until i hit the save file with high casino coins.

At this point i was tired of this project so i just asked (your favorite LLM) to make a script that maxes out each value that was different, it spit out something that looked good enough, i read it and it seemed fine, i ran it, it worked properly! now all that’s left to do is to test each save file until i hit the one with a different amount of casino coins

it was the 5th offset, so 0x4089

horray, i don’t have to grind for real this time!

Fun oddities

  • The keen-eyes amoung you might have noticed that the value at offset 0x4089 is 0xF523, which if written as 0x23F5, comes up to exactly 9205, which is the amount of coins i had, you might now say “why didn’t you just search for the amount of coins you had?? are you stupid???” first of all, yes im dumb, but second, i did search for it, but i have no idea why it didn’t come up in the search since i was searching for 0x23F5, and not 0xF523, you live and learn

me being stupid

  • Of course messing with hex values in save files could cause unwanted effects, some of the few i noticed while testing the save files after i changed the hex values in:
    • 2 or more were softlocked where i couldn’t teleport into another area
    • 1 where i was in different area but could teleport normally
    • 3 or so where it had seemingly no effects

    Im sure i would’ve been able to find what had changed in the last few if i digged further, but i was only interested in the casino coins

  • Another thing worth mentioning is that the game crashed on the switch right before the final cutscene of the game, after defeating the final boss, whether that is related to my save editing or not remains unknown

Final thoughts

I love spending 5hrs+ tinkering with software to automate a one-time instead of doing that one-time in 2hrs or so and never worrying about it too much :D

Well i did what i set out to do so i can’t complain too much, im not sure if this post will find anyone on this vast internet, but if it does, i hope it was insightful, helpful, entertaining, or at least interesting enough, we shall meet again with another random project of mine, random internet stranger, thanks for reading this:)