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 */ 22 23 #ifndef GRAPHICS_PALETTE_H 24 #define GRAPHICS_PALETTE_H 25 26 #include "common/scummsys.h" 27 #include "common/noncopyable.h" 28 29 /** 30 * The PaletteManager is part of the OSystem backend API and responsible 31 * for handling the (possibly emulated) "hardware" palette needed for 32 * many old games (e.g. in EGA and VGA mode). 33 * 34 * By itself it is a pure abstract class, i.e. an "interface"; you can 35 * use the OSystem::getPaletteManager() method to obtain an instance 36 * that you can use to perform actual palette modifications. 37 */ 38 class PaletteManager : Common::NonCopyable { 39 public: ~PaletteManager()40 virtual ~PaletteManager() {} 41 42 /** 43 * Replace the specified range of the palette with new colors. 44 * The palette entries from 'start' till (start+num-1) will be replaced - so 45 * a full palette update is accomplished via start=0, num=256. 46 * 47 * The palette data is specified in interleaved RGB format. That is, the 48 * first byte of the memory block 'colors' points at is the red component 49 * of the first new color; the second byte the green component of the first 50 * new color; the third byte the blue component, the last byte to the alpha 51 * (transparency) value. Then the second color starts, and so on. So memory 52 * looks like this: R1-G1-B1-R2-G2-B2-R3-... 53 * 54 * @param colors the new palette data, in interleaved RGB format 55 * @param start the first palette entry to be updated 56 * @param num the number of palette entries to be updated 57 * 58 * @note It is an error if start+num exceeds 256, behavior is undefined 59 * in that case (the backend may ignore it silently or assert). 60 * @note It is an error if this function gets called when the pixel format 61 * in use (the return value of getScreenFormat) has more than one 62 * byte per pixel. 63 * 64 * @see getScreenFormat 65 */ 66 virtual void setPalette(const byte *colors, uint start, uint num) = 0; 67 68 /** 69 * Grabs a specified part of the currently active palette. 70 * The format is the same as for setPalette. 71 * 72 * This should return exactly the same RGB data as was setup via previous 73 * setPalette calls. 74 * 75 * For example, for every valid value of start and num of the following 76 * code: 77 * 78 * byte origPal[num*3]; 79 * // Setup origPal's data however you like 80 * g_system->setPalette(origPal, start, num); 81 * byte obtainedPal[num*3]; 82 * g_system->grabPalette(obtainedPal, start, num); 83 * 84 * the following should be true: 85 * 86 * memcmp(origPal, obtainedPal, num*3) == 0 87 * 88 * @see setPalette 89 * @param colors the palette data, in interleaved RGB format 90 * @param start the first platte entry to be read 91 * @param num the number of palette entries to be read 92 * 93 * @note It is an error if this function gets called when the pixel format 94 * in use (the return value of getScreenFormat) has more than one 95 * byte per pixel. 96 * 97 * @see getScreenFormat 98 */ 99 virtual void grabPalette(byte *colors, uint start, uint num) = 0; 100 }; 101 102 #endif 103