1 /* 2 * This file is released under the GNU General Public Licence 3 * 4 * authors: 5 * Richard Ashbury <richard.asbury@btinternet.com> 6 * Jean-Christophe Hoelt <jeko@ios-software.com> 7 */ 8 9 #ifndef _PALETTE_H 10 #define _PALETTE_H 11 12 #define NB_PALETTES 30 13 14 #include "corona_types.h" 15 16 // PALETTE 17 // 18 typedef ColorRGB Palette[256]; 19 class CompressedPalette; 20 21 // COLLECTION OF PALETTES 22 // 23 // Definition of some palettes stored in compressed format. 24 // 25 class PaletteCollection 26 { 27 public: 28 PaletteCollection(const int palettes[][NB_PALETTES], int nbPalettes); 29 ~PaletteCollection(); 30 size()31 int size() const { return m_nbPalettes; } 32 void expandPalette(int i, Palette dest) const; 33 34 private: 35 CompressedPalette *m_cpal; 36 int m_nbPalettes; 37 }; 38 39 // PALETTE CYCLER 40 // 41 // A class to create cycling palettes. 42 // 43 class PaletteCycler 44 { 45 private: 46 Palette m_srcpal; 47 Palette m_destpal; 48 Palette m_curpal; 49 50 PaletteCollection m_palettes; 51 int m_srcnum, m_destnum; 52 bool m_transferring; 53 double m_progress; 54 55 void startPaletteTransition(); 56 void affectPaletteTransition(double p); 57 58 public: 59 PaletteCycler(const int palettes[][NB_PALETTES], int nbPalettes); 60 void update(TimedLevel *pLevels); getPalette()61 const Palette &getPalette() const { return m_curpal; } 62 }; 63 64 // PALETTE CONVERSIOn 65 // 66 // Display/Architecture specific routines to convert Palette to int[] (hardware color) 67 // 68 void paletteToRGBA(int dest[256], const Palette src); 69 70 // BLIT A PALETTIZED SURFACE using converted palette. 71 void blitSurface8To32(unsigned char *byteSurf, int *colorSurf, int palette[256], int size); 72 73 #endif 74