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.
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.
Yes, of course. Either way slash or backslash, Visual Studio Code reports cannot open source file "hardware/flash.h" C/C++(1696)
when hovering over the red-wavy line for the #include.
I suspect this is a cmake issue, as I found within within pico-sdk/src/rp2_common/CMakeList.txt the first line is:
option(PICO_NO_FLASH "Default binaries to not not use flash")
So I’m assuming PICO_NO_FLASH is being set and I’m not sure where I can set that option allowing the flash.h to be included.