play_memory_fli(3alleg4)

πŸ’– play_memory_fli πŸ’–

okay bestie, so this is a page from the Allegro manual β€” Allegro being the game programming library, yes the whole vibe ✨ β€” and it's filed under section 3alleg4. The function is play_memory_fli, and no cap, it's giving "animation but make it RAM".


✨ SYNOPSIS ✨

#include <allegro.h>

int play_memory_fli(const void *fli_data, BITMAP *bmp, int loop, int
(*callback)());

🌸 DESCRIPTION 🌸

So basically play_memory_fli plays an Autodesk Animator FLI or FLC animation onto the BITMAP you point it at, except β€” and this is the moment β€” it reads the data from a copy of the file held in memory, not from disk. Iconic behavior, honestly.

You get that fli_data pointer one of two ways:

  • allocate a block of memory and read an FLI file into it, or
  • import an FLI into a grabber datafile.

Now the loop parameter, listen: if loop is not zero, the player cycles back around when it hits the end of the file. If it is zero, it plays the whole animation through exactly once and then returns. That's it, that's the deal. πŸŽ€

And for the callback parameter? Girl, go read the beginning of the chapter called "FLIC routines" β€” it's all described there, I'm not gonna paraphrase the good people.

Playing animations from memory is obviously faster than cueing them directly from disk, and it's lowkey perfect for short, looped FLI's. But here's the tea: animations can get very large very fast, so in most cases you'll probably be better off just using play_fli(). Fr fr. Think of this function as a cute little wrapper layered on top of open_memory_fli(), next_fli_frame() and close_fli(). She's a girlboss delegating πŸ’…

Example, bestie:

int ret = play_memory_fli(anim_data, screen, 0, NULL);
if (ret == FLI_ERROR)
   abort_on_error("Corrupted animation data?");

πŸ”₯ RETURN VALUE πŸ”₯

The FLI player hands you back:

  • FLI_OK β€” she reached the end of the file, slay
  • FLI_ERROR β€” something went wrong 😭
  • whatever value the callback function returned β€” but only if that was the thing that stopped her

πŸ¦‹ SEE ALSO πŸ¦‹


k that's the whole page, you ate it. this was Allegro version 4.4.3, manual page play_memory_fli(3alleg4), and yes she's been sitting here since forever β€” go read the source, it's giving history πŸ’œ byeeee 🫢