Bash Linux PCSXR to RetroArch cheat format toggle

Five years later and I decided to try a scripted approach to this topic Epsxe/pcsxr notepad++ regex cheat conversion. It’s wonky Linux Bash foolishness. You can check it out on my Github, pr2ro.

Looks like the code format is hex (8 4) with a delimiter of space, colon, or plus. I decided to go with a two-dimensional array to allow for headings to be numbered properly. Since Bash doesn’t really do 2D arrays, I preprocess the heading names into one array and codes into another, doing some magic to ensure both are valid (not blank, strip headings without codes, remove leading/trailing spaces, etc.).

If that goes to plan, both arrays are the same length and we can write the data out. Works well in my test cases. The script will try to identify what code types are in the input file, and it can easily swap between the two. _pcsr and _retro are appended to the input filename and reused so you can just keep going back and forth.

One nice thing is to switch from RetroArch to PCSXR, add, rearrange codes, etc, then reformat back and the numbering will be handled. Only code type I don’t reformat is that weird xploder which is in the format hex 12 prepended by a dollar sign. I assume it’s encrypted. Decrypted codes are usually in hex (8 4).

It really only works for a properly formatted PCSXR or RetroArch .cht cheat file. If the file is bad to begin with… well, garbage in, garbage out.