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
28 #include "wine/debug.h"
30 WINE_DEFAULT_DEBUG_CHANNEL(ttydrv
);
32 /**********************************************************************/
34 static PALETTEENTRY
*COLOR_sysPal
;
36 static unsigned int palette_size
= 256; /* FIXME */
38 /***********************************************************************
39 * TTYDRV_PALETTE_Initialize
41 BOOL
TTYDRV_PALETTE_Initialize(void)
44 PALETTEENTRY sys_pal_template
[NB_RESERVED_COLORS
];
48 COLOR_sysPal
= HeapAlloc(GetProcessHeap(), 0, sizeof(PALETTEENTRY
) * palette_size
);
49 if(COLOR_sysPal
== NULL
) {
50 WARN("No memory to create system palette!\n");
54 GetPaletteEntries( GetStockObject(DEFAULT_PALETTE
), 0, NB_RESERVED_COLORS
, sys_pal_template
);
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
= &sys_pal_template
[i
];
62 } else if(i
>= palette_size
- NB_RESERVED_COLORS
/2) {
63 src
= &sys_pal_template
[NB_RESERVED_COLORS
+ i
- palette_size
];
65 PALETTEENTRY pe
= { 0, 0, 0, 0 };
69 if((src
->peRed
+ src
->peGreen
+ src
->peBlue
) <= 0xB0) {
73 dst
->peFlags
= PC_SYS_USED
;
78 dst
->peFlags
= PC_SYS_USED
;
86 /***********************************************************************
87 * GetSystemPaletteEntries (TTYDRV.@)
89 UINT
TTYDRV_GetSystemPaletteEntries( TTYDRV_PDEVICE
*dev
, UINT start
, UINT count
,
90 LPPALETTEENTRY entries
)
94 if (!entries
) return palette_size
;
95 if (start
>= palette_size
) return 0;
96 if (start
+ count
>= palette_size
) count
= palette_size
- start
;
98 for (i
= 0; i
< count
; i
++)
100 entries
[i
].peRed
= COLOR_sysPal
[start
+ i
].peRed
;
101 entries
[i
].peGreen
= COLOR_sysPal
[start
+ i
].peGreen
;
102 entries
[i
].peBlue
= COLOR_sysPal
[start
+ i
].peBlue
;
103 entries
[i
].peFlags
= 0;
104 TRACE("\tidx(%02x) -> RGB(%08lx)\n", start
+ i
, *(COLORREF
*)(entries
+ i
) );