/*=========================================================================== * * File: Dfpal.H * Author: Dave Humphrey (uesp@m0use.net) * Created On: Tuesday, June 26, 2001 * * Defines Daggerfall palette related routines and the CDFPalette class. * *=========================================================================*/ #ifndef __DFPAL_H #define __DFPAL_H /*=========================================================================== * * Begin Required Include Files * *=========================================================================*/ #include "common/images/rgbpal.h" #include "uesp/dagger/common/dfcommon.h" /*=========================================================================== * End of Required Include Files *=========================================================================*/ /*=========================================================================== * * Begin Definitions * *=========================================================================*/ /* Maximum number of entries in the palette */ #define DF_MAX_PALENTRIES 256 /* Daggerfall palette types */ #define DFPALETTE_PAL 1 #define DFPALETTE_COL 2 /* Default file sizes */ #define DF_PAL_FILESIZE 768 #define DF_COL_FILESIZE 776 /* Default record sizes */ #define DF_COL_HEADERSIZE 8 /*=========================================================================== * End of Definitions *=========================================================================*/ /*=========================================================================== * * Begin Type and Structure Definitions * *=========================================================================*/ #pragma pack(push, 1) /* Header information contained in COL files */ typedef struct { long FileSize; long Unknown; } dfcolheader_t; #pragma pack(pop) /*=========================================================================== * End of Type and Structure Definitions *=========================================================================*/ /*=========================================================================== * * Class CDFPalette Definition * * Handles the manipulation of Daggerfall PAL/COL files and palettes. * *=========================================================================*/ class CDFPalette { /*---------- Begin Private Class Members -----------------------*/ private: rgbpalraw_t m_Palette[DF_MAX_PALENTRIES]; /* The raw DF palette data */ int m_PaletteSize; /* Number of colors currently defined */ dfcolheader_t m_COLHeader; /* Header information for COL files */ int m_FileType; /* Is the file a COL or PAL? */ /*---------- Begin Public Class Methods ------------------------*/ public: /* Class constructor */ CDFPalette(); /* Class get members */ int GetPaletteSize (void) const; rgbpalraw_t* GetPalette (void) const; byte* GetBytePalette (void) const; rgbpalraw_t* GetPalEntry (const int Index) const; /* Get the type of palette data */ boolean IsCOLFile (void) const; boolean IsPALFile (void) const; /* Attempt to load a COL/PAL file */ boolean Load (const char* pFilename); boolean LoadCOL (const char* pFilename); boolean LoadPAL (const char* pFilename); }; /*=========================================================================== * End of Class CDFPalette Definition *=========================================================================*/ /*=========================================================================== * * Begin CDFPalette Inline Methods * *=========================================================================*/ /* Get class members */ inline int CDFPalette::GetPaletteSize (void) const { return (m_PaletteSize); } inline rgbpalraw_t* CDFPalette::GetPalette (void) const { return (rgbpalraw_t *)(&m_Palette[0]); } inline byte* CDFPalette::GetBytePalette (void) const { return (byte *)(&m_Palette[0].r); } /* Access a specific palette entry */ inline rgbpalraw_t* CDFPalette::GetPalEntry (const int Index) const { IASSERT(Index >= 0 && Index < m_PaletteSize); return (rgbpalraw_t *)(&m_Palette[Index]); } /* Get the type of palette data */ inline boolean CDFPalette::IsCOLFile (void) const { return (m_FileType == DFPALETTE_COL); } inline boolean CDFPalette::IsPALFile (void) const { return (m_FileType == DFPALETTE_PAL); } /*=========================================================================== * End of CDFPalette Inline Methods *=========================================================================*/ /*=========================================================================== * * Begin Function Prototypes * *=========================================================================*/ /* Access the default Daggerfall palette data */ rgbpalraw_t* GetDefaultDFPal (void); /*=========================================================================== * End of Function Prototypes *=========================================================================*/ #endif /*=========================================================================== * End of File DFPal.H *=========================================================================*/