ReactOS 0.4.16-dev-297-gc569aee
palette.c File Reference
#include "driver.h"
Include dependency graph for palette.c:

Go to the source code of this file.

Classes

struct  _VGALOGPALETTE
 

Typedefs

typedef struct _VGALOGPALETTE VGALOGPALETTE
 

Functions

BOOL bInitDefaultPalette (PPDEV ppdev, DEVINFO *pDevInfo)
 
BOOL bInitPaletteInfo (PPDEV ppdev, DEVINFO *pDevInfo)
 
VOID vDisablePalette (PPDEV ppdev)
 
BOOL bInit256ColorPalette (PPDEV ppdev)
 
BOOL APIENTRY DrvSetPalette (DHPDEV dhpdev, PALOBJ *ppalo, FLONG fl, ULONG iStart, ULONG cColors)
 

Variables

const VGALOGPALETTE logPalVGA
 

Typedef Documentation

◆ VGALOGPALETTE

Function Documentation

◆ bInit256ColorPalette()

BOOL bInit256ColorPalette ( PPDEV  ppdev)

Definition at line 226 of file palette.c.

227{
228 BYTE ajClutSpace[MAX_CLUT_SIZE];
229 PVIDEO_CLUT pScreenClut;
230 ULONG ulReturnedDataLength;
231 ULONG cColors;
232 PVIDEO_CLUTDATA pScreenClutData;
233
234 if (ppdev->ulBitCount == 8)
235 {
236 //
237 // Fill in pScreenClut header info:
238 //
239
240 pScreenClut = (PVIDEO_CLUT) ajClutSpace;
241 pScreenClut->NumEntries = 256;
242 pScreenClut->FirstEntry = 0;
243
244 //
245 // Copy colours in:
246 //
247
248 cColors = 256;
249 pScreenClutData = (PVIDEO_CLUTDATA) (&(pScreenClut->LookupTable[0]));
250
251 while(cColors--)
252 {
253 pScreenClutData[cColors].Red = ppdev->pPal[cColors].peRed >>
254 ppdev->cPaletteShift;
255 pScreenClutData[cColors].Green = ppdev->pPal[cColors].peGreen >>
256 ppdev->cPaletteShift;
257 pScreenClutData[cColors].Blue = ppdev->pPal[cColors].peBlue >>
258 ppdev->cPaletteShift;
259 pScreenClutData[cColors].Unused = 0;
260 }
261
262 //
263 // Set palette registers:
264 //
265
266 if (EngDeviceIoControl(ppdev->hDriver,
268 pScreenClut,
270 NULL,
271 0,
272 &ulReturnedDataLength))
273 {
274 DISPDBG((0, "Failed bEnablePalette"));
275 return(FALSE);
276 }
277 }
278
279 DISPDBG((5, "Passed bEnablePalette"));
280
281 return(TRUE);
282}
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define IOCTL_VIDEO_SET_COLOR_REGISTERS
Definition: ntddvdeo.h:218
struct VIDEO_CLUT * PVIDEO_CLUT
struct _VIDEO_CLUTDATA * PVIDEO_CLUTDATA
union VIDEO_CLUT::@3174 LookupTable[1]
USHORT FirstEntry
Definition: ntddvdeo.h:590
USHORT NumEntries
Definition: ntddvdeo.h:589
ULONG cPaletteShift
Definition: driver.h:37
ULONG ulBitCount
Definition: driver.h:40
PALETTEENTRY * pPal
Definition: driver.h:46
HANDLE hDriver
Definition: framebuf.h:35
uint32_t ULONG
Definition: typedefs.h:59
#define DISPDBG(arg)
Definition: debug.h:23
#define MAX_CLUT_SIZE
Definition: driver.h:66
unsigned char BYTE
Definition: xxhash.c:193

Referenced by DrvEnableSurface().

◆ bInitDefaultPalette()

BOOL bInitDefaultPalette ( PPDEV  ppdev,
DEVINFO pDevInfo 
)

Definition at line 107 of file palette.c.

