diff options
107 files changed, 730 insertions, 860 deletions
diff --git a/audio/softsynth/mt32.cpp b/audio/softsynth/mt32.cpp index 3a3958d494..a980b564fc 100644 --- a/audio/softsynth/mt32.cpp +++ b/audio/softsynth/mt32.cpp @@ -315,9 +315,9 @@ int MidiDriver_MT32::open() { if (screenFormat.bytesPerPixel == 1) { const byte dummy_palette[] = { - 0, 0, 0, 0, // background - 0, 171, 0, 0, // border, font - 171, 0, 0, 0 // fill + 0, 0, 0, // background + 0, 171, 0, // border, font + 171, 0, 0 // fill }; g_system->getPaletteManager()->setPalette(dummy_palette, 0, 3); diff --git a/backends/graphics/default-palette.h b/backends/graphics/default-palette.h index 6e3a75350e..12436aae51 100644 --- a/backends/graphics/default-palette.h +++ b/backends/graphics/default-palette.h @@ -38,7 +38,7 @@ */ class DefaultPaletteManager : public PaletteManager { protected: - byte _palette[4 * 256]; + byte _palette[3 * 256]; /** * Subclasses should only implement this method and none of the others. @@ -51,12 +51,12 @@ protected: public: void setPalette(const byte *colors, uint start, uint num) { assert(start + num <= 256); - memcpy(_palette + 4 * start, colors, 4 * num); + memcpy(_palette + 3 * start, colors, 3 * num); setPaletteIntern(colors, start, num); } void grabPalette(byte *colors, uint start, uint num) { assert(start + num <= 256); - memcpy(colors, _palette + 4 * start, 4 * num); + memcpy(colors, _palette + 3 * start, 3 * num); } }; diff --git a/backends/graphics/opengl/opengl-graphics.cpp b/backends/graphics/opengl/opengl-graphics.cpp index a1b2e00f51..beac2f6d3e 100644 --- a/backends/graphics/opengl/opengl-graphics.cpp +++ b/backends/graphics/opengl/opengl-graphics.cpp @@ -62,8 +62,8 @@ OpenGLGraphicsManager::OpenGLGraphicsManager() _videoMode.fullscreen = ConfMan.getBool("fullscreen"); _videoMode.antialiasing = false; - _gamePalette = (byte *)calloc(sizeof(byte) * 4, 256); - _cursorPalette = (byte *)calloc(sizeof(byte) * 4, 256); + _gamePalette = (byte *)calloc(sizeof(byte) * 3, 256); + _cursorPalette = (byte *)calloc(sizeof(byte) * 3, 256); } OpenGLGraphicsManager::~OpenGLGraphicsManager() { @@ -314,7 +314,7 @@ void OpenGLGraphicsManager::setPalette(const byte *colors, uint start, uint num) #endif // Save the screen palette - memcpy(_gamePalette + start * 4, colors, num * 4); + memcpy(_gamePalette + start * 3, colors, num * 3); _screenNeedsRedraw = true; @@ -330,7 +330,7 @@ void OpenGLGraphicsManager::grabPalette(byte *colors, uint start, uint num) { #endif // Copies current palette to buffer - memcpy(colors, _gamePalette + start * 4, num * 4); + memcpy(colors, _gamePalette + start * 3, num * 3); } void OpenGLGraphicsManager::copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h) { @@ -580,7 +580,7 @@ void OpenGLGraphicsManager::setCursorPalette(const byte *colors, uint start, uin assert(colors); // Save the cursor palette - memcpy(_cursorPalette + start * 4, colors, num * 4); + memcpy(_cursorPalette + start * 3, colors, num * 3); _cursorPaletteDisabled = false; _cursorNeedsRedraw = true; @@ -686,9 +686,9 @@ void OpenGLGraphicsManager::refreshGameScreen() { byte *dst = surface; for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { - dst[0] = _gamePalette[src[j] * 4]; - dst[1] = _gamePalette[src[j] * 4 + 1]; - dst[2] = _gamePalette[src[j] * 4 + 2]; + dst[0] = _gamePalette[src[j] * 3]; + dst[1] = _gamePalette[src[j] * 3 + 1]; + dst[2] = _gamePalette[src[j] * 3 + 2]; dst += 3; } src += _screenData.pitch; @@ -728,9 +728,9 @@ void OpenGLGraphicsManager::refreshOverlay() { byte *dst = surface; for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { - dst[0] = _gamePalette[src[j] * 4]; - dst[1] = _gamePalette[src[j] * 4 + 1]; - dst[2] = _gamePalette[src[j] * 4 + 2]; + dst[0] = _gamePalette[src[j] * 3]; + dst[1] = _gamePalette[src[j] * 3 + 1]; + dst[2] = _gamePalette[src[j] * 3 + 2]; dst += 3; } src += _screenData.pitch; @@ -772,9 +772,9 @@ void OpenGLGraphicsManager::refreshCursor() { for (int i = 0; i < _cursorState.w * _cursorState.h; i++) { // Check for keycolor if (src[i] != _cursorKeyColor) { - dst[0] = palette[src[i] * 4]; - dst[1] = palette[src[i] * 4 + 1]; - dst[2] = palette[src[i] * 4 + 2]; + dst[0] = palette[src[i] * 3]; + dst[1] = palette[src[i] * 3 + 1]; + dst[2] = palette[src[i] * 3 + 2]; dst[3] = 255; } dst += 4; diff --git a/backends/graphics/sdl/sdl-graphics.cpp b/backends/graphics/sdl/sdl-graphics.cpp index 480cf2e795..15d896c57a 100644 --- a/backends/graphics/sdl/sdl-graphics.cpp +++ b/backends/graphics/sdl/sdl-graphics.cpp @@ -1337,11 +1337,10 @@ void SdlGraphicsManager::setPalette(const byte *colors, uint start, uint num) { const byte *b = colors; uint i; SDL_Color *base = _currentPalette + start; - for (i = 0; i < num; i++) { + for (i = 0; i < num; i++, b += 3) { base[i].r = b[0]; base[i].g = b[1]; base[i].b = b[2]; - b += 4; } if (start < _paletteDirtyStart) @@ -1365,10 +1364,9 @@ void SdlGraphicsManager::grabPalette(byte *colors, uint start, uint num) { const SDL_Color *base = _currentPalette + start; for (uint i = 0; i < num; ++i) { - colors[i * 4] = base[i].r; - colors[i * 4 + 1] = base[i].g; - colors[i * 4 + 2] = base[i].b; - colors[i * 4 + 3] = 0xFF; + colors[i * 3] = base[i].r; + colors[i * 3 + 1] = base[i].g; + colors[i * 3 + 2] = base[i].b; } } @@ -1377,11 +1375,10 @@ void SdlGraphicsManager::setCursorPalette(const byte *colors, uint start, uint n const byte *b = colors; uint i; SDL_Color *base = _cursorPalette + start; - for (i = 0; i < num; i++) { + for (i = 0; i < num; i++, b += 3) { base[i].r = b[0]; base[i].g = b[1]; base[i].b = b[2]; - b += 4; } _cursorPaletteDisabled = false; diff --git a/backends/platform/android/android.cpp b/backends/platform/android/android.cpp index 0424983824..38bc94eb7f 100644 --- a/backends/platform/android/android.cpp +++ b/backends/platform/android/android.cpp @@ -749,32 +749,12 @@ void OSystem_Android::setPalette(const byte *colors, uint start, uint num) { if (!_use_mouse_palette) _setCursorPalette(colors, start, num); - byte *palette = _game_texture->palette() + start * 3; - - do { - for (int i = 0; i < 3; ++i) - palette[i] = colors[i]; - - palette += 3; - colors += 4; - } while (--num); + memcpy(_game_texture->palette() + start * 3, colors, num * 3); } void OSystem_Android::grabPalette(byte *colors, uint start, uint num) { ENTER("%p, %u, %u", colors, start, num); - - const byte *palette = _game_texture->palette_const() + start * 3; - - do { - for (int i = 0; i < 3; ++i) - colors[i] = palette[i]; - - // alpha - colors[3] = 0xff; - - palette += 3; - colors += 4; - } while (--num); + memcpy(colors, _game_texture->palette_const() + start * 3, num * 3); } void OSystem_Android::copyRectToScreen(const byte *buf, int pitch, @@ -1051,7 +1031,7 @@ void OSystem_Android::_setCursorPalette(const byte *colors, // Leave alpha untouched to preserve keycolor palette += 4; - colors += 4; + colors += 3; } while (--num); } diff --git a/backends/platform/dc/display.cpp b/backends/platform/dc/display.cpp index 53dbff333d..b297022775 100644 --- a/backends/platform/dc/display.cpp +++ b/backends/platform/dc/display.cpp @@ -156,7 +156,7 @@ void OSystem_Dreamcast::setPalette(const byte *colors, uint start, uint num) *dst++ = ((colors[0]<<7)&0x7c00)| ((colors[1]<<2)&0x03e0)| ((colors[2]>>3)&0x001f); - colors += 4; + colors += 3; } _screen_dirty = true; } @@ -169,7 +169,7 @@ void OSystem_Dreamcast::setCursorPalette(const byte *colors, uint start, uint nu *dst++ = ((colors[0]<<7)&0x7c00)| ((colors[1]<<2)&0x03e0)| ((colors[2]>>3)&0x001f); - colors += 4; + colors += 3; } _enable_cursor_palette = true; } @@ -188,8 +188,7 @@ void OSystem_Dreamcast::grabPalette(byte *colors, uint start, uint num) colors[0] = ((p&0x7c00)>>7)|((p&0x7000)>>12); colors[1] = ((p&0x03e0)>>2)|((p&0x0380)>>7); colors[2] = ((p&0x001f)<<3)|((p&0x001c)>>2); - colors[3] = 0xff; - colors += 4; + colors += 3; } } diff --git a/backends/platform/ds/arm9/source/osystem_ds.cpp b/backends/platform/ds/arm9/source/osystem_ds.cpp index 55e3be6cca..3ad92b4355 100644 --- a/backends/platform/ds/arm9/source/osystem_ds.cpp +++ b/backends/platform/ds/arm9/source/osystem_ds.cpp @@ -204,7 +204,7 @@ void OSystem_DS::setPalette(const byte *colors, uint start, uint num) { } // if (num == 255) consolePrintf("pal:%d r:%d g:%d b:%d\n", r, red, green, blue); - colors += 4; + colors += 3; } } @@ -235,7 +235,7 @@ void OSystem_DS::setCursorPalette(const byte *colors, uint start, uint num) { u16 paletteValue = red | (green << 5) | (blue << 10); _cursorPalette[r] = paletteValue; - colors += 4; + colors += 3; } _disableCursorPalette = false; @@ -266,7 +266,6 @@ void OSystem_DS::grabPalette(unsigned char *colours, uint start, uint num) { *colours++ = (BG_PALETTE[r] & 0x001F) << 3; *colours++ = (BG_PALETTE[r] & 0x03E0) >> 5 << 3; *colours++ = (BG_PALETTE[r] & 0x7C00) >> 10 << 3; - colours++; } } diff --git a/backends/platform/iphone/osys_video.cpp b/backends/platform/iphone/osys_video.cpp index ee27e4d87c..d67d38932a 100644 --- a/backends/platform/iphone/osys_video.cpp +++ b/backends/platform/iphone/osys_video.cpp @@ -102,7 +102,7 @@ void OSystem_IPHONE::setPalette(const byte *colors, uint start, uint num) { for (uint i = start; i < start + num; ++i) { _palette[i] = Graphics::RGBToColor<Graphics::ColorMasks<565> >(b[0], b[1], b[2]); - b += 4; + b += 3; } dirtyFullScreen(); @@ -114,8 +114,7 @@ void OSystem_IPHONE::grabPalette(byte *colors, uint start, uint num) { for (uint i = start; i < start + num; ++i) { Graphics::colorToRGB<Graphics::ColorMasks<565> >(_palette[i], b[0], b[1], b[2]); - b[3] = 0xFF; - b += 4; + b += 3; } } diff --git a/backends/platform/n64/osys_n64.h b/backends/platform/n64/osys_n64.h index e5ffc7f3bc..2daa41a9f6 100644 --- a/backends/platform/n64/osys_n64.h +++ b/backends/platform/n64/osys_n64.h @@ -93,7 +93,7 @@ protected: uint16 *_screenPalette; // Array for palette entries (256 colors max) #ifndef N64_EXTREME_MEMORY_SAVING - uint32 *_screenExactPalette; // Array for palette entries, as received by setPalette(), no precision loss + uint8 *_screenExactPalette; // Array for palette entries, as received by setPalette(), no precision loss #endif uint16 _cursorPalette[256]; // Palette entries for the cursor diff --git a/backends/platform/n64/osys_n64_base.cpp b/backends/platform/n64/osys_n64_base.cpp index 1b9c704225..54eab0fd52 100644 --- a/backends/platform/n64/osys_n64_base.cpp +++ b/backends/platform/n64/osys_n64_base.cpp @@ -113,8 +113,8 @@ OSystem_N64::OSystem_N64() { // Clear palette array _screenPalette = (uint16*)memalign(8, 256 * sizeof(uint16)); #ifndef N64_EXTREME_MEMORY_SAVING - _screenExactPalette = (uint32*)memalign(8, 256 * sizeof(uint32)); - memset(_screenExactPalette, 0, 256 * sizeof(uint32)); + _screenExactPalette = (uint8*)memalign(8, 256 * 3); + memset(_screenExactPalette, 0, 256 * 3); #endif memset(_screenPalette, 0, 256 * sizeof(uint16)); memset(_cursorPalette, 0, 256 * sizeof(uint16)); @@ -350,12 +350,13 @@ int16 OSystem_N64::getWidth() { } void OSystem_N64::setPalette(const byte *colors, uint start, uint num) { - for (uint i = 0; i < num; ++i) { - _screenPalette[start + i] = colRGB888toBGR555(colors[2], colors[1], colors[0]); #ifndef N64_EXTREME_MEMORY_SAVING - _screenExactPalette[start + i] = *((uint32*)(colors)); + memcpy(_screenExactPalette + start * 3, colors, num * 3); #endif - colors += 4; + + for (uint i = 0; i < num; ++i) { + _screenPalette[start + i] = colRGB888toBGR555(colors[2], colors[1], colors[0]); + colors += 3; } // If cursor uses the game palette, we need to rebuild the hicolor buffer @@ -413,10 +414,9 @@ void OSystem_N64::grabPalette(byte *colors, uint start, uint num) { *colors++ = ((color & 0x1F) << 3); *colors++ = (((color >> 5) & 0x1F) << 3); *colors++ = (((color >> 10) & 0x1F) << 3); - *colors++ = 0; } #else - memcpy(colors, (uint8*)(_screenExactPalette + start), num * 4); + memcpy(colors, _screenExactPalette + start * 3, num * 3); #endif return; @@ -425,7 +425,7 @@ void OSystem_N64::grabPalette(byte *colors, uint start, uint num) { void OSystem_N64::setCursorPalette(const byte *colors, uint start, uint num) { for (uint i = 0; i < num; ++i) { _cursorPalette[start + i] = colRGB888toBGR555(colors[2], colors[1], colors[0]); - colors += 4; + colors += 3; } _cursorPaletteDisabled = false; diff --git a/backends/platform/ps2/Gs2dScreen.cpp b/backends/platform/ps2/Gs2dScreen.cpp index c6318e73d0..f869779573 100644 --- a/backends/platform/ps2/Gs2dScreen.cpp +++ b/backends/platform/ps2/Gs2dScreen.cpp @@ -408,25 +408,33 @@ void Gs2dScreen::unlockScreen() { SignalSema(g_DmacSema); } -void Gs2dScreen::setPalette(const uint32 *pal, uint8 start, uint16 num) { +void Gs2dScreen::setPalette(const uint8 *pal, uint8 start, uint16 num) { assert(start + num <= 256); WaitSema(g_DmacSema); for (uint16 cnt = 0; cnt < num; cnt++) { uint16 dest = start + cnt; dest = (dest & 0xE7) | ((dest & 0x8) << 1) | ((dest & 0x10) >> 1); // rearrange like the GS expects it - _clut[dest] = pal[cnt] & 0xFFFFFF; + + uint32 color = pal[0] | (pal[1] << 8) | (pal[2] << 16); + _clut[dest] = color; + pal += 3; } _clutChanged = true; SignalSema(g_DmacSema); } -void Gs2dScreen::grabPalette(uint32 *pal, uint8 start, uint16 num) { +void Gs2dScreen::grabPalette(uint8 *pal, uint8 start, uint16 num) { assert(start + num <= 256); for (uint16 cnt = 0; cnt < num; cnt++) { uint16 src = start + cnt; src = (src & 0xE7) | ((src & 0x8) << 1) | ((src & 0x10) >> 1); - pal[cnt] = _clut[src]; + + uint32 color = _clut[src]; + pal[0] = (color >> 0) & 0xFF; + pal[1] = (color >> 8) & 0xFF; + pal[2] = (color >> 16) & 0xFF; + pal += 3; } } diff --git a/backends/platform/ps2/Gs2dScreen.h b/backends/platform/ps2/Gs2dScreen.h index 81f47d5f4a..358e717cbe 100644 --- a/backends/platform/ps2/Gs2dScreen.h +++ b/backends/platform/ps2/Gs2dScreen.h @@ -65,9 +65,9 @@ public: void unlockScreen(); void copyScreenRect(const uint8 *buf, int pitch, int x, int y, int w, int h); - void setPalette(const uint32 *pal, uint8 start, uint16 num); + void setPalette(const uint8 *pal, uint8 start, uint16 num); void updateScreen(void); - void grabPalette(uint32 *pal, uint8 start, uint16 num); + void grabPalette(uint8 *pal, uint8 start, uint16 num); void grabScreen(Graphics::Surface *surf); //- overlay routines void copyOverlayRect(const uint16 *buf, uint16 pitch, uint16 x, uint16 y, uint16 w, uint16 h); diff --git a/backends/platform/ps2/systemps2.cpp b/backends/platform/ps2/systemps2.cpp index ab7839e18f..77de74eb5b 100644 --- a/backends/platform/ps2/systemps2.cpp +++ b/backends/platform/ps2/systemps2.cpp @@ -544,11 +544,11 @@ void OSystem_PS2::initSize(uint width, uint height, const Graphics::PixelFormat } void OSystem_PS2::setPalette(const byte *colors, uint start, uint num) { - _screen->setPalette((const uint32*)colors, (uint8)start, (uint16)num); + _screen->setPalette(colors, (uint8)start, (uint16)num); } void OSystem_PS2::grabPalette(byte *colors, uint start, uint num) { - _screen->grabPalette((uint32*)colors, (uint8)start, (uint16)num); + _screen->grabPalette(colors, (uint8)start, (uint16)num); } void OSystem_PS2::copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h) { diff --git a/backends/platform/psp/display_client.cpp b/backends/platform/psp/display_client.cpp index 82e2d17d10..76b4a28e4a 100644 --- a/backends/platform/psp/display_client.cpp +++ b/backends/platform/psp/display_client.cpp @@ -110,7 +110,7 @@ void Palette::setPartial(const byte *colors, uint32 start, uint32 num, bool supp for (uint32 i = 0; i < num; ++i) { byte alphaVal = supportsAlpha ? src[3] : 0xFF; *palette = (uint16)_pixelFormat.rgbaToColor(src[0], src[1], src[2], alphaVal); - src += 4; + src += 3; palette++; } } else if (_pixelFormat.bitsPerPixel == 32) { @@ -120,7 +120,7 @@ void Palette::setPartial(const byte *colors, uint32 start, uint32 num, bool supp for (uint32 i = 0; i < num; ++i) { byte alphaVal = supportsAlpha ? src[3] : 0xFF; *palette = _pixelFormat.rgbaToColor(src[0], src[1], src[2], alphaVal); - src += 4; + src += 3; palette++; } } @@ -214,7 +214,6 @@ void Palette::getPartial(byte *colors, uint start, uint num) { *colors++ = (byte)r; *colors++ = (byte)g; *colors++ = (byte)b; - *colors++ = (byte)a; palette++; } } else if (_pixelFormat.bitsPerPixel == 32) { @@ -227,7 +226,6 @@ void Palette::getPartial(byte *colors, uint start, uint num) { *colors++ = (byte)r; *colors++ = (byte)g; *colors++ = (byte)b; - *colors++ = (byte)a; palette++; } } diff --git a/backends/platform/wii/osystem_gfx.cpp b/backends/platform/wii/osystem_gfx.cpp index 4a925a60c9..cb9a8c72e9 100644 --- a/backends/platform/wii/osystem_gfx.cpp +++ b/backends/platform/wii/osystem_gfx.cpp @@ -326,19 +326,16 @@ void OSystem_Wii::setPalette(const byte *colors, uint start, uint num) { const byte *s = colors; u16 *d = _texGame.palette; - for (uint i = 0; i < num; ++i) { + for (uint i = 0; i < num; ++i, s +=3) d[start + i] = Graphics::RGBToColor<Graphics::ColorMasks<565> >(s[0], s[1], s[2]); - s += 4; - } gfx_tex_flush_palette(&_texGame); s = colors; d = _cursorPalette; - for (uint i = 0; i < num; ++i) { + for (uint i = 0; i < num; ++i, s += 3) { d[start + i] = Graphics::ARGBToColor<Graphics::ColorMasks<3444> >(0xff, s[0], s[1], s[2]); - s += 4; } if (_cursorPaletteDisabled) { @@ -360,13 +357,11 @@ void OSystem_Wii::grabPalette(byte *colors, uint start, uint num) { byte *d = colors; u8 r, g, b; - for (uint i = 0; i < num; ++i) { + for (uint i = 0; i < num; ++i, d += 3) { Graphics::colorToRGB<Graphics::ColorMasks<565> >(s[start + i], r, g, b); d[0] = r; d[1] = g; d[2] = b; - d[3] = 0xff; - d += 4; } } @@ -391,10 +386,8 @@ void OSystem_Wii::setCursorPalette(const byte *colors, uint start, uint num) { const byte *s = colors; u16 *d = _texMouse.palette; - for (uint i = 0; i < num; ++i) { + for (uint i = 0; i < num; ++i, s += 3) d[start + i] = Graphics::ARGBToColor<Graphics::ColorMasks<3444> >(0xff, s[0], s[1], s[2]); - s += 4; - } _cursorPaletteDirty = true; } diff --git a/common/macresman.cpp b/common/macresman.cpp index 9a50549a9d..4fd4e72ee3 100644 --- a/common/macresman.cpp +++ b/common/macresman.cpp @@ -638,23 +638,21 @@ void MacResManager::convertCrsrCursor(byte *data, int datasize, byte **cursor, i dis.readUint16BE(); // ctFlag ctSize = dis.readUint16BE() + 1; - *palette = (byte *)malloc(ctSize * 4); + *palette = (byte *)malloc(ctSize * 3); // Read just high byte of 16-bit color for (int c = 0; c < ctSize; c++) { // We just use indices 0..ctSize, so ignore color ID dis.readUint16BE(); // colorID[c] - palette[0][c * 4 + 0] = dis.readByte(); + palette[0][c * 3 + 0] = dis.readByte(); dis.readByte(); - palette[0][c * 4 + 1] = dis.readByte(); + palette[0][c * 3 + 1] = dis.readByte(); dis.readByte(); - palette[0][c * 4 + 2] = dis.readByte(); + palette[0][c * 3 + 2] = dis.readByte(); dis.readByte(); - - palette[0][c * 4 + 3] = 0; } *palSize = ctSize; diff --git a/engines/agi/graphics.cpp b/engines/agi/graphics.cpp index 7f8d99cc2f..b1198123ff 100644 --- a/engines/agi/graphics.cpp +++ b/engines/agi/graphics.cpp @@ -799,9 +799,8 @@ void GfxMgr::initPalette(const uint8 *p, uint colorCount, uint fromBits, uint to const uint destMax = (1 << toBits) - 1; for (uint col = 0; col < colorCount; col++) { for (uint comp = 0; comp < 3; comp++) { // Convert RGB components - _palette[col * 4 + comp] = (p[col * 3 + comp] * destMax) / srcMax; + _palette[col * 3 + comp] = (p[col * 3 + comp] * destMax) / srcMax; } - _palette[col * 4 + 3] = 0; // Set alpha to zero } } @@ -931,8 +930,8 @@ static const byte appleIIgsMouseCursor[] = { * RGBA-palette for the black and white SCI and Apple IIGS arrow cursors. */ static const byte sciMouseCursorPalette[] = { - 0x00, 0x00, 0x00, 0x00, // Black - 0xFF, 0xFF, 0xFF, 0x00 // White + 0x00, 0x00, 0x00, // Black + 0xFF, 0xFF, 0xFF // White }; /** @@ -961,9 +960,9 @@ static const byte amigaMouseCursor[] = { * and the Amiga-style busy cursor. */ static const byte amigaMouseCursorPalette[] = { - 0x00, 0x00, 0x00, 0x00, // Black - 0xDE, 0x20, 0x21, 0x00, // Red - 0xFF, 0xCF, 0xAD, 0x00 // Light red + 0x00, 0x00, 0x00, // Black + 0xDE, 0x20, 0x21, // Red + 0xFF, 0xCF, 0xAD // Light red }; /** @@ -994,17 +993,17 @@ static const byte busyAmigaMouseCursor[] = { void GfxMgr::setCursor(bool amigaStyleCursor, bool busy) { if (busy) { - CursorMan.replaceCursorPalette(amigaMouseCursorPalette, 1, ARRAYSIZE(amigaMouseCursorPalette) / 4); + CursorMan.replaceCursorPalette(amigaMouseCursorPalette, 1, ARRAYSIZE(amigaMouseCursorPalette) / 3); CursorMan.replaceCursor(busyAmigaMouseCursor, 13, 16, 7, 8, 0); return; } if (!amigaStyleCursor) { - CursorMan.replaceCursorPalette(sciMouseCursorPalette, 1, ARRAYSIZE(sciMouseCursorPalette) / 4); + CursorMan.replaceCursorPalette(sciMouseCursorPalette, 1, ARRAYSIZE(sciMouseCursorPalette) / 3); CursorMan.replaceCursor(sciMouseCursor, 11, 16, 1, 1, 0); } else { // amigaStyleCursor - CursorMan.replaceCursorPalette(amigaMouseCursorPalette, 1, ARRAYSIZE(amigaMouseCursorPalette) / 4); + CursorMan.replaceCursorPalette(amigaMouseCursorPalette, 1, ARRAYSIZE(amigaMouseCursorPalette) / 3); CursorMan.replaceCursor(amigaMouseCursor, 8, 11, 1, 1, 0); } } @@ -1012,12 +1011,12 @@ void GfxMgr::setCursor(bool amigaStyleCursor, bool busy) { void GfxMgr::setCursorPalette(bool amigaStyleCursor) { if (!amigaStyleCursor) { if (_currentCursorPalette != 1) { - CursorMan.replaceCursorPalette(sciMouseCursorPalette, 1, ARRAYSIZE(sciMouseCursorPalette) / 4); + CursorMan.replaceCursorPalette(sciMouseCursorPalette, 1, ARRAYSIZE(sciMouseCursorPalette) / 3); _currentCursorPalette = 1; } } else { // amigaStyleCursor if (_currentCursorPalette != 2) { - CursorMan.replaceCursorPalette(amigaMouseCursorPalette, 1, ARRAYSIZE(amigaMouseCursorPalette) / 4); + CursorMan.replaceCursorPalette(amigaMouseCursorPalette, 1, ARRAYSIZE(amigaMouseCursorPalette) / 3); _currentCursorPalette = 2; } } diff --git a/engines/agi/graphics.h b/engines/agi/graphics.h index 18f323d596..60fbea2285 100644 --- a/engines/agi/graphics.h +++ b/engines/agi/graphics.h @@ -41,7 +41,7 @@ class GfxMgr { private: AgiBase *_vm; - uint8 _palette[256 * 4]; + uint8 _palette[256 * 3]; uint8 *_agiScreen; unsigned char *_screen; diff --git a/engines/agos/agos.h b/engines/agos/agos.h index a2962cd827..7201dfd9d3 100644 --- a/engines/agos/agos.h +++ b/engines/agos/agos.h @@ -529,8 +529,8 @@ protected: uint16 _PVCount1; uint16 _GPVCount1; - uint8 _currentPalette[1024]; - uint8 _displayPalette[1024]; + uint8 _currentPalette[768]; + uint8 _displayPalette[768]; byte *_planarBuf; byte _videoBuf1[32000]; diff --git a/engines/agos/animation.cpp b/engines/agos/animation.cpp index 4c01f6b826..d39ca377dc 100644 --- a/engines/agos/animation.cpp +++ b/engines/agos/animation.cpp @@ -87,7 +87,7 @@ void MoviePlayer::play() { if (_vm->getBitFlag(41)) { _vm->fillBackFromFront(); } else { - uint8 palette[1024]; + uint8 palette[768]; memset(palette, 0, sizeof(palette)); _vm->clearSurfaces(); _vm->_system->getPaletteManager()->setPalette(palette, 0, 256); diff --git a/engines/agos/cursor.cpp b/engines/agos/cursor.cpp index 5ff2f014a6..cf42fe1f36 100644 --- a/engines/agos/cursor.cpp +++ b/engines/agos/cursor.cpp @@ -781,8 +781,8 @@ void AGOSEngine_Simon1::initMouse() { } static const byte mouseCursorPalette[] = { - 0x00, 0x00, 0x00, 0x00, // Black - 0xFF, 0xFF, 0xFF, 0x00, // White + 0x00, 0x00, 0x00, // Black + 0xFF, 0xFF, 0xFF // White }; void AGOSEngine::initMouse() { @@ -792,7 +792,7 @@ void AGOSEngine::initMouse() { memset(_mouseData, 0xFF, _maxCursorWidth * _maxCursorHeight); - CursorMan.replaceCursorPalette(mouseCursorPalette, 0, ARRAYSIZE(mouseCursorPalette) / 4); + CursorMan.replaceCursorPalette(mouseCursorPalette, 0, ARRAYSIZE(mouseCursorPalette) / 3); } void AGOSEngine::drawMousePointer() { diff --git a/engines/agos/debug.cpp b/engines/agos/debug.cpp index cb11d65218..d0dc8cc42e 100644 --- a/engines/agos/debug.cpp +++ b/engines/agos/debug.cpp @@ -436,7 +436,7 @@ static const byte bmp_hdr[] = { 0x00, 0x01, 0x00, 0x00, }; -void dumpBMP(const char *filename, int16 w, int16 h, const byte *bytes, const uint32 *palette) { +void dumpBMP(const char *filename, int16 w, int16 h, const byte *bytes, const byte *palette) { Common::DumpFile out; byte my_hdr[sizeof(bmp_hdr)]; int i; @@ -454,11 +454,11 @@ void dumpBMP(const char *filename, int16 w, int16 h, const byte *bytes, const ui out.write(my_hdr, sizeof(my_hdr)); - for (i = 0; i != 256; i++, palette++) { + for (i = 0; i != 256; i++, palette += 3) { byte color[4]; - color[0] = (byte)(*palette >> 16); - color[1] = (byte)(*palette >> 8); - color[2] = (byte)(*palette); + color[0] = palette[2]; + color[1] = palette[1]; + color[2] = palette[0]; color[3] = 0; out.write(color, 4); } @@ -565,7 +565,7 @@ void AGOSEngine::dumpBitmap(const char *filename, const byte *offs, uint16 w, ui } } - dumpBMP(filename, w, h, imageBuffer, (const uint32 *)palette); + dumpBMP(filename, w, h, imageBuffer, palette); free(imageBuffer); } @@ -594,7 +594,7 @@ void AGOSEngine::palLoad(byte *pal, const byte *vga1, int a, int b) { } if (getGameType() == GType_PN && (getFeatures() & GF_EGA)) { - memcpy(palptr, _displayPalette, 64); + memcpy(palptr, _displayPalette, 3 * 16); } else if (getGameType() == GType_PN || getGameType() == GType_ELVIRA1 || getGameType() == GType_ELVIRA2 || getGameType() == GType_WW) { src = vga1 + READ_BE_UINT16(vga1 + 6) + b * 32; @@ -603,9 +603,8 @@ void AGOSEngine::palLoad(byte *pal, const byte *vga1, int a, int b) { palptr[0] = ((color & 0xf00) >> 8) * 32; palptr[1] = ((color & 0x0f0) >> 4) * 32; palptr[2] = ((color & 0x00f) >> 0) * 32; - palptr[3] = 0; - palptr += 4; + palptr += 3; src += 2; } while (--num); } else { @@ -615,9 +614,8 @@ void AGOSEngine::palLoad(byte *pal, const byte *vga1, int a, int b) { palptr[0] = src[0] << 2; palptr[1] = src[1] << 2; palptr[2] = src[2] << 2; - palptr[3] = 0; - palptr += 4; + palptr += 3; src += 3; } while (--num); } @@ -627,7 +625,7 @@ void AGOSEngine::dumpVgaBitmaps(uint16 zoneNum) { uint16 width, height, flags; uint32 offs, curOffs = 0; const byte *p2; - byte pal[1024]; + byte pal[768]; uint16 zone = (getGameType() == GType_PN) ? 0 : zoneNum; VgaPointersEntry *vpe = &_vgaBufferPointers[zone]; diff --git a/engines/agos/draw.cpp b/engines/agos/draw.cpp index 37abe9324c..317c68d31a 100644 --- a/engines/agos/draw.cpp +++ b/engines/agos/draw.cpp @@ -779,8 +779,8 @@ void AGOSEngine::setMoveRect(uint16 x, uint16 y, uint16 width, uint16 height) { void AGOSEngine::displayScreen() { if (_fastFadeInFlag == 0 && _paletteFlag == 1) { _paletteFlag = 0; - if (memcmp(_displayPalette, _currentPalette, 1024)) { - memcpy(_currentPalette, _displayPalette, 1024); + if (memcmp(_displayPalette, _currentPalette, sizeof(_currentPalette))) { + memcpy(_currentPalette, _displayPalette, sizeof(_displayPalette)); _system->getPaletteManager()->setPalette(_displayPalette, 0, 256); } } @@ -860,7 +860,7 @@ void AGOSEngine::fastFadeIn() { slowFadeIn(); } else { _paletteFlag = false; - memcpy(_currentPalette, _displayPalette, 1024); + memcpy(_currentPalette, _displayPalette, sizeof(_displayPalette)); _system->getPaletteManager()->setPalette(_displayPalette, 0, _fastFadeInFlag); _fastFadeInFlag = 0; } @@ -879,15 +879,15 @@ void AGOSEngine::slowFadeIn() { src = _displayPalette; dst = _currentPalette; - for (p = _fastFadeInFlag; p !=0; p -= 3) { + for (p = _fastFadeInFlag; p != 0; p -= 3) { if (src[0] >= c) dst[0] += 4; if (src[1] >= c) dst[1] += 4; if (src[2] >= c) dst[2] += 4; - src += 4; - dst += 4; + src += 3; + dst += 3; } _system->getPaletteManager()->setPalette(_currentPalette, 0, _fastFadeCount); delay(5); diff --git a/engines/agos/gfx.cpp b/engines/agos/gfx.cpp index b784e4fcb3..710c9ddd7e 100644 --- a/engines/agos/gfx.cpp +++ b/engines/agos/gfx.cpp @@ -1041,7 +1041,7 @@ void AGOSEngine::paletteFadeOut(byte *palPtr, uint num, uint size) { p[2] -= size; else p[2] = 0; - p += 4; + p += 3; } while (--num); } diff --git a/engines/agos/pn.cpp b/engines/agos/pn.cpp index 7471b73d16..62d65de219 100644 --- a/engines/agos/pn.cpp +++ b/engines/agos/pn.cpp @@ -128,12 +128,7 @@ Common::Error AGOSEngine_PN::go() { if (getFeatures() & GF_EGA) { // Set EGA Palette - for (int i = 0; i < 16; i++) { - _displayPalette[i * 4 + 0] = egaPalette[i * 3 + 0]; - _displayPalette[i * 4 + 1] = egaPalette[i * 3 + 1]; - _displayPalette[i * 4 + 2] = egaPalette[i * 3 + 2]; - _displayPalette[i * 4 + 3] = 0; - } + memcpy(_displayPalette, egaPalette, sizeof(egaPalette)); _paletteFlag = 1; } diff --git a/engines/agos/script_ff.cpp b/engines/agos/script_ff.cpp index 5d640af6ad..3198b1b499 100644 --- a/engines/agos/script_ff.cpp +++ b/engines/agos/script_ff.cpp @@ -640,7 +640,7 @@ void AGOSEngine_Feeble::off_restartClock() { void AGOSEngine_Feeble::off_setColor() { // 195: set palette color - uint16 c = getVarOrByte() * 4; + uint16 c = getVarOrByte() * 3; uint8 r = getVarOrByte(); uint8 g = getVarOrByte(); uint8 b = getVarOrByte(); diff --git a/engines/agos/script_s1.cpp b/engines/agos/script_s1.cpp index 9dd1e3c5ab..05a725cb50 100644 --- a/engines/agos/script_s1.cpp +++ b/engines/agos/script_s1.cpp @@ -578,13 +578,13 @@ void AGOSEngine_Simon1::os1_specialFade() { for (i = 32; i != 0; --i) { paletteFadeOut(_currentPalette, 32, 8); - paletteFadeOut(_currentPalette + 4 * 48, 144, 8); - paletteFadeOut(_currentPalette + 4 * 208, 48, 8); + paletteFadeOut(_currentPalette + 3 * 48, 144, 8); + paletteFadeOut(_currentPalette + 3 * 208, 48, 8); _system->getPaletteManager()->setPalette(_currentPalette, 0, 256); delay(5); } - memcpy(_displayPalette, _currentPalette, 1024); + memcpy(_displayPalette, _currentPalette, sizeof(_currentPalette)); } void AGOSEngine::scriptMouseOff() { diff --git a/engines/agos/vga.cpp b/engines/agos/vga.cpp index 8b8b16c9bb..83ee05036c 100644 --- a/engines/agos/vga.cpp +++ b/engines/agos/vga.cpp @@ -935,8 +935,8 @@ void AGOSEngine::vc22_setPalette() { if (getGameType() == GType_PN) { if (b > 128) { - b-= 128; - palptr = _displayPalette + 64; + b -= 128; + palptr = _displayPalette + 3 * 16; } } else if (getGameType() == GType_ELVIRA1) { if (b >= 1000) { @@ -956,24 +956,22 @@ void AGOSEngine::vc22_setPalette() { num = 13; for (int i = 0; i < 19; i++) { - palptr[(13 + i) * 4 + 0] = extraColors[i * 3 + 0] * 4; - palptr[(13 + i) * 4 + 1] = extraColors[i * 3 + 1] * 4; - palptr[(13 + i) * 4 + 2] = extraColors[i * 3 + 2] * 4; - palptr[(13 + i) * 4 + 3] = 0; + palptr[(13 + i) * 3 + 0] = extraColors[i * 3 + 0] * 4; + palptr[(13 + i) * 3 + 1] = extraColors[i * 3 + 1] * 4; + palptr[(13 + i) * 3 + 2] = extraColors[i * 3 + 2] * 4; } } } if (getGameType() == GType_ELVIRA2 && getPlatform() == Common::kPlatformAtariST) { // Custom palette used for icon area - palptr = &_displayPalette[13 * 64]; + palptr = &_displayPalette[13 * 3 * 16]; for (uint8 c = 0; c < 16; c++) { palptr[0] = iconPalette[c * 3 + 0] * 2; palptr[1] = iconPalette[c * 3 + 1] * 2; palptr[2] = iconPalette[c * 3 + 2] * 2; - palptr[3] = 0; - palptr += 4; + palptr += 3; }; palptr = _displayPalette; } @@ -986,9 +984,8 @@ void AGOSEngine::vc22_setPalette() { palptr[0] = ((color & 0xf00) >> 8) * 32; palptr[1] = ((color & 0x0f0) >> 4) * 32; palptr[2] = ((color & 0x00f) >> 0) * 32; - palptr[3] = 0; - palptr += 4; + palptr += 3; src += 2; } while (--num); @@ -1212,10 +1209,9 @@ void AGOSEngine::vc33_setMouseOn() { _mouseHideCount = 1; if (getGameType() == GType_ELVIRA2 || getGameType() == GType_WW) { // Set mouse palette - _displayPalette[65 * 4 + 0] = 48 * 4; - _displayPalette[65 * 4 + 1] = 48 * 4; - _displayPalette[65 * 4 + 2] = 40 * 4; - _displayPalette[65 * 4 + 3] = 0; + _displayPalette[65 * 3 + 0] = 48 * 4; + _displayPalette[65 * 3 + 1] = 48 * 4; + _displayPalette[65 * 3 + 2] = 40 * 4; _paletteFlag = 1; } mouseOn(); @@ -1313,11 +1309,10 @@ void AGOSEngine::vc37_pokePalette() { if (getGameType() == GType_PN && (getFeatures() & GF_EGA)) return; - byte *palptr = _displayPalette + offs * 4; + byte *palptr = _displayPalette + offs * 3; palptr[0] = ((color & 0xf00) >> 8) * 32; palptr[1] = ((color & 0x0f0) >> 4) * 32; palptr[2] = ((color & 0x00f) >> 0) * 32; - palptr[3] = 0; if (!(_videoLockOut & 0x20)) { _paletteFlag = 1; diff --git a/engines/agos/vga_e2.cpp b/engines/agos/vga_e2.cpp index a01e79ff99..b0431db801 100644 --- a/engines/agos/vga_e2.cpp +++ b/engines/agos/vga_e2.cpp @@ -115,7 +115,7 @@ void AGOSEngine::setPaletteSlot(uint16 srcOffs, uint8 dstOffs) { byte *offs, *palptr, *src; uint16 num; - palptr = _displayPalette + dstOffs * 64; + palptr = _displayPalette + dstOffs * 3 * 16; offs = _curVgaFile1 + READ_BE_UINT16(_curVgaFile1 + 6); src = offs + srcOffs * 32; num = 16; @@ -125,9 +125,8 @@ void AGOSEngine::setPaletteSlot(uint16 srcOffs, uint8 dstOffs) { palptr[0] = ((color & 0xf00) >> 8) * 32; palptr[1] = ((color & 0x0f0) >> 4) * 32; palptr[2] = ((color & 0x00f) >> 0) * 32; - palptr[3] = 0; - palptr += 4; + palptr += 3; src += 2; } while (--num); @@ -371,7 +370,7 @@ void AGOSEngine::fullFade() { if (dstPal[2] != b) dstPal[2] += 4; srcPal += 3; - dstPal += 4; + dstPal += 3; } _system->getPaletteManager()->setPalette(_currentPalette, 0, 256); delay(5); diff --git a/engines/agos/vga_s1.cpp b/engines/agos/vga_s1.cpp index bb13d211fe..a2306d3cdb 100644 --- a/engines/agos/vga_s1.cpp +++ b/engines/agos/vga_s1.cpp @@ -112,7 +112,7 @@ void AGOSEngine_Simon1::vc22_setPalette() { num = a == 0 ? 32 : 16; palSize = 96; - palptr = &_displayPalette[(a * 64)]; + palptr = &_displayPalette[(a * 3 * 16)]; } offs = _curVgaFile1 + 6; @@ -122,22 +122,20 @@ void AGOSEngine_Simon1::vc22_setPalette() { palptr[0] = src[0] * 4; palptr[1] = src[1] * 4; palptr[2] = src[2] * 4; - palptr[3] = 0; - palptr += 4; + palptr += 3; src += 3; } while (--num); if (getFeatures() & GF_32COLOR) { // Custom palette used for verb area - palptr = &_displayPalette[(13 * 64)]; + palptr = &_displayPalette[(13 * 3 * 16)]; for (uint8 c = 0; c < 32; c++) { palptr[0] = customPalette[c * 3 + 0]; palptr[1] = customPalette[c * 3 + 1]; palptr[2] = customPalette[c * 3 + 2]; - palptr[3] = 0; - palptr += 4; + palptr += 3; }; } diff --git a/engines/agos/window.cpp b/engines/agos/window.cpp index 54e7928f38..a03c7e178a 100644 --- a/engines/agos/window.cpp +++ b/engines/agos/window.cpp @@ -151,13 +151,13 @@ void AGOSEngine::colorWindow(WindowBlock *window) { if (getGameType() == GType_ELVIRA2 && window->y == 146) { if (window->fillColor == 1) { - _displayPalette[33 * 4 + 0] = 48 * 4; - _displayPalette[33 * 4 + 1] = 40 * 4; - _displayPalette[33 * 4 + 2] = 32 * 4; + _displayPalette[33 * 3 + 0] = 48 * 4; + _displayPalette[33 * 3 + 1] = 40 * 4; + _displayPalette[33 * 3 + 2] = 32 * 4; } else { - _displayPalette[33 * 4 + 0] = 56 * 4; - _displayPalette[33 * 4 + 1] = 56 * 4; - _displayPalette[33 * 4 + 2] = 40 * 4; + _displayPalette[33 * 3 + 0] = 56 * 4; + _displayPalette[33 * 3 + 1] = 56 * 4; + _displayPalette[33 * 3 + 2] = 40 * 4; } y--; diff --git a/engines/cine/pal.cpp b/engines/cine/pal.cpp index a074bd3f09..3c8ffc295b 100644 --- a/engines/cine/pal.cpp +++ b/engines/cine/pal.cpp @@ -185,16 +185,16 @@ const Graphics::PixelFormat &Palette::colorFormat() const { } void Palette::setGlobalOSystemPalette() const { - byte buf[256 * 4]; // Allocate space for the largest possible palette + byte buf[256 * 3]; // Allocate space for the largest possible palette // The color format used by OSystem's setPalette-function: - save(buf, sizeof(buf), Graphics::PixelFormat(4, 8, 8, 8, 0, 0, 8, 16, 0), CINE_LITTLE_ENDIAN); + save(buf, sizeof(buf), Graphics::PixelFormat(3, 8, 8, 8, 0, 0, 8, 16, 0), CINE_LITTLE_ENDIAN); if (g_cine->getPlatform() == Common::kPlatformAmiga && colorCount() == 16) { // The Amiga version of Future Wars does use the upper 16 colors for a darkened // game palette to allow transparent dialog boxes. To support that in our code // we do calculate that palette over here and append it to the screen palette. - for (uint i = 0; i < 16 * 4; ++i) - buf[16 * 4 + i] = buf[i] >> 1; + for (uint i = 0; i < 16 * 3; ++i) + buf[16 * 3 + i] = buf[i] >> 1; g_system->getPaletteManager()->setPalette(buf, 0, colorCount() * 2); } else { diff --git a/engines/cruise/gfxModule.cpp b/engines/cruise/gfxModule.cpp index 00e44465f8..59561de8dc 100644 --- a/engines/cruise/gfxModule.cpp +++ b/engines/cruise/gfxModule.cpp @@ -273,16 +273,15 @@ static void mergeClipRects() { } void gfxModuleData_updatePalette() { - byte paletteRGBA[256 * 4]; + byte paletteRGBA[256 * 3]; if (palDirtyMax != -1) { for (int i = palDirtyMin; i <= palDirtyMax; i++) { - paletteRGBA[i * 4 + 0] = lpalette[i].R; - paletteRGBA[i * 4 + 1] = lpalette[i].G; - paletteRGBA[i * 4 + 2] = lpalette[i].B; - paletteRGBA[i * 4 + 3] = 0xFF; + paletteRGBA[i * 3 + 0] = lpalette[i].R; + paletteRGBA[i * 3 + 1] = lpalette[i].G; + paletteRGBA[i * 3 + 2] = lpalette[i].B; } - g_system->getPaletteManager()->setPalette(paletteRGBA + palDirtyMin*4, palDirtyMin, palDirtyMax - palDirtyMin + 1); + g_system->getPaletteManager()->setPalette(paletteRGBA + palDirtyMin*3, palDirtyMin, palDirtyMax - palDirtyMin + 1); palDirtyMin = 256; palDirtyMax = -1; } diff --git a/engines/cruise/mouse.cpp b/engines/cruise/mouse.cpp index 521ba3a54e..24309030da 100644 --- a/engines/cruise/mouse.cpp +++ b/engines/cruise/mouse.cpp @@ -52,8 +52,8 @@ static const MouseCursor mouseCursors[] = { CursorType currentCursor = CURSOR_NOMOUSE; static const byte cursorPalette[] = { - 0, 0, 0, 0xff, - 0xff, 0xff, 0xff, 0xff + 0, 0, 0, + 0xff, 0xff, 0xff }; void changeCursor(CursorType eType) { diff --git a/engines/draci/screen.cpp b/engines/draci/screen.cpp index bb7a093d8f..dbe3fd98b8 100644 --- a/engines/draci/screen.cpp +++ b/engines/draci/screen.cpp @@ -36,7 +36,7 @@ namespace Draci { Screen::Screen(DraciEngine *vm) : _vm(vm) { _surface = new Surface(kScreenWidth, kScreenHeight); - _palette = new byte[4 * kNumColours]; + _palette = new byte[3 * kNumColours]; _blackPalette = new byte[3 * kNumColours]; for (int i = 0; i < 3 * kNumColours; ++i) { _blackPalette[i] = 0; @@ -63,15 +63,14 @@ void Screen::setPalette(const byte *data, uint16 start, uint16 num) { // Copy the palette for (uint16 i = start; i < start + num; ++i) { - _palette[i * 4] = pal.readByte(); - _palette[i * 4 + 1] = pal.readByte(); - _palette[i * 4 + 2] = pal.readByte(); - _palette[i * 4 + 3] = 0; + _palette[i * 3] = pal.readByte(); + _palette[i * 3 + 1] = pal.readByte(); + _palette[i * 3 + 2] = pal.readByte(); } // Shift the palette two bits to the left to make it brighter. The // original game only uses 6-bit colors 0..63. - for (int i = start * 4; i < (start + num) * 4; ++i) { + for (int i = start * 3; i < (start + num) * 3; ++i) { _palette[i] <<= 2; } @@ -86,14 +85,13 @@ void Screen::interpolatePalettes(const byte *first, const byte *second, uint16 s // Interpolate the palettes for (uint16 i = start; i < start + num; ++i) { - _palette[i * 4] = interpolate(firstPal.readByte(), secondPal.readByte(), index, number); - _palette[i * 4 + 1] = interpolate(firstPal.readByte(), secondPal.readByte(), index, number); - _palette[i * 4 + 2] = interpolate(firstPal.readByte(), secondPal.readByte(), index, number); - _palette[i * 4 + 3] = 0; + _palette[i * 3] = interpolate(firstPal.readByte(), secondPal.readByte(), index, number); + _palette[i * 3 + 1] = interpolate(firstPal.readByte(), secondPal.readByte(), index, number); + _palette[i * 3 + 2] = interpolate(firstPal.readByte(), secondPal.readByte(), index, number); } // Shift the palette two bits to the left to make it brighter - for (int i = start * 4; i < (start + num) * 4; ++i) { + for (int i = start * 3; i < (start + num) * 3; ++i) { _palette[i] <<= 2; } diff --git a/engines/drascula/palette.cpp b/engines/drascula/palette.cpp index 67597efd0c..b521c0313b 100644 --- a/engines/drascula/palette.cpp +++ b/engines/drascula/palette.cpp @@ -65,15 +65,12 @@ void DrasculaEngine::black() { } void DrasculaEngine::setPalette(byte *PalBuf) { - byte pal[256 * 4]; - int i; - - for (i = 0; i < 256; i++) { - pal[i * 4 + 0] = PalBuf[i * 3 + 0] * 4; - pal[i * 4 + 1] = PalBuf[i * 3 + 1] * 4; - pal[i * 4 + 2] = PalBuf[i * 3 + 2] * 4; - pal[i * 4 + 3] = 0; + byte pal[256 * 3]; + + for (int i = 0; i < 3 * 256; ++i) { + pal[i] = PalBuf[i] * 4; } + _system->getPaletteManager()->setPalette(pal, 0, 256); _system->updateScreen(); } diff --git a/engines/gob/util.cpp b/engines/gob/util.cpp index f0b475f65b..4d51b3d61f 100644 --- a/engines/gob/util.cpp +++ b/engines/gob/util.cpp @@ -318,13 +318,13 @@ void Util::forceMouseUp(bool onlyWhenSynced) { void Util::clearPalette() { int16 i; - byte colors[1024]; + byte colors[768]; _vm->validateVideoMode(_vm->_global->_videoMode); if (_vm->_global->_setAllPalette) { if (_vm->getPixelFormat().bytesPerPixel == 1) { - memset(colors, 0, 1024); + memset(colors, 0, sizeof(colors)); g_system->getPaletteManager()->setPalette(colors, 0, 256); } diff --git a/engines/gob/video.cpp b/engines/gob/video.cpp index 4a32489138..444ff8ed9e 100644 --- a/engines/gob/video.cpp +++ b/engines/gob/video.cpp @@ -345,7 +345,7 @@ void Video::drawPackedSprite(const char *path, Surface &dest, int width) { void Video::setPalElem(int16 index, char red, char green, char blue, int16 unused, int16 vidMode) { - byte pal[4]; + byte pal[3]; _vm->validateVideoMode(vidMode); @@ -359,14 +359,14 @@ void Video::setPalElem(int16 index, char red, char green, char blue, } void Video::setPalette(PalDesc *palDesc) { - byte pal[1024]; + byte pal[768]; int16 numcolors; _vm->validateVideoMode(_vm->_global->_videoMode); numcolors = _vm->_global->_setAllPalette ? 256 : 16; for (int i = 0; i < numcolors; i++) - setPalColor(pal + i * 4, palDesc->vgaPal[i]); + setPalColor(pal + i * 3, palDesc->vgaPal[i]); if (_vm->getPixelFormat().bytesPerPixel == 1) g_system->getPaletteManager()->setPalette(pal, 0, numcolors); @@ -374,14 +374,14 @@ void Video::setPalette(PalDesc *palDesc) { void Video::setFullPalette(PalDesc *palDesc) { if (_vm->_global->_setAllPalette) { - byte pal[1024]; + byte pal[768]; Color *colors = palDesc->vgaPal; for (int i = 0; i < 256; i++) { _vm->_global->_redPalette[i] = colors[i].red; _vm->_global->_greenPalette[i] = colors[i].green; _vm->_global->_bluePalette[i] = colors[i].blue; - setPalColor(pal + i * 4, colors[i]); + setPalColor(pal + i * 3, colors[i]); } if (_vm->getPixelFormat().bytesPerPixel == 1) diff --git a/engines/gob/video.h b/engines/gob/video.h index 8828b666b3..69cdfe49ed 100644 --- a/engines/gob/video.h +++ b/engines/gob/video.h @@ -125,7 +125,6 @@ public: pal[0] = red << 2; pal[1] = green << 2; pal[2] = blue << 2; - pal[3] = 0; } void setPalColor(byte *pal, Color &color) { setPalColor(pal, color.red, color.green, color.blue); diff --git a/engines/groovie/cursor.cpp b/engines/groovie/cursor.cpp index 2d0a2df245..6a87af8daf 100644 --- a/engines/groovie/cursor.cpp +++ b/engines/groovie/cursor.cpp @@ -226,13 +226,8 @@ byte *GrvCursorMan_t7g::loadImage(Common::SeekableReadStream &file) { } byte *GrvCursorMan_t7g::loadPalette(Common::SeekableReadStream &file) { - byte *palette = new byte[4 * 32]; - for (uint8 colournum = 0; colournum < 32; colournum++) { - palette[colournum * 4 + 0] = file.readByte(); - palette[colournum * 4 + 1] = file.readByte(); - palette[colournum * 4 + 2] = file.readByte(); - palette[colournum * 4 + 3] = 0; - } + byte *palette = new byte[3 * 32]; + file.read(palette, 3 * 32); return palette; } diff --git a/engines/groovie/debug.cpp b/engines/groovie/debug.cpp index 92afbb0115..bd4b671e11 100644 --- a/engines/groovie/debug.cpp +++ b/engines/groovie/debug.cpp @@ -137,11 +137,11 @@ bool Debugger::cmd_playref(int argc, const char **argv) { bool Debugger::cmd_dumppal(int argc, const char **argv) { uint16 i; - byte palettedump[256 * 4]; + byte palettedump[256 * 3]; _vm->_system->getPaletteManager()->grabPalette(palettedump, 0, 256); for (i = 0; i < 256; i++) { - DebugPrintf("%3d: %3d,%3d,%3d,%3d\n", i, palettedump[(i * 4)], palettedump[(i * 4) + 1], palettedump[(i * 4) + 2], palettedump[(i * 4) + 3]); + DebugPrintf("%3d: %3d,%3d,%3d\n", i, palettedump[(i * 3)], palettedump[(i * 3) + 1], palettedump[(i * 3) + 2]); } return true; } diff --git a/engines/groovie/graphics.cpp b/engines/groovie/graphics.cpp index 9d6da81fb6..3ceeeb6018 100644 --- a/engines/groovie/graphics.cpp +++ b/engines/groovie/graphics.cpp @@ -106,11 +106,7 @@ void GraphicsMan::fadeIn(byte *pal) { _fadeStartTime = _vm->_system->getMillis(); // Copy the target palette - for (int i = 0; i < 256; i++) { - _paletteFull[(i * 4) + 0] = pal[(i * 3) + 0]; - _paletteFull[(i * 4) + 1] = pal[(i * 3) + 1]; - _paletteFull[(i * 4) + 2] = pal[(i * 3) + 2]; - } + memcpy(_paletteFull, pal, 3 * 256); // Set the current fading _fading = 1; @@ -151,11 +147,11 @@ void GraphicsMan::applyFading(int step) { } // Calculate the new palette - byte newpal[256 * 4]; + byte newpal[256 * 3]; for (int i = 0; i < 256; i++) { - newpal[(i * 4) + 0] = (_paletteFull[(i * 4) + 0] * factorR) / 256; - newpal[(i * 4) + 1] = (_paletteFull[(i * 4) + 1] * factorG) / 256; - newpal[(i * 4) + 2] = (_paletteFull[(i * 4) + 2] * factorB) / 256; + newpal[(i * 3) + 0] = (_paletteFull[(i * 3) + 0] * factorR) / 256; + newpal[(i * 3) + 1] = (_paletteFull[(i * 3) + 1] * factorG) / 256; + newpal[(i * 3) + 2] = (_paletteFull[(i * 3) + 2] * factorB) / 256; } // Set the screen palette diff --git a/engines/groovie/graphics.h b/engines/groovie/graphics.h index c9bade9538..a405822c9c 100644 --- a/engines/groovie/graphics.h +++ b/engines/groovie/graphics.h @@ -58,7 +58,7 @@ private: // Palette fading void applyFading(int step); int _fading; - byte _paletteFull[256 * 4]; + byte _paletteFull[256 * 3]; uint32 _fadeStartTime; }; diff --git a/engines/groovie/roq.cpp b/engines/groovie/roq.cpp index 540465050d..4d7157c797 100644 --- a/engines/groovie/roq.cpp +++ b/engines/groovie/roq.cpp @@ -53,46 +53,37 @@ ROQPlayer::ROQPlayer(GroovieEngine *vm) : _prevBuf = new Graphics::Surface(); if (_vm->_mode8bit) { - byte pal[256 * 4]; + byte pal[256 * 3]; #ifdef DITHER - byte pal3[256 * 3]; // Initialize to a black palette - for (int i = 0; i < 256 * 3; i++) { - pal3[i] = 0; - } + memset(pal, 0, 256 * 3); // Build a basic color palette for (int r = 0; r < 4; r++) { for (int g = 0; g < 4; g++) { for (int b = 0; b < 4; b++) { byte col = (r << 4) | (g << 2) | (b << 0); - pal3[3 * col + 0] = r << 6; - pal3[3 * col + 1] = g << 6; - pal3[3 * col + 2] = b << 6; + pal[3 * col + 0] = r << 6; + pal[3 * col + 1] = g << 6; + pal[3 * col + 2] = b << 6; } } } // Initialize the dithering algorithm _paletteLookup = new Graphics::PaletteLUT(8, Graphics::PaletteLUT::kPaletteYUV); - _paletteLookup->setPalette(pal3, Graphics::PaletteLUT::kPaletteRGB, 8); + _paletteLookup->setPalette(pal, Graphics::PaletteLUT::kPaletteRGB, 8); for (int i = 0; (i < 64) && !_vm->shouldQuit(); i++) { debug("Groovie::ROQ: Building palette table: %02d/63", i); _paletteLookup->buildNext(); } - // Prepare the palette to show - for (int i = 0; i < 256; i++) { - pal[(i * 4) + 0] = pal3[(i * 3) + 0]; - pal[(i * 4) + 1] = pal3[(i * 3) + 1]; - pal[(i * 4) + 2] = pal3[(i * 3) + 2]; - } #else // !DITHER // Set a grayscale palette for (int i = 0; i < 256; i++) { - pal[(i * 4) + 0] = i; - pal[(i * 4) + 1] = i; - pal[(i * 4) + 2] = i; + pal[(i * 3) + 0] = i; + pal[(i * 3) + 1] = i; + pal[(i * 3) + 2] = i; } #endif // DITHER diff --git a/engines/groovie/vdx.cpp b/engines/groovie/vdx.cpp index 10177dad34..1b4a2b7800 100644 --- a/engines/groovie/vdx.cpp +++ b/engines/groovie/vdx.cpp @@ -555,15 +555,8 @@ void VDXPlayer::setPalette(uint8 *palette) { if (_flagSkipPalette) return; - uint8 palBuf[4 * 256]; debugC(7, kGroovieDebugVideo | kGroovieDebugAll, "Groovie::VDX: Setting palette"); - for (int i = 0; i < 256; i++) { - palBuf[(i * 4) + 0] = palette[(i * 3) + 0]; - palBuf[(i * 4) + 1] = palette[(i * 3) + 1]; - palBuf[(i * 4) + 2] = palette[(i * 3) + 2]; - palBuf[(i * 4) + 3] = 0; - } - _syst->getPaletteManager()->setPalette(palBuf, 0, 256); + _syst->getPaletteManager()->setPalette(palette, 0, 256); } } // End of Groovie namespace diff --git a/engines/hugo/display.cpp b/engines/hugo/display.cpp index f8fa90330d..a2962ff354 100644 --- a/engines/hugo/display.cpp +++ b/engines/hugo/display.cpp @@ -131,10 +131,24 @@ viewdib_t &Screen::getGUIBuffer() { void Screen::createPal() { debugC(1, kDebugDisplay, "createPal"); - g_system->getPaletteManager()->setPalette(_mainPalette, 0, _paletteSize / 4); + byte pal[3 * 256]; + for (uint i = 0; i < _paletteSize; ++i) { + pal[3 * i + 0] = _mainPalette[4 * i + 0]; + pal[3 * i + 1] = _mainPalette[4 * i + 1]; + pal[3 * i + 2] = _mainPalette[4 * i + 2]; + } + + g_system->getPaletteManager()->setPalette(pal, 0, _paletteSize / 4); } void Screen::setCursorPal() { + byte pal[3 * 256]; + for (uint i = 0; i < _paletteSize; ++i) { + pal[3 * i + 0] = _curPalette[4 * i + 0]; + pal[3 * i + 1] = _curPalette[4 * i + 1]; + pal[3 * i + 2] = _curPalette[4 * i + 2]; + } + CursorMan.replaceCursorPalette(_curPalette, 0, _paletteSize / 4); } @@ -191,12 +205,12 @@ void Screen::displayRect(const int16 x, const int16 y, const int16 dx, const int void Screen::remapPal(const uint16 oldIndex, const uint16 newIndex) { debugC(1, kDebugDisplay, "Remap_pal(%d, %d)", oldIndex, newIndex); - byte pal[4]; + byte pal[3]; pal[0] = _curPalette[4 * oldIndex + 0] = _mainPalette[newIndex * 4 + 0]; pal[1] = _curPalette[4 * oldIndex + 1] = _mainPalette[newIndex * 4 + 1]; pal[2] = _curPalette[4 * oldIndex + 2] = _mainPalette[newIndex * 4 + 2]; - pal[3] = _curPalette[4 * oldIndex + 3] = _mainPalette[newIndex * 4 + 3]; + //pal[3] = _curPalette[4 * oldIndex + 3] = _mainPalette[newIndex * 4 + 3]; g_system->getPaletteManager()->setPalette(pal, oldIndex, 1); } @@ -217,7 +231,7 @@ void Screen::savePal(Common::WriteStream *f) const { void Screen::restorePal(Common::ReadStream *f) { debugC(1, kDebugDisplay, "restorePal()"); - byte pal[4]; + byte pal[3]; for (int i = 0; i < _paletteSize; i++) _curPalette[i] = f->readByte(); @@ -226,7 +240,7 @@ void Screen::restorePal(Common::ReadStream *f) { pal[0] = _curPalette[i * 4 + 0]; pal[1] = _curPalette[i * 4 + 1]; pal[2] = _curPalette[i * 4 + 2]; - pal[3] = _curPalette[i * 4 + 3]; + //pal[3] = _curPalette[i * 4 + 3]; g_system->getPaletteManager()->setPalette(pal, i, 1); } } diff --git a/engines/kyra/screen.cpp b/engines/kyra/screen.cpp index b8eac058fd..3eea7aab14 100644 --- a/engines/kyra/screen.cpp +++ b/engines/kyra/screen.cpp @@ -137,16 +137,15 @@ bool Screen::init() { // We setup the PC98 text mode palette at [16, 24], since that will be used // for KANJI characters in Lands of Lore. if (_use16ColorMode && _vm->gameFlags().platform == Common::kPlatformPC98) { - uint8 palette[8 * 4]; + uint8 palette[8 * 3]; for (int i = 0; i < 8; ++i) { - palette[i * 4 + 0] = ((i >> 1) & 1) * 0xFF; - palette[i * 4 + 1] = ((i >> 2) & 1) * 0xFF; - palette[i * 4 + 2] = ((i >> 0) & 1) * 0xFF; - palette[i * 4 + 3] = 0; - - _system->getPaletteManager()->setPalette(palette, 16, 8); + palette[i * 3 + 0] = ((i >> 1) & 1) * 0xFF; + palette[i * 3 + 1] = ((i >> 2) & 1) * 0xFF; + palette[i * 3 + 2] = ((i >> 0) & 1) * 0xFF; } + + _system->getPaletteManager()->setPalette(palette, 16, 8); } _curDim = 0; @@ -180,7 +179,7 @@ bool Screen::enableScreenDebug(bool enable) { } void Screen::setResolution() { - byte palette[4*256]; + byte palette[3*256]; _system->getPaletteManager()->grabPalette(palette, 0, 256); int width = 320, height = 200; @@ -700,14 +699,13 @@ void Screen::getRealPalette(int num, uint8 *dst) { } void Screen::setScreenPalette(const Palette &pal) { - uint8 screenPal[256 * 4]; + uint8 screenPal[256 * 3]; _screenPalette->copy(pal); for (int i = 0; i < pal.getNumColors(); ++i) { - screenPal[4 * i + 0] = (pal[i * 3 + 0] * 0xFF) / 0x3F; - screenPal[4 * i + 1] = (pal[i * 3 + 1] * 0xFF) / 0x3F; - screenPal[4 * i + 2] = (pal[i * 3 + 2] * 0xFF) / 0x3F; - screenPal[4 * i + 3] = 0; + screenPal[3 * i + 0] = (pal[i * 3 + 0] * 0xFF) / 0x3F; + screenPal[3 * i + 1] = (pal[i * 3 + 1] * 0xFF) / 0x3F; + screenPal[3 * i + 2] = (pal[i * 3 + 2] * 0xFF) / 0x3F; } _paletteChanged = true; @@ -729,19 +727,19 @@ void Screen::setInterfacePalette(const Palette &pal, uint8 r, uint8 g, uint8 b) if (!_isAmiga) return; - uint8 screenPal[32 * 4]; + uint8 screenPal[32 * 3]; assert(32 <= pal.getNumColors()); for (int i = 0; i < pal.getNumColors(); ++i) { if (i != 0x10) { - screenPal[4 * i + 0] = (pal[i * 3 + 0] * 0xFF) / 0x3F; - screenPal[4 * i + 1] = (pal[i * 3 + 1] * 0xFF) / 0x3F; - screenPal[4 * i + 2] = (pal[i * 3 + 2] * 0xFF) / 0x3F; + screenPal[3 * i + 0] = (pal[i * 3 + 0] * 0xFF) / 0x3F; + screenPal[3 * i + 1] = (pal[i * 3 + 1] * 0xFF) / 0x3F; + screenPal[3 * i + 2] = (pal[i * 3 + 2] * 0xFF) / 0x3F; } else { - screenPal[4 * i + 0] = (r * 0xFF) / 0x3F; - screenPal[4 * i + 1] = (g * 0xFF) / 0x3F; - screenPal[4 * i + 2] = (b * 0xFF) / 0x3F; + screenPal[3 * i + 0] = (r * 0xFF) / 0x3F; + screenPal[3 * i + 1] = (g * 0xFF) / 0x3F; + screenPal[3 * i + 2] = (b * 0xFF) / 0x3F; } screenPal[4 * i + 3] = 0; } diff --git a/engines/kyra/screen_lok.cpp b/engines/kyra/screen_lok.cpp index da96ea6821..227349754f 100644 --- a/engines/kyra/screen_lok.cpp +++ b/engines/kyra/screen_lok.cpp @@ -447,12 +447,11 @@ void Screen_LoK_16::mergeOverlay(int x, int y, int w, int h) { } void Screen_LoK_16::set16ColorPalette(const uint8 *pal) { - uint8 palette[16 * 4]; + uint8 palette[16 * 3]; for (int i = 0; i < 16; ++i) { - palette[i * 4 + 0] = (pal[i * 3 + 0] * 0xFF) / 0x0F; - palette[i * 4 + 1] = (pal[i * 3 + 1] * 0xFF) / 0x0F; - palette[i * 4 + 2] = (pal[i * 3 + 2] * 0xFF) / 0x0F; - palette[i * 4 + 3] = 0; + palette[i * 3 + 0] = (pal[i * 3 + 0] * 0xFF) / 0x0F; + palette[i * 3 + 1] = (pal[i * 3 + 1] * 0xFF) / 0x0F; + palette[i * 3 + 2] = (pal[i * 3 + 2] * 0xFF) / 0x0F; } _system->getPaletteManager()->setPalette(palette, 0, 16); diff --git a/engines/kyra/screen_lol.cpp b/engines/kyra/screen_lol.cpp index e85ea13371..ff35facbb5 100644 --- a/engines/kyra/screen_lol.cpp +++ b/engines/kyra/screen_lol.cpp @@ -795,11 +795,10 @@ void Screen_LoL::copyColor(int dstColorIndex, int srcColorIndex) { uint8 *d = _screenPalette->getData() + dstColorIndex * 3; memcpy(d, s, 3); - uint8 ci[4]; + uint8 ci[3]; ci[0] = (d[0] << 2) | (d[0] & 3); ci[1] = (d[1] << 2) | (d[1] & 3); ci[2] = (d[2] << 2) | (d[2] & 3); - ci[3] = 0; _system->getPaletteManager()->setPalette(ci, dstColorIndex, 1); } diff --git a/engines/lure/screen.cpp b/engines/lure/screen.cpp index d00d969770..282e382bba 100644 --- a/engines/lure/screen.cpp +++ b/engines/lure/screen.cpp @@ -52,12 +52,26 @@ Screen::~Screen() { delete _palette; } +void Screen::setSystemPalette(Palette *p, uint16 start, uint16 num) { + byte pal[3 * 256]; + assert(start + num <= 256); + + const byte *rawData = p->data(); + for (uint i = 0; i < num; ++i) { + pal[i * 3 + 0] = rawData[(i + start) * 4 + 0]; + pal[i * 3 + 1] = rawData[(i + start) * 4 + 1]; + pal[i * 3 + 2] = rawData[(i + start) * 4 + 2]; + } + + _system.getPaletteManager()->setPalette(pal, start, num); +} + // setPaletteEmpty // Defaults the palette to an empty set void Screen::setPaletteEmpty(int numEntries) { Palette emptyPalette(numEntries, NULL, RGB64); - _system.getPaletteManager()->setPalette(emptyPalette.data(), 0, numEntries); + setSystemPalette(&emptyPalette, 0, numEntries); _palette->copyFrom(&emptyPalette); /* delete _palette; @@ -73,7 +87,7 @@ void Screen::setPaletteEmpty(int numEntries) { void Screen::setPalette(Palette *p) { _palette->copyFrom(p); - _system.getPaletteManager()->setPalette(_palette->data(), 0, GAME_COLOURS); + setSystemPalette(_palette, 0, GAME_COLOURS); _system.updateScreen(); } @@ -82,7 +96,7 @@ void Screen::setPalette(Palette *p) { void Screen::setPalette(Palette *p, uint16 start, uint16 num) { _palette->palette()->copyFrom(p->palette(), start * 4, start * 4, num * 4); - _system.getPaletteManager()->setPalette(_palette->data(), start, num); + setSystemPalette(_palette, start, num); _system.updateScreen(); } @@ -114,7 +128,7 @@ void Screen::paletteFadeIn(Palette *p) { } if (changed) { - _system.getPaletteManager()->setPalette(_palette->data(), 0, p->numEntries()); + setSystemPalette(_palette, 0, p->numEntries()); _system.updateScreen(); _system.delayMillis(20); while (events.pollEvent()) @@ -147,7 +161,7 @@ void Screen::paletteFadeOut(int numEntries) { } if (changed) { - _system.getPaletteManager()->setPalette(_palette->data(), 0, numEntries); + setSystemPalette(_palette, 0, numEntries); _system.updateScreen(); _system.delayMillis(20); while (events.pollEvent()) diff --git a/engines/lure/screen.h b/engines/lure/screen.h index 373683df2b..94bbab932e 100644 --- a/engines/lure/screen.h +++ b/engines/lure/screen.h @@ -42,6 +42,8 @@ private: Disk &_disk; Surface *_screen; Palette *_palette; + + void setSystemPalette(Palette *p, uint16 start, uint16 num); public: Screen(OSystem &system); ~Screen(); diff --git a/engines/made/screen.cpp b/engines/made/screen.cpp index 7a4c12eefb..2649e2bd37 100644 --- a/engines/made/screen.cpp +++ b/engines/made/screen.cpp @@ -32,7 +32,6 @@ namespace Made { Screen::Screen(MadeEngine *vm) : _vm(vm) { - _screenPalette = new byte[256 * 4]; _palette = new byte[768]; _newPalette = new byte[768]; @@ -95,7 +94,6 @@ Screen::Screen(MadeEngine *vm) : _vm(vm) { Screen::~Screen() { - delete[] _screenPalette; delete[] _palette; delete[] _newPalette; @@ -220,14 +218,7 @@ void Screen::drawSurface(Graphics::Surface *sourceSurface, int x, int y, int16 f } void Screen::setRGBPalette(byte *palRGB, int start, int count) { - for (int i = 0; i < count; i++) { - _screenPalette[i * 4 + 0] = palRGB[i * 3 + 0]; - _screenPalette[i * 4 + 1] = palRGB[i * 3 + 1]; - _screenPalette[i * 4 + 2] = palRGB[i * 3 + 2]; - _screenPalette[i * 4 + 3] = 0; - } - - _vm->_system->getPaletteManager()->setPalette(_screenPalette, start, count); + _vm->_system->getPaletteManager()->setPalette(palRGB, start, count); } uint16 Screen::updateChannel(uint16 channelIndex) { diff --git a/engines/made/screen.h b/engines/made/screen.h index c91704ef79..e9292240a1 100644 --- a/engines/made/screen.h +++ b/engines/made/screen.h @@ -200,7 +200,6 @@ protected: bool _screenLock; bool _paletteLock; - byte *_screenPalette; byte *_palette, *_newPalette; int _paletteColorCount, _oldPaletteColorCount; bool _paletteInitialized, _needPalette; diff --git a/engines/mohawk/cursors.cpp b/engines/mohawk/cursors.cpp index 45f3329f13..08f863544a 100644 --- a/engines/mohawk/cursors.cpp +++ b/engines/mohawk/cursors.cpp @@ -38,8 +38,8 @@ namespace Mohawk { static const byte s_bwPalette[] = { - 0x00, 0x00, 0x00, 0x00, // Black - 0xFF, 0xFF, 0xFF, 0x00 // White + 0x00, 0x00, 0x00, // Black + 0xFF, 0xFF, 0xFF // White }; void CursorManager::showCursor() { @@ -153,7 +153,16 @@ void MystCursorManager::setCursor(uint16 id) { // Myst ME stores some cursors as 24bpp images instead of 8bpp if (surface->bytesPerPixel == 1) { CursorMan.replaceCursor((byte *)surface->pixels, surface->w, surface->h, hotspotX, hotspotY, 0); - CursorMan.replaceCursorPalette(mhkSurface->getPalette(), 0, 256); + + const byte *srcPal = mhkSurface->getPalette(); + byte pal[3*256]; + for (uint i = 0; i < 256; ++i) { + pal[i * 3 + 0] = srcPal[i * 4 + 0]; + pal[i * 3 + 1] = srcPal[i * 4 + 1]; + pal[i * 3 + 2] = srcPal[i * 4 + 2]; + } + + CursorMan.replaceCursorPalette(pal, 0, 256); } else { Graphics::PixelFormat pixelFormat = g_system->getScreenFormat(); CursorMan.replaceCursor((byte *)surface->pixels, surface->w, surface->h, hotspotX, hotspotY, pixelFormat.RGBToColor(255, 255, 255), 1, &pixelFormat); @@ -174,92 +183,92 @@ void RivenCursorManager::setCursor(uint16 id) { case 1002: // Zip Mode CursorMan.replaceCursor(s_zipModeCursor, 16, 16, 8, 8, 0); - CursorMan.replaceCursorPalette(s_zipModeCursorPalette, 1, ARRAYSIZE(s_zipModeCursorPalette) / 4); + CursorMan.replaceCursorPalette(s_zipModeCursorPalette, 1, ARRAYSIZE(s_zipModeCursorPalette) / 3); break; case 2003: // Hand Over Object CursorMan.replaceCursor(s_objectHandCursor, 16, 16, 8, 8, 0); - CursorMan.replaceCursorPalette(s_handCursorPalette, 1, ARRAYSIZE(s_handCursorPalette) / 4); + CursorMan.replaceCursorPalette(s_handCursorPalette, 1, ARRAYSIZE(s_handCursorPalette) / 3); break; case 2004: // Grabbing/Using Object CursorMan.replaceCursor(s_grabbingHandCursor, 13, 13, 6, 6, 0); - CursorMan.replaceCursorPalette(s_handCursorPalette, 1, ARRAYSIZE(s_handCursorPalette) / 4); + CursorMan.replaceCursorPalette(s_handCursorPalette, 1, ARRAYSIZE(s_handCursorPalette) / 3); break; case 3000: // Standard Hand CursorMan.replaceCursor(s_standardHandCursor, 15, 16, 6, 0, 0); - CursorMan.replaceCursorPalette(s_handCursorPalette, 1, ARRAYSIZE(s_handCursorPalette) / 4); + CursorMan.replaceCursorPalette(s_handCursorPalette, 1, ARRAYSIZE(s_handCursorPalette) / 3); break; case 3001: // Pointing Left CursorMan.replaceCursor(s_pointingLeftCursor, 15, 13, 0, 3, 0); - CursorMan.replaceCursorPalette(s_handCursorPalette, 1, ARRAYSIZE(s_handCursorPalette) / 4); + CursorMan.replaceCursorPalette(s_handCursorPalette, 1, ARRAYSIZE(s_handCursorPalette) / 3); break; case 3002: // Pointing Right CursorMan.replaceCursor(s_pointingRightCursor, 15, 13, 14, 3, 0); - CursorMan.replaceCursorPalette(s_handCursorPalette, 1, ARRAYSIZE(s_handCursorPalette) / 4); + CursorMan.replaceCursorPalette(s_handCursorPalette, 1, ARRAYSIZE(s_handCursorPalette) / 3); break; case 3003: // Pointing Down (Palm Up) CursorMan.replaceCursor(s_pointingDownCursorPalmUp, 13, 16, 3, 15, 0); - CursorMan.replaceCursorPalette(s_handCursorPalette, 1, ARRAYSIZE(s_handCursorPalette) / 4); + CursorMan.replaceCursorPalette(s_handCursorPalette, 1, ARRAYSIZE(s_handCursorPalette) / 3); break; case 3004: // Pointing Up (Palm Up) CursorMan.replaceCursor(s_pointingUpCursorPalmUp, 13, 16, 3, 0, 0); - CursorMan.replaceCursorPalette(s_handCursorPalette, 1, ARRAYSIZE(s_handCursorPalette) / 4); + CursorMan.replaceCursorPalette(s_handCursorPalette, 1, ARRAYSIZE(s_handCursorPalette) / 3); break; case 3005: // Pointing Left (Curved) CursorMan.replaceCursor(s_pointingLeftCursorBent, 15, 13, 0, 5, 0); - CursorMan.replaceCursorPalette(s_handCursorPalette, 1, ARRAYSIZE(s_handCursorPalette) / 4); + CursorMan.replaceCursorPalette(s_handCursorPalette, 1, ARRAYSIZE(s_handCursorPalette) / 3); break; case 3006: // Pointing Right (Curved) CursorMan.replaceCursor(s_pointingRightCursorBent, 15, 13, 14, 5, 0); - CursorMan.replaceCursorPalette(s_handCursorPalette, 1, ARRAYSIZE(s_handCursorPalette) / 4); + CursorMan.replaceCursorPalette(s_handCursorPalette, 1, ARRAYSIZE(s_handCursorPalette) / 3); break; case 3007: // Pointing Down (Palm Down) CursorMan.replaceCursor(s_pointingDownCursorPalmDown, 15, 16, 7, 15, 0); - CursorMan.replaceCursorPalette(s_handCursorPalette, 1, ARRAYSIZE(s_handCursorPalette) / 4); + CursorMan.replaceCursorPalette(s_handCursorPalette, 1, ARRAYSIZE(s_handCursorPalette) / 3); break; case 4001: // Red Marble CursorMan.replaceCursor(s_redMarbleCursor, 12, 12, 5, 5, 0); - CursorMan.replaceCursorPalette(s_redMarbleCursorPalette, 1, ARRAYSIZE(s_redMarbleCursorPalette) / 4); + CursorMan.replaceCursorPalette(s_redMarbleCursorPalette, 1, ARRAYSIZE(s_redMarbleCursorPalette) / 3); break; case 4002: // Orange Marble CursorMan.replaceCursor(s_orangeMarbleCursor, 12, 12, 5, 5, 0); - CursorMan.replaceCursorPalette(s_orangeMarbleCursorPalette, 1, ARRAYSIZE(s_orangeMarbleCursorPalette) / 4); + CursorMan.replaceCursorPalette(s_orangeMarbleCursorPalette, 1, ARRAYSIZE(s_orangeMarbleCursorPalette) / 3); break; case 4003: // Yellow Marble CursorMan.replaceCursor(s_yellowMarbleCursor, 12, 12, 5, 5, 0); - CursorMan.replaceCursorPalette(s_yellowMarbleCursorPalette, 1, ARRAYSIZE(s_yellowMarbleCursorPalette) / 4); + CursorMan.replaceCursorPalette(s_yellowMarbleCursorPalette, 1, ARRAYSIZE(s_yellowMarbleCursorPalette) / 3); break; case 4004: // Green Marble CursorMan.replaceCursor(s_greenMarbleCursor, 12, 12, 5, 5, 0); - CursorMan.replaceCursorPalette(s_greenMarbleCursorPalette, 1, ARRAYSIZE(s_greenMarbleCursorPalette) / 4); + CursorMan.replaceCursorPalette(s_greenMarbleCursorPalette, 1, ARRAYSIZE(s_greenMarbleCursorPalette) / 3); break; case 4005: // Blue Marble CursorMan.replaceCursor(s_blueMarbleCursor, 12, 12, 5, 5, 0); - CursorMan.replaceCursorPalette(s_blueMarbleCursorPalette, 1, ARRAYSIZE(s_blueMarbleCursorPalette) / 4); + CursorMan.replaceCursorPalette(s_blueMarbleCursorPalette, 1, ARRAYSIZE(s_blueMarbleCursorPalette) / 3); break; case 4006: // Violet Marble CursorMan.replaceCursor(s_violetMarbleCursor, 12, 12, 5, 5, 0); - CursorMan.replaceCursorPalette(s_violetMarbleCursorPalette, 1, ARRAYSIZE(s_violetMarbleCursorPalette) / 4); + CursorMan.replaceCursorPalette(s_violetMarbleCursorPalette, 1, ARRAYSIZE(s_violetMarbleCursorPalette) / 3); break; case 5000: // Pellet CursorMan.replaceCursor(s_pelletCursor, 8, 8, 4, 4, 0); - CursorMan.replaceCursorPalette(s_pelletCursorPalette, 1, ARRAYSIZE(s_pelletCursorPalette) / 4); + CursorMan.replaceCursorPalette(s_pelletCursorPalette, 1, ARRAYSIZE(s_pelletCursorPalette) / 3); break; case 9000: // Hide Cursor @@ -302,7 +311,16 @@ void NECursorManager::setCursor(uint16 id) { if (cursors[i].id == id) { Common::NECursor *cursor = cursors[i].cursors[0]; CursorMan.replaceCursor(cursor->getSurface(), cursor->getWidth(), cursor->getHeight(), cursor->getHotspotX(), cursor->getHotspotY(), 0); - CursorMan.replaceCursorPalette(cursor->getPalette(), 0, 256); + + const byte *srcPal = cursor->getPalette(); + byte pal[3 * 256]; + for (uint j = 0; j < 256; ++j) { + pal[j * 3 + 0] = srcPal[j * 4 + 0]; + pal[j * 3 + 1] = srcPal[j * 4 + 1]; + pal[j * 3 + 2] = srcPal[j * 4 + 2]; + } + + CursorMan.replaceCursorPalette(pal, 0, 256); return; } } diff --git a/engines/mohawk/graphics.cpp b/engines/mohawk/graphics.cpp index be2fe01c4d..78916be85c 100644 --- a/engines/mohawk/graphics.cpp +++ b/engines/mohawk/graphics.cpp @@ -136,13 +136,13 @@ void GraphicsManager::setPalette(uint16 id) { uint16 colorStart = tpalStream->readUint16BE(); uint16 colorCount = tpalStream->readUint16BE(); - byte *palette = new byte[colorCount * 4]; + byte *palette = new byte[colorCount * 3]; for (uint16 i = 0; i < colorCount; i++) { - palette[i * 4] = tpalStream->readByte(); - palette[i * 4 + 1] = tpalStream->readByte(); - palette[i * 4 + 2] = tpalStream->readByte(); - palette[i * 4 + 3] = tpalStream->readByte(); + palette[i * 3 + 0] = tpalStream->readByte(); + palette[i * 3 + 1] = tpalStream->readByte(); + palette[i * 3 + 2] = tpalStream->readByte(); + tpalStream->readByte(); } delete tpalStream; @@ -1005,13 +1005,13 @@ void LBGraphics::setPalette(uint16 id) { if (_vm->isPreMohawk()) { Common::SeekableSubReadStreamEndian *ctblStream = _vm->wrapStreamEndian(ID_CTBL, id); uint16 colorCount = ctblStream->readUint16(); - byte *palette = new byte[colorCount * 4]; + byte *palette = new byte[colorCount * 3]; for (uint16 i = 0; i < colorCount; i++) { - palette[i * 4] = ctblStream->readByte(); - palette[i * 4 + 1] = ctblStream->readByte(); - palette[i * 4 + 2] = ctblStream->readByte(); - palette[i * 4 + 3] = ctblStream->readByte(); + palette[i * 3 + 0] = ctblStream->readByte(); + palette[i * 3 + 1] = ctblStream->readByte(); + palette[i * 3 + 2] = ctblStream->readByte(); + ctblStream->readByte(); } delete ctblStream; diff --git a/engines/mohawk/riven_cursors.h b/engines/mohawk/riven_cursors.h index 71cb8fd804..dadfdf0549 100644 --- a/engines/mohawk/riven_cursors.h +++ b/engines/mohawk/riven_cursors.h @@ -62,8 +62,8 @@ static const byte s_zipModeCursor[] = { // Palette For The Zip Mode Cursor //////////////////////////////////////// static const byte s_zipModeCursorPalette[] = { - 0x00, 0x00, 0x00, 0x00, // Black - 0xDC, 0xFF, 0x00, 0x00, // Yellow + 0x00, 0x00, 0x00, // Black + 0xDC, 0xFF, 0x00 // Yellow }; @@ -356,10 +356,10 @@ static const byte s_pointingDownCursorPalmDown[] = { // Palette For All Hand Cursors //////////////////////////////////////// static const byte s_handCursorPalette[] = { - 0x00, 0x00, 0x00, 0x00, // Black - 0xED, 0xCD, 0x96, 0x00, // Light Peach - 0x8A, 0x67, 0x2F, 0x00, // Brown - 0xE8, 0x9A, 0x62, 0x00 // Dark Peach + 0x00, 0x00, 0x00, // Black + 0xED, 0xCD, 0x96, // Light Peach + 0x8A, 0x67, 0x2F, // Brown + 0xE8, 0x9A, 0x62 // Dark Peach }; @@ -392,13 +392,13 @@ static const byte s_pelletCursor[] = { // Palette For The Pellet Cursor //////////////////////////////////////// static const byte s_pelletCursorPalette[] = { - 0x5D, 0x67, 0x30, 0x00, - 0x5E, 0x33, 0x33, 0x00, - 0x55, 0x55, 0x55, 0x00, - 0x44, 0x44, 0x44, 0x00, - 0x33, 0x33, 0x33, 0x00, - 0x2D, 0x33, 0x00, 0x00, - 0x22, 0x22, 0x22, 0x00 + 0x5D, 0x67, 0x30, + 0x5E, 0x33, 0x33, + 0x55, 0x55, 0x55, + 0x44, 0x44, 0x44, + 0x33, 0x33, 0x33, + 0x2D, 0x33, 0x00, + 0x22, 0x22, 0x22 }; //////////////////////////////////////// @@ -426,29 +426,29 @@ static const byte s_redMarbleCursor[] = { // Palette For The Red Marble Cursor //////////////////////////////////////// static const byte s_redMarbleCursorPalette[] = { - 0xb8, 0x33, 0x32, 0x00, - 0xe5, 0x33, 0x31, 0x00, - 0x98, 0x06, 0x00, 0x00, - 0xb8, 0x00, 0x34, 0x00, - 0xe6, 0x00, 0x34, 0x00, - 0x7a, 0x04, 0x00, 0x00, - 0xe8, 0x9a, 0x62, 0x00, - 0xea, 0x31, 0x67, 0x00, - 0x6a, 0x03, 0x00, 0x00, - 0x8c, 0x00, 0x35, 0x00, - 0xb6, 0x36, 0x00, 0x00, - 0xed, 0xcd, 0x96, 0x00, - 0xe9, 0x66, 0x65, 0x00, - 0x5b, 0x35, 0x00, 0x00, - 0x5b, 0x02, 0x00, 0x00, - 0x5f, 0x00, 0x35, 0x00, - 0x4c, 0x01, 0x00, 0x00, - 0x5e, 0x33, 0x33, 0x00, - 0x89, 0x05, 0x00, 0x00, - 0xb6, 0x08, 0x00, 0x00, - 0xa7, 0x07, 0x00, 0x00, - 0x88, 0x36, 0x00, 0x00, - 0x8b, 0x33, 0x33, 0x00 + 0xb8, 0x33, 0x32, + 0xe5, 0x33, 0x31, + 0x98, 0x06, 0x00, + 0xb8, 0x00, 0x34, + 0xe6, 0x00, 0x34, + 0x7a, 0x04, 0x00, + 0xe8, 0x9a, 0x62, + 0xea, 0x31, 0x67, + 0x6a, 0x03, 0x00, + 0x8c, 0x00, 0x35, + 0xb6, 0x36, 0x00, + 0xed, 0xcd, 0x96, + 0xe9, 0x66, 0x65, + 0x5b, 0x35, 0x00, + 0x5b, 0x02, 0x00, + 0x5f, 0x00, 0x35, + 0x4c, 0x01, 0x00, + 0x5e, 0x33, 0x33, + 0x89, 0x05, 0x00, + 0xb6, 0x08, 0x00, + 0xa7, 0x07, 0x00, + 0x88, 0x36, 0x00, + 0x8b, 0x33, 0x33 }; //////////////////////////////////////// @@ -475,26 +475,26 @@ static const byte s_orangeMarbleCursor[] = { // Palette For The Orange Marble Cursor //////////////////////////////////////// static const byte s_orangeMarbleCursorPalette[] = { - 0xe1, 0x9e, 0x00, 0x00, - 0xe3, 0x9b, 0x28, 0x00, - 0xe2, 0xcf, 0x20, 0x00, - 0xb5, 0x6a, 0x00, 0x00, - 0xb6, 0x9b, 0x29, 0x00, - 0x87, 0x69, 0x00, 0x00, - 0xb7, 0x67, 0x2f, 0x00, - 0xe9, 0xff, 0x93, 0x00, - 0xe1, 0xff, 0x5a, 0x00, - 0xe0, 0xd0, 0x00, 0x00, - 0x5e, 0x33, 0x33, 0x00, - 0x88, 0x36, 0x00, 0x00, - 0xf3, 0xff, 0xc9, 0x00, - 0x5b, 0x35, 0x00, 0x00, - 0x8b, 0x33, 0x33, 0x00, - 0xe6, 0xce, 0x5f, 0x00, - 0x8a, 0x67, 0x2f, 0x00, - 0x5d, 0x67, 0x30, 0x00, - 0xe2, 0x6a, 0x00, 0x00, - 0xb3, 0x9d, 0x00, 0x00 + 0xe1, 0x9e, 0x00, + 0xe3, 0x9b, 0x28, + 0xe2, 0xcf, 0x20, + 0xb5, 0x6a, 0x00, + 0xb6, 0x9b, 0x29, + 0x87, 0x69, 0x00, + 0xb7, 0x67, 0x2f, + 0xe9, 0xff, 0x93, + 0xe1, 0xff, 0x5a, + 0xe0, 0xd0, 0x00, + 0x5e, 0x33, 0x33, + 0x88, 0x36, 0x00, + 0xf3, 0xff, 0xc9, + 0x5b, 0x35, 0x00, + 0x8b, 0x33, 0x33, + 0xe6, 0xce, 0x5f, + 0x8a, 0x67, 0x2f, + 0x5d, 0x67, 0x30, + 0xe2, 0x6a, 0x00, + 0xb3, 0x9d, 0x00 }; //////////////////////////////////////// @@ -521,20 +521,20 @@ static const byte s_yellowMarbleCursor[] = { // Palette For The Yellow Marble Cursor //////////////////////////////////////// static const byte s_yellowMarbleCursorPalette[] = { - 0xb3, 0xd0, 0x00, 0x00, - 0xb0, 0xff, 0x00, 0x00, - 0x86, 0x9c, 0x00, 0x00, - 0x87, 0xd0, 0x00, 0x00, - 0xe0, 0xd0, 0x00, 0x00, - 0xdc, 0xff, 0x00, 0x00, - 0xb3, 0x9d, 0x00, 0x00, - 0xdc, 0xff, 0x11, 0x00, - 0x5a, 0x68, 0x00, 0x00, - 0xe1, 0xff, 0x5a, 0x00, - 0x5d, 0x67, 0x30, 0x00, - 0x87, 0x69, 0x00, 0x00, - 0x88, 0x9b, 0x2a, 0x00, - 0x5a, 0x9c, 0x00, 0x00 + 0xb3, 0xd0, 0x00, + 0xb0, 0xff, 0x00, + 0x86, 0x9c, 0x00, + 0x87, 0xd0, 0x00, + 0xe0, 0xd0, 0x00, + 0xdc, 0xff, 0x00, + 0xb3, 0x9d, 0x00, + 0xdc, 0xff, 0x11, + 0x5a, 0x68, 0x00, + 0xe1, 0xff, 0x5a, + 0x5d, 0x67, 0x30, + 0x87, 0x69, 0x00, + 0x88, 0x9b, 0x2a, + 0x5a, 0x9c, 0x00 }; //////////////////////////////////////// @@ -561,25 +561,25 @@ static const byte s_greenMarbleCursor[] = { // Palette For The Green Marble Cursor //////////////////////////////////////// static const byte s_greenMarbleCursorPalette[] = { - 0x0e, 0xd0, 0x00, 0x00, - 0x0f, 0xe1, 0x00, 0x00, - 0x10, 0xf2, 0x00, 0x00, - 0x0b, 0x9c, 0x00, 0x00, - 0x0c, 0xad, 0x00, 0x00, - 0x11, 0xff, 0x00, 0x00, - 0x09, 0x8a, 0x00, 0x00, - 0x0d, 0xbe, 0x00, 0x00, - 0x30, 0xff, 0x5a, 0x00, - 0x0d, 0x67, 0x30, 0x00, - 0x6b, 0xff, 0x92, 0x00, - 0x00, 0xff, 0x28, 0x00, - 0x08, 0x79, 0x00, 0x00, - 0x05, 0x57, 0x00, 0x00, - 0x30, 0x67, 0x30, 0x00, - 0x06, 0x68, 0x00, 0x00, - 0x00, 0x9b, 0x2c, 0x00, - 0x2e, 0x9c, 0x00, 0x00, - 0x2e, 0x68, 0x00, 0x00 + 0x0e, 0xd0, 0x00, + 0x0f, 0xe1, 0x00, + 0x10, 0xf2, 0x00, + 0x0b, 0x9c, 0x00, + 0x0c, 0xad, 0x00, + 0x11, 0xff, 0x00, + 0x09, 0x8a, 0x00, + 0x0d, 0xbe, 0x00, + 0x30, 0xff, 0x5a, + 0x0d, 0x67, 0x30, + 0x6b, 0xff, 0x92, + 0x00, 0xff, 0x28, + 0x08, 0x79, 0x00, + 0x05, 0x57, 0x00, + 0x30, 0x67, 0x30, + 0x06, 0x68, 0x00, + 0x00, 0x9b, 0x2c, + 0x2e, 0x9c, 0x00, + 0x2e, 0x68, 0x00 }; //////////////////////////////////////// @@ -606,28 +606,28 @@ static const byte s_blueMarbleCursor[] = { // Palette For The Blue Marble Cursor //////////////////////////////////////// static const byte s_blueMarbleCursorPalette[] = { - 0x6b, 0x00, 0xd2, 0x00, - 0x66, 0x00, 0xe3, 0x00, - 0x72, 0x00, 0xff, 0x00, - 0x53, 0x2d, 0x9d, 0x00, - 0x4e, 0x00, 0xaf, 0x00, - 0x6d, 0x00, 0xf5, 0x00, - 0x7d, 0x00, 0xff, 0x00, - 0x44, 0x00, 0x69, 0x00, - 0x56, 0x00, 0x9d, 0x00, - 0x56, 0x00, 0xc0, 0x00, - 0x5e, 0x00, 0xd2, 0x00, - 0x2b, 0x31, 0x68, 0x00, - 0x3f, 0x00, 0x8c, 0x00, - 0x91, 0x22, 0xff, 0x00, - 0x41, 0x31, 0x68, 0x00, - 0xd7, 0x95, 0xff, 0x00, - 0x77, 0x22, 0xff, 0x00, - 0x2f, 0x00, 0x69, 0x00, - 0x37, 0x00, 0x7a, 0x00, - 0x27, 0x00, 0x58, 0x00, - 0x46, 0x00, 0x9d, 0x00, - 0x33, 0x33, 0x33, 0x00 + 0x6b, 0x00, 0xd2, + 0x66, 0x00, 0xe3, + 0x72, 0x00, 0xff, + 0x53, 0x2d, 0x9d, + 0x4e, 0x00, 0xaf, + 0x6d, 0x00, 0xf5, + 0x7d, 0x00, 0xff, + 0x44, 0x00, 0x69, + 0x56, 0x00, 0x9d, + 0x56, 0x00, 0xc0, + 0x5e, 0x00, 0xd2, + 0x2b, 0x31, 0x68, + 0x3f, 0x00, 0x8c, + 0x91, 0x22, 0xff, + 0x41, 0x31, 0x68, + 0xd7, 0x95, 0xff, + 0x77, 0x22, 0xff, + 0x2f, 0x00, 0x69, + 0x37, 0x00, 0x7a, + 0x27, 0x00, 0x58, + 0x46, 0x00, 0x9d, + 0x33, 0x33, 0x33 }; //////////////////////////////////////// @@ -654,17 +654,17 @@ static const byte s_violetMarbleCursor[] = { // Palette For The Violet Marble Cursor //////////////////////////////////////// static const byte s_violetMarbleCursorPalette[] = { - 0xaa, 0x00, 0xd1, 0x00, - 0xd8, 0x00, 0xff, 0x00, - 0x76, 0x00, 0x9d, 0x00, - 0xb5, 0x00, 0xff, 0x00, - 0x87, 0x00, 0xd2, 0x00, - 0xd7, 0x22, 0xff, 0x00, - 0x68, 0x00, 0x69, 0x00, - 0x44, 0x00, 0x69, 0x00, - 0xd7, 0x5e, 0xff, 0x00, - 0x9c, 0x00, 0x9d, 0x00, - 0x56, 0x00, 0x9d, 0x00 + 0xaa, 0x00, 0xd1, + 0xd8, 0x00, 0xff, + 0x76, 0x00, 0x9d, + 0xb5, 0x00, 0xff, + 0x87, 0x00, 0xd2, + 0xd7, 0x22, 0xff, + 0x68, 0x00, 0x69, + 0x44, 0x00, 0x69, + 0xd7, 0x5e, 0xff, + 0x9c, 0x00, 0x9d, + 0x56, 0x00, 0x9d }; } // End of namespace Mohawk diff --git a/engines/mohawk/view.cpp b/engines/mohawk/view.cpp index 241b2c3663..837d386b58 100644 --- a/engines/mohawk/view.cpp +++ b/engines/mohawk/view.cpp @@ -421,13 +421,13 @@ void View::installBG(uint16 id) { void View::setColors(Common::SeekableReadStream *tpalStream) { uint16 colorStart = tpalStream->readUint16BE(); uint16 colorCount = tpalStream->readUint16BE(); - byte *palette = new byte[colorCount * 4]; + byte *palette = new byte[colorCount * 3]; for (uint16 i = 0; i < colorCount; i++) { - palette[i * 4] = tpalStream->readByte(); - palette[i * 4 + 1] = tpalStream->readByte(); - palette[i * 4 + 2] = tpalStream->readByte(); - palette[i * 4 + 3] = tpalStream->readByte(); + palette[i * 3 + 0] = tpalStream->readByte(); + palette[i * 3 + 1] = tpalStream->readByte(); + palette[i * 3 + 2] = tpalStream->readByte(); + tpalStream->readByte(); } // TODO: copy into temporary buffer diff --git a/engines/parallaction/graphics.cpp b/engines/parallaction/graphics.cpp index 79993a297a..35441d7e3e 100644 --- a/engines/parallaction/graphics.cpp +++ b/engines/parallaction/graphics.cpp @@ -160,26 +160,24 @@ void Palette::fadeTo(const Palette& target, uint step) { return; } -uint Palette::fillRGBA(byte *rgba) { +uint Palette::fillRGB(byte *rgb) { byte r, g, b; - byte *hbPal = rgba + _colors * 4; + byte *hbPal = rgb + _colors * 3; for (uint32 i = 0; i < _colors; i++) { r = (_data[i*3] << 2) | (_data[i*3] >> 4); g = (_data[i*3+1] << 2) | (_data[i*3+1] >> 4); b = (_data[i*3+2] << 2) | (_data[i*3+2] >> 4); - rgba[i*4] = r; - rgba[i*4+1] = g; - rgba[i*4+2] = b; - rgba[i*4+3] = 0; + rgb[i*3] = r; + rgb[i*3+1] = g; + rgb[i*3+2] = b; if (_hb) { - hbPal[i*4] = r >> 1; - hbPal[i*4+1] = g >> 1; - hbPal[i*4+2] = b >> 1; - hbPal[i*4+3] = 0; + hbPal[i*3] = r >> 1; + hbPal[i*3+1] = g >> 1; + hbPal[i*3+2] = b >> 1; } } @@ -222,9 +220,9 @@ void Palette::rotate(uint first, uint last, bool forward) { void Gfx::setPalette(Palette pal) { - byte sysPal[256*4]; + byte sysPal[256*3]; - uint n = pal.fillRGBA(sysPal); + uint n = pal.fillRGB(sysPal); _vm->_system->getPaletteManager()->setPalette(sysPal, 0, n); } diff --git a/engines/parallaction/graphics.h b/engines/parallaction/graphics.h index afabcad21c..d6732e6fe4 100644 --- a/engines/parallaction/graphics.h +++ b/engines/parallaction/graphics.h @@ -250,7 +250,7 @@ public: void setEntry(uint index, int red, int green, int blue); void makeGrayscale(); void fadeTo(const Palette& target, uint step); - uint fillRGBA(byte *rgba); + uint fillRGB(byte *rgb); void rotate(uint first, uint last, bool forward); }; diff --git a/engines/queen/display.cpp b/engines/queen/display.cpp index 4557588732..7b16df52bf 100644 --- a/engines/queen/display.cpp +++ b/engines/queen/display.cpp @@ -159,15 +159,7 @@ void Display::palSet(const uint8 *pal, int start, int end, bool updateScreen) { debug(9, "Display::palSet(%d, %d)", start, end); const int numColors = end - start + 1; assert(numColors <= 256); - uint8 tempPal[256 * 4]; - pal += start * 3; - for (int i = 0; i < numColors; i++) { - tempPal[4 * i + 0] = *pal++; - tempPal[4 * i + 1] = *pal++; - tempPal[4 * i + 2] = *pal++; - tempPal[4 * i + 3] = 0; - } - _system->getPaletteManager()->setPalette(tempPal, start, numColors); + _system->getPaletteManager()->setPalette(pal + start * 3, start, numColors); if (updateScreen) { _vm->input()->delay(20); } diff --git a/engines/saga/gfx.cpp b/engines/saga/gfx.cpp index 771284f632..c46da4cd4e 100644 --- a/engines/saga/gfx.cpp +++ b/engines/saga/gfx.cpp @@ -201,20 +201,19 @@ void Gfx::setPalette(const PalEntry *pal, bool full) { numcolors = 248; } - for (i = 0, ppal = &_currentPal[from * 4]; i < numcolors; i++, ppal += 4) { + for (i = 0, ppal = &_currentPal[from * 3]; i < numcolors; i++, ppal += 3) { ppal[0] = _globalPalette[i].red = pal[i].red; ppal[1] = _globalPalette[i].green = pal[i].green; ppal[2] = _globalPalette[i].blue = pal[i].blue; - ppal[3] = 0; } // Color 0 should always be black in IHNM if (_vm->getGameId() == GID_IHNM) - memset(&_currentPal[0 * 4], 0, 4); + memset(&_currentPal[0 * 3], 0, 3); // Make 256th color black. See bug #1256368 if ((_vm->getPlatform() == Common::kPlatformMacintosh) && !_vm->_scene->isInIntro()) - memset(&_currentPal[255 * 4], 0, 4); + memset(&_currentPal[255 * 3], 0, 3); _system->getPaletteManager()->setPalette(_currentPal, 0, PAL_ENTRIES); } @@ -225,20 +224,16 @@ void Gfx::setPaletteColor(int n, int r, int g, int b) { // This function may get called a lot. To avoid forcing full-screen // updates, only update the palette if the color actually changes. - if (_currentPal[4 * n + 0] != r) { - _currentPal[4 * n + 0] = _globalPalette[n].red = r; + if (_currentPal[3 * n + 0] != r) { + _currentPal[3 * n + 0] = _globalPalette[n].red = r; update = true; } - if (_currentPal[4 * n + 1] != g) { - _currentPal[4 * n + 1] = _globalPalette[n].green = g; + if (_currentPal[3 * n + 1] != g) { + _currentPal[3 * n + 1] = _globalPalette[n].green = g; update = true; } - if (_currentPal[4 * n + 2] != b) { - _currentPal[4 * n + 2] = _globalPalette[n].blue = b; - update = true; - } - if (_currentPal[4 * n + 3] != 0) { - _currentPal[4 * n + 3] = 0; + if (_currentPal[3 * n + 2] != b) { + _currentPal[3 * n + 2] = _globalPalette[n].blue = b; update = true; } @@ -250,7 +245,7 @@ void Gfx::getCurrentPal(PalEntry *src_pal) { int i; byte *ppal; - for (i = 0, ppal = _currentPal; i < PAL_ENTRIES; i++, ppal += 4) { + for (i = 0, ppal = _currentPal; i < PAL_ENTRIES; i++, ppal += 3) { src_pal[i].red = ppal[0]; src_pal[i].green = ppal[1]; src_pal[i].blue = ppal[2]; @@ -285,7 +280,7 @@ void Gfx::palToBlack(PalEntry *srcPal, double percent) { fpercent = 1.0 - fpercent; // Use the correct percentage change per frame for each palette entry - for (i = 0, ppal = _currentPal; i < PAL_ENTRIES; i++, ppal += 4) { + for (i = 0, ppal = _currentPal; i < PAL_ENTRIES; i++, ppal += 3) { if (i < from || i >= from + numcolors) palE = &_globalPalette[i]; else @@ -314,16 +309,15 @@ void Gfx::palToBlack(PalEntry *srcPal, double percent) { } else { ppal[2] = (byte) new_entry; } - ppal[3] = 0; } // Color 0 should always be black in IHNM if (_vm->getGameId() == GID_IHNM) - memset(&_currentPal[0 * 4], 0, 4); + memset(&_currentPal[0 * 3], 0, 3); // Make 256th color black. See bug #1256368 if ((_vm->getPlatform() == Common::kPlatformMacintosh) && !_vm->_scene->isInIntro()) - memset(&_currentPal[255 * 4], 0, 4); + memset(&_currentPal[255 * 3], 0, 3); _system->getPaletteManager()->setPalette(_currentPal, 0, PAL_ENTRIES); } @@ -352,7 +346,7 @@ void Gfx::blackToPal(PalEntry *srcPal, double percent) { fpercent = percent * percent; // Use the correct percentage change per frame for each palette entry - for (i = 0, ppal = _currentPal; i < PAL_ENTRIES; i++, ppal += 4) { + for (i = 0, ppal = _currentPal; i < PAL_ENTRIES; i++, ppal += 3) { if (i < from || i >= from + numcolors) palE = &_globalPalette[i]; else @@ -381,16 +375,15 @@ void Gfx::blackToPal(PalEntry *srcPal, double percent) { } else { ppal[2] = (byte) new_entry; } - ppal[3] = 0; } // Color 0 should always be black in IHNM if (_vm->getGameId() == GID_IHNM) - memset(&_currentPal[0 * 4], 0, 4); + memset(&_currentPal[0 * 3], 0, 3); // Make 256th color black. See bug #1256368 if ((_vm->getPlatform() == Common::kPlatformMacintosh) && !_vm->_scene->isInIntro()) - memset(&_currentPal[255 * 4], 0, 4); + memset(&_currentPal[255 * 3], 0, 3); _system->getPaletteManager()->setPalette(_currentPal, 0, PAL_ENTRIES); } @@ -420,10 +413,10 @@ void Gfx::palFade(PalEntry *srcPal, int16 from, int16 to, int16 start, int16 num if (from > to) percent = 1.0 - percent; - byte fadePal[PAL_ENTRIES * 4]; + byte fadePal[PAL_ENTRIES * 3]; // Use the correct percentage change per frame for each palette entry - for (i = start, ppal = fadePal + start * 4; i < start + numColors; i++, ppal += 4) { + for (i = start, ppal = fadePal + start * 3; i < start + numColors; i++, ppal += 3) { palE = &srcPal[i]; new_entry = (int)(palE->red * percent); @@ -449,13 +442,12 @@ void Gfx::palFade(PalEntry *srcPal, int16 from, int16 to, int16 start, int16 num } else { ppal[2] = (byte) new_entry; } - ppal[3] = 0; } // Color 0 should always be black in IHNM - memset(&fadePal[0 * 4], 0, 4); + memset(&fadePal[0 * 3], 0, 3); - _system->getPaletteManager()->setPalette(&fadePal[start * 4], start, numColors); + _system->getPaletteManager()->setPalette(&fadePal[start * 3], start, numColors); } #endif diff --git a/engines/saga/gfx.h b/engines/saga/gfx.h index 18d88503ce..33fac10c63 100644 --- a/engines/saga/gfx.h +++ b/engines/saga/gfx.h @@ -224,7 +224,7 @@ public: private: Surface _backBuffer; - byte _currentPal[PAL_ENTRIES * 4]; + byte _currentPal[PAL_ENTRIES * 3]; OSystem *_system; SagaEngine *_vm; diff --git a/engines/sci/graphics/cursor.cpp b/engines/sci/graphics/cursor.cpp index e78d3e67cb..b085654d02 100644 --- a/engines/sci/graphics/cursor.cpp +++ b/engines/sci/graphics/cursor.cpp @@ -488,7 +488,7 @@ void GfxCursor::kernelSetMacCursor(GuiResourceId viewNum, int loopNum, int celNu uint16 hotspotX = READ_BE_UINT16(data); uint16 hotspotY = READ_BE_UINT16(data + 2); - static const byte cursorPalette[] = { 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00 }; + static const byte cursorPalette[] = { 0x00, 0x00, 0x00, 0xff, 0xff, 0xff }; CursorMan.replaceCursor(cursorBitmap, 16, 16, hotspotX, hotspotY, 0); CursorMan.replaceCursorPalette(cursorPalette, 1, 2); diff --git a/engines/sci/graphics/palette.cpp b/engines/sci/graphics/palette.cpp index b802f7294a..534890315c 100644 --- a/engines/sci/graphics/palette.cpp +++ b/engines/sci/graphics/palette.cpp @@ -431,7 +431,7 @@ static byte convertMacGammaToSCIGamma(int comp) { void GfxPalette::copySysPaletteToScreen() { // just copy palette to system - byte bpal[4 * 256]; + byte bpal[3 * 256]; // Get current palette, update it and put back g_system->getPaletteManager()->grabPalette(bpal, 0, 256); @@ -439,14 +439,14 @@ void GfxPalette::copySysPaletteToScreen() { for (int16 i = 0; i < 256; i++) { if (colorIsFromMacClut(i)) { // If we've got a Mac CLUT, override the SCI palette with its non-black colors - bpal[i * 4 ] = convertMacGammaToSCIGamma(_macClut[i * 3 ]); - bpal[i * 4 + 1] = convertMacGammaToSCIGamma(_macClut[i * 3 + 1]); - bpal[i * 4 + 2] = convertMacGammaToSCIGamma(_macClut[i * 3 + 2]); + bpal[i * 3 ] = convertMacGammaToSCIGamma(_macClut[i * 3 ]); + bpal[i * 3 + 1] = convertMacGammaToSCIGamma(_macClut[i * 3 + 1]); + bpal[i * 3 + 2] = convertMacGammaToSCIGamma(_macClut[i * 3 + 2]); } else if (_sysPalette.colors[i].used != 0) { // Otherwise, copy to the screen - bpal[i * 4 ] = CLIP(_sysPalette.colors[i].r * _sysPalette.intensity[i] / 100, 0, 255); - bpal[i * 4 + 1] = CLIP(_sysPalette.colors[i].g * _sysPalette.intensity[i] / 100, 0, 255); - bpal[i * 4 + 2] = CLIP(_sysPalette.colors[i].b * _sysPalette.intensity[i] / 100, 0, 255); + bpal[i * 3 ] = CLIP(_sysPalette.colors[i].r * _sysPalette.intensity[i] / 100, 0, 255); + bpal[i * 3 + 1] = CLIP(_sysPalette.colors[i].g * _sysPalette.intensity[i] / 100, 0, 255); + bpal[i * 3 + 2] = CLIP(_sysPalette.colors[i].b * _sysPalette.intensity[i] / 100, 0, 255); } } @@ -609,14 +609,14 @@ void GfxPalette::kernelAssertPalette(GuiResourceId resourceId) { void GfxPalette::kernelSyncScreenPalette() { // just copy palette to system - byte bpal[4 * 256]; + byte bpal[3 * 256]; // Get current palette, update it and put back g_system->getPaletteManager()->grabPalette(bpal, 0, 256); for (int16 i = 1; i < 255; i++) { - _sysPalette.colors[i].r = bpal[i * 4]; - _sysPalette.colors[i].g = bpal[i * 4 + 1]; - _sysPalette.colors[i].b = bpal[i * 4 + 2]; + _sysPalette.colors[i].r = bpal[i * 3]; + _sysPalette.colors[i].g = bpal[i * 3 + 1]; + _sysPalette.colors[i].b = bpal[i * 3 + 2]; } } diff --git a/engines/sci/graphics/transitions.cpp b/engines/sci/graphics/transitions.cpp index e741f66fde..e025a2f9ab 100644 --- a/engines/sci/graphics/transitions.cpp +++ b/engines/sci/graphics/transitions.cpp @@ -302,7 +302,7 @@ void GfxTransitions::copyRectToScreen(const Common::Rect rect, bool blackoutFlag // Note: don't do too many steps in here, otherwise cpu will crap out because of // the load void GfxTransitions::fadeOut() { - byte oldPalette[4 * 256], workPalette[4 * 256]; + byte oldPalette[3 * 256], workPalette[3 * 256]; int16 stepNr, colorNr; // Sierra did not fade in/out color 255 for sci1.1, but they used it in // several pictures (e.g. qfg3 demo/intro), so the fading looked weird @@ -313,17 +313,16 @@ void GfxTransitions::fadeOut() { for (stepNr = 100; stepNr >= 0; stepNr -= 10) { for (colorNr = 1; colorNr < tillColorNr; colorNr++) { if (_palette->colorIsFromMacClut(colorNr)) { - workPalette[colorNr * 4 + 0] = oldPalette[colorNr * 4]; - workPalette[colorNr * 4 + 1] = oldPalette[colorNr * 4 + 1]; - workPalette[colorNr * 4 + 2] = oldPalette[colorNr * 4 + 2]; + workPalette[colorNr * 3 + 0] = oldPalette[colorNr * 3]; + workPalette[colorNr * 3 + 1] = oldPalette[colorNr * 3 + 1]; + workPalette[colorNr * 3 + 2] = oldPalette[colorNr * 3 + 2]; } else { - workPalette[colorNr * 4 + 0] = oldPalette[colorNr * 4] * stepNr / 100; - workPalette[colorNr * 4 + 1] = oldPalette[colorNr * 4 + 1] * stepNr / 100; - workPalette[colorNr * 4 + 2] = oldPalette[colorNr * 4 + 2] * stepNr / 100; + workPalette[colorNr * 3 + 0] = oldPalette[colorNr * 3] * stepNr / 100; + workPalette[colorNr * 3 + 1] = oldPalette[colorNr * 3 + 1] * stepNr / 100; + workPalette[colorNr * 3 + 2] = oldPalette[colorNr * 3 + 2] * stepNr / 100; } } - - g_system->getPaletteManager()->setPalette(workPalette + 4, 1, 254); + g_system->getPaletteManager()->setPalette(workPalette + 3, 1, 254); g_sci->getEngineState()->wait(2); } } diff --git a/engines/scumm/cursor.cpp b/engines/scumm/cursor.cpp index 8e211a5041..f49635d10f 100644 --- a/engines/scumm/cursor.cpp +++ b/engines/scumm/cursor.cpp @@ -176,9 +176,9 @@ void ScummEngine_v70he::setCursorFromImg(uint img, uint room, uint imgindex) { void ScummEngine_v70he::setDefaultCursor() { const uint16 *src; int i, j; - static const byte palette[] = {0, 0, 0, 0, - 0xff, 0xff, 0xff, 0, - 0, 0, 0, 0}; + static const byte palette[] = {0, 0, 0, + 0xff, 0xff, 0xff, + 0, 0, 0, }; if (_bytesPerPixel == 2) { for (i = 0; i < 1024; i++) diff --git a/engines/scumm/he/cup_player_he.cpp b/engines/scumm/he/cup_player_he.cpp index 516ff6b977..79bb47aafc 100644 --- a/engines/scumm/he/cup_player_he.cpp +++ b/engines/scumm/he/cup_player_he.cpp @@ -298,9 +298,7 @@ void CUP_Player::handleSFXB(Common::SeekableReadStream &dataStream, uint32 dataS } void CUP_Player::handleRGBS(Common::SeekableReadStream &dataStream, uint32 dataSize) { - for (int i = 0; i < 256; i++) { - dataStream.read(&_paletteData[i * 4], 3); - } + dataStream.read(_paletteData, 256 * 3); _paletteChanged = true; } diff --git a/engines/scumm/he/cup_player_he.h b/engines/scumm/he/cup_player_he.h index 1b1c32d86f..93146fdf85 100644 --- a/engines/scumm/he/cup_player_he.h +++ b/engines/scumm/he/cup_player_he.h @@ -90,7 +90,7 @@ protected: int _playbackRate; int _width, _height; - uint8 _paletteData[256 * 4]; + uint8 _paletteData[256 * 3]; bool _paletteChanged; uint8 *_offscreenBuffer; diff --git a/engines/scumm/he/palette_he.cpp b/engines/scumm/he/palette_he.cpp index c7ed9e64a8..b42d6e97e2 100644 --- a/engines/scumm/he/palette_he.cpp +++ b/engines/scumm/he/palette_he.cpp @@ -380,21 +380,8 @@ void ScummEngine_v99he::updatePalette() { return; int num = _palDirtyMax - _palDirtyMin + 1; - int i; - - byte palette_colors[1024]; - byte *p = palette_colors; - - for (i = _palDirtyMin; i <= _palDirtyMax; i++) { - byte *data = _hePalettes + 1024 + i * 3; - - *p++ = data[0]; - *p++ = data[1]; - *p++ = data[2]; - *p++ = 0; - } - _system->getPaletteManager()->setPalette(palette_colors, _palDirtyMin, num); + _system->getPaletteManager()->setPalette(_hePalettes + 1024 + _palDirtyMin * 3, _palDirtyMin, num); _palDirtyMax = -1; _palDirtyMin = 256; diff --git a/engines/scumm/palette.cpp b/engines/scumm/palette.cpp index 52592cd90e..18784151b7 100644 --- a/engines/scumm/palette.cpp +++ b/engines/scumm/palette.cpp @@ -1081,7 +1081,7 @@ void ScummEngine::updatePalette() { int num = _palDirtyMax - first + 1; int i; - byte palette_colors[1024]; + byte palette_colors[3 * 256]; byte *p = palette_colors; for (i = _palDirtyMin; i <= _palDirtyMax; i++) { @@ -1108,12 +1108,10 @@ void ScummEngine::updatePalette() { *p++ = brightness; *p++ = brightness; *p++ = brightness; - *p++ = 0; } else { *p++ = data[0]; *p++ = data[1]; *p++ = data[2]; - *p++ = 0; } } @@ -1126,7 +1124,7 @@ void ScummEngine::updatePalette() { p = palette_colors; for (i = first; i < first + num; ++i) { _16BitPalette[i] = get16BitColor(p[0], p[1], p[2]); - p += 4; + p += 3; } return; } diff --git a/engines/scumm/smush/smush_player.cpp b/engines/scumm/smush/smush_player.cpp index ad8a135a7c..fe2b9d99ff 100644 --- a/engines/scumm/smush/smush_player.cpp +++ b/engines/scumm/smush/smush_player.cpp @@ -1217,19 +1217,7 @@ void SmushPlayer::play(const char *filename, int32 speed, int32 offset, int32 st _vm->parseEvents(); _vm->processInput(); if (_palDirtyMax >= _palDirtyMin) { - byte palette_colors[1024]; - byte *p = palette_colors; - - for (int i = _palDirtyMin; i <= _palDirtyMax; i++) { - byte *data = _pal + i * 3; - - *p++ = data[0]; - *p++ = data[1]; - *p++ = data[2]; - *p++ = 0; - } - - _vm->_system->getPaletteManager()->setPalette(palette_colors, _palDirtyMin, _palDirtyMax - _palDirtyMin + 1); + _vm->_system->getPaletteManager()->setPalette(_pal + _palDirtyMin * 3, _palDirtyMin, _palDirtyMax - _palDirtyMin + 1); _palDirtyMax = -1; _palDirtyMin = 256; diff --git a/engines/sky/screen.cpp b/engines/sky/screen.cpp index dae158e41b..a77017de38 100644 --- a/engines/sky/screen.cpp +++ b/engines/sky/screen.cpp @@ -63,7 +63,7 @@ Screen::Screen(OSystem *pSystem, Disk *pDisk, SkyCompact *skyCompact) { _skyCompact = skyCompact; int i; - uint8 tmpPal[1024]; + uint8 tmpPal[VGA_COLOURS * 3]; _gameGrid = (uint8 *)malloc(GRID_X * GRID_Y * 2); forceRefresh(); @@ -72,14 +72,13 @@ Screen::Screen(OSystem *pSystem, Disk *pDisk, SkyCompact *skyCompact) { _scrollScreen = NULL; //blank the first 240 colors of the palette - memset(tmpPal, 0, GAME_COLOURS * 4); + memset(tmpPal, 0, GAME_COLOURS * 3); //set the remaining colors for (i = 0; i < (VGA_COLOURS-GAME_COLOURS); i++) { - tmpPal[4 * GAME_COLOURS + i * 4] = (_top16Colours[i * 3] << 2) + (_top16Colours[i * 3] >> 4); - tmpPal[4 * GAME_COLOURS + i * 4 + 1] = (_top16Colours[i * 3 + 1] << 2) + (_top16Colours[i * 3 + 1] >> 4); - tmpPal[4 * GAME_COLOURS + i * 4 + 2] = (_top16Colours[i * 3 + 2] << 2) + (_top16Colours[i * 3 + 2] >> 4); - tmpPal[4 * GAME_COLOURS + i * 4 + 3] = 0x00; + tmpPal[3 * GAME_COLOURS + i * 3 + 0] = (_top16Colours[i * 3 + 0] << 2) + (_top16Colours[i * 3 + 0] >> 4); + tmpPal[3 * GAME_COLOURS + i * 3 + 1] = (_top16Colours[i * 3 + 1] << 2) + (_top16Colours[i * 3 + 1] >> 4); + tmpPal[3 * GAME_COLOURS + i * 3 + 2] = (_top16Colours[i * 3 + 2] << 2) + (_top16Colours[i * 3 + 2] >> 4); } //set the palette @@ -116,8 +115,8 @@ void Screen::setPalette(uint8 *pal) { void Screen::setPaletteEndian(uint8 *pal) { #ifdef SCUMM_BIG_ENDIAN - uint8 endPalette[256 * 3]; - for (uint16 cnt = 0; cnt < 256 * 3; cnt++) + uint8 endPalette[VGA_COLOURS * 3]; + for (uint16 cnt = 0; cnt < VGA_COLOURS * 3; cnt++) endPalette[cnt] = pal[cnt ^ 1]; convertPalette(endPalette, _palette); #else @@ -128,12 +127,12 @@ void Screen::setPaletteEndian(uint8 *pal) { } void Screen::halvePalette() { - uint8 halfPalette[1024]; + uint8 halfPalette[VGA_COLOURS * 3]; + for (uint8 cnt = 0; cnt < GAME_COLOURS; cnt++) { - halfPalette[(cnt << 2) | 0] = _palette[(cnt << 2) | 0] >> 1; - halfPalette[(cnt << 2) | 1] = _palette[(cnt << 2) | 1] >> 1; - halfPalette[(cnt << 2) | 2] = _palette[(cnt << 2) | 2] >> 1; - halfPalette[(cnt << 2) | 3] = 0; + halfPalette[cnt * 3 + 0] = _palette[cnt * 3 + 0] >> 1; + halfPalette[cnt * 3 + 1] = _palette[cnt * 3 + 1] >> 1; + halfPalette[cnt * 3 + 2] = _palette[cnt * 3 + 2] >> 1; } _system->getPaletteManager()->setPalette(halfPalette, 0, GAME_COLOURS); } @@ -165,14 +164,14 @@ void Screen::showScreen(uint8 *pScreen) { _system->updateScreen(); } -void Screen::convertPalette(uint8 *inPal, uint8* outPal) { //convert 3 byte 0..63 rgb to 4byte 0..255 rgbx +//convert 3 byte 0..63 rgb to 3 byte 0..255 rgb +void Screen::convertPalette(uint8 *inPal, uint8* outPal) { int i; for (i = 0; i < VGA_COLOURS; i++) { - outPal[4 * i] = (inPal[3 * i] << 2) + (inPal[3 * i] >> 4); - outPal[4 * i + 1] = (inPal[3 * i + 1] << 2) + (inPal[3 * i + 1] >> 4); - outPal[4 * i + 2] = (inPal[3 * i + 2] << 2) + (inPal[3 * i + 2] >> 4); - outPal[4 * i + 3] = 0x00; + outPal[3 * i + 0] = (inPal[3 * i + 0] << 2) + (inPal[3 * i + 0] >> 4); + outPal[3 * i + 1] = (inPal[3 * i + 1] << 2) + (inPal[3 * i + 1] >> 4); + outPal[3 * i + 2] = (inPal[3 * i + 2] << 2) + (inPal[3 * i + 2] >> 4); } } @@ -248,7 +247,7 @@ void Screen::fnFadeDown(uint32 scroll) { uint32 delayTime = _system->getMillis(); for (uint8 cnt = 0; cnt < 32; cnt++) { delayTime += 20; - palette_fadedown_helper((uint32 *)_palette, GAME_COLOURS); + palette_fadedown_helper(_palette, GAME_COLOURS); _system->getPaletteManager()->setPalette(_palette, 0, GAME_COLOURS); _system->updateScreen(); int32 waitTime = (int32)delayTime - _system->getMillis(); @@ -266,23 +265,24 @@ void Screen::fnFadeDown(uint32 scroll) { } } -void Screen::palette_fadedown_helper(uint32 *pal, uint num) { - byte *p = (byte *)pal; - +void Screen::palette_fadedown_helper(uint8 *pal, uint num) { do { - if (p[0] >= 8) - p[0] -= 8; + if (pal[0] >= 8) + pal[0] -= 8; else - p[0] = 0; - if (p[1] >= 8) - p[1] -= 8; + pal[0] = 0; + + if (pal[1] >= 8) + pal[1] -= 8; else - p[1] = 0; - if (p[2] >= 8) - p[2] -= 8; + pal[1] = 0; + + if (pal[2] >= 8) + pal[2] -= 8; else - p[2] = 0; - p += sizeof(uint32); + pal[2] = 0; + + pal += 3; } while (--num); } @@ -296,20 +296,23 @@ void Screen::paletteFadeUp(uint16 fileNr) { } void Screen::paletteFadeUp(uint8 *pal) { - byte tmpPal[1024]; + byte tmpPal[VGA_COLOURS * 3]; convertPalette(pal, tmpPal); uint32 delayTime = _system->getMillis(); for (uint8 cnt = 1; cnt <= 32; cnt++) { delayTime += 20; + for (uint8 colCnt = 0; colCnt < GAME_COLOURS; colCnt++) { - _palette[(colCnt << 2) | 0] = (tmpPal[(colCnt << 2) | 0] * cnt) >> 5; - _palette[(colCnt << 2) | 1] = (tmpPal[(colCnt << 2) | 1] * cnt) >> 5; - _palette[(colCnt << 2) | 2] = (tmpPal[(colCnt << 2) | 2] * cnt) >> 5; + _palette[colCnt * 3 + 0] = (tmpPal[colCnt * 3 + 0] * cnt) >> 5; + _palette[colCnt * 3 + 1] = (tmpPal[colCnt * 3 + 1] * cnt) >> 5; + _palette[colCnt * 3 + 2] = (tmpPal[colCnt * 3 + 2] * cnt) >> 5; } + _system->getPaletteManager()->setPalette(_palette, 0, GAME_COLOURS); _system->updateScreen(); + int32 waitTime = (int32)delayTime - _system->getMillis(); if (waitTime < 0) waitTime = 0; @@ -328,8 +331,8 @@ void Screen::fnFadeUp(uint32 palNum, uint32 scroll) { if (palette == NULL) error("Screen::fnFadeUp: can't fetch compact %X", palNum); #ifdef SCUMM_BIG_ENDIAN - byte tmpPal[256 * 3]; - for (uint16 cnt = 0; cnt < 256*3; cnt++) + byte tmpPal[VGA_COLOURS * 3]; + for (uint16 cnt = 0; cnt < VGA_COLOURS * 3; cnt++) tmpPal[cnt] = palette[cnt ^ 1]; paletteFadeUp(tmpPal); #else diff --git a/engines/sky/screen.h b/engines/sky/screen.h index 5310aebeee..69a9a2fc8f 100644 --- a/engines/sky/screen.h +++ b/engines/sky/screen.h @@ -100,8 +100,8 @@ private: OSystem *_system; Disk *_skyDisk; SkyCompact *_skyCompact; - static uint8 _top16Colours[16*3]; - uint8 _palette[1024]; + static uint8 _top16Colours[16 * 3]; + uint8 _palette[VGA_COLOURS * 3]; uint32 _currentPalette; uint8 _seqGrid[20 * 12]; @@ -121,7 +121,7 @@ private: //- more regular screen.asm + layer.asm routines void convertPalette(uint8 *inPal, uint8* outPal); - void palette_fadedown_helper(uint32 *pal, uint num); + void palette_fadedown_helper(uint8 *pal, uint num); //- sprite.asm routines // fixme: get rid of these globals diff --git a/engines/sword1/animation.cpp b/engines/sword1/animation.cpp index fa876b565f..60176be1a9 100644 --- a/engines/sword1/animation.cpp +++ b/engines/sword1/animation.cpp @@ -174,7 +174,7 @@ void MoviePlayer::play() { // previous location would be momentarily drawn, before switching to // the new one. Work around this by setting the palette to black. - byte pal[4 * 256]; + byte pal[3 * 256]; memset(pal, 0, sizeof(pal)); _system->getPaletteManager()->setPalette(pal, 0, 256); } diff --git a/engines/sword1/control.cpp b/engines/sword1/control.cpp index c61d0b7c85..d4f6bfd1fe 100644 --- a/engines/sword1/control.cpp +++ b/engines/sword1/control.cpp @@ -248,13 +248,13 @@ void Control::askForCd() { fontId = CZECH_SR_FONT; _font = (uint8*)_resMan->openFetchRes(fontId); uint8 *pal = (uint8*)_resMan->openFetchRes(SR_PALETTE); - uint8 *palOut = (uint8*)malloc(256 * 4); + uint8 *palOut = (uint8*)malloc(256 * 3); for (uint16 cnt = 1; cnt < 256; cnt++) { - palOut[cnt * 4 + 0] = pal[cnt * 3 + 0] << 2; - palOut[cnt * 4 + 1] = pal[cnt * 3 + 1] << 2; - palOut[cnt * 4 + 2] = pal[cnt * 3 + 2] << 2; + palOut[cnt * 3 + 0] = pal[cnt * 3 + 0] << 2; + palOut[cnt * 3 + 1] = pal[cnt * 3 + 1] << 2; + palOut[cnt * 3 + 2] = pal[cnt * 3 + 2] << 2; } - palOut[0] = palOut[1] = palOut[2] = palOut[3] = 0; + palOut[0] = palOut[1] = palOut[2] = 0; _resMan->resClose(SR_PALETTE); _system->getPaletteManager()->setPalette(palOut, 0, 256); free(palOut); @@ -318,13 +318,13 @@ uint8 Control::runPanel() { _redFont = (uint8*)_resMan->openFetchRes(redFontId); uint8 *pal = (uint8*)_resMan->openFetchRes(SR_PALETTE); - uint8 *palOut = (uint8*)malloc(256 * 4); + uint8 *palOut = (uint8*)malloc(256 * 3); for (uint16 cnt = 1; cnt < 256; cnt++) { - palOut[cnt * 4 + 0] = pal[cnt * 3 + 0] << 2; - palOut[cnt * 4 + 1] = pal[cnt * 3 + 1] << 2; - palOut[cnt * 4 + 2] = pal[cnt * 3 + 2] << 2; + palOut[cnt * 3 + 0] = pal[cnt * 3 + 0] << 2; + palOut[cnt * 3 + 1] = pal[cnt * 3 + 1] << 2; + palOut[cnt * 3 + 2] = pal[cnt * 3 + 2] << 2; } - palOut[0] = palOut[1] = palOut[2] = palOut[3] = 0; + palOut[0] = palOut[1] = palOut[2] = 0; _resMan->resClose(SR_PALETTE); _system->getPaletteManager()->setPalette(palOut, 0, 256); free(palOut); diff --git a/engines/sword1/screen.cpp b/engines/sword1/screen.cpp index 031ab74d9a..24fd5b502f 100644 --- a/engines/sword1/screen.cpp +++ b/engines/sword1/screen.cpp @@ -144,19 +144,19 @@ void Screen::fnSetPalette(uint8 start, uint16 length, uint32 id, bool fadeUp) { } for (uint32 cnt = 0; cnt < length; cnt++) { - _targetPalette[(start + cnt) * 4 + 0] = palData[cnt * 3 + 0] << 2; - _targetPalette[(start + cnt) * 4 + 1] = palData[cnt * 3 + 1] << 2; - _targetPalette[(start + cnt) * 4 + 2] = palData[cnt * 3 + 2] << 2; + _targetPalette[(start + cnt) * 3 + 0] = palData[cnt * 3 + 0] << 2; + _targetPalette[(start + cnt) * 3 + 1] = palData[cnt * 3 + 1] << 2; + _targetPalette[(start + cnt) * 3 + 2] = palData[cnt * 3 + 2] << 2; } _resMan->resClose(id); _isBlack = false; if (fadeUp) { _fadingStep = 1; _fadingDirection = FADE_UP; - memset(_currentPalette, 0, 256 * 4); + memset(_currentPalette, 0, 256 * 3); _system->getPaletteManager()->setPalette(_currentPalette, 0, 256); } else - _system->getPaletteManager()->setPalette(_targetPalette + 4 * start, start, length); + _system->getPaletteManager()->setPalette(_targetPalette + 3 * start, start, length); } void Screen::fullRefresh() { @@ -1125,11 +1125,11 @@ void Screen::flushPsxCache() { void Screen::fadePalette() { if (_fadingStep == 16) - memcpy(_currentPalette, _targetPalette, 256 * 4); + memcpy(_currentPalette, _targetPalette, 256 * 3); else if ((_fadingStep == 1) && (_fadingDirection == FADE_DOWN)) { - memset(_currentPalette, 0, 4 * 256); + memset(_currentPalette, 0, 3 * 256); } else - for (uint16 cnt = 0; cnt < 256 * 4; cnt++) + for (uint16 cnt = 0; cnt < 256 * 3; cnt++) _currentPalette[cnt] = (_targetPalette[cnt] * _fadingStep) >> 4; _fadingStep += _fadingDirection; diff --git a/engines/sword1/screen.h b/engines/sword1/screen.h index fc998c6f28..88326a730e 100644 --- a/engines/sword1/screen.h +++ b/engines/sword1/screen.h @@ -161,8 +161,8 @@ private: static RoomDef _roomDefTable[TOTAL_ROOMS]; // from ROOMS.C (not const, see fnSetParallax) - uint8 _targetPalette[256 * 4]; - uint8 _currentPalette[256 * 4]; // for fading + uint8 _targetPalette[256 * 3]; + uint8 _currentPalette[256 * 3]; // for fading uint8 _fadingStep; int8 _fadingDirection; // 1 for fade up, -1 for fade down bool _isBlack; // if the logic already faded down the palette, this is set to show the diff --git a/engines/sword2/console.cpp b/engines/sword2/console.cpp index 6f4665a34c..bca3cd6184 100644 --- a/engines/sword2/console.cpp +++ b/engines/sword2/console.cpp @@ -319,7 +319,7 @@ bool Debugger::Cmd_Starts(int argc, const char **argv) { } bool Debugger::Cmd_Start(int argc, const char **argv) { - uint8 pal[4] = { 255, 255, 255, 0 }; + uint8 pal[3] = { 255, 255, 255 }; if (argc != 2) { DebugPrintf("Usage: %s number\n", argv[0]); diff --git a/engines/sword2/function.cpp b/engines/sword2/function.cpp index 5bc82b5f9e..5e570fbaad 100644 --- a/engines/sword2/function.cpp +++ b/engines/sword2/function.cpp @@ -1897,11 +1897,11 @@ int32 Logic::fnColour(int32 *params) { #define GREEN 3 #define BLUE 4 -static const uint8 black[4] = { 0, 0, 0, 0 }; -static const uint8 white[4] = { 255, 255, 255, 0 }; -static const uint8 red[4] = { 255, 0, 0, 0 }; -static const uint8 green[4] = { 0, 255, 0, 0 }; -static const uint8 blue[4] = { 0, 0, 255, 0 }; +static const uint8 black[3] = { 0, 0, 0 }; +static const uint8 white[3] = { 255, 255, 255 }; +static const uint8 red[3] = { 255, 0, 0 }; +static const uint8 green[3] = { 0, 255, 0 }; +static const uint8 blue[3] = { 0, 0, 255 }; #endif int32 Logic::fnFlash(int32 *params) { @@ -2163,7 +2163,7 @@ int32 Logic::fnPlaySequence(int32 *params) { // zero the entire palette in case we're about to fade up! - byte pal[4 * 256]; + byte pal[3 * 256]; memset(pal, 0, sizeof(pal)); _vm->_screen->setPalette(0, 256, pal, RDPAL_INSTANT); diff --git a/engines/sword2/mouse.cpp b/engines/sword2/mouse.cpp index 7998079944..c8e9387cb7 100644 --- a/engines/sword2/mouse.cpp +++ b/engines/sword2/mouse.cpp @@ -1410,8 +1410,8 @@ void Mouse::addHuman() { // info if (_vm->_debugger->_testingSnR) { - uint8 black[4] = { 0, 0, 0, 0 }; - uint8 white[4] = { 255, 255, 255, 0 }; + uint8 black[3] = { 0, 0, 0 }; + uint8 white[3] = { 255, 255, 255 }; // Testing logic scripts by simulating instant Save & Restore diff --git a/engines/sword2/palette.cpp b/engines/sword2/palette.cpp index 2b9b5b7f49..b348fd6bb5 100644 --- a/engines/sword2/palette.cpp +++ b/engines/sword2/palette.cpp @@ -53,7 +53,8 @@ void Screen::startNewPalette() { if (!Sword2Engine::isPsx()) memcpy(_paletteMatch, _vm->fetchPaletteMatchTable(screenFile), PALTABLESIZE); - setPalette(0, 256, _vm->fetchPalette(screenFile), RDPAL_FADE); + _vm->fetchPalette(screenFile, _palette); + setPalette(0, 256, _palette, RDPAL_FADE); // Indicating that it's a screen palette _lastPaletteRes = 0; @@ -110,12 +111,17 @@ void Screen::setFullPalette(int32 palRes) { // palettes have a bright colour 0 although it should come out // as black in the game! - pal[0] = 0; - pal[1] = 0; - pal[2] = 0; - pal[3] = 0; + _palette[0] = 0; + _palette[1] = 0; + _palette[2] = 0; - setPalette(0, 256, pal, RDPAL_INSTANT); + for (uint i = 4, j = 3; i < 4 * 256; i += 4, j += 3) { + _palette[j + 0] = pal[i + 0]; + _palette[j + 1] = pal[i + 1]; + _palette[j + 2] = pal[i + 2]; + } + + setPalette(0, 256, _palette, RDPAL_INSTANT); _vm->_resman->closeResource(palRes); } else { if (_thisScreen.background_layer_id) { @@ -126,7 +132,8 @@ void Screen::setFullPalette(int32 palRes) { if (!Sword2Engine::isPsx()) memcpy(_paletteMatch, _vm->fetchPaletteMatchTable(data), PALTABLESIZE); - setPalette(0, 256, _vm->fetchPalette(data), RDPAL_INSTANT); + _vm->fetchPalette(data, _palette); + setPalette(0, 256, _palette, RDPAL_INSTANT); _vm->_resman->closeResource(_thisScreen.background_layer_id); } else error("setFullPalette(0) called, but no current screen available"); @@ -162,7 +169,7 @@ uint8 Screen::quickMatch(uint8 r, uint8 g, uint8 b) { void Screen::setPalette(int16 startEntry, int16 noEntries, byte *colourTable, uint8 fadeNow) { assert(noEntries > 0); - memcpy(&_palette[4 * startEntry], colourTable, noEntries * 4); + memmove(&_palette[3 * startEntry], colourTable, noEntries * 3); if (fadeNow == RDPAL_INSTANT) { setSystemPalette(_palette, startEntry, noEntries); @@ -232,7 +239,7 @@ void Screen::waitForFade() { void Screen::fadeServer() { static int32 previousTime = 0; - byte fadePalette[256 * 4]; + byte fadePalette[256 * 3]; byte *newPalette = fadePalette; int32 currentTime; int16 fadeMultiplier; @@ -257,9 +264,9 @@ void Screen::fadeServer() { } else { fadeMultiplier = (int16)(((int32)(currentTime - _fadeStartTime) * 256) / _fadeTotalTime); for (i = 0; i < 256; i++) { - newPalette[i * 4 + 0] = (_palette[i * 4 + 0] * fadeMultiplier) >> 8; - newPalette[i * 4 + 1] = (_palette[i * 4 + 1] * fadeMultiplier) >> 8; - newPalette[i * 4 + 2] = (_palette[i * 4 + 2] * fadeMultiplier) >> 8; + newPalette[i * 3 + 0] = (_palette[i * 3 + 0] * fadeMultiplier) >> 8; + newPalette[i * 3 + 1] = (_palette[i * 3 + 1] * fadeMultiplier) >> 8; + newPalette[i * 3 + 2] = (_palette[i * 3 + 2] * fadeMultiplier) >> 8; } } } else { @@ -269,9 +276,9 @@ void Screen::fadeServer() { } else { fadeMultiplier = (int16)(((int32)(_fadeTotalTime - (currentTime - _fadeStartTime)) * 256) / _fadeTotalTime); for (i = 0; i < 256; i++) { - newPalette[i * 4 + 0] = (_palette[i * 4 + 0] * fadeMultiplier) >> 8; - newPalette[i * 4 + 1] = (_palette[i * 4 + 1] * fadeMultiplier) >> 8; - newPalette[i * 4 + 2] = (_palette[i * 4 + 2] * fadeMultiplier) >> 8; + newPalette[i * 3 + 0] = (_palette[i * 3 + 0] * fadeMultiplier) >> 8; + newPalette[i * 3 + 1] = (_palette[i * 3 + 1] * fadeMultiplier) >> 8; + newPalette[i * 3 + 2] = (_palette[i * 3 + 2] * fadeMultiplier) >> 8; } } } @@ -284,9 +291,9 @@ void Screen::setSystemPalette(const byte *colors, uint start, uint num) { const byte *palette; if (_dimPalette) { - byte pal[256 * 4]; + byte pal[256 * 3]; - for (uint i = start * 4; i < 4 * (start + num); i++) + for (uint i = start * 3; i < 3 * (start + num); i++) pal[i] = colors[i] / 2; palette = pal; diff --git a/engines/sword2/protocol.cpp b/engines/sword2/protocol.cpp index 6c47c07401..ef2c622287 100644 --- a/engines/sword2/protocol.cpp +++ b/engines/sword2/protocol.cpp @@ -40,7 +40,7 @@ namespace Sword2 { * of the screen file. */ -byte *Sword2Engine::fetchPalette(byte *screenFile) { +void Sword2Engine::fetchPalette(byte *screenFile, byte *palBuffer) { byte *palette; if (isPsx()) { // PSX version doesn't have a "MultiScreenHeader", instead there's a ScreenHeader and a tag @@ -56,12 +56,15 @@ byte *Sword2Engine::fetchPalette(byte *screenFile) { // palettes have a bright colour 0 it should come out as black in the // game. - palette[0] = 0; - palette[1] = 0; - palette[2] = 0; - palette[3] = 0; + palBuffer[0] = 0; + palBuffer[1] = 0; + palBuffer[2] = 0; - return palette; + for (uint i = 4, j = 3; i < 4 * 256; i += 4, j += 3) { + palBuffer[j + 0] = palette[i + 0]; + palBuffer[j + 1] = palette[i + 1]; + palBuffer[j + 2] = palette[i + 2]; + } } /** diff --git a/engines/sword2/render.cpp b/engines/sword2/render.cpp index 99295be571..a71d503d95 100644 --- a/engines/sword2/render.cpp +++ b/engines/sword2/render.cpp @@ -194,21 +194,21 @@ void Screen::scaleImageGood(byte *dst, uint16 dstPitch, uint16 dstWidth, uint16 } if (!transparent) { - uint32 r1 = _palette[c1 * 4 + 0]; - uint32 g1 = _palette[c1 * 4 + 1]; - uint32 b1 = _palette[c1 * 4 + 2]; + uint32 r1 = _palette[c1 * 3 + 0]; + uint32 g1 = _palette[c1 * 3 + 1]; + uint32 b1 = _palette[c1 * 3 + 2]; - uint32 r2 = _palette[c2 * 4 + 0]; - uint32 g2 = _palette[c2 * 4 + 1]; - uint32 b2 = _palette[c2 * 4 + 2]; + uint32 r2 = _palette[c2 * 3 + 0]; + uint32 g2 = _palette[c2 * 3 + 1]; + uint32 b2 = _palette[c2 * 3 + 2]; - uint32 r3 = _palette[c3 * 4 + 0]; - uint32 g3 = _palette[c3 * 4 + 1]; - uint32 b3 = _palette[c3 * 4 + 2]; + uint32 r3 = _palette[c3 * 3 + 0]; + uint32 g3 = _palette[c3 * 3 + 1]; + uint32 b3 = _palette[c3 * 3 + 2]; - uint32 r4 = _palette[c4 * 4 + 0]; - uint32 g4 = _palette[c4 * 4 + 1]; - uint32 b4 = _palette[c4 * 4 + 2]; + uint32 r4 = _palette[c4 * 3 + 0]; + uint32 g4 = _palette[c4 * 3 + 1]; + uint32 b4 = _palette[c4 * 3 + 2]; uint32 r5 = (r1 * xFrac + r2 * (dstWidth - xFrac)) / dstWidth; uint32 g5 = (g1 * xFrac + g2 * (dstWidth - xFrac)) / dstWidth; diff --git a/engines/sword2/screen.cpp b/engines/sword2/screen.cpp index 1e45c0fc1f..8c2db79297 100644 --- a/engines/sword2/screen.cpp +++ b/engines/sword2/screen.cpp @@ -355,8 +355,8 @@ void Screen::buildDisplay() { */ void Screen::displayMsg(byte *text, int time) { - byte pal[256 * 4]; - byte oldPal[256 * 4]; + byte pal[256 * 3]; + byte oldPal[256 * 3]; debug(2, "DisplayMsg: %s", text); @@ -402,9 +402,9 @@ void Screen::displayMsg(byte *text, int time) { memcpy(oldPal, _palette, sizeof(oldPal)); memset(pal, 0, sizeof(pal)); - pal[187 * 4 + 0] = 255; - pal[187 * 4 + 1] = 255; - pal[187 * 4 + 2] = 255; + pal[187 * 3 + 0] = 255; + pal[187 * 3 + 1] = 255; + pal[187 * 3 + 2] = 255; setPalette(0, 256, pal, RDPAL_FADE); fadeUp(); @@ -926,17 +926,16 @@ void Screen::rollCredits() { uint16 logoWidth = 0; uint16 logoHeight = 0; byte *logoData = NULL; - byte palette[256 * 4]; + byte palette[256 * 3]; if (f.open("credits.bmp")) { logoWidth = f.readUint16LE(); logoHeight = f.readUint16LE(); for (i = 0; i < 256; i++) { - palette[i * 4 + 0] = f.readByte() << 2; - palette[i * 4 + 1] = f.readByte() << 2; - palette[i * 4 + 2] = f.readByte() << 2; - palette[i * 4 + 3] = 0; + palette[i * 3 + 0] = f.readByte() << 2; + palette[i * 3 + 1] = f.readByte() << 2; + palette[i * 3 + 2] = f.readByte() << 2; } logoData = (byte *)malloc(logoWidth * logoHeight); @@ -946,10 +945,9 @@ void Screen::rollCredits() { } else { warning("Can't find credits.bmp"); memset(palette, 0, sizeof(palette)); - palette[14 * 4 + 0] = 252; - palette[14 * 4 + 1] = 252; - palette[14 * 4 + 2] = 252; - palette[14 * 4 + 3] = 0; + palette[14 * 3 + 0] = 252; + palette[14 * 3 + 1] = 252; + palette[14 * 3 + 2] = 252; } setPalette(0, 256, palette, RDPAL_INSTANT); @@ -1235,7 +1233,8 @@ void Screen::splashScreen() { initialiseBackgroundLayer(NULL); initialiseBackgroundLayer(NULL); - setPalette(0, 256, _vm->fetchPalette(bgfile), RDPAL_FADE); + _vm->fetchPalette(bgfile, _palette); + setPalette(0, 256, _palette, RDPAL_FADE); renderParallax(_vm->fetchBackgroundLayer(bgfile), 2); closeBackgroundLayer(); diff --git a/engines/sword2/screen.h b/engines/sword2/screen.h index 0abaebc5af..46eb53d0db 100644 --- a/engines/sword2/screen.h +++ b/engines/sword2/screen.h @@ -242,7 +242,7 @@ private: uint16 _gridWide; uint16 _gridDeep; - byte _palette[256 * 4]; + byte _palette[256 * 3]; byte _paletteMatch[PALTABLESIZE]; uint8 _fadeStatus; diff --git a/engines/sword2/sprite.cpp b/engines/sword2/sprite.cpp index 7d45f8df4e..255176292a 100644 --- a/engines/sword2/sprite.cpp +++ b/engines/sword2/sprite.cpp @@ -747,9 +747,9 @@ int32 Screen::drawSprite(SpriteInfo *s) { for (i = 0; i < rs.height(); i++) { for (j = 0; j < rs.width(); j++) { if (src[j] && lightMap[j]) { - uint8 r = ((32 - lightMap[j]) * _palette[src[j] * 4 + 0]) >> 5; - uint8 g = ((32 - lightMap[j]) * _palette[src[j] * 4 + 1]) >> 5; - uint8 b = ((32 - lightMap[j]) * _palette[src[j] * 4 + 2]) >> 5; + uint8 r = ((32 - lightMap[j]) * _palette[src[j] * 3 + 0]) >> 5; + uint8 g = ((32 - lightMap[j]) * _palette[src[j] * 3 + 1]) >> 5; + uint8 b = ((32 - lightMap[j]) * _palette[src[j] * 3 + 2]) >> 5; src[j] = quickMatch(r, g, b); } } @@ -787,12 +787,12 @@ int32 Screen::drawSprite(SpriteInfo *s) { for (i = 0; i < rs.height(); i++) { for (j = 0; j < rs.width(); j++) { if (src[j]) { - uint8 r1 = _palette[src[j] * 4 + 0]; - uint8 g1 = _palette[src[j] * 4 + 1]; - uint8 b1 = _palette[src[j] * 4 + 2]; - uint8 r2 = _palette[dst[j] * 4 + 0]; - uint8 g2 = _palette[dst[j] * 4 + 1]; - uint8 b2 = _palette[dst[j] * 4 + 2]; + uint8 r1 = _palette[src[j] * 3 + 0]; + uint8 g1 = _palette[src[j] * 3 + 1]; + uint8 b1 = _palette[src[j] * 3 + 2]; + uint8 r2 = _palette[dst[j] * 3 + 0]; + uint8 g2 = _palette[dst[j] * 3 + 1]; + uint8 b2 = _palette[dst[j] * 3 + 2]; uint8 r = (r1 * n + r2 * (8 - n)) >> 3; uint8 g = (g1 * n + g2 * (8 - n)) >> 3; diff --git a/engines/sword2/sword2.h b/engines/sword2/sword2.h index 302627b635..e741c51ce1 100644 --- a/engines/sword2/sword2.h +++ b/engines/sword2/sword2.h @@ -206,7 +206,7 @@ public: bool heldIsInInventory(); #endif - byte *fetchPalette(byte *screenFile); + void fetchPalette(byte *screenFile, byte *palBuffer); byte *fetchScreenHeader(byte *screenFile); byte *fetchLayerHeader(byte *screenFile, uint16 layerNo); byte *fetchShadingMask(byte *screenFile); diff --git a/engines/teenagent/scene.cpp b/engines/teenagent/scene.cpp index 4b37576846..f9756b5b91 100644 --- a/engines/teenagent/scene.cpp +++ b/engines/teenagent/scene.cpp @@ -1177,12 +1177,10 @@ bool Scene::processEventQueue() { void Scene::setPalette(unsigned mul) { //debug(0, "setPalette(%u)", mul); - byte p[1024]; + byte p[3*256]; - memset(p, 0, 1024); - for (int i = 0; i < 256; ++i) { - for (int c = 0; c < 3; ++c) - p[i * 4 + c] = (unsigned)palette[i * 3 + c] * mul; + for (int i = 0; i < 3*256; ++i) { + p[i] = (unsigned)palette[i] * mul; } _system->getPaletteManager()->setPalette(p, 0, 256); diff --git a/engines/teenagent/teenagent.cpp b/engines/teenagent/teenagent.cpp index a492237adb..e66de70079 100644 --- a/engines/teenagent/teenagent.cpp +++ b/engines/teenagent/teenagent.cpp @@ -290,18 +290,12 @@ bool TeenAgentEngine::showCDLogo() { return true; byte bg[0xfa00]; - byte palette[0x400]; + byte palette[3*256]; cdlogo.read(bg, sizeof(bg)); - memset(palette, 0, sizeof(palette)); - - for(uint c = 0; c < 0x100; ++c) { - uint idx = c * 4; - cdlogo.read(palette + idx, 3); - palette[idx] *= 4; - palette[idx + 1] *= 4; - palette[idx + 2] *= 4; - } + cdlogo.read(palette, sizeof(palette)); + for (uint c = 0; c < 3*256; ++c) + palette[c] *= 4; _system->getPaletteManager()->setPalette(palette, 0, 0x100); _system->copyRectToScreen(bg, 320, 0, 0, 320, 200); _system->updateScreen(); @@ -323,22 +317,16 @@ bool TeenAgentEngine::showLogo() { return true; byte bg[0xfa00]; - byte palette[0x400]; + byte palette[3*256]; Common::ScopedPtr<Common::SeekableReadStream> frame(logo.getStream(1)); if (!frame) return true; frame->read(bg, sizeof(bg)); - memset(palette, 0, sizeof(palette)); - - for(uint c = 0; c < 0x100; ++c) { - uint idx = c * 4; - frame->read(palette + idx, 3); - palette[idx] *= 4; - palette[idx + 1] *= 4; - palette[idx + 2] *= 4; - } + frame->read(palette, sizeof(palette)); + for (uint c = 0; c < 3*256; ++c) + palette[c] *= 4; _system->getPaletteManager()->setPalette(palette, 0, 0x100); uint n = logo.fileCount(); @@ -375,16 +363,12 @@ bool TeenAgentEngine::showMetropolis() { FilePack varia; varia.open("varia.res"); - byte palette[0x400]; - memset(palette, 0, sizeof(palette)); + byte palette[3*256]; { Common::ScopedPtr<Common::SeekableReadStream> s(varia.getStream(5)); - for(uint c = 0; c < 0x400; c += 4) { - s->read(palette + c, 3); + s->read(palette, sizeof(palette)); + for (uint c = 0; c < 3*256; ++c) palette[c] *= 4; - palette[c + 1] *= 4; - palette[c + 2] *= 4; - } } _system->getPaletteManager()->setPalette(palette, 0, 0x100); diff --git a/engines/testbed/graphics.cpp b/engines/testbed/graphics.cpp index ed51b33e94..a0e2754fe4 100644 --- a/engines/testbed/graphics.cpp +++ b/engines/testbed/graphics.cpp @@ -38,7 +38,7 @@ namespace Testbed { -byte GFXTestSuite::_palette[256 * 4] = {0, 0, 0, 0, 255, 255, 255, 0, 255, 255, 255, 0}; +byte GFXTestSuite::_palette[256 * 3] = {0, 0, 0, 255, 255, 255, 255, 255, 255}; GFXTestSuite::GFXTestSuite() { // Initialize color palettes @@ -79,12 +79,12 @@ GFXTestSuite::GFXTestSuite() { } void GFXTestSuite::setCustomColor(uint r, uint g, uint b) { - _palette[8] = r; - _palette[9] = g; - _palette[10] = b; + _palette[6] = r; + _palette[7] = g; + _palette[8] = b; // Set colorNum kColorSpecial with a special color. - int absIndx = kColorSpecial * 4; + int absIndx = kColorSpecial * 3; _palette[absIndx + 1] = 173; _palette[absIndx + 2] = 255; _palette[absIndx + 3] = 47; @@ -94,12 +94,12 @@ void GFXTestSuite::setCustomColor(uint r, uint g, uint b) { // Helper functions used by GFX tests void GFXtests::initMousePalette() { - byte palette[3 * 4]; // Black, white and yellow + byte palette[3 * 3]; // Black, white and yellow palette[0] = palette[1] = palette[2] = 0; - palette[4] = palette[5] = palette[6] = 255; - palette[8] = palette[9] = 255; - palette[10] = 0; + palette[3] = palette[4] = palette[5] = 255; + palette[6] = palette[7] = 255; + palette[8] = 0; CursorMan.replaceCursorPalette(palette, 0, 3); } @@ -968,14 +968,14 @@ TestExitStatus GFXtests::paletteRotation() { Testsuite::clearEntireScreen(); // Use 256 colors - byte palette[256 * 4] = {0}; + byte palette[256 * 3] = {0}; int r, g, b; int colIndx; for (int i = 0; i < 256; i++) { HSVtoRGB(r, g, b, i, 1, 1); - colIndx = i * 4; + colIndx = i * 3; palette[colIndx] = r; palette[colIndx + 1] = g; palette[colIndx + 2] = b; diff --git a/engines/testbed/graphics.h b/engines/testbed/graphics.h index 4ab4ba65ab..01c76efea5 100644 --- a/engines/testbed/graphics.h +++ b/engines/testbed/graphics.h @@ -86,7 +86,7 @@ private: * 2 (R:255, G:255, B:255) your customized color (by default white) (kColorCustom) * The remaining values are zero */ - static byte _palette[256 * 4]; + static byte _palette[256 * 3]; }; } // End of namespace Testbed diff --git a/engines/tinsel/palette.cpp b/engines/tinsel/palette.cpp index 7cc6564832..a0ceec54eb 100644 --- a/engines/tinsel/palette.cpp +++ b/engines/tinsel/palette.cpp @@ -133,6 +133,7 @@ void psxPaletteMapper(PALQ *originalPal, uint8 *psxClut, byte *mapperTable) { void PalettesToVideoDAC() { PALQ *pPalQ; // palette Q iterator VIDEO_DAC_Q *pDACtail = vidDACdata; // set tail pointer + byte pal[768]; // while Q is not empty while (pDAChead != pDACtail) { @@ -164,8 +165,14 @@ void PalettesToVideoDAC() { pColours = pDACtail->pal.pRGBarray; } + for (int i = 0; i < pDACtail->numColours; ++i) { + pal[i * 3 + 0] = TINSEL_GetRValue(pColours[i]); + pal[i * 3 + 1] = TINSEL_GetGValue(pColours[i]); + pal[i * 3 + 2] = TINSEL_GetBValue(pColours[i]); + } + // update the system palette - g_system->getPaletteManager()->setPalette((const byte *)pColours, pDACtail->destDACindex, pDACtail->numColours); + g_system->getPaletteManager()->setPalette(pal, pDACtail->destDACindex, pDACtail->numColours); // update tail pointer pDACtail++; diff --git a/engines/toon/toon.cpp b/engines/toon/toon.cpp index d2b98c2ed0..d65230df85 100644 --- a/engines/toon/toon.cpp +++ b/engines/toon/toon.cpp @@ -927,14 +927,7 @@ void ToonEngine::flushPalette(bool deferFlushToNextRender) { return; } _needPaletteFlush = false; - uint8 vmpalette[1024]; - for (int32 i = 0; i < 256; i++) { - vmpalette[i*4+0] = _finalPalette[i*3+0]; - vmpalette[i*4+1] = _finalPalette[i*3+1]; - vmpalette[i*4+2] = _finalPalette[i*3+2]; - vmpalette[i*4+3] = 0; - } - _system->getPaletteManager()->setPalette(vmpalette, 0, 256); + _system->getPaletteManager()->setPalette(_finalPalette, 0, 256); } void ToonEngine::setPaletteEntries(uint8 *palette, int32 offset, int32 num) { memcpy(_finalPalette + offset * 3, palette, num * 3); @@ -1755,12 +1748,11 @@ void ToonEngine::flipScreens() { void ToonEngine::fadeIn(int32 numFrames) { for (int32 f = 0; f < numFrames; f++) { - uint8 vmpalette[1024]; + uint8 vmpalette[3 * 256]; for (int32 i = 0; i < 256; i++) { - vmpalette[i*4+0] = f * _finalPalette[i*3+0] / (numFrames - 1); - vmpalette[i*4+1] = f * _finalPalette[i*3+1] / (numFrames - 1); - vmpalette[i*4+2] = f * _finalPalette[i*3+2] / (numFrames - 1); - vmpalette[i*4+3] = 0; + vmpalette[i*3+0] = f * _finalPalette[i*3+0] / (numFrames - 1); + vmpalette[i*3+1] = f * _finalPalette[i*3+1] / (numFrames - 1); + vmpalette[i*3+2] = f * _finalPalette[i*3+2] / (numFrames - 1); } _system->getPaletteManager()->setPalette(vmpalette, 0, 256); _system->updateScreen(); @@ -1770,16 +1762,15 @@ void ToonEngine::fadeIn(int32 numFrames) { void ToonEngine::fadeOut(int32 numFrames) { - uint8 oldpalette[1024]; + uint8 oldpalette[3 * 256]; _system->getPaletteManager()->grabPalette(oldpalette, 0, 256); for (int32 f = 0; f < numFrames; f++) { - uint8 vmpalette[1024]; + uint8 vmpalette[3 * 256]; for (int32 i = 0; i < 256; i++) { - vmpalette[i*4+0] = (numFrames - f - 1) * oldpalette[i*4+0] / (numFrames - 1); - vmpalette[i*4+1] = (numFrames - f - 1) * oldpalette[i*4+1] / (numFrames - 1); - vmpalette[i*4+2] = (numFrames - f - 1) * oldpalette[i*4+2] / (numFrames - 1); - vmpalette[i*4+3] = 255; + vmpalette[i*3+0] = (numFrames - f - 1) * oldpalette[i*3+0] / (numFrames - 1); + vmpalette[i*3+1] = (numFrames - f - 1) * oldpalette[i*3+1] / (numFrames - 1); + vmpalette[i*3+2] = (numFrames - f - 1) * oldpalette[i*3+2] / (numFrames - 1); } _system->getPaletteManager()->setPalette(vmpalette, 0, 256); _system->updateScreen(); diff --git a/engines/touche/resource.cpp b/engines/touche/resource.cpp index df7992f26c..3c108e2931 100644 --- a/engines/touche/resource.cpp +++ b/engines/touche/resource.cpp @@ -423,10 +423,7 @@ void ToucheEngine::res_loadRoom(int num) { _fData.skip(2); const int roomImageNum = _fData.readUint16LE(); _fData.skip(2); - for (int i = 0; i < 256; ++i) { - _fData.read(&_paletteBuffer[i * 4], 3); - _paletteBuffer[i * 4 + 3] = 0; - } + _fData.read(_paletteBuffer, 3 * 256); const uint32 offsImage = res_getDataOffset(kResourceTypeRoomImage, roomImageNum); _fData.seek(offsImage); diff --git a/engines/touche/touche.cpp b/engines/touche/touche.cpp index ff8b0d944e..97d533f29f 100644 --- a/engines/touche/touche.cpp +++ b/engines/touche/touche.cpp @@ -3243,23 +3243,21 @@ void ToucheEngine::clearDirtyRects() { } void ToucheEngine::setPalette(int firstColor, int colorCount, int rScale, int gScale, int bScale) { - uint8 pal[256 * 4]; + uint8 pal[256 * 3]; for (int i = firstColor; i < firstColor + colorCount; ++i) { - int r = _paletteBuffer[i * 4 + 0]; + int r = _paletteBuffer[i * 3 + 0]; r = (r * rScale) >> 8; - pal[i * 4 + 0] = (uint8)r; + pal[i * 3 + 0] = (uint8)r; - int g = _paletteBuffer[i * 4 + 1]; + int g = _paletteBuffer[i * 3 + 1]; g = (g * gScale) >> 8; - pal[i * 4 + 1] = (uint8)g; + pal[i * 3 + 1] = (uint8)g; - int b = _paletteBuffer[i * 4 + 2]; + int b = _paletteBuffer[i * 3 + 2]; b = (b * bScale) >> 8; - pal[i * 4 + 2] = (uint8)b; - - pal[i * 4 + 3] = 0; + pal[i * 3 + 2] = (uint8)b; } - _system->getPaletteManager()->setPalette(&pal[firstColor * 4], firstColor, colorCount); + _system->getPaletteManager()->setPalette(&pal[firstColor * 3], firstColor, colorCount); } void ToucheEngine::updateScreenArea(int x, int y, int w, int h) { diff --git a/engines/touche/touche.h b/engines/touche/touche.h index 8b5f14d926..1580d072e6 100644 --- a/engines/touche/touche.h +++ b/engines/touche/touche.h @@ -781,7 +781,7 @@ protected: int _fullRedrawCounter; int _menuRedrawCounter; uint8 *_offscreenBuffer; - uint8 _paletteBuffer[256 * 4]; + uint8 _paletteBuffer[256 * 3]; Common::Rect _dirtyRectsTable[NUM_DIRTY_RECTS]; int _dirtyRectsTableCount; diff --git a/engines/tucker/locations.cpp b/engines/tucker/locations.cpp index cd99656695..108c6bcad5 100644 --- a/engines/tucker/locations.cpp +++ b/engines/tucker/locations.cpp @@ -1791,11 +1791,11 @@ void TuckerEngine::execData3PreUpdate_locationNum29() { _updateLocationFadePaletteCounter = 0; } const int d = _updateLocationFadePaletteCounter / 2; - uint8 scrollPal[5 * 4]; + uint8 scrollPal[5 * 3]; for (int i = 0; i < 5; ++i) { - scrollPal[i * 4] = r[i + d]; - scrollPal[i * 4 + 1] = g[i + d]; - scrollPal[i * 4 + 2] = b[i + d]; + scrollPal[i * 3] = r[i + d]; + scrollPal[i * 3 + 1] = g[i + d]; + scrollPal[i * 3 + 2] = b[i + d]; } _system->getPaletteManager()->setPalette(scrollPal, 118, 5); if (_flagsTable[143] == 1) { diff --git a/engines/tucker/sequences.cpp b/engines/tucker/sequences.cpp index 40706aee0f..5e99e3ccef 100644 --- a/engines/tucker/sequences.cpp +++ b/engines/tucker/sequences.cpp @@ -677,14 +677,14 @@ void AnimationSequencePlayer::updateSounds() { } void AnimationSequencePlayer::fadeInPalette() { - uint8 paletteBuffer[256 * 4]; + uint8 paletteBuffer[256 * 3]; memset(paletteBuffer, 0, sizeof(paletteBuffer)); bool fadeColors = true; for (int step = 0; step < 64; ++step) { if (fadeColors) { fadeColors = false; - for (int i = 0; i < 1024; ++i) { - if ((i & 3) != 3 && paletteBuffer[i] < _animationPalette[i]) { + for (int i = 0; i < 3*256; ++i) { + if (paletteBuffer[i] < _animationPalette[i]) { const int color = paletteBuffer[i] + 4; paletteBuffer[i] = MIN<int>(color, _animationPalette[i]); fadeColors = true; @@ -698,14 +698,14 @@ void AnimationSequencePlayer::fadeInPalette() { } void AnimationSequencePlayer::fadeOutPalette() { - uint8 paletteBuffer[256 * 4]; - memcpy(paletteBuffer, _animationPalette, 1024); + uint8 paletteBuffer[256 * 3]; + memcpy(paletteBuffer, _animationPalette, 3*256); bool fadeColors = true; for (int step = 0; step < 64; ++step) { if (fadeColors) { fadeColors = false; - for (int i = 0; i < 1024; ++i) { - if ((i & 3) != 3 && paletteBuffer[i] > 0) { + for (int i = 0; i < 3*256; ++i) { + if (paletteBuffer[i] > 0) { const int color = paletteBuffer[i] - 4; paletteBuffer[i] = MAX<int>(0, color); fadeColors = true; @@ -741,13 +741,7 @@ uint8 *AnimationSequencePlayer::loadPicture(const char *fileName) { } void AnimationSequencePlayer::getRGBPalette(int index) { - const byte *rgbPalette = _flicPlayer[index].getPalette(); - for (int i = 0; i < 256; i++) { - _animationPalette[i * 4 + 0] = rgbPalette[i * 3 + 0]; - _animationPalette[i * 4 + 1] = rgbPalette[i * 3 + 1]; - _animationPalette[i * 4 + 2] = rgbPalette[i * 3 + 2]; - _animationPalette[i * 4 + 3] = 0; - } + memcpy(_animationPalette, _flicPlayer[index].getPalette(), 3 * 256); } void AnimationSequencePlayer::openAnimation(int index, const char *fileName) { @@ -827,9 +821,7 @@ void AnimationSequencePlayer::displayLoadingScreen() { if (f.open("graphics/loading.pic")) { fadeOutPalette(); f.seek(32); - for (int i = 0; i < 1024; i += 4) { - f.read(_animationPalette + i, 3); - } + f.read(_animationPalette, 3 * 256); f.read(_offscreenBuffer, 64000); _system->copyRectToScreen(_offscreenBuffer, 320, 0, 0, kScreenWidth, kScreenHeight); fadeInPalette(); @@ -846,12 +838,7 @@ void AnimationSequencePlayer::initPicPart4() { void AnimationSequencePlayer::drawPicPart4() { static const uint8 offsets[] = { 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1 }; if (_updateScreenIndex == -1) { - for (int i = 0; i < 256; ++i) { - if (memcmp(_animationPalette + i * 4, _picBufPtr + 32 + i * 3, 3) != 0) { - memcpy(_animationPalette + i * 4, _picBufPtr + 32 + i * 3, 3); - _animationPalette[i * 4 + 3] = 0; - } - } + memcpy(_animationPalette, _picBufPtr + 32, 3 * 256); } if (_updateScreenCounter == 0) { static const uint8 counter[] = { 1, 2, 3, 4, 5, 35, 5, 4, 3, 2, 1 }; diff --git a/engines/tucker/tucker.cpp b/engines/tucker/tucker.cpp index d4afdaba56..6e44eadc47 100644 --- a/engines/tucker/tucker.cpp +++ b/engines/tucker/tucker.cpp @@ -933,12 +933,12 @@ void TuckerEngine::updateFlagsForCharPosition() { } void TuckerEngine::fadeOutPalette(int colorsCount) { - uint8 pal[256 * 4]; + uint8 pal[256 * 3]; _system->getPaletteManager()->grabPalette(pal, 0, colorsCount); for (int color = 0; color < colorsCount; ++color) { for (int i = 0; i < 3; ++i) { - const int c = int(pal[color * 4 + i]) + kFadePaletteStep * 4; - pal[color * 4 + i] = MIN<int>(c, _currentPalette[color * 3 + i]); + const int c = int(pal[color * 3 + i]) + kFadePaletteStep * 3; + pal[color * 3 + i] = MIN<int>(c, _currentPalette[color * 3 + i]); } } _system->getPaletteManager()->setPalette(pal, 0, colorsCount); @@ -946,12 +946,12 @@ void TuckerEngine::fadeOutPalette(int colorsCount) { } void TuckerEngine::fadeInPalette(int colorsCount) { - uint8 pal[256 * 4]; + uint8 pal[256 * 3]; _system->getPaletteManager()->grabPalette(pal, 0, colorsCount); for (int color = 0; color < colorsCount; ++color) { for (int i = 0; i < 3; ++i) { - const int c = int(pal[color * 4 + i]) - kFadePaletteStep * 4; - pal[color * 4 + i] = MAX<int>(c, 0); + const int c = int(pal[color * 3 + i]) - kFadePaletteStep * 3; + pal[color * 3 + i] = MAX<int>(c, 0); } } _system->getPaletteManager()->setPalette(pal, 0, colorsCount); @@ -969,7 +969,7 @@ void TuckerEngine::fadePaletteColor(int color, int step) { } void TuckerEngine::setBlackPalette() { - uint8 pal[256 * 4]; + uint8 pal[256 * 3]; memset(pal, 0, sizeof(pal)); _system->getPaletteManager()->setPalette(pal, 0, 256); } diff --git a/engines/tucker/tucker.h b/engines/tucker/tucker.h index 6488bbc215..fd931998e4 100644 --- a/engines/tucker/tucker.h +++ b/engines/tucker/tucker.h @@ -975,7 +975,7 @@ private: const SequenceUpdateFunc *_updateFunc; int _updateFuncIndex; Video::FlicDecoder _flicPlayer[2]; - uint8 _animationPalette[256 * 4]; + uint8 _animationPalette[256 * 3]; int _soundSeqDataCount; int _soundSeqDataIndex; const SoundSequenceData *_soundSeqData; diff --git a/graphics/cursorman.h b/graphics/cursorman.h index c041beb957..2f3891aee7 100644 --- a/graphics/cursorman.h +++ b/graphics/cursorman.h @@ -130,7 +130,7 @@ public: * The palette entries from 'start' till (start+num-1) will be replaced * so a full palette updated is accomplished via start=0, num=256. * - * The palette data is specified in the same interleaved RGBA format as + * The palette data is specified in the same interleaved RGB format as * used by all backends. * * @param colors the new palette data, in interleaved RGB format diff --git a/graphics/palette.h b/graphics/palette.h index 72db16a3d3..2a4fdb656a 100644 --- a/graphics/palette.h +++ b/graphics/palette.h @@ -46,12 +46,12 @@ public: * The palette entries from 'start' till (start+num-1) will be replaced - so * a full palette update is accomplished via start=0, num=256. * - * The palette data is specified in interleaved RGBA format. That is, the + * The palette data is specified in interleaved RGB format. That is, the * first byte of the memory block 'colors' points at is the red component * of the first new color; the second byte the green component of the first * new color; the third byte the blue component, the last byte to the alpha * (transparency) value. Then the second color starts, and so on. So memory - * looks like this: R1-G1-B1-A1-R2-G2-B2-A2-R3-... + * looks like this: R1-G1-B1-R2-G2-B2-R3-... * * @param colors the new palette data, in interleaved RGBA format * @param start the first palette entry to be updated @@ -79,16 +79,15 @@ public: * For example, for every valid value of start and num of the following * code: * - * byte origPal[num*4]; + * byte origPal[num*3]; * // Setup origPal's data however you like * g_system->setPalette(origPal, start, num); - * byte obtainedPal[num*4]; + * byte obtainedPal[num*3]; * g_system->grabPalette(obtainedPal, start, num); * * the following should be true: * - * For each i < num : memcmp(&origPal[i*4], &obtainedPal[i*4], 3) == 0 - * (i is an uint here) + * memcmp(origPal, obtainedPal, num*3) == 0 * * @see setPalette * @param colors the palette data, in interleaved RGBA format diff --git a/graphics/scaler/thumbnail_intern.cpp b/graphics/scaler/thumbnail_intern.cpp index bd325aca63..5cee1c7a72 100644 --- a/graphics/scaler/thumbnail_intern.cpp +++ b/graphics/scaler/thumbnail_intern.cpp @@ -108,7 +108,7 @@ static bool grabScreen565(Graphics::Surface *surf) { byte *palette = 0; if (screenFormat.bytesPerPixel == 1) { - palette = new byte[256 * 4]; + palette = new byte[256 * 3]; assert(palette); g_system->getPaletteManager()->grabPalette(palette, 0, 256); } @@ -118,9 +118,9 @@ static bool grabScreen565(Graphics::Surface *surf) { byte r = 0, g = 0, b = 0; if (screenFormat.bytesPerPixel == 1) { - r = palette[((uint8*)screen->pixels)[y * screen->pitch + x] * 4]; - g = palette[((uint8*)screen->pixels)[y * screen->pitch + x] * 4 + 1]; - b = palette[((uint8*)screen->pixels)[y * screen->pitch + x] * 4 + 2]; + r = palette[((uint8*)screen->pixels)[y * screen->pitch + x] * 3]; + g = palette[((uint8*)screen->pixels)[y * screen->pitch + x] * 3 + 1]; + b = palette[((uint8*)screen->pixels)[y * screen->pitch + x] * 3 + 2]; } else if (screenFormat.bytesPerPixel == 2) { uint16 col = READ_UINT16(screen->getBasePtr(x, y)); screenFormat.colorToRGB(col, r, g, b); diff --git a/gui/ThemeEngine.cpp b/gui/ThemeEngine.cpp index beb17b0c88..ee83ca620c 100644 --- a/gui/ThemeEngine.cpp +++ b/gui/ThemeEngine.cpp @@ -1327,10 +1327,9 @@ bool ThemeEngine::createCursor(const Common::String &filename, int hotspotX, int const int index = colorsFound++; colorToIndex[col] = index; - _cursorPal[index * 4 + 0] = r; - _cursorPal[index * 4 + 1] = g; - _cursorPal[index * 4 + 2] = b; - _cursorPal[index * 4 + 3] = 0xFF; + _cursorPal[index * 3 + 0] = r; + _cursorPal[index * 3 + 1] = g; + _cursorPal[index * 3 + 2] = b; if (colorsFound > MAX_CURS_COLORS) { warning("Cursor contains too many colors (%d, but only %d are allowed)", colorsFound, MAX_CURS_COLORS); diff --git a/gui/ThemeEngine.h b/gui/ThemeEngine.h index 966c792042..e852760e44 100644 --- a/gui/ThemeEngine.h +++ b/gui/ThemeEngine.h @@ -661,7 +661,7 @@ protected: byte *_cursor; bool _needPaletteUpdates; uint _cursorWidth, _cursorHeight; - byte _cursorPal[4*MAX_CURS_COLORS]; + byte _cursorPal[3*MAX_CURS_COLORS]; byte _cursorPalSize; }; diff --git a/gui/gui-manager.cpp b/gui/gui-manager.cpp index af567c65d8..7644cbe7b2 100644 --- a/gui/gui-manager.cpp +++ b/gui/gui-manager.cpp @@ -441,10 +441,10 @@ void GuiManager::closeTopDialog() { void GuiManager::setupCursor() { const byte palette[] = { - 255, 255, 255, 0, - 255, 255, 255, 0, - 171, 171, 171, 0, - 87, 87, 87, 0 + 255, 255, 255, + 255, 255, 255, + 171, 171, 171, + 87, 87, 87 }; CursorMan.pushCursorPalette(palette, 0, 4); diff --git a/video/video_decoder.cpp b/video/video_decoder.cpp index 3f23d83761..a6317bac8f 100644 --- a/video/video_decoder.cpp +++ b/video/video_decoder.cpp @@ -50,18 +50,7 @@ uint32 VideoDecoder::getElapsedTime() const { } void VideoDecoder::setSystemPalette() { - const byte *vidPalette = getPalette(); - byte *sysPalette = new byte[256 * 4]; - - for (uint16 i = 0; i < 256; i++) { - sysPalette[i * 4] = vidPalette[i * 3]; - sysPalette[i * 4 + 1] = vidPalette[i * 3 + 1]; - sysPalette[i * 4 + 2] = vidPalette[i * 3 + 2]; - sysPalette[i * 4 + 3] = 0; - } - - g_system->getPaletteManager()->setPalette(sysPalette, 0, 256); - delete[] sysPalette; + g_system->getPaletteManager()->setPalette(getPalette(), 0, 256); } bool VideoDecoder::needsUpdate() const { |