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 
28 namespace Tinsel {
29 
30 typedef 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 
35 enum {
36  MAX_COLORS = 256,
38  MAX_INTENSITY = 255,
39  NUM_PALETTES = 32,
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 
62 struct PALETTE {
63  int32 numColors;
64  COLORREF palRGB[MAX_COLORS];
65  byte palette[MAX_COLORS * 3];
66 };
67 
69 struct PALQ {
71  int objCount;
72  int posInDAC;
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 
90 void ResetPalAllocator(); // wipe out all palettes
91 
92 #ifdef DEBUG
93 void PaletteStats(); // Shows the maximum number of palettes used at once
94 #endif
95 
96 void psxPaletteMapper(PALQ *originalPal, uint8 *psxClut, byte *mapperTable); // Maps PSX CLUTs to original palette in resource file
97 
98 void PalettesToVideoDAC(); // Update the video DAC with palettes currently in the DAC queue
99 
100 void UpdateDACqueueHandle(
101  int posInDAC, // position in video DAC
102  int numColors, // number of colors in palette
103  SCNHANDLE hPalette); // handle to palette
104 
105 void 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 
110 void UpdateDACqueue(int posInDAC, COLORREF color);
111 
112 PALQ *AllocPalette( // allocate a new palette
113  SCNHANDLE hNewPal); // palette to allocate
114 
115 void FreePalette( // free a palette allocated with "AllocPalette"
116  PALQ *pFreePal); // palette queue entry to free
117 
118 PALQ *FindPalette( // find a palette in the palette queue
119  SCNHANDLE hSrchPal); // palette to search for
120 
121 void SwapPalette( // swaps palettes at the specified palette queue position
122  PALQ *pPalQ, // palette queue position
123  SCNHANDLE hNewPal); // new palette
124 
125 PALQ *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 
128 COLORREF GetBgndColor(); // returns current background color
129 
130 void SetBgndColor( // sets current background color
131  COLORREF color); // color to set the background to
132 
133 void FadingPalette(PALQ *pPalQ, bool bFading);
134 
135 void CreateTranslucentPalette(SCNHANDLE BackPal);
136 
137 void NoFadingPalettes(); // All fading processes have just been killed
138 
139 void DimPartPalette(
140  SCNHANDLE hPal,
141  int startColor,
142  int length,
143  int brightness); // 0 = black, 10 == 100%
144 
145 
146 int TranslucentColor();
147 int DarkGreen();
148 
149 #define BoxColor (TinselVersion == 3 ? DarkGreen : TranslucentColor)
150 
151 int HighlightColor();
152 
153 int TalkColor();
154 
155 void SetTalkColorRef(COLORREF colRef);
156 
157 COLORREF GetTalkColorRef();
158 
159 void SetTagColorRef(COLORREF colRef);
160 
161 COLORREF GetTagColorRef();
162 
163 void SetTalkTextOffset(int offset);
164 
165 void SetTranslucencyOffset(int offset);
166 
167 } // End of namespace Tinsel
168 
169 #endif // TINSEL_PALETTE_H
COLORREF palRGB[MAX_COLORS]
actual palette colors
Definition: palette.h:64
int objCount
number of objects using this palette
Definition: palette.h:71
Definition: palette.h:69
SCNHANDLE hPal
handle to palette data struct
Definition: palette.h:70
uint32 SCNHANDLE
Definition: dw.h:31
int32 numColors
number of colors in the palette
Definition: palette.h:73
Blue used in translucent rectangles.
Definition: palette.h:45
the biggest value R, G or B can have
Definition: palette.h:38
Blue used in translucent rectangles.
Definition: palette.h:44
Definition: palette.h:62
number of palettes
Definition: palette.h:39
byte palette[MAX_COLORS *3]
actual palette colors (RGB values)
Definition: palette.h:65
index of background color in Video DAC
Definition: palette.h:42
index of first foreground color in Video DAC
Definition: palette.h:43
int32 numColors
number of colors in the palette
Definition: palette.h:63
Definition: actors.h:36
Blue used in translucent rectangles.
Definition: palette.h:46
Blue used in translucent rectangles.
Definition: palette.h:47
maximum number of colors - for VGA 256
Definition: palette.h:36
number of bits per pixel for VGA 256
Definition: palette.h:37
int posInDAC
palette position in the video DAC
Definition: palette.h:72