Skip to content

Commit

Permalink
vt(4): Put for() loop outside switch() in vt_generate_cons_palette()
Browse files Browse the repository at this point in the history
This makes it more logical:
 1. It checks the requested color format
 2. It fills the palette accordingly

Also vt_palette_init() is only called when needed (i.e. when the format
is `COLOR_FORMAT_RGB`).
  • Loading branch information
dumbbell committed May 10, 2018
1 parent 21f4249 commit c7886ad
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions sys/dev/vt/colors/vt_termcolors.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,21 +171,21 @@ vt_generate_cons_palette(uint32_t *palette, int format, uint32_t rmax,
{
int i;

vt_palette_init();

#define CF(_f, _i) ((_f ## max * color_def[(_i)]._f / 100) << _f ## offset)
for (i = 0; i < NCOLORS; i++) {
switch (format) {
case COLOR_FORMAT_VGA:
switch (format) {
case COLOR_FORMAT_VGA:
for (i = 0; i < NCOLORS; i++)
palette[i] = cons_to_vga_colors[i];
break;
case COLOR_FORMAT_RGB:
break;
case COLOR_FORMAT_RGB:
vt_palette_init();
#define CF(_f, _i) ((_f ## max * color_def[(_i)]._f / 100) << _f ## offset)
for (i = 0; i < NCOLORS; i++)
palette[i] = CF(r, i) | CF(g, i) | CF(b, i);
break;
default:
return (ENODEV);
}
}
#undef CF
break;
default:
return (ENODEV);
}

return (0);
}

0 comments on commit c7886ad

Please sign in to comment.