http://pulkomandy.tk/projects/GrafX2/ticket/39

pass the palette argument from Compute_optimal_menu_colors(palette)
to compute_xor_table()
This commit is contained in:
Thomas Bernard 2018-11-29 15:26:22 +01:00
parent 96083c3c3b
commit 775a594858
No known key found for this signature in database
GPG Key ID: 0FF11B67A5C0863C
2 changed files with 18 additions and 17 deletions

View File

@ -3365,15 +3365,15 @@ void Remap_screen_after_menu_colors_change(void)
} }
static int Diff(int i, int j) { static int Diff(const T_Components * palette, int i, int j) {
int dr = Main.palette[i].R - Main.palette[j].R; int dr = palette[i].R - palette[j].R;
int dg = Main.palette[i].G - Main.palette[j].G; int dg = palette[i].G - palette[j].G;
int db = Main.palette[i].B - Main.palette[j].B; int db = palette[i].B - palette[j].B;
return dr*dr + dg*dg + db*db; return dr*dr + dg*dg + db*db;
} }
static void compute_xor_table() static void compute_xor_table(const T_Components * palette)
{ {
int i; int i;
byte found; byte found;
@ -3397,10 +3397,10 @@ static void compute_xor_table()
for(i = 0; i < 256; i++) for(i = 0; i < 256; i++)
{ {
// diffs before the swap // diffs before the swap
int before = Diff(idx, xor_lut[idx]) + Diff(i, xor_lut[i]); int before = Diff(palette, idx, xor_lut[idx]) + Diff(palette, i, xor_lut[i]);
// diffs after the swap // diffs after the swap
int after = Diff(idx, xor_lut[i]) + Diff(i, xor_lut[idx]); int after = Diff(palette, idx, xor_lut[i]) + Diff(palette, i, xor_lut[idx]);
if (after - before > improvement) if (after - before > improvement)
{ {
@ -3426,7 +3426,7 @@ static void compute_xor_table()
} while(found); } while(found);
} }
int Same_color(T_Components * palette, byte c1, byte c2) static int Same_color(const T_Components * palette, byte c1, byte c2)
{ {
if (palette[c1].R==palette[c2].R && if (palette[c1].R==palette[c2].R &&
palette[c1].G==palette[c2].G && palette[c1].G==palette[c2].G &&
@ -3435,7 +3435,9 @@ int Same_color(T_Components * palette, byte c1, byte c2)
return 0; return 0;
} }
void Compute_optimal_menu_colors(T_Components * palette) static void Remap_menu_sprites(const T_Components * palette);
void Compute_optimal_menu_colors(const T_Components * palette)
{ {
int i; int i;
byte l[256]; byte l[256];
@ -3498,7 +3500,7 @@ void Compute_optimal_menu_colors(T_Components * palette)
MC_Window=MC_Light; MC_Window=MC_Light;
MC_Lighter=MC_White; MC_Lighter=MC_White;
MC_Darker=MC_Dark; MC_Darker=MC_Dark;
Remap_menu_sprites(); Remap_menu_sprites(palette);
return; return;
} }
} }
@ -3548,7 +3550,7 @@ void Compute_optimal_menu_colors(T_Components * palette)
MC_Window=MC_Light; MC_Window=MC_Light;
MC_Lighter=MC_White; MC_Lighter=MC_White;
MC_Darker=MC_Dark; MC_Darker=MC_Dark;
Remap_menu_sprites(); Remap_menu_sprites(palette);
return; return;
} }
} }
@ -3661,15 +3663,15 @@ void Compute_optimal_menu_colors(T_Components * palette)
} }
MC_Lighter=MC_White; MC_Lighter=MC_White;
Remap_menu_sprites(); Remap_menu_sprites(palette);
} }
/// Remap all menu data when the palette changes or a new skin is loaded /// Remap all menu data when the palette changes or a new skin is loaded
void Remap_menu_sprites() static void Remap_menu_sprites(const T_Components * palette)
{ {
int i, j, k, l; int i, j, k, l;
compute_xor_table(); compute_xor_table(palette);
if ( (MC_Light!=Old_light) if ( (MC_Light!=Old_light)
|| (MC_Dark!=Old_dark) || (MC_Dark!=Old_dark)
|| (MC_White!=Old_white) || (MC_White!=Old_white)

View File

@ -40,8 +40,7 @@ void Display_cursor(void);
void Hide_cursor(void); void Hide_cursor(void);
void Remap_screen_after_menu_colors_change(void); void Remap_screen_after_menu_colors_change(void);
void Compute_optimal_menu_colors(T_Components * palette); void Compute_optimal_menu_colors(const T_Components * palette);
void Remap_menu_sprites();
void Position_screen_according_to_zoom(void); void Position_screen_according_to_zoom(void);
void Compute_separator_data(void); void Compute_separator_data(void);