diff options
-rw-r--r-- | engines/kyra/screen_lol.cpp | 26 | ||||
-rw-r--r-- | engines/kyra/screen_lol.h | 2 | ||||
-rw-r--r-- | engines/kyra/script_lol.cpp | 52 |
3 files changed, 36 insertions, 44 deletions
diff --git a/engines/kyra/screen_lol.cpp b/engines/kyra/screen_lol.cpp index 408e568b0b..ccb9ea1e04 100644 --- a/engines/kyra/screen_lol.cpp +++ b/engines/kyra/screen_lol.cpp @@ -898,38 +898,40 @@ bool Screen_LoL::fadePaletteStep(uint8 *pal1, uint8 *pal2, uint32 elapsedTime, u return res; } -uint8 *Screen_LoL::generateFadeTable(uint8 *dst, uint8 *src1, uint8 *src2, int numTabs) { +Palette **Screen_LoL::generateFadeTable(Palette **dst, Palette *src1, Palette *src2, int numTabs) { if (!src1) - src1 = _screenPalette->getData(); + src1 = _screenPalette; - uint8 *p1 = dst; - uint8 *p2 = src1; - uint8 *p3 = src2; + uint8 *p1 = (*dst++)->getData(); + uint8 *p2 = src1->getData(); + uint8 *p3 = src2->getData(); + uint8 *p4 = p1; + uint8 *p5 = p2; for (int i = 0; i < 768; i++) { int8 val = (int8)*p3++ - (int8)*p2++; - *dst++ = (uint8)val; + *p4++ = (uint8)val; } int16 t = 0; int16 d = 256 / numTabs; for (int i = 1; i < numTabs - 1; i++) { - p2 = src1; + p2 = p5; p3 = p1; t += d; + p4 = (*dst++)->getData(); for (int ii = 0; ii < 768; ii++) { int16 val = (((int8)*p3++ * t) >> 8) + (int8)*p2++; - *dst++ = (uint8)val; + *p4++ = (uint8)val; } } - memcpy(p1, src1, 768); - memcpy(dst, src2, 768); + memcpy(p1, p5, 768); + (*dst)->copy(*src2); - dst += 768; - return dst; + return ++dst; } uint8 Screen_LoL::getShapePaletteSize(const uint8 *shp) { diff --git a/engines/kyra/screen_lol.h b/engines/kyra/screen_lol.h index 0a300ef8d1..7916cf0aca 100644 --- a/engines/kyra/screen_lol.h +++ b/engines/kyra/screen_lol.h @@ -74,7 +74,7 @@ public: void copyColor(int dstColorIndex, int srcColorIndex); bool fadeColor(int dstColorIndex, int srcColorIndex, uint32 elapsedTime, uint32 targetTime); bool fadePaletteStep(uint8 *pal1, uint8 *pal2, uint32 elapsedTime, uint32 targetTime); - uint8 *generateFadeTable(uint8 *dst, uint8 *src1, uint8 *src2, int numTabs); + Palette **generateFadeTable(Palette **dst, Palette *src1, Palette *src2, int numTabs); void generateGrayOverlay(const Palette &Pal, uint8 *grayOverlay, int factor, int addR, int addG, int addB, int lastColor, bool skipSpecialColors); uint8 *generateLevelOverlay(const Palette &Pal, uint8 *ovl, int opColor, int weight); diff --git a/engines/kyra/script_lol.cpp b/engines/kyra/script_lol.cpp index ad3e739cd6..7c00e6971c 100644 --- a/engines/kyra/script_lol.cpp +++ b/engines/kyra/script_lol.cpp @@ -2174,44 +2174,35 @@ int LoLEngine::olol_restoreMagicShroud(EMCState *script) { _screen->hideMouse(); - // TODO: This function could need some major cleanup to work with our - // new palette code without needless conversions. - uint8 *fadeTab = new uint8[21504]; - assert(fadeTab); - memset(fadeTab, 0, sizeof(fadeTab)); - - uint8 *tpal1 = fadeTab; - uint8 *tpal2 = tpal1 + 768; - uint8 *tpal3 = tpal2 + 768; - uint8 *tpal4 = 0; - _res->loadFileToBuf("LITEPAL1.COL", tpal1, 768); - tpal2 = _screen->generateFadeTable(tpal3, 0, tpal1, 21); - _res->loadFileToBuf("LITEPAL2.COL", tpal2, 768); - tpal4 = tpal2; - tpal2 += 768; - _res->loadFileToBuf("LITEPAL3.COL", tpal1, 768); - _screen->generateFadeTable(tpal2, tpal4, tpal1, 4); - - Palette pal(256); + Palette *fadeTab[28]; + for (int i = 0; i < 28; i++) + fadeTab[i] = new Palette(256); + + Palette **tpal1 = &fadeTab[0]; + Palette **tpal2 = &fadeTab[1]; + Palette **tpal3 = &fadeTab[2]; + Palette **tpal4 = 0; + _screen->loadPalette("LITEPAL1.COL", **tpal1); + tpal2 = _screen->generateFadeTable(tpal3, 0, *tpal1, 21); + _screen->loadPalette("LITEPAL2.COL", **tpal2); + tpal4 = tpal2++; + _screen->loadPalette("LITEPAL3.COL", **tpal1); + _screen->generateFadeTable(tpal2, *tpal4, *tpal1, 4); for (int i = 0; i < 21; i++) { uint32 etime = _system->getMillis() + 20 * _tickLength; mov->displayFrame(i, 0, 0, 0, 0, 0, 0); _screen->updateScreen(); - - pal.copy(tpal3, 0, 256); - _screen->setScreenPalette(pal); - tpal3 += 768; + _screen->setScreenPalette(**tpal3++); if (i == 2 || i == 5 || i == 8 || i == 11 || i == 13 || i == 15 || i == 17 || i == 19) snd_playSoundEffect(95, -1); + delayUntil(etime); } - pal.copy(tpal3, 0, 256); snd_playSoundEffect(91, -1); - _screen->fadePalette(pal, 300); - tpal3 += 768; + _screen->fadePalette(**tpal3++, 300); for (int i = 22; i < 38; i++) { uint32 etime = _system->getMillis() + 12 * _tickLength; @@ -2219,17 +2210,16 @@ int LoLEngine::olol_restoreMagicShroud(EMCState *script) { _screen->updateScreen(); if (i == 22 || i == 24 || i == 28 || i == 32) { snd_playSoundEffect(131, -1); - - pal.copy(tpal3, 0, 256); - _screen->setScreenPalette(pal); - tpal3 += 768; + _screen->setScreenPalette(**tpal3++); } delayUntil(etime); } mov->close(); delete mov; - delete[] fadeTab; + + for (int i = 0; i < 28; i++) + delete fadeTab[i]; _screen->showMouse(); |