garden game save/memory shenanigans
so I've got x,y coordinates on a 16x16 grid, saving those is one byte
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 assuming I can figure out how to split the info between bytes despite having byte-level peek/poke commands, that's 19 bits per flower, which means 107 flowers before I run out of save memory.
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
@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 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