2 * Copyright (c) 2013 The FreeBSD Foundation
5 * This software was developed by Aleksandr Rybalko under sponsorship from the
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 #include <sys/param.h>
34 #include <dev/vt/colors/vt_termcolors.h>
37 unsigned char r; /* Red percentage value. */
38 unsigned char g; /* Green percentage value. */
39 unsigned char b; /* Blue percentage value. */
41 {0, 0, 0}, /* black */
42 {0, 0, 50}, /* dark blue */
43 {0, 50, 0}, /* dark green */
44 {0, 50, 50}, /* dark cyan */
45 {50, 0, 0}, /* dark red */
46 {50, 0, 50}, /* dark magenta */
47 {50, 50, 0}, /* brown */
48 {75, 75, 75}, /* light gray */
49 {50, 50, 50}, /* dark gray */
50 {0, 0, 100}, /* light blue */
51 {0, 100, 0}, /* light green */
52 {0, 100, 100}, /* light cyan */
53 {100, 0, 0}, /* light red */
54 {100, 0, 100}, /* light magenta */
55 {100, 100, 0}, /* yellow */
56 {100, 100, 100}, /* white */
60 vt_generate_vga_palette(uint32_t *palette, int format, uint32_t rmax, int roffset,
61 uint32_t gmax, int goffset, uint32_t bmax, int boffset)
65 #define CF(_f, _i) ((_f ## max * color_def[(_i)]._f / 100) << _f ## offset)
66 for (i = 0; i < 16; i++) {
68 case COLOR_FORMAT_VGA:
71 case COLOR_FORMAT_RGB:
72 palette[i] = CF(r, i) | CF(g, i) | CF(b, i);