Log In  

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!

P#44986 2017-10-08 09:14 ( Edited 2017-10-11 20:55)

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.

P#44996 2017-10-08 11:43 ( Edited 2017-10-09 02:27)

What happens if we try to load or swap different cartdatas? Like save slots for complex characters and game states?

P#45010 2017-10-08 22:54 ( Edited 2017-10-09 02:54)

Oh, well it says you can't... I gotta look into cstore then...

P#45103 2017-10-11 07:36 ( Edited 2017-10-11 11:36)

here's a snippet that saves user mem in a side cart


-- save full user mem
function umsave()
    -- 6912 bytes from 0x4300

-- load full user mem
function umload()
    -- 6912 bytes from 0x4300

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

P#45104 2017-10-11 08:17 ( Edited 2017-10-11 12:17)

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!

P#45126 2017-10-11 16:55 ( Edited 2017-10-11 20:55)

[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2023-12-09 01:36:45 | 0.007s | Q:15