MADS: Implement palette animation code