home *** CD-ROM | disk | FTP | other *** search
- /*
- disppcco.c
-
- % Device independent pc-like color table initialization.
-
- 2/4/90 by Ted.
-
- OWL 1.2a
- Copyright (c) 1988, 1989 by Oakland Group, Inc.
- ALL RIGHTS RESERVED.
-
- Revision History:
- -----------------
- 3/28/90 jmd ansi-fied
- 6/06/90 ted Made pccols initializer in-line instead of a macro for some unix compilers.
- 6/22/90 ted added "void" to no-parameter function per ansii.
- 9/12/90 bkd fixed declaration of pccols to compile under SunOS (and
- hopefully others as well)
- */
-
- #include "oakhead.h"
- #include "disppriv.h"
- #include "disppvs.h"
-
- #define MAX_RADIUS 255
- #define PC_NCOLS 16
- /* -------------------------------------------------------------------------- */
-
- void disp_MapPcColors(void)
- /*
- Set system colors and the attribute map to look like pc colors are in their
- accustomed places in the first 16 pixel values.
- */
- {
- static ocolmap_struct(PC_NCOLS) pccols = { 0, PC_NCOLS, {
- {{ 0, 0, 0}}, /* Black */
- {{ 15, 15, 171}}, /* Dim Blue */
- {{ 68, 155, 68}}, /* Dim Green */
- {{ 28, 202, 202}}, /* Dim Cyan */
- {{ 218, 70, 70}}, /* Dim Red */
- {{ 211, 111, 211}}, /* Dim Magenta */
- {{ 171, 78, 78}}, /* Dim Yellow (Brown) */
- {{ 216, 218, 218}}, /* Dim White */
- {{ 156, 155, 155}}, /* Gray (Bright Black */
- {{ 0, 0, 255}}, /* Blue */
- {{ 0, 255, 0}}, /* Green */
- {{ 0, 255, 255}}, /* Cyan */
- {{ 255, 0, 0}}, /* Red */
- {{ 255, 0, 255}}, /* Magenta */
- {{ 255, 255, 0}}, /* Yellow */
- {{ 255, 255, 255}} /* White */
- }};
-
- disp_MapAttrColors((ocolmap_type) &pccols);
- }
- /* -------------------------------------------------------------------------- */
-
- void disp_MapAttrColors(ocolmap_type cmap)
- /*
- Set system colors and the attribute map to look like the given 16 colors
- are in the first 16 pixel values.
- */
- {
- unsigned i;
- opixval ipcpix, firstpix;
- opixval pcvals[PC_NCOLS];
-
- /* For each pc color, find a system color close to it */
- firstpix = cmap->firstpix;
- for (i = 0; i < cmap->nentries; i++) {
- ipcpix = firstpix + i;
- if (disp_GetPixval(ocolmap_entry((ocolmap_type) cmap,ipcpix),
- &pcvals[i], 1)
- == -1) {
- if (disp_FindPixval(ocolmap_entry((ocolmap_type) cmap,ipcpix),
- &pcvals[i], MAX_RADIUS)
- == -1) {
- pcvals[i] = i; /* If color can't be had, use color i */
- }
- }
- }
- /* Map the attribute table so that it refers to the pc colors */
- for (i = 0; i < 256; i++) {
- disp_SetAttrColors((byte) i, pcvals[i >> 4], pcvals[i & 0x0F]);
- }
- }
- /* -------------------------------------------------------------------------- */
-