1999-04-01 08:16:08 +00:00
|
|
|
/*
|
|
|
|
* TTY palette driver
|
|
|
|
*
|
|
|
|
* Copyright 1999 Patrik Stridvall
|
2002-03-09 23:29:33 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
1999-04-01 08:16:08 +00:00
|
|
|
*/
|
|
|
|
|
2001-11-06 20:57:11 +00:00
|
|
|
#include "config.h"
|
|
|
|
|
2000-04-09 18:41:15 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
2004-03-04 20:41:12 +00:00
|
|
|
#include "gdi.h"
|
2000-04-15 20:44:21 +00:00
|
|
|
#include "winbase.h"
|
1999-04-01 08:16:08 +00:00
|
|
|
#include "ttydrv.h"
|
2002-06-02 21:40:24 +00:00
|
|
|
#include "wine/debug.h"
|
1999-04-01 08:16:08 +00:00
|
|
|
|
2002-03-09 23:29:33 +00:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(ttydrv);
|
1999-11-23 23:43:29 +00:00
|
|
|
|
|
|
|
/**********************************************************************/
|
|
|
|
|
2002-06-02 21:40:24 +00:00
|
|
|
static PALETTEENTRY *COLOR_sysPal;
|
1999-11-23 23:43:29 +00:00
|
|
|
|
2004-09-22 02:46:38 +00:00
|
|
|
static unsigned int palette_size = 256; /* FIXME */
|
2001-07-28 00:18:02 +00:00
|
|
|
|
1999-11-23 23:43:29 +00:00
|
|
|
/***********************************************************************
|
1999-04-01 08:16:08 +00:00
|
|
|
* TTYDRV_PALETTE_Initialize
|
|
|
|
*/
|
|
|
|
BOOL TTYDRV_PALETTE_Initialize(void)
|
|
|
|
{
|
2004-09-22 02:46:38 +00:00
|
|
|
unsigned int i;
|
2002-06-02 21:40:24 +00:00
|
|
|
PALETTEENTRY sys_pal_template[NB_RESERVED_COLORS];
|
1999-11-23 23:43:29 +00:00
|
|
|
|
|
|
|
TRACE("(void)\n");
|
|
|
|
|
2001-07-28 00:18:02 +00:00
|
|
|
COLOR_sysPal = (PALETTEENTRY *) HeapAlloc(GetProcessHeap(), 0, sizeof(PALETTEENTRY) * palette_size);
|
2000-04-09 18:41:15 +00:00
|
|
|
if(COLOR_sysPal == NULL) {
|
2001-05-09 17:31:31 +00:00
|
|
|
WARN("No memory to create system palette!\n");
|
2000-04-09 18:41:15 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
1999-11-23 23:43:29 +00:00
|
|
|
|
2002-06-02 21:40:24 +00:00
|
|
|
GetPaletteEntries( GetStockObject(DEFAULT_PALETTE), 0, NB_RESERVED_COLORS, sys_pal_template );
|
|
|
|
|
2001-07-28 00:18:02 +00:00
|
|
|
for(i=0; i < palette_size; i++ ) {
|
1999-11-23 23:43:29 +00:00
|
|
|
const PALETTEENTRY *src;
|
|
|
|
PALETTEENTRY *dst = &COLOR_sysPal[i];
|
|
|
|
|
|
|
|
if(i < NB_RESERVED_COLORS/2) {
|
2002-06-02 21:40:24 +00:00
|
|
|
src = &sys_pal_template[i];
|
2001-07-28 00:18:02 +00:00
|
|
|
} else if(i >= palette_size - NB_RESERVED_COLORS/2) {
|
2002-06-02 21:40:24 +00:00
|
|
|
src = &sys_pal_template[NB_RESERVED_COLORS + i - palette_size];
|
1999-11-23 23:43:29 +00:00
|
|
|
} else {
|
|
|
|
PALETTEENTRY pe = { 0, 0, 0, 0 };
|
|
|
|
src = &pe;
|
|
|
|
}
|
|
|
|
|
|
|
|
if((src->peRed + src->peGreen + src->peBlue) <= 0xB0) {
|
|
|
|
dst->peRed = 0;
|
2002-05-31 23:06:46 +00:00
|
|
|
dst->peGreen = 0;
|
1999-11-23 23:43:29 +00:00
|
|
|
dst->peBlue = 0;
|
|
|
|
dst->peFlags = PC_SYS_USED;
|
|
|
|
} else {
|
2002-05-31 23:06:46 +00:00
|
|
|
dst->peRed = 255;
|
|
|
|
dst->peGreen= 255;
|
1999-11-23 23:43:29 +00:00
|
|
|
dst->peBlue = 255;
|
|
|
|
dst->peFlags = PC_SYS_USED;
|
2002-05-31 23:06:46 +00:00
|
|
|
}
|
1999-11-23 23:43:29 +00:00
|
|
|
}
|
|
|
|
|
1999-04-01 08:16:08 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
2002-06-02 21:40:24 +00:00
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* GetSystemPaletteEntries (TTYDRV.@)
|
|
|
|
*/
|
|
|
|
UINT TTYDRV_GetSystemPaletteEntries( TTYDRV_PDEVICE *dev, UINT start, UINT count,
|
|
|
|
LPPALETTEENTRY entries )
|
|
|
|
{
|
|
|
|
UINT i;
|
|
|
|
|
|
|
|
if (!entries) return palette_size;
|
|
|
|
if (start >= palette_size) return 0;
|
|
|
|
if (start + count >= palette_size) count = palette_size - start;
|
|
|
|
|
|
|
|
for (i = 0; i < count; i++)
|
|
|
|
{
|
|
|
|
entries[i].peRed = COLOR_sysPal[start + i].peRed;
|
|
|
|
entries[i].peGreen = COLOR_sysPal[start + i].peGreen;
|
|
|
|
entries[i].peBlue = COLOR_sysPal[start + i].peBlue;
|
|
|
|
entries[i].peFlags = 0;
|
|
|
|
TRACE("\tidx(%02x) -> RGB(%08lx)\n", start + i, *(COLORREF*)(entries + i) );
|
|
|
|
}
|
|
|
|
return count;
|
|
|
|
}
|