Picosystem how to get persistent storage in C++?

Hello, I’ve been going through the C++ SDK and API documentation, but I’ve not seen any methods to create and read a file. I’m making a game, and would be great to allow players to save their game state to pickup where they left off, rather than restart each time.

I’ve played the game Gate Keeper on the Picosystem, and that game allows saved game states. Can anyone point out how to save data using C++ on the Picosystem.

Thanks.

There is this post: The basics of writing/reading user data to the flash memory for long term storage - Raspberry Pi Forums
Note it has a correction at the end, so read the complete post.

This is only reading/writing raw bytes, which should be enough to save the state of a game. If you really need files, you should add an sd-card and use one of the fatfs-libraries available.

You can, of course, use fatfs to wrangle files in flash too - it’s what I do with my Picow Boilerplate. But you are somewhat limited by size, of course!

Good point. Regarding the size limit: I have added an xtsd chip to one of my Pico-designs. This is a flash chip with emulated sd-controller. Compared to the cost of a sd-reader and sd-card, these chips are really cheap (and faster and non-mechanical). Adafruit has one on a breakout, nice for testing, but very expensive.