108{
109// eVb: 4.3 [VGARISC Change] - VGA Palette is static, no need to build
110#if 0
111 if (ppdev->ulBitCount == 8)
112 {
113 ULONG ulLoop;
114 BYTE jRed,jGre,jBlu;
115
116 //
117 // Allocate our palette
118 //
119
120 ppdev->pPal = (PPALETTEENTRY)EngAllocMem(0, sizeof(PALETTEENTRY) * 256,
121 ALLOC_TAG);
122
123 if ((ppdev->pPal) == NULL) {
124 RIP("DISP bInitDefaultPalette() failed EngAllocMem\n");
125 return(FALSE);
126 }
127
128 //
129 // Generate 256 (8*4*4) RGB combinations to fill the palette
130 //
131
132 jRed = jGre = jBlu = 0;
133
134 for (ulLoop = 0; ulLoop < 256; ulLoop++)
135 {
136 ppdev->pPal[ulLoop].peRed = jRed;
137 ppdev->pPal[ulLoop].peGreen = jGre;
138 ppdev->pPal[ulLoop].peBlue = jBlu;
139 ppdev->pPal[ulLoop].peFlags = (BYTE)0;
140
141 if (!(jRed += 32))
142 if (!(jGre += 32))
143 jBlu += 64;
144 }
145
146 //
147 // Fill in Windows Reserved Colors from the WIN 3.0 DDK
148 // The Window Manager reserved the first and last 10 colors for
149 // painting windows borders and for non-palette managed applications.
150 //
151
152 for (ulLoop = 0; ulLoop < 10; ulLoop++)
153 {
154 //
155 // First 10
156 //
157
158 ppdev->pPal[ulLoop] = BASEPALETTE[ulLoop];
159
160 //
161 // Last 10
162 //
163
164 ppdev->pPal[246 + ulLoop] = BASEPALETTE[ulLoop+10];
165 }
166
167#endif
168// eVb: 4.3 [END]
169 //
170 // Create handle for palette.
171 //
172
173 ppdev->hpalDefault =
175// eVb: 4.4 [VGARISC Change] - VGA Palette is 16 colors, not 256, and static
176 16,
178// eVb: 4.4 [END]
179 0,0,0);
180
181 if (ppdev->hpalDefault == NULL)
182 {
183 RIP("DISP bInitDefaultPalette failed EngCreatePalette\n");
184// eVb: 4.5 [VGARISC Change] - VGA Palette is static, no need to free
185 //EngFreeMem(ppdev->pPal);
186// eVb: 4.5 [END]
187 return(FALSE);
188 }
189
190 //
191 // Initialize the hardware with the initial palette.
192 //
193
194 return(TRUE);
195
196// eVb: 4.6 [VGARISC Change] - VGA Palette is static, no bitfield palette needed
197#if 0
198 } else {
199
200 ppdev->hpalDefault =
202 0, NULL,
203 ppdev->flRed,
204 ppdev->flGreen,
205 ppdev->flBlue);
206
207 if (ppdev->hpalDefault == NULL)
208 {
209 RIP("DISP bInitDefaultPalette failed EngCreatePalette\n");
210 return(FALSE);
211 }
212 }
213
214 return(TRUE);
215#endif
216// eVb: 4.6 [END]
217}
#define ALLOC_TAG
Definition: btrfs_drv.h:87
void * EngAllocMem(int zero, unsigned long size, int tag=0)
Definition: polytest.cpp:70
HPALETTE hpalDefault
Definition: winddi.h:398
FLONG flRed
Definition: driver.h:34
FLONG flGreen
Definition: driver.h:35
FLONG flBlue
Definition: driver.h:36
HPALETTE hpalDefault
Definition: driver.h:25
PALETTEENTRY palPalEntry[16]
Definition: palette.c:26
uint32_t * PULONG
Definition: typedefs.h:59
const PALETTEENTRY BASEPALETTE[20]
Definition: palette.c:28
#define RIP(x)
Definition: debug.h:24
const VGALOGPALETTE logPalVGA
Definition: palette.c:29
#define PAL_BITFIELDS
Definition: winddi.h:1562
#define PAL_INDEXED
Definition: winddi.h:1561
_Must_inspect_result_ ENGAPI HPALETTE APIENTRY EngCreatePalette(_In_ ULONG iMode, _In_ ULONG cColors, _In_ ULONG *pulColors, _In_ FLONG flRed, _In_ FLONG flGreen, _In_ FLONG flBlue)
struct tagPALETTEENTRY * PPALETTEENTRY

Referenced by bInitPaletteInfo().

◆ bInitPaletteInfo()

BOOL bInitPaletteInfo ( PPDEV  ppdev,
DEVINFO pDevInfo 
)

Definition at line 67 of file palette.c.

68{
69 if (!bInitDefaultPalette(ppdev, pDevInfo))
70 return(FALSE);
71
72 return(TRUE);
73}
BOOL bInitDefaultPalette(PPDEV ppdev, DEVINFO *pDevInfo)
Definition: palette.c:107

Referenced by DrvEnablePDEV().

◆ DrvSetPalette()

BOOL APIENTRY DrvSetPalette ( DHPDEV  dhpdev,
PALOBJ ppalo,
FLONG  fl,
ULONG  iStart,
ULONG  cColors 
)

Definition at line 291 of file palette.c.

297{
298 BYTE ajClutSpace[MAX_CLUT_SIZE];
299 PVIDEO_CLUT pScreenClut;
300 PVIDEO_CLUTDATA pScreenClutData;
301 PDEV* ppdev;
302
304
305 ppdev = (PDEV*) dhpdev;
306
307 //
308 // Fill in pScreenClut header info:
309 //
310
311 pScreenClut = (PVIDEO_CLUT) ajClutSpace;
312 pScreenClut->NumEntries = (USHORT) cColors;
313 pScreenClut->FirstEntry = (USHORT) iStart;
314
315 pScreenClutData = (PVIDEO_CLUTDATA) (&(pScreenClut->LookupTable[0]));
316
317 if (cColors != PALOBJ_cGetColors(ppalo, iStart, cColors,
318 (ULONG*) pScreenClutData))
319 {
320 DISPDBG((0, "DrvSetPalette failed PALOBJ_cGetColors\n"));
321 return (FALSE);
322 }
323
324 //
325 // Set the high reserved byte in each palette entry to 0.
326 // Do the appropriate palette shifting to fit in the DAC.
327 //
328
329 if (ppdev->cPaletteShift)
330 {
331 while(cColors--)
332 {
333 pScreenClutData[cColors].Red >>= ppdev->cPaletteShift;
334 pScreenClutData[cColors].Green >>= ppdev->cPaletteShift;
335 pScreenClutData[cColors].Blue >>= ppdev->cPaletteShift;
336 pScreenClutData[cColors].Unused = 0;
337 }
338 }
339 else
340 {
341 while(cColors--)
342 {
343 pScreenClutData[cColors].Unused = 0;
344 }
345 }
346
347 //
348 // Set palette registers
349 //
350
351 if (EngDeviceIoControl(ppdev->hDriver,
353 pScreenClut,
355 NULL,
356 0,
357 &cColors))
358 {
359 DISPDBG((0, "DrvSetPalette failed EngDeviceIoControl\n"));
360 return (FALSE);
361 }
362
363 return(TRUE);
364
365}
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:325
unsigned short USHORT
Definition: pedump.c:61
Definition: framebuf.h:34
_In_ PALOBJ * ppalo
Definition: winddi.h:4012
_In_ FLONG fl
Definition: winddi.h:1279
ENGAPI ULONG APIENTRY PALOBJ_cGetColors(_In_ PALOBJ *ppalo, _In_ ULONG iStart, _In_ ULONG cColors, _Out_writes_(cColors) ULONG *pulColors)
_In_ UINT iStart
Definition: wingdi.h:3620

◆ vDisablePalette()

VOID vDisablePalette ( PPDEV  ppdev)

Definition at line 82 of file palette.c.

83{
84// Delete the default palette if we created one.
85
86 if (ppdev->hpalDefault)
87 {
89 ppdev->hpalDefault = NULL;
90 }
91
92// eVb: 4.2 [VGARISC Change] - VGA Palette is static, no need to free
93#if 0
94 if (ppdev->pPal != NULL)
95 EngFreeMem((PVOID)ppdev->pPal);
96#endif
97// eVb: 4.2 [END]
98}
#define EngFreeMem
Definition: polytest.cpp:56
ENGAPI BOOL APIENTRY EngDeletePalette(_In_ _Post_ptr_invalid_ HPALETTE hpal)

Referenced by DrvDisablePDEV().

Variable Documentation

◆ logPalVGA

const VGALOGPALETTE logPalVGA
Initial value:
=
{
0x400,
16,
{
{ 0, 0, 0, 0 },
{ 0x80,0, 0, 0 },
{ 0, 0x80,0, 0 },
{ 0x80,0x80,0, 0 },
{ 0, 0, 0x80,0 },
{ 0x80,0, 0x80,0 },
{ 0, 0x80,0x80,0 },
{ 0x80,0x80,0x80,0 },
{ 0xC0,0xC0,0xC0,0 },
{ 0xFF,0, 0, 0 },
{ 0, 0xFF,0, 0 },
{ 0xFF,0xFF,0, 0 },
{ 0, 0, 0xFF,0 },
{ 0xFF,0, 0xFF,0 },
{ 0, 0xFF,0xFF,0 },
{ 0xFF,0xFF,0xFF,0 }
}
}

Definition at line 29 of file palette.c.

Referenced by bInitDefaultPalette().