vivh.c
470 Bytes
void vivh(unsigned int frac, unsigned int rgb_a, unsigned int rgb_b,
unsigned int sync_b, unsigned int *rgb, unsigned int *sync)
{
static unsigned int vhlerp_rgb, vhlerp_sync, csa;
*rgb = vhlerp_rgb % 256;
*sync = vhlerp_sync;
csa = (((rgb_b - rgb_a) * frac + 16 >> 5) + rgb_a) % 256;
vhlerp_rgb =
sync_b ?
((rgb_a & (1 << 7)) | (rgb_b & (1 << 7))) | (rgb_b & ((1 << 7) - 1)) :
((frac == 0) ? rgb_a : csa);
vhlerp_sync = sync_b;
}