Speed up the translucency effect when there's a perfect match.

git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@1477 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
Yves Rizoud 2010-05-16 14:29:13 +00:00
parent 039c8a7194
commit a29c025156

View File

@ -2629,14 +2629,22 @@ void Display_all_screen(void)
byte Best_color(byte r,byte g,byte b)
{
short col;
// This "static" allows the loop to start on the last successful match.
// If the same color is requested again (and it happens often) and the match
// was perfect, it allows an early exit that avoids
// 255 computations of color distance.
// This system still works with no bad effects when the palette changes.
static byte col=0;
byte end_color;
int delta_r,delta_g,delta_b;
int dist;
int best_dist=0x7FFFFFFF;
int rmean;
byte best_color=0;
for (col=0; col<256; col++)
end_color=col;
do
{
if (!Exclude_color[col])
{
@ -2656,21 +2664,31 @@ byte Best_color(byte r,byte g,byte b)
best_color=col;
}
}
}
// Loop
col++;
} while(col!=end_color);
return best_color;
}
byte Best_color_nonexcluded(byte red,byte green,byte blue)
{
short col;
// This "static" allows the loop to start on the last successful match.
// If the same color is requested again (and it happens often) and the match
// was perfect, it allows an early exit that avoids
// 255 computations of color distance.
// This system still works with no bad effects when the palette changes.
static byte col=0;
byte end_color;
int delta_r,delta_g,delta_b;
int dist;
int best_dist=0x7FFFFFFF;
int rmean;
byte best_color=0;
for (col=0; col<256; col++)
end_color=col;
do
{
delta_r=(int)Main_palette[col].R-red;
delta_g=(int)Main_palette[col].G-green;
@ -2688,7 +2706,11 @@ byte Best_color_nonexcluded(byte red,byte green,byte blue)
best_dist=dist;
best_color=col;
}
}
// Loop
col++;
} while(col!=end_color);
return best_color;
}