BACKGROUND INFORMATION:
Hi, I wrote a function that takes an rgb value, finds an un-used palette color and sets that color to the specified rgb value then returns the color that it set, once it has set a certain color to a value it marks it as "USED" so that it wont be re-set to something else on further calls to the function. I also wrote a function which goes through the screen too try too free up some colors that were marked as "USED" but are no longer in use.

THE QUESTION:
Is there a faster way too free un-used colors, my way is pretty slow. I go pixel by pixel checking.

thanks