This repository has been archived by the owner on Oct 24, 2020. It is now read-only.
Add cartdata support, for persistent storage #31
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I'm not at all sure this is the best approach, but it's a naive attempt.
I made some choices:
cartdata()
set up a LÖVE save file in a common "picolove" directory (this choice was already made in the config) with the cartdata id as a filename, to mirror PICO-8's setup and make it possible for carts to share cartdatadget()
loads the entire cartdata each time, to make sure we're always reading from the persistent storage (is this necessary unless we want to support multiple carts accessing memory at the same time?)dset()
saves the entire cartdata each time (this is probably necessary)peek()
/poke()
at persistent memory now callsdget()
/dset()
, which means there's some overhead but I'm not sure we can escape itThere might be more efficient ways to do the serializing and file handling. I'm pretty new to LÖVE. We could perhaps even do away with the serializing and the entire
pico8.cartdata
table now that it's just a transparent cache, and scan to the correct location in the file every time instead... Suggestions welcome.