vivl.c 470 Bytes

void vivl(unsigned int frac, unsigned int rgb_a, unsigned int rgb_b,
	  unsigned int sync_b, unsigned int *rgb, unsigned int *sync)
{
    static unsigned int vllerp_rgb, vllerp_sync, csa;

    *rgb  = vllerp_rgb % 256;
    *sync = vllerp_sync;

    csa = (((rgb_b - rgb_a) * frac + 16 >> 5) + rgb_a) % 256;

    vllerp_rgb  = 
	sync_b ?
	((rgb_a & (1 << 7)) | (rgb_b & (1 << 7))) | (rgb_b & ((1 << 7) - 1)) :
	((frac == 0) ? rgb_a : csa);
    vllerp_sync = sync_b;
}