I got this code:


/*******************************************
*******************************************/

typedef unsigned char byte;
typedef byte palete[256][3];


void setcolorrgb(int pos, byte r, byte g, byte b)
{
if (pos < 256)
{
outportb (0x03c8,pos);
outportb (0x03c9,r);
outportb (0x03c9,g);
outportb (0x03c9,b);
}
}

void setpaletergb(palete p)
{
int pos = 0;
for (pos=0; pos<256; pos++)
setcolorrgb(pos,p[pos][0],p[pos][1],p[pos][2]);
}

void getpaletergb(palete &p)
{
int pos = 0;
byte index = 0;
for (pos=0; pos<256; pos++)
{
outportb (0x03c7,pos);
for (index=0; index<3; index++)
p[pos][index] = inportb (0x03c9);
}


/*******************************************
*******************************************/


i need to know is there some kind of math procedure to make a palete fade to a color... i know how to fade from white (255,255,255) to black (0,0,0) is quite simple just use something like this

/* This is when i got all the colores in 255, 255, 255 */
for (x = 255; x >= 0; x--)
for (pos=0; pos<256; pos++)
setcolorrgb(pos, x, x, x);

but when i got other colors in the palete???