Ok, new state-saving code is checked in on github.
I have tested it but it’s a large-ish change, so the possibility of bugs is not insignificant.
Please give it a try and see how it works and performs.
I don’t think we need to test if it is better for sd corruption or not, I think we can just assume that it is, as long as we assume that when the SD writes are interrupted, they don’t randomly corrupt other parts of the SD card.
It should still be able to read files which don’t have the new format, so if you want to edit files manually you can. To convert a new save file into the old format, you just cut off the first 512 bytes and everything after the first end
line. Note that there will be a lot of zeroes and other invisible characters, so you need an editor that can handle and show those characters.