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 NEVERHOOD_PALETTE_H
24 #define NEVERHOOD_PALETTE_H
25 
26 #include "neverhood/neverhood.h"
27 #include "neverhood/entity.h"
28 
29 namespace Neverhood {
30 
31 class Palette : public Entity {
32 public:
33 	// Default constructor with black palette
34 	Palette(NeverhoodEngine *vm);
35 	// Create from existing palette
36 	Palette(NeverhoodEngine *vm, byte *palette);
37 	// Create from resource with filename
38 	Palette(NeverhoodEngine *vm, const char *filename);
39 	// Create from resource with fileHash
40 	Palette(NeverhoodEngine *vm, uint32 fileHash);
41 	virtual ~Palette();
42 	void init();
43 	void usePalette();
44 	void addPalette(const char *filename, int toIndex, int count, int fromIndex);
45 	void addPalette(uint32 fileHash, int toIndex, int count, int fromIndex);
46 	void addBasePalette(uint32 fileHash, int toIndex, int count, int fromIndex);
47 	void copyPalette(const byte *palette, int toIndex, int count, int fromIndex);
48 	void copyBasePalette(int toIndex, int count, int fromIndex);
49 	void startFadeToBlack(int counter);
50 	void startFadeToWhite(int counter);
51 	void startFadeToPalette(int counter);
52 	void fillBaseWhite(int index, int count);
53 	void fillBaseBlack(int index, int count);
54 	void copyToBasePalette(byte *palette);
55 protected:
56 	int _status;
57 	byte *_palette;
58 	byte *_basePalette;
59 	int _palCounter;
60 	byte _fadeToR, _fadeToG, _fadeToB;
61 	int _fadeStep;
62 	void update();
63 	void fadeColor(byte *rgb, byte toR, byte toG, byte toB);
64 	int calculateFadeStep(int counter);
65 };
66 
67 } // End of namespace Neverhood
68 
69 #endif /* NEVERHOOD_PALETTE_H */
70