Utility to convert between Unix and Windows paths at the command
[wine/multimedia.git] / dlls / ttydrv / palette.c
blob7a25ad2b62aa039769955db264eb78fc297291b3
1 /*
2 * TTY palette driver
4 * Copyright 1999 Patrik Stridvall
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #include "config.h"
23 #include <stdlib.h>
25 #include "color.h"
26 #include "wine/debug.h"
27 #include "palette.h"
28 #include "winbase.h"
29 #include "ttydrv.h"
31 WINE_DEFAULT_DEBUG_CHANNEL(ttydrv);
33 /**********************************************************************/
35 extern PALETTEENTRY *COLOR_sysPal;
37 static int palette_size = 256; /* FIXME */
39 extern const PALETTEENTRY COLOR_sysPalTemplate[NB_RESERVED_COLORS];
41 /***********************************************************************
42 * TTYDRV_PALETTE_Initialize
44 BOOL TTYDRV_PALETTE_Initialize(void)
46 int i;
48 TRACE("(void)\n");
50 COLOR_sysPal = (PALETTEENTRY *) HeapAlloc(GetProcessHeap(), 0, sizeof(PALETTEENTRY) * palette_size);
51 if(COLOR_sysPal == NULL) {
52 WARN("No memory to create system palette!\n");
53 return FALSE;
56 for(i=0; i < palette_size; i++ ) {
57 const PALETTEENTRY *src;
58 PALETTEENTRY *dst = &COLOR_sysPal[i];
60 if(i < NB_RESERVED_COLORS/2) {
61 src = &COLOR_sysPalTemplate[i];
62 } else if(i >= palette_size - NB_RESERVED_COLORS/2) {
63 src = &COLOR_sysPalTemplate[NB_RESERVED_COLORS + i - palette_size];
64 } else {
65 PALETTEENTRY pe = { 0, 0, 0, 0 };
66 src = &pe;
69 if((src->peRed + src->peGreen + src->peBlue) <= 0xB0) {
70 dst->peRed = 0;
71 dst->peGreen = 0;
72 dst->peBlue = 0;
73 dst->peFlags = PC_SYS_USED;
74 } else {
75 dst->peRed = 255;
76 dst->peGreen= 255;
77 dst->peBlue = 255;
78 dst->peFlags = PC_SYS_USED;
82 return TRUE;