(11-16-2024, 09:34 PM)ahenry3068 Wrote: Its good code. And I've been playing with similar techniques to pack RAM more tightly on the X16 a neo-retro 8 bit computer. However, I can't see why would ever need this technique on even a barely modern system. It's seems kind of a waste for a relatively small RAM savings.
No offense meant. It is quite nice code actually. IMO I just don't see the point. .
The point is to use a variable for bit-packing. In this case though, I personally think I'd just use a custom type and save myself a lot of shifting and headache.
TYPE msl_type
game as _byte
mask as _byte
hour as _byte
minute as _byte
second as _byte
END TYPE
5 bytes with each to use, access, and something everyone can understand at a glance. Compared to 4 bytes which is rather complex for a lot of folks to ever sort out and work with.
Trust me, I can promise you which one is easiest to come back to and work on after a 2 year break or whatnot.
(11-16-2024, 10:28 PM)Petr Wrote:(11-16-2024, 09:34 PM)ahenry3068 Wrote: Its good code. And I've been playing with similar techniques to pack RAM more tightly on the X16 a neo-retro 8 bit computer. However, I can't see why would ever need this technique on even a barely modern system. It's seems kind of a waste for a relatively small RAM savings.
No offense meant. It is quite nice code actually. IMO I just don't see the point. .
What's the point? Huge. Just read the documentation for MP3 or MP4 format, for GIF format, also for TTF font files, for 1-bit bitmaps and so on. Bit fields need to be decoded everywhere, it's a perfectly common practice.
It's also not just for modern formats. Even old-school graphics did this with bit packing for black/white screens. Screen 7(I think) packs it's memory into 4-bit nibbles (half-bytes). It's not rare at all to see this type of thing in use with more advanced code and projects.