aboutsummaryrefslogtreecommitdiff
path: root/engines/cine/pal.h
diff options
context:
space:
mode:
Diffstat (limited to 'engines/cine/pal.h')
-rw-r--r--engines/cine/pal.h37
1 files changed, 29 insertions, 8 deletions
diff --git a/engines/cine/pal.h b/engines/cine/pal.h
index 23c9007986..f7c7dee354 100644
--- a/engines/cine/pal.h
+++ b/engines/cine/pal.h
@@ -39,6 +39,15 @@ static const Graphics::PixelFormat kHighPalFormat = {3, 0, 0, 0, 8, 0, 8, 16, 0}
/*! \brief The color format used by OSystem's setPalette-function. */
static const Graphics::PixelFormat kSystemPalFormat = {4, 0, 0, 0, 8, 0, 8, 16, 0};
+/*! \brief Endian types. Used at least by Palette class's load and save functions.
+ * TODO: Move somewhere more general as this is definitely not Cine-engine specific
+ */
+enum EndianType {
+ NATIVE_ENDIAN,
+ LITTLE_ENDIAN,
+ BIG_ENDIAN
+};
+
struct PalEntry {
char name[10];
byte pal1[16];
@@ -63,45 +72,55 @@ void transformPaletteRange(byte *srcPal, byte *dstPal, int startColor, int stopC
// TODO: Test
class Palette {
public:
- /*! \brief Load palette from buffer with given color format and number of colors.
+ /*! \brief Load palette from buffer with given color format, endianness and number of colors.
* \param buf Input buffer
* \param size Input buffer size in bytes
* \param format Input color format
* \param numColors Number of colors to load
+ * \param endianType The endianness of the colors in the input buffer
*/
- Palette &load(const byte *buf, const uint size, const Graphics::PixelFormat format, const uint numColors);
+ Palette &load(const byte *buf, const uint size, const Graphics::PixelFormat format, const uint numColors, const EndianType endianType);
- /*! \brief Save the whole palette to buffer in original color format.
+ /*! \brief Save the whole palette to buffer in original color format using defined endianness.
* \param buf Output buffer
* \param size Output buffer size in bytes
+ * \param endianType The endian type to use
*/
- byte *save(byte *buf, const uint size) const;
+ byte *save(byte *buf, const uint size, const EndianType endianType) const;
- /*! \brief Save the whole palette to buffer with given color format.
+ /*! \brief Save the whole palette to buffer in given color format using defined endianness.
* \param buf Output buffer
* \param size Output buffer size in bytes
* \param format Output color format
+ * \param endianType The endian type to use
*/
- byte *save(byte *buf, const uint size, const Graphics::PixelFormat format) const;
+ byte *save(byte *buf, const uint size, const Graphics::PixelFormat format, const EndianType endianType) const;
- /*! \brief Save (partial) palette to buffer with given color format.
+ /*! \brief Save (partial) palette to buffer in given color format using defined endianness.
* \param buf Output buffer
* \param size Output buffer size in bytes
* \param format Output color format
* \param numColors Number of colors to save
+ * \param endianType The endian type to use
* \param firstIndex Starting color index (from which onwards to save the colors)
*/
- byte *save(byte *buf, const uint size, const Graphics::PixelFormat format, const uint numColors, const byte firstIndex = 0) const;
+ byte *save(byte *buf, const uint size, const Graphics::PixelFormat format, const uint numColors, const EndianType endianType, const byte firstIndex = 0) const;
Palette &rotateRight(byte firstIndex, byte lastIndex);
Palette &saturatedAddColor(byte firstIndex, byte lastIndex, signed r, signed g, signed b);
uint colorCount() const;
+ /*! \brief The original endian type in which this palette was loaded.
+ * \note This will always return either BIG_ENDIAN or LITTLE_ENDIAN (So no NATIVE_ENDIAN).
+ */
+ const EndianType endianType() const;
+
/*! \brief The original color format in which this palette was loaded. */
Graphics::PixelFormat colorFormat() const;
private:
void setColorFormat(const Graphics::PixelFormat format);
+ void setEndianType(const EndianType endianType);
void saturatedAddColor(byte index, signed r, signed g, signed b);
private:
@@ -109,9 +128,11 @@ private:
uint8 r, g, b;
};
+ // The used source format, its endianness etc.
Graphics::PixelFormat _format;
uint _rBits, _gBits, _bBits;
uint _rMax, _gMax, _bMax;
+ bool _bigEndian;
Common::Array<Color> _colors;
};