1 /* $NetBSD: hpccmap_gen.c,v 1.3.22.3 2004/09/21 13:27:37 skrll Exp $ */
5 * Shin Takemura and PocketBSD Project. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by the PocketBSD project
18 * and its contributors.
19 * 4. Neither the name of the project nor the names of its contributors
20 * may be used to endorse or promote products derived from this software
21 * without specific prior written permission.
23 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37 #include <sys/cdefs.h>
38 __RCSID("$NetBSD: hpccmap_gen.c,v 1.3.22.3 2004/09/21 13:27:37 skrll Exp $");
40 typedef unsigned char u_char
;
41 typedef void (*output_func
)(void*, int, u_char
, u_char
, u_char
);
43 void main(int ac
, char *av
[]);
44 void rgb_separate_out(void*, int, u_char
, u_char
, u_char
);
45 void cmap_gen(output_func
, void *);
47 unsigned char compo6
[6] = { 0, 51, 102, 153, 204, 255 };
48 unsigned char compo7
[7] = { 0, 42, 85, 127, 170, 212, 255 };
51 main(int ac
, char *av
[])
57 printf(" * Do not edit.\n");
58 printf(" * This file is automatically generated by hpccmap_gen.\n");
60 printf("#include <dev/hpc/hpccmapar.h>\n");
61 for (i
= 0; i
< 3; i
++) {
62 printf("unsigned char bivideo_cmap_%c[256] = {\n", rgb
[i
]);
63 cmap_gen(rgb_separate_out
, (void*)i
);
69 rgb_separate_out(void *ctxx
, int idx
, unsigned char r
, unsigned char g
,
92 cmap_gen(output_func func
, void *ctx
)
99 * 0 - 15, for ANSI escape sequence
100 * (see sys/dev/rasops/rasops.c)
102 (*func
)(ctx
, i
++, 0x00, 0x00, 0x00); /* black */
103 (*func
)(ctx
, i
++, 0x7f, 0x00, 0x00); /* red */
104 (*func
)(ctx
, i
++, 0x00, 0x7f, 0x00); /* green */
105 (*func
)(ctx
, i
++, 0x7f, 0x7f, 0x00); /* brown */
106 (*func
)(ctx
, i
++, 0x00, 0x00, 0x7f); /* blue */
107 (*func
)(ctx
, i
++, 0x7f, 0x00, 0x7f); /* magenta */
108 (*func
)(ctx
, i
++, 0x00, 0x7f, 0x7f); /* cyan */
109 (*func
)(ctx
, i
++, 0xc7, 0xc7, 0xc7); /* white */
111 (*func
)(ctx
, i
++, 0x7f, 0x7f, 0x7f); /* black */
112 (*func
)(ctx
, i
++, 0xff, 0x00, 0x00); /* red */
113 (*func
)(ctx
, i
++, 0x00, 0xff, 0x00); /* green */
114 (*func
)(ctx
, i
++, 0xff, 0xff, 0x00); /* brown */
115 (*func
)(ctx
, i
++, 0x00, 0x00, 0xff); /* blue */
116 (*func
)(ctx
, i
++, 0xff, 0x00, 0xff); /* magenta */
117 (*func
)(ctx
, i
++, 0x00, 0xff, 0xff); /* cyan */
118 (*func
)(ctx
, i
++, 0xff, 0xff, 0xff); /* white */
121 * 16 - 31, gray scale
123 for (; i
< 32; i
++) {
124 (*func
)(ctx
, i
, (i
- 16) * 17, (i
- 16) * 17, (i
- 16) * 17);
128 * 32 - 247, RGB color
130 for (r
= 0; r
< 6; r
++) {
131 for (g
= 0; g
< 6; g
++) {
132 for (b
= 0; b
< 6; b
++) {
134 compo6
[r
], compo6
[g
], compo6
[b
]);
141 * 248 - 255, just white
143 for ( ; i
< 256; i
++) {
144 (*func
)(ctx
, i
, 255, 255, 255);