diff options
Diffstat (limited to 'engines/sci/graphics/palette.cpp')
-rw-r--r-- | engines/sci/graphics/palette.cpp | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/engines/sci/graphics/palette.cpp b/engines/sci/graphics/palette.cpp index 6fe1fb1b49..307c8aedde 100644 --- a/engines/sci/graphics/palette.cpp +++ b/engines/sci/graphics/palette.cpp @@ -134,12 +134,12 @@ void GfxPalette::setDefault() { #define SCI_PAL_FORMAT_CONSTANT 1 #define SCI_PAL_FORMAT_VARIABLE 0 -void GfxPalette::createFromData(byte *data, int bytesLeft, Palette *paletteOut) const { +void GfxPalette::createFromData(const SciSpan<const byte> &data, Palette *paletteOut) const { int palFormat = 0; - int palOffset = 0; - int palColorStart = 0; - int palColorCount = 0; - int colorNo = 0; + uint palOffset = 0; + uint palColorStart = 0; + uint palColorCount = 0; + uint colorNo = 0; memset(paletteOut, 0, sizeof(Palette)); @@ -148,16 +148,16 @@ void GfxPalette::createFromData(byte *data, int bytesLeft, Palette *paletteOut) paletteOut->mapping[colorNo] = colorNo; } - if (bytesLeft < 37) { + if (data.size() < 37) { // This happens when loading palette of picture 0 in sq5 - the resource is broken and doesn't contain a full // palette - debugC(kDebugLevelResMan, "GfxPalette::createFromData() - not enough bytes in resource (%d), expected palette header", bytesLeft); + debugC(kDebugLevelResMan, "GfxPalette::createFromData() - not enough bytes in resource (%lu), expected palette header", data.size()); return; } // palette formats in here are not really version exclusive, we can not use sci-version to differentiate between them // they were just called that way, because they started appearing in sci1.1 for example - if ((data[0] == 0 && data[1] == 1) || (data[0] == 0 && data[1] == 0 && READ_SCI11ENDIAN_UINT16(data + 29) == 0)) { + if ((data[0] == 0 && data[1] == 1) || (data[0] == 0 && data[1] == 0 && data.getUint16SEAt(29) == 0)) { // SCI0/SCI1 palette palFormat = SCI_PAL_FORMAT_VARIABLE; // CONSTANT; palOffset = 260; @@ -168,13 +168,13 @@ void GfxPalette::createFromData(byte *data, int bytesLeft, Palette *paletteOut) palFormat = data[32]; palOffset = 37; palColorStart = data[25]; - palColorCount = READ_SCI11ENDIAN_UINT16(data + 29); + palColorCount = data.getUint16SEAt(29); } switch (palFormat) { case SCI_PAL_FORMAT_CONSTANT: // Check, if enough bytes left - if (bytesLeft < palOffset + (3 * palColorCount)) { + if (data.size() < palOffset + (3 * palColorCount)) { warning("GfxPalette::createFromData() - not enough bytes in resource, expected palette colors"); return; } @@ -187,7 +187,7 @@ void GfxPalette::createFromData(byte *data, int bytesLeft, Palette *paletteOut) } break; case SCI_PAL_FORMAT_VARIABLE: - if (bytesLeft < palOffset + (4 * palColorCount)) { + if (data.size() < palOffset + (4 * palColorCount)) { warning("GfxPalette::createFromData() - not enough bytes in resource, expected palette colors"); return; } @@ -237,7 +237,7 @@ bool GfxPalette::setAmiga() { } // Called from picture class, some amiga sci1 games set half of the palette -void GfxPalette::modifyAmigaPalette(byte *data) { +void GfxPalette::modifyAmigaPalette(const SciSpan<const byte> &data) { int16 curPos = 0; for (int curColor = 0; curColor < 16; curColor++) { @@ -525,7 +525,7 @@ bool GfxPalette::kernelSetFromResource(GuiResourceId resourceId, bool force) { Palette palette; if (palResource) { - createFromData(palResource->data, palResource->size, &palette); + createFromData(*palResource, &palette); set(&palette, force); return true; } @@ -723,7 +723,7 @@ bool GfxPalette::palVaryLoadTargetPalette(GuiResourceId resourceId) { Resource *palResource = _resMan->findResource(ResourceId(kResourceTypePalette, resourceId), false); if (palResource) { // Load and initialize destination palette - createFromData(palResource->data, palResource->size, &_palVaryTargetPalette); + createFromData(*palResource, &_palVaryTargetPalette); return true; } return false; @@ -810,7 +810,7 @@ int16 GfxPalette::kernelPalVaryChangeTarget(GuiResourceId resourceId) { Resource *palResource = _resMan->findResource(ResourceId(kResourceTypePalette, resourceId), false); if (palResource) { Palette insertPalette; - createFromData(palResource->data, palResource->size, &insertPalette); + createFromData(*palResource, &insertPalette); // insert new palette into target insert(&insertPalette, &_palVaryTargetPalette); // update palette and set on screen |