ModifyPalette refactored in TexCache.c