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