Skip to content
This repository has been archived by the owner on Oct 24, 2020. It is now read-only.

Add cartdata support, for persistent storage #31

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tobiasvl
Copy link

@tobiasvl tobiasvl commented Aug 9, 2018

I'm not at all sure this is the best approach, but it's a naive attempt.

I made some choices:

  • Used LÖVE 11's new love.data.pack/love.data.unpack functions (there are a million other serializing libraries, but I opted for this to use a built-in)
  • Changed internal cartdata table to a 1-indexed sequence, to make it easier to pack/unpack it
  • Made 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 cartdata
  • dget() 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 calls dget()/dset(), which means there's some overhead but I'm not sure we can escape it

There 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.

- Change internal cartdata table to a 1-indexed sequence for ease
- cartdata() sets up LÖVE save file
- dget() loads entire cartdata each time
- dset() saves entire cartdata each time
- peek()/poke() at persistent memory calls dget()/dset()
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant