Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Bite operations with ShL and ShR
#5
(11-16-2024, 10:30 PM)SMcNeill 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.   Wink.

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. Smile

(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.   Wink.

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.  Smile
  Ahh.  Ok I stand corrected.   I just didn't get the context for the code.      I didn't think of decoding packed file formats at all.   I've been using bit packed variables to save memory and that's what I thought of first...     I'll think twice next time.
Reply


Messages In This Thread
Bite operations with ShL and ShR - by Petr - 11-16-2024, 08:44 PM
RE: Bite operations with ShL and ShR - by Petr - 11-16-2024, 10:28 PM
RE: Bite operations with ShL and ShR - by ahenry3068 - 11-16-2024, 11:26 PM
RE: Bite operations with ShL and ShR - by Pete - 11-17-2024, 01:31 AM
RE: Bite operations with ShL and ShR - by Pete - 11-19-2024, 01:03 AM



Users browsing this thread: 1 Guest(s)