I'm relatively new to Pico-8 (and programming in general). So I have two quick questions.
Can you save strings similar to the dset method? I know you can save each character in a slot but that brings me onto my next question.
Can you have more than one cartdata to save to? I'm trying to economize my 256 memory slots. Without saving character names, I can fit about 4 saves in that space. But I can only fit about 2 or 3 with doing letters in each slot.
If there is no way to have multiple cartdatas or a similar feature, is there a more effective and accurate way to store multiple characters in a single byte?
I was thinking of some crazy stuff like adding up the alpha-numeric value and dividing it or taking away a certain amount but it's too late at night and I'm a bit brain dead from all my stuff before hand.
Thanks in advance!
I did a thing once with a filesystem I had to cache in very limited memory:
First, I reduced the legal characters to a bare minimum set of 39: 0
-9
, A
-Z
, _
, .
. With a nul (value 0) terminator/pad value, this comes to 40 possible values per character.
Then I stored filenames with three characters per two bytes. A 16-bit value can hold 65536 values, and 40x40x40 is only 64000, so it fits.
Extracting the three characters was just a matter of using %40 and /40 a few times on the 16-bit value.
I padded to the destination buffer's constant length with nuls, but you could use spaces instead. Either way, after you read the name, just trim the padding off of the right end.
Edit: Actually, your best bet for names spelled in the roman character set would probably be A-Z, 0-9 (people do like using numbers in their nicknames, e.g. Punchmaster 9000), hyphen, apostrophe, and space. I think you can do just about any reasonable name with those, and it leaves one slot open, perhaps for a period or a comma. Or you could make the last one an escape code to allow additional characters, kinda like UTF-8 does, but that's a whole other can of worms and I'm not sure I'd recommend it.
What happens if we try to load or swap different cartdatas? Like save slots for complex characters and game states?
Oh, well it says you can't... I gotta look into cstore then...
here's a snippet that saves user mem in a side cart
savecart="mysavecart" -- save full user mem function umsave() -- 6912 bytes from 0x4300 cstore(0x4300,0x4300,0x1b00,savecart) end -- load full user mem function umload() -- 6912 bytes from 0x4300 reload(0x4300,0x4300,0x1b00,savecart) end |
doesn't work well in firefox but should be fixed in next version
(see https://www.lexaloffle.com/bbs/?tid=29986)
note you can save anywhere from 0x0000 to 0x5dff in the side cart, that's 24064 bytes
Thank you ;-; you have saved the day.
I got this multiplayer game based on Battle Hunter (for PS1) and since it is multiplayer, it was super important to save more than a few characters.
😍 Thank you!
[Please log in to post a comment]