I’m still loving the Anbernic RG35XX but sometimes thing go wrong and I need to pop the SD card into a computer to delete a file to get some things working again. The OS saves the game state when you close a game, and occasionally with PICO-8 games the save file gets corrupted and you can’t launch the game again until you delete the bad file…
Since there’s a terminal application you could go into that and cd to the correct directory and delete the file, but they keyboard is… well, it’s like a TV remote. Arrow around a keyboard and enter keys one at a time, so there has to be a better way… so I wrote a script.
I just launch SimpleTerminal, and to save keystrokes the script lives right in that directory…
So I type ./fixp8.sh
(Or actually just ./fi
and then the tab
key to autocomplete…
…And then the script runs, and shows some instructions. It also shows the most recently modified file so you can choose to fix it, skip it, or quit the script.
If that file doesn’t belong to the game causing issues, I skip it, and it moves on to the next most recently modified file…
The script only accepts f, s, or q for input. When you are done (hopefully after fixing the bad file) you can quit.
Note that the script doesn’t delete any files, just renames them, in case you “fix” the wrong file. (You can un-fix it easily on a computer by renaming it back. We just add a ~ after the file name.)
I think (and should confirm) that the way the system works, if you launch a game by selecting it and pressing the A button it should try to reload the last saved state, but if you press the Start button, it should start fresh ignoring the save file. It seemed like this didn’t always work… maybe just with PICO-8 games? If you find out, let me know.
In the meantime it’s been really interesting (and a little fun!?) learning how to write and run scripts on this device. I mean, it’s basically Linux. You can even run scripts at startup, and I think I saw that you can get cron installed, which is pretty wild but also not really, because Linux.
(Note: Since I wrote this I found another use case for fixing files, and I’ll follow up with that in another post.)
Here’s the script!
#!/bin/sh # where the directory is located # mms for first card, SDCARD for second card SAVEDIR="/mnt/SDCARD/Saves/CurrentProfile/saves/fake-08/cdata/" cd "$SAVEDIR" # we need a way to get only txt files not txt~ files FILES=`ls -t *txt | head -n 50` echo "" echo "This will fix bad P8 save files." echo "Fix a file, skip it, or quit." echo "Fix [F], Skip [S], Quit [Q]." echo "" for f in $FILES do while true; do read -p "Fix $f? " fsq case $fsq in [Ff]* ) echo "Fixing $f"; echo ""; mv "$f" "$f~"; break;; [Ss]* ) echo "Skipping $f"; echo""; break;; [Qq]* ) echo "Quitting"; echo""; exit;; * ) echo "Please answer F, S, or Q.";; esac done done