aboutsummaryrefslogtreecommitdiff
path: root/engines/sci
diff options
context:
space:
mode:
authorColin Snover2017-07-03 15:42:09 -0500
committerColin Snover2017-07-06 19:12:37 -0500
commitc6f58401969fa5ab90c809c46f490e7c0e5dc02e (patch)
treef46cf5ab89c9c2a24b23c0cefcdfeca0232fe188 /engines/sci
parentf7fcce24e1da22815a589fbefcf34458d558acb4 (diff)
downloadscummvm-rg350-c6f58401969fa5ab90c809c46f490e7c0e5dc02e.tar.gz
scummvm-rg350-c6f58401969fa5ab90c809c46f490e7c0e5dc02e.tar.bz2
scummvm-rg350-c6f58401969fa5ab90c809c46f490e7c0e5dc02e.zip
SCI32: Remove magic numbers in HunkPalette
Diffstat (limited to 'engines/sci')
-rw-r--r--engines/sci/graphics/palette32.cpp12
-rw-r--r--engines/sci/graphics/palette32.h33
2 files changed, 38 insertions, 7 deletions
diff --git a/engines/sci/graphics/palette32.cpp b/engines/sci/graphics/palette32.cpp
index 3667e1fac1..fcef2a7fa8 100644
--- a/engines/sci/graphics/palette32.cpp
+++ b/engines/sci/graphics/palette32.cpp
@@ -44,7 +44,7 @@ HunkPalette::HunkPalette(const SciSpan<const byte> &rawPalette) :
// set to 14, but the *actual* size of the header structure used in SSCI is
// 13, which is reflected by `kHunkPaletteHeaderSize`.
// _headerSize(rawPalette[0]),
- _numPalettes(rawPalette.getUint8At(10)),
+ _numPalettes(rawPalette.getUint8At(kNumPaletteEntriesOffset)),
_data() {
assert(_numPalettes == 0 || _numPalettes == 1);
if (_numPalettes) {
@@ -54,7 +54,7 @@ HunkPalette::HunkPalette(const SciSpan<const byte> &rawPalette) :
}
void HunkPalette::setVersion(const uint32 version) const {
- if (_numPalettes != _data.getUint8At(10)) {
+ if (_numPalettes != _data.getUint8At(kNumPaletteEntriesOffset)) {
error("Invalid HunkPalette");
}
@@ -74,10 +74,10 @@ const HunkPalette::EntryHeader HunkPalette::getEntryHeader() const {
const SciSpan<const byte> data(getPalPointer());
EntryHeader header;
- header.startColor = data.getUint8At(10);
- header.numColors = data.getUint16SEAt(14);
- header.used = data.getUint8At(16);
- header.sharedUsed = data.getUint8At(17);
+ header.startColor = data.getUint8At(kEntryStartColorOffset);
+ header.numColors = data.getUint16SEAt(kEntryNumColorsOffset);
+ header.used = data.getUint8At(kEntryUsedOffset);
+ header.sharedUsed = data.getUint8At(kEntrySharedUsedOffset);
header.version = data.getUint32SEAt(kEntryVersionOffset);
return header;
diff --git a/engines/sci/graphics/palette32.h b/engines/sci/graphics/palette32.h
index 0fcd7e00ab..fb0b226130 100644
--- a/engines/sci/graphics/palette32.h
+++ b/engines/sci/graphics/palette32.h
@@ -56,6 +56,12 @@ public:
private:
enum {
/**
+ * The offset into the HunkPalette header of the number of palettes in
+ * the HunkPalette.
+ */
+ kNumPaletteEntriesOffset = 10,
+
+ /**
* The size of the HunkPalette header.
*/
kHunkPaletteHeaderSize = 13,
@@ -63,7 +69,32 @@ private:
/**
* The size of a palette entry header.
*/
- kEntryHeaderSize = 22,
+ kEntryHeaderSize = 22
+ };
+
+ enum {
+ /**
+ * The offset of the start color within the palette entry header.
+ */
+ kEntryStartColorOffset = 10,
+
+ /**
+ * The offset of the color count within the palette entry header.
+ */
+ kEntryNumColorsOffset = 14,
+
+ /**
+ * The offset of the shared used palette index flag within the palette
+ * entry header.
+ */
+ kEntryUsedOffset = 16,
+
+ /**
+ * The offset of the flag within the palette entry header that says
+ * whether or not the corresponding palette data includes used flags for
+ * each palette index individually.
+ */
+ kEntrySharedUsedOffset = 17,
/**
* The offset of the hunk palette version within the palette entry