From 362b0cd5e4a71a0b2610ff8abb6aeecddc842cf0 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sun, 13 Feb 2011 20:43:17 +0100 Subject: TUCKER: Adapt to setPalette RGBA->RGB change. This change has not been tested, since I do not own copy of Tucker. --- engines/tucker/locations.cpp | 8 ++++---- engines/tucker/sequences.cpp | 33 ++++++++++----------------------- engines/tucker/tucker.cpp | 14 +++++++------- engines/tucker/tucker.h | 2 +- 4 files changed, 22 insertions(+), 35 deletions(-) diff --git a/engines/tucker/locations.cpp b/engines/tucker/locations.cpp index 009695e8aa..c1a8eee31b 100644 --- a/engines/tucker/locations.cpp +++ b/engines/tucker/locations.cpp @@ -1792,11 +1792,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 73018b8c00..18def277c5 100644 --- a/engines/tucker/sequences.cpp +++ b/engines/tucker/sequences.cpp @@ -678,14 +678,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(color, _animationPalette[i]); fadeColors = true; @@ -699,14 +699,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(0, color); fadeColors = true; @@ -742,13 +742,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) { @@ -828,9 +822,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(); @@ -847,12 +839,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 c61a4228c6..557830194a 100644 --- a/engines/tucker/tucker.cpp +++ b/engines/tucker/tucker.cpp @@ -942,12 +942,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(c, _currentPalette[color * 3 + i]); + const int c = int(pal[color * 3 + i]) + kFadePaletteStep * 3; + pal[color * 3 + i] = MIN(c, _currentPalette[color * 3 + i]); } } _system->getPaletteManager()->setPalette(pal, 0, colorsCount); @@ -956,12 +956,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(c, 0); + const int c = int(pal[color * 3 + i]) - kFadePaletteStep * 3; + pal[color * 3 + i] = MAX(c, 0); } } _system->getPaletteManager()->setPalette(pal, 0, colorsCount); @@ -980,7 +980,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 4d7b530bbc..944b72824b 100644 --- a/engines/tucker/tucker.h +++ b/engines/tucker/tucker.h @@ -977,7 +977,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; -- cgit v1.2.3