Implement ResetDC and PHYSICALOFFSET[X|Y] devcaps.
[wine] / dlls / ttydrv / palette.c
1 /*
2  * TTY palette driver
3  *
4  * Copyright 1999 Patrik Stridvall
5  *
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.
10  *
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.
15  *
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
19  */
20
21 #include "config.h"
22
23 #include <stdlib.h>
24
25 #include "color.h"
26 #include "wine/debug.h"
27 #include "palette.h"
28 #include "winbase.h"
29 #include "ttydrv.h"
30
31 WINE_DEFAULT_DEBUG_CHANNEL(ttydrv);
32
33 /**********************************************************************/
34
35 extern PALETTEENTRY *COLOR_sysPal;
36 extern int COLOR_gapStart;
37 extern int COLOR_gapEnd;
38 extern int COLOR_gapFilled;
39 extern int COLOR_max;
40
41 static int palette_size = 256;  /* FIXME */
42
43 extern const PALETTEENTRY COLOR_sysPalTemplate[NB_RESERVED_COLORS]; 
44
45 /***********************************************************************
46  *           TTYDRV_PALETTE_Initialize
47  */
48 BOOL TTYDRV_PALETTE_Initialize(void)
49 {
50   int i;
51
52   TRACE("(void)\n");
53
54   COLOR_sysPal = (PALETTEENTRY *) HeapAlloc(GetProcessHeap(), 0, sizeof(PALETTEENTRY) * palette_size);
55   if(COLOR_sysPal == NULL) {
56     WARN("No memory to create system palette!\n");
57     return FALSE;
58   }
59
60   for(i=0; i < palette_size; i++ ) {
61     const PALETTEENTRY *src;
62     PALETTEENTRY *dst = &COLOR_sysPal[i];
63
64     if(i < NB_RESERVED_COLORS/2) {
65       src = &COLOR_sysPalTemplate[i];
66     } else if(i >= palette_size - NB_RESERVED_COLORS/2) {
67       src = &COLOR_sysPalTemplate[NB_RESERVED_COLORS + i - palette_size];
68     } else {
69       PALETTEENTRY pe = { 0, 0, 0, 0 };
70       src = &pe;
71     }
72
73     if((src->peRed + src->peGreen + src->peBlue) <= 0xB0) {
74       dst->peRed = 0;
75       dst->peGreen = 0;  
76       dst->peBlue = 0;
77       dst->peFlags = PC_SYS_USED;
78     } else {
79       dst->peRed = 255;  
80       dst->peGreen= 255;  
81       dst->peBlue = 255;
82       dst->peFlags = PC_SYS_USED;
83     }    
84   }
85
86   COLOR_gapStart = NB_RESERVED_COLORS/2;
87   COLOR_gapEnd = NB_RESERVED_COLORS/2;
88
89   return TRUE;
90 }
91
92 /***********************************************************************
93  *           TTYDRV_PALETTE_SetMapping
94  */
95 int TTYDRV_PALETTE_SetMapping(
96   PALETTEOBJ *palPtr, UINT uStart, UINT uNum, BOOL mapOnly)
97 {
98   FIXME("(%p, %u, %u, %d): stub\n", palPtr, uStart, uNum, mapOnly);
99
100   return 0;
101 }
102
103 /***********************************************************************
104  *           TTYDRV_PALETTE_UpdateMapping
105  */
106 int TTYDRV_PALETTE_UpdateMapping(PALETTEOBJ *palPtr)
107 {
108   TRACE("(%p)\n", palPtr);
109
110   return 0;
111 }
112
113 /***********************************************************************
114  *           TTYDRV_PALETTE_IsDark
115  */
116 int TTYDRV_PALETTE_IsDark(int pixel)
117 {
118   FIXME("(%d): stub\n", pixel);
119
120   return 0;
121 }