With the new version of Pico8 you can use 4 diffrent CARTDATA-Ids to store 1000 bytes.
But what can you do, when you need more? This demo-file stores 1k bytes (16 cartdata-ids!) of data.
How it's work:
The Run-command does the trick. It restart the cartridge, reset the cartdata-ids-usage (and other stuff, like music) and you can pass a command line (even in the web-version). Sadly it erased every variable BUT it does not erase the free memory (0x4300 to 0x5fff and 0x8000 to 0xffff). So simple store there your complete gamedata and use "RUN".
The magic happen at the beginning. The code checks if a command line was passed to the cartridge. In the commandline is encoded what to do, which memory-adress should be saved, how many bytes and which "baseid" should be used.
It simple calls a series of cartdata and memcpy to save or load the data. When more than 4 ids are needed, it re-"run" the code with a updated command line.
When all data is saved or loaded, the variable "resume" is set to "true".
The game-code must then decide, if a title screen should be displayed, or the gamedata is load.
Some note:
- All variables are deleted, you need to peek/poke it to the memory
- storing so many data will take some time!
- since "run" performance a "soft"-reset, you can't play music or do other fancy stuff.
Here is the example-code.
It only generate 1k random numbers in the area 0x8000 to 0x8fff and display some of them. You can create new random numbers, load, save and clear them all. Nothing special.


[Please log in to post a comment]