1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169
|
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program 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 3 of the License, or
* (at your option) any later version.
*
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
*
* Palette Allocator Definitions
*/
#ifndef TINSEL_PALETTE_H // prevent multiple includes
#define TINSEL_PALETTE_H
#include "tinsel/dw.h"
namespace Tinsel {
typedef uint32 COLORREF;
#define TINSEL_RGB(r,g,b) ((COLORREF)((uint8)(r)|((uint16)(g)<<8))|(((uint32)(uint8)(b))<<16))
#define TINSEL_PSX_RGB(r,g,b) ((uint16)(((uint8)(r))|((uint16)(g)<<5)|(((uint16)(b))<<10)))
enum {
MAX_COLORS = 256, ///< maximum number of colors - for VGA 256
BITS_PER_PIXEL = 8, ///< number of bits per pixel for VGA 256
MAX_INTENSITY = 255, ///< the biggest value R, G or B can have
NUM_PALETTES = 32, ///< number of palettes
// Discworld has some fixed apportioned bits in the palette.
BGND_DAC_INDEX = 0, ///< index of background color in Video DAC
FGND_DAC_INDEX = 1, ///< index of first foreground color in Video DAC
TBLUE1 = 228, ///< Blue used in translucent rectangles
TBLUE2 = 229, ///< Blue used in translucent rectangles
TBLUE3 = 230, ///< Blue used in translucent rectangles
TBLUE4 = 231, ///< Blue used in translucent rectangles
TALKFONT_COL = 233
};
// some common colors
#define BLACK (TINSEL_RGB(0, 0, 0))
#define WHITE (TINSEL_RGB(MAX_INTENSITY, MAX_INTENSITY, MAX_INTENSITY))
#define RED (TINSEL_RGB(MAX_INTENSITY, 0, 0))
#define GREEN (TINSEL_RGB(0, MAX_INTENSITY, 0))
#define BLUE (TINSEL_RGB(0, 0, MAX_INTENSITY))
#define YELLOW (TINSEL_RGB(MAX_INTENSITY, MAX_INTENSITY, 0))
#define MAGENTA (TINSEL_RGB(MAX_INTENSITY, 0, MAX_INTENSITY))
#define CYAN (TINSEL_RGB(0, MAX_INTENSITY, MAX_INTENSITY))
struct PALETTE {
int32 numColors; ///< number of colors in the palette
COLORREF palRGB[MAX_COLORS]; ///< actual palette colors
byte palette[MAX_COLORS * 3]; ///< actual palette colors (RGB values)
};
/** palette queue structure */
struct PALQ {
SCNHANDLE hPal; ///< handle to palette data struct
int objCount; ///< number of objects using this palette
int posInDAC; ///< palette position in the video DAC
int32 numColors; ///< number of colors in the palette
// Discworld 2 fields
bool bFading; // Whether or not fading
COLORREF palRGB[MAX_COLORS]; // actual palette colors
};
#define PALETTE_MOVED 0x8000 // when this bit is set in the "posInDAC"
// field - the palette entry has moved
// Translucent objects have NULL pPal
#define HasPalMoved(pPal) (((pPal) != NULL) && ((pPal)->posInDAC & PALETTE_MOVED))
/*----------------------------------------------------------------------*\
|* Palette Manager Function Prototypes *|
\*----------------------------------------------------------------------*/
void ResetPalAllocator(); // wipe out all palettes
#ifdef DEBUG
void PaletteStats(); // Shows the maximum number of palettes used at once
#endif
void psxPaletteMapper(PALQ *originalPal, uint8 *psxClut, byte *mapperTable); // Maps PSX CLUTs to original palette in resource file
void PalettesToVideoDAC(); // Update the video DAC with palettes currently in the DAC queue
void UpdateDACqueueHandle(
int posInDAC, // position in video DAC
int numColors, // number of colors in palette
SCNHANDLE hPalette); // handle to palette
void UpdateDACqueue( // places a palette in the video DAC queue
int posInDAC, // position in video DAC
int numColors, // number of colors in palette
COLORREF *pColors); // list of RGB tripples
void UpdateDACqueue(int posInDAC, COLORREF color);
PALQ *AllocPalette( // allocate a new palette
SCNHANDLE hNewPal); // palette to allocate
void FreePalette( // free a palette allocated with "AllocPalette"
PALQ *pFreePal); // palette queue entry to free
PALQ *FindPalette( // find a palette in the palette queue
SCNHANDLE hSrchPal); // palette to search for
void SwapPalette( // swaps palettes at the specified palette queue position
PALQ *pPalQ, // palette queue position
SCNHANDLE hNewPal); // new palette
PALQ *GetNextPalette( // returns the next palette in the queue
PALQ *pStrtPal); // queue position to start from - when NULL will start from beginning of queue
COLORREF GetBgndColor(); // returns current background color
void SetBgndColor( // sets current background color
COLORREF color); // color to set the background to
void FadingPalette(PALQ *pPalQ, bool bFading);
void CreateTranslucentPalette(SCNHANDLE BackPal);
void NoFadingPalettes(); // All fading processes have just been killed
void DimPartPalette(
SCNHANDLE hPal,
int startColor,
int length,
int brightness); // 0 = black, 10 == 100%
int TranslucentColor();
int DarkGreen();
#define BoxColor (TinselVersion == 3 ? DarkGreen : TranslucentColor)
int HighlightColor();
int TalkColor();
void SetTalkColorRef(COLORREF colRef);
COLORREF GetTalkColorRef();
void SetTagColorRef(COLORREF colRef);
COLORREF GetTagColorRef();
void SetTalkTextOffset(int offset);
void SetTranslucencyOffset(int offset);
} // End of namespace Tinsel
#endif // TINSEL_PALETTE_H
|