garden game save/memory shenanigans
@InspectorCaracal if you don't save xy and plan it in a map instead you can fit each flower in 11 bits
garden game save/memory shenanigans
@InspectorCaracal park editors*
garden game save/memory shenanigans
@squirrel how would you do that?
garden game save/memory shenanigans
this won't guarantee you can plant the entire field but here's an idea:
start from 0,0 (or whatever top left is on your field)
0x00 0x## means next ## spaces are blank (no flower)
anything other than 0x00 means flower data
this would be a very rudimentary RLE in that you're compressing whitespace
but once you get enough flowers filling it up it'll overflow your save space regardless
garden game save/memory shenanigans
@squirrel wait planning it in a map means like, you assign specific coordinates to specific address points? 🤔 *reads over everything again*
garden game save/memory shenanigans
@InspectorCaracal nonono.
you start at 0,0 right
say i store a string like
0x00 15
(code for red flower)
0x00 2
(code for blue flower)
and assume your field is 16 wide
this means:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ R
_ _ B _ _ _ _ _ _ (etc...)
garden game save/memory shenanigans
@InspectorCaracal actually you can save more space if you:
make blank space only one byte by keeping it under 128
use two blank space bytes if it's >127 (for a blank space > 127, store 127, x - 127 etc)
that way, you know it's a count for blank spaces if the leftmost bit is 0, otherwise it's a flower byte
garden game save/memory shenanigans
@squirrel *attempts to wrap my mind around this*
I'm not getting it. .-.
garden game save/memory shenanigans
let's go over your flower data again:
16 possible Flowers, that's 4 bits
8 Maturity stages, that's 3 bits
6 Leaf types, that's 3 bits
and Rarity, which is one bit
so:
0b1FFFFMMM 0bLLLR0000
first bit is 1 to indicate there's flower data, followed by 11 bits of data
if the first bit is 0, which would coincidentally be a number lower than 128, we treat it as blank space, no flower is planted
so:
0b0010000 = 16 blank spaces
garden game save/memory shenanigans
@InspectorCaracal
if we see that in the save data, that means, starting from the top left, we skip 16 field spaces, then treat next byte, etc
garden game save/memory shenanigans
@InspectorCaracal
if <byte> < 128, jump <byte> space in field, starting top left, going left to right
if <byte> >= 128, decode flower data <byte>, <byte+1>
does that make sense?
garden game save/memory shenanigans
@squirrel oooh!! Yes, I got it!
Is there any way to use the rest of the second byte for the next flower or something, or do I have to divide the data into in byte-sized chunks?
garden game save/memory shenanigans
@InspectorCaracal i wouldn't know of an easy way to do it... the bytes sort of help you know when to expect the next block of data, be it whitespace or flower data
garden game save/memory shenanigans
@squirrel okay cool cool, so that puts me at a max # of flowers of about 126ish or so. An improvement~
Maybe I'll put a check in the save function, like, if you have too many flowers, you can't save, with a prompt telling you that you need to get rid of some flowers. That way it'd let you plant more flowers than that if you want to while playing.
garden game save/memory shenanigans
@InspectorCaracal with this way, you can store up to 128 flowers (best case scenario, they're sequential and starting at top left) or at least ~85 flowers (blank space byte between each flower bytes)
not sure how to improve this any more :( sorry
garden game save/memory shenanigans
@InspectorCaracal also: this kind of problem is why thps part editors had a gauge that would fill up ;)