2 * ReactOS Generic Framebuffer display driver
4 * Copyright (C) 2004 Filip Navara
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
11 * This program 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
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 * Standard color that must be in palette, because they're used for
25 * drawing window borders and other GUI elements.
28 const PALETTEENTRY BASEPALETTE
[20] =
30 { 0x00, 0x00, 0x00, 0x00 },
31 { 0x80, 0x00, 0x00, 0x00 },
32 { 0x00, 0x80, 0x00, 0x00 },
33 { 0x80, 0x80, 0x00, 0x00 },
34 { 0x00, 0x00, 0x80, 0x00 },
35 { 0x80, 0x00, 0x80, 0x00 },
36 { 0x00, 0x80, 0x80, 0x00 },
37 { 0xC0, 0xC0, 0xC0, 0x00 },
38 { 0xC0, 0xDC, 0xC0, 0x00 },
39 { 0xD4, 0xD0, 0xC8, 0x00 },
40 { 0xFF, 0xFB, 0xF0, 0x00 },
41 { 0x3A, 0x6E, 0xA5, 0x00 },
42 { 0x80, 0x80, 0x80, 0x00 },
43 { 0xFF, 0x00, 0x00, 0x00 },
44 { 0x00, 0xFF, 0x00, 0x00 },
45 { 0xFF, 0xFF, 0x00, 0x00 },
46 { 0x00, 0x00, 0xFF, 0x00 },
47 { 0xFF, 0x00, 0xFF, 0x00 },
48 { 0x00, 0xFF, 0xFF, 0x00 },
49 { 0xFF, 0xFF, 0xFF, 0x00 },
53 * IntInitDefaultPalette
55 * Initializes default palette for PDEV and fill it with the colors specified
56 * by the GDI standard.
60 IntInitDefaultPalette(
65 PPALETTEENTRY PaletteEntryPtr
;
67 if (ppdev
->BitsPerPixel
> 8)
69 ppdev
->DefaultPalette
= pDevInfo
->hpalDefault
=
70 EngCreatePalette(PAL_BITFIELDS
, 0, NULL
,
71 ppdev
->RedMask
, ppdev
->GreenMask
, ppdev
->BlueMask
);
75 ppdev
->PaletteEntries
= EngAllocMem(0, sizeof(PALETTEENTRY
) << 8, ALLOC_TAG
);
76 if (ppdev
->PaletteEntries
== NULL
)
81 for (ColorLoop
= 256, PaletteEntryPtr
= ppdev
->PaletteEntries
;
83 ColorLoop
--, PaletteEntryPtr
++)
85 PaletteEntryPtr
->peRed
= ((ColorLoop
>> 5) & 7) * 255 / 7;
86 PaletteEntryPtr
->peGreen
= ((ColorLoop
>> 3) & 3) * 255 / 3;
87 PaletteEntryPtr
->peBlue
= (ColorLoop
& 7) * 255 / 7;
88 PaletteEntryPtr
->peFlags
= 0;
91 memcpy(ppdev
->PaletteEntries
, BASEPALETTE
, 10 * sizeof(PALETTEENTRY
));
92 memcpy(ppdev
->PaletteEntries
+ 246, BASEPALETTE
+ 10, 10 * sizeof(PALETTEENTRY
));
94 ppdev
->DefaultPalette
= pDevInfo
->hpalDefault
=
95 EngCreatePalette(PAL_INDEXED
, 256, (PULONG
)ppdev
->PaletteEntries
, 0, 0, 0);
98 return ppdev
->DefaultPalette
!= NULL
;
104 * Requests that the driver realize the palette for a specified device. The
105 * driver sets the hardware palette to match the entries in the given palette
106 * as closely as possible.
112 IN PPALETTEENTRY ppalent
,
119 ClutSize
= sizeof(VIDEO_CLUT
) + (cColors
* sizeof(ULONG
));
120 pClut
= EngAllocMem(0, ClutSize
, ALLOC_TAG
);
121 pClut
->FirstEntry
= iStart
;
122 pClut
->NumEntries
= cColors
;
123 memcpy(&pClut
->LookupTable
[0].RgbLong
, ppalent
, sizeof(ULONG
) * cColors
);
125 if (((PPDEV
)dhpdev
)->PaletteShift
)
129 pClut
->LookupTable
[cColors
].RgbArray
.Red
>>= ((PPDEV
)dhpdev
)->PaletteShift
;
130 pClut
->LookupTable
[cColors
].RgbArray
.Green
>>= ((PPDEV
)dhpdev
)->PaletteShift
;
131 pClut
->LookupTable
[cColors
].RgbArray
.Blue
>>= ((PPDEV
)dhpdev
)->PaletteShift
;
132 pClut
->LookupTable
[cColors
].RgbArray
.Unused
= 0;
139 pClut
->LookupTable
[cColors
].RgbArray
.Unused
= 0;
144 * Set the palette registers.
147 if (EngDeviceIoControl(((PPDEV
)dhpdev
)->hDriver
, IOCTL_VIDEO_SET_COLOR_REGISTERS
,
148 pClut
, ClutSize
, NULL
, 0, &cColors
))
161 * Requests that the driver realize the palette for a specified device. The
162 * driver sets the hardware palette to match the entries in the given palette
163 * as closely as possible.
177 PPALETTEENTRY PaletteEntries
;
179 PaletteEntries
= EngAllocMem(0, cColors
* sizeof(ULONG
), ALLOC_TAG
);
180 if (PaletteEntries
== NULL
)
185 if (PALOBJ_cGetColors(ppalo
, iStart
, cColors
, (PULONG
)PaletteEntries
) !=
191 return IntSetPalette(dhpdev
, PaletteEntries
, iStart
, cColors
);