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