I'm not sure how I'd write a value (like a lua number) to memory and then read it back in a useful way.
for example, how would you go about saving the player's x,y coordinates to memory, storing it to the cart and then read it back and get numbers.
Saving is on the cards for 0.1.2:
64 bytes from 0x5fc0 will be persistent and automatically saved and restored per cartridge. They can be accessed using PEEK and POKE. e.g.
function save_score(score) poke(0x5fc0, flr(score/256)) poke(0x5fc0, score % 256) end function load_score() return peek(0x5fc0)*256 + peek(0x5fc1) end
So it will be possible to cram in enough data for a simple rpg at the most, but not for something like storing a sim city game state.
It would be possible for the cartridge to modify and save itself using cstore() + save(), but this is only supported on some pico-8 platforms where the editing tools are present. It's normally used for things like saving data generated by custom tools. Carts published as pngs to the web or on future platforms won't necessarily support it, for example.
Update: v1.0.1 of the demo includes an load_score function that displays raw values of 0x5fc0 and c1.
Also increased the increment from 1 to 10.
v1.0.0 of demo
I noticed the load_score function (thanks zep for example code) gives an entirely different value vs just peeking 0x5fc0. Do I need to do something else to the returned score before I can use it?
print(peek(0x5fc0)) -- yields 82 -- using the load function i get 20992
Did some experimenting and suspect it's to avoid overflowing when you hit 256? Do I need to do some bitshifting?
[Please log in to post a comment]