fixup_datafile(3)

πŸ“¦ version 4.4.3.1, in fedora 43, fedora 44

✨ fixup_datafile(3) ✨

okay bestie, welcome to the Allegro manual πŸ’– this one's short but she is IMPORTANT, so pay attention fr fr


🌸 NAME 🌸

fixup_datafile β€” Fixes truecolor images in compiled datafiles. Allegro game programming library.

like. the name literally tells you what it does. iconic behaviour honestly πŸ‘‘


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <allegro.h>

void fixup_datafile(DATAFILE *data);

one function, one argument, zero drama πŸ’…


πŸŽ€ DESCRIPTION πŸŽ€

okay so here's the tea β˜• if you're using compiled datafiles (those are the ones produced by the dat2s and dat2c utilities, iykyk) on a platform that doesn't support constructors β€” which, rn, is literally any non GCC-based platform β€” OR if your datafiles contain truecolor images, then you MUST call this function. Once. After you set the video mode you're gonna be using. No cap, it's mandatory in those cases 🫢

what does it do for you, queen? two things:

  • makes sure the datafiles are properly initialised, in that first no-constructors case
  • converts the color values into the appropriate format, in the truecolor case

and the way it handles all that? it deals with flipping between RGB and BGR formats, and it converts between different color depths whenever that can be done without changing the size of the image. which specifically means:

  • changing 15<->16-bit hicolor β€” for both bitmaps AND RLE sprites ✨
  • changing 24<->32-bit truecolor β€” for RLE sprites πŸ’«
⚠️ okay this next bit is the important warning, do NOT skip it. You can only call this once and expect it to work correctly. Because after the call, the DATAFILE you fixed up is permanently converted to whatever the current component ordering is for your screen mode. If you call fixup_datafile again, the function just assumes you've got a freshly loaded datafile. It literally cannot "undo" the previous conversion. there is no take-backsies 😭

so what if your program supports changing resolution and/or color depth during runtime? bestie, you've got two choices and only two 😌

  1. Call fixup_datafile() just once and hope that the component ordering and bit depth doesn't change when the screen mode changes. (unlikely. be so fr πŸ™ˆ)
  2. Or, you can reload your datafiles whenever the screen mode changes. much safer energy ✨

🌈 SEE ALSO 🌈


and that's the whole page bestie, you ate that πŸ’… this was the Allegro manual, version 4.4.3, and yeah that's the source right there β€” Allegro itself, serving looks since forever πŸ‘‘ go set your gfx mode and call your fixup function, but like... only once πŸŽ€πŸ’–βœ¨

πŸ“¦ where this page comes from