diff options
Diffstat (limited to 'engines/toon')
-rw-r--r-- | engines/toon/movie.cpp | 2 | ||||
-rw-r--r-- | engines/toon/toon.cpp | 49 | ||||
-rw-r--r-- | engines/toon/toon.h | 3 |
3 files changed, 38 insertions, 16 deletions
diff --git a/engines/toon/movie.cpp b/engines/toon/movie.cpp index 272fadf75e..7743b6aa7f 100644 --- a/engines/toon/movie.cpp +++ b/engines/toon/movie.cpp @@ -87,7 +87,7 @@ void Movie::play(Common::String video, int32 flags) { _vm->getAudioManager()->setMusicVolume(0); _decoder->loadFile(video.c_str(), flags); playVideo(); - _vm->flushPalette(); + _vm->flushPalette(false); if (flags & 1) _vm->getAudioManager()->setMusicVolume(_vm->getAudioManager()->isMusicMuted() ? 0 : 255); _decoder->close(); diff --git a/engines/toon/toon.cpp b/engines/toon/toon.cpp index 49f8f7897f..4c377220d1 100644 --- a/engines/toon/toon.cpp +++ b/engines/toon/toon.cpp @@ -402,6 +402,11 @@ void ToonEngine::render() { } #endif + if (_needPaletteFlush) { + flushPalette(false); + _needPaletteFlush = false; + } + if (_firstFrame) { copyToVirtualScreen(false); fadeIn(5); @@ -544,6 +549,7 @@ bool ToonEngine::showMainmenu(bool &loadedGame) { Picture *mainmenuPicture = new Picture(this); mainmenuPicture->loadPicture("TITLESCR.CPS", true); mainmenuPicture->setupPalette(); + flushPalette(false); MainMenuEntry entries[MAINMENU_ENTRYCOUNT]; @@ -894,8 +900,13 @@ ToonEngine::~ToonEngine() { delete _console; } -void ToonEngine::flushPalette() { +void ToonEngine::flushPalette(bool deferFlushToNextRender) { + if (deferFlushToNextRender) { + _needPaletteFlush = true; + return; + } + _needPaletteFlush = false; uint8 vmpalette[1024]; for (int32 i = 0; i < 256; i++) { vmpalette[i*4+0] = _finalPalette[i*3+0]; @@ -907,14 +918,7 @@ void ToonEngine::flushPalette() { } void ToonEngine::setPaletteEntries(uint8 *palette, int32 offset, int32 num) { memcpy(_finalPalette + offset * 3, palette, num * 3); - uint8 vmpalette[1024]; - for (int32 i = 0; i < num; i++) { - vmpalette[i*4+0] = palette[i*3+0]; - vmpalette[i*4+1] = palette[i*3+1]; - vmpalette[i*4+2] = palette[i*3+2]; - vmpalette[i*4+3] = 0; - } - _system->setPalette(vmpalette, offset, num); + flushPalette(); } void ToonEngine::simpleUpdate(bool waitCharacterToTalk) { @@ -1753,14 +1757,17 @@ void ToonEngine::fadeIn(int32 numFrames) { } void ToonEngine::fadeOut(int32 numFrames) { - for (int32 f = 0; f < numFrames; f++) { + uint8 oldpalette[1024]; + _system->grabPalette(oldpalette, 0, 256); + + for (int32 f = 0; f < numFrames; f++) { uint8 vmpalette[1024]; for (int32 i = 0; i < 256; i++) { - vmpalette[i*4+0] = (numFrames - f - 1) * _finalPalette[i*3+0] / (numFrames - 1); - vmpalette[i*4+1] = (numFrames - f - 1) * _finalPalette[i*3+1] / (numFrames - 1); - vmpalette[i*4+2] = (numFrames - f - 1) * _finalPalette[i*3+2] / (numFrames - 1); - vmpalette[i*4+3] = (numFrames - f - 1); + 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; } _system->setPalette(vmpalette, 0, 256); _system->updateScreen(); @@ -3204,6 +3211,20 @@ bool ToonEngine::loadGame(int32 slot) { delete[] buf; } delete loadFile; + + // setup correct palette if we are in a closeup/cutaway or not. + if (_gameState->_inCloseUp) { + _gameState->_inCloseUp = false; + flipScreens(); + } else if (_gameState->_inCutaway) { + _currentCutaway->setupPalette(); + setupGeneralPalette(); + } else { + _currentPicture->setupPalette(); + setupGeneralPalette(); + } + flushPalette(); + return true; } diff --git a/engines/toon/toon.h b/engines/toon/toon.h index 05b2bac47c..c16336722d 100644 --- a/engines/toon/toon.h +++ b/engines/toon/toon.h @@ -115,7 +115,7 @@ public: void unloadToonDat(); void setPaletteEntries(uint8 *palette, int32 offset, int32 num); void fixPaletteEntries(uint8 *palette, int num); - void flushPalette(); + void flushPalette(bool deferFlushToNextRender = true); void parseInput(); void initChapter(); void initFonts(); @@ -425,6 +425,7 @@ protected: bool _firstFrame; bool _isDemo; bool _showConversationText; + bool _needPaletteFlush; private: ToonConsole *_console; }; |