/* This file is part of Warzone 2100. Copyright (C) 1999-2004 Eidos Interactive Copyright (C) 2005-2007 Warzone Resurrection Project Warzone 2100 is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. Warzone 2100 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 General Public License for more details. You should have received a copy of the GNU General Public License along with Warzone 2100; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include #include "lib/ivis_common/piestate.h" #include "lib/ivis_common/piepalette.h" #include "lib/ivis_common/rendmode.h" #include "lib/framework/fractions.h" #include "screen.h" #define RED_CHROMATICITY 1 #define GREEN_CHROMATICITY 1 #define BLUE_CHROMATICITY 1 Uint8 pal_GetNearestColour(Uint8 r, Uint8 g, Uint8 b); void pie_SetColourDefines(void); /* This is how far from the end you want the drawn as the artist intended shades to appear */ #define COLOUR_BALANCE 6 // 3 from the end. (two brighter shades!) iColour* psGamePal = NULL; Uint8 palShades[PALETTE_SIZE * PALETTE_SHADE_LEVEL]; BOOL bPaletteInitialised = FALSE; Uint8 colours[16]; //************************************************************************* //*** add a new palette //* //* params pal = pointer to palette to add //* //* returns slot number of added palette or -1 if error //* //****** int pal_AddNewPalette(iColour *pal) { int i; iColour *p; bPaletteInitialised = TRUE; if (psGamePal == NULL) { psGamePal = (iColour*) malloc(PALETTE_SIZE * sizeof(iColour)); if (psGamePal == NULL) { debug( LOG_ERROR, "pal_AddNewPalette - Out of memory" ); abort(); return FALSE; } } p = psGamePal; for (i=0; i255) seekRed = 255; if(seekGreen >255) seekGreen = 255; if(seekBlue >255) seekBlue = 255; palShades[(numColours * PALETTE_SHADE_LEVEL) + (numShades-COLOUR_BALANCE)] = pal_GetNearestColour((Uint8) seekRed, (Uint8) seekGreen, (Uint8) seekBlue); } } } iColour* pie_GetGamePal(void) { ASSERT( bPaletteInitialised,"pie_GetGamePal, palette not initialised" ); return psGamePal; }