Log In  


It'd be awesome to be able to save/load state in your game like old console games.

Maybe a small per/game buffer we can read from/write to.
Or a virtual memory card type device we can access.

4


ohh, maybe I can use the cstore somehow to write a save game to the cart! anyone tried this?


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.


Thanks for the info zep! 64 bytes sounds like quite the challenge! =)


oh sweet! I was just planning on coding in passwords :P still might because that's kind of cute


Welp if all you need is to save the highest level the player's beaten you can still have a looooot of levels.


3

Cart #18763 | 2016-02-11 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
3

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


Cart #18761 | 2016-02-11 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
3


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]