fli_pal_dirty_from(3)

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

πŸ’– fli_pal_dirty_from β€” bestie, it's the palette gossip tracker

okay so this is from the Allegro manual, section 3, and it's literally just two lil global ints that tell you which slice of your palette just changed. main character energy fr fr. πŸŽ€


✨ NAME ✨

fli_pal_dirty_from, fli_pal_dirty_to β€” these two tell you which parts of the palette have changed. part of the Allegro game programming library, bestie πŸ¦‹


🌸 SYNOPSIS 🌸

#include <allegro.h>

extern int fli_pal_dirty_from;

extern int fli_pal_dirty_to;

πŸ’… DESCRIPTION πŸ’…

so the way this works: next_fli_frame() sets these two variables for you, and they mark which part of fli_palette has changed since the last time somebody called reset_fli_variables(). it's giving "here's your update, queen." πŸ‘‘

the rule is lowkey simple:

  • if fli_pal_dirty_from is greater than fli_pal_dirty_to β†’ the palette has NOT changed, nothing to see here, go home, no notes πŸ’€
  • otherwise β†’ colors fli_pal_dirty_from to fli_pal_dirty_to, inclusive, have altered ✨

and why do you care? because when you're updating the hardware palette you can use these to dodge unnecessary calls to set_palette(). it's called not wasting cycles, and it's iconic. 🫢

example, verbatim, no cap:

if (fli_pal_dirty_from <= fli_pal_dirty_to)
   set_palette_range(fli_palette, fli_pal_dirty_from,
                     fli_pal_dirty_to, 1);

like… look at that. only touch the palette if the palette actually moved. periodt. πŸ”₯


πŸ‘‘ SEE ALSO πŸ‘‘


ngl bestie, if you're out here calling set_palette() on a palette that hasn't changed, that's not the vibe. check the dirty range first. iykyk πŸ’œ

and that's the whole page, babes 🌈 β€” brought to you by the Allegro manual, version 4.4.3. mwah πŸ’…βœ¨

πŸ“¦ where this page comes from