aboutsummaryrefslogtreecommitdiff
path: root/engines/toon
diff options
context:
space:
mode:
authorSylvain Dupont2011-01-29 20:59:46 +0000
committerSylvain Dupont2011-01-29 20:59:46 +0000
commit7765c245588ffb8fd4007efcbf172299a40a0c7d (patch)
treea89d166f67959e8e3c3ef4e8e0f6d49e58a5c9fc /engines/toon
parent96f4cc4b8a4273ec728419645363952d35f8ebe0 (diff)
downloadscummvm-rg350-7765c245588ffb8fd4007efcbf172299a40a0c7d.tar.gz
scummvm-rg350-7765c245588ffb8fd4007efcbf172299a40a0c7d.tar.bz2
scummvm-rg350-7765c245588ffb8fd4007efcbf172299a40a0c7d.zip
TOON: Fix some palette issues
- In fade out when leaving certain rooms - When loading a game in a cutaway/closeup state svn-id: r55625
Diffstat (limited to 'engines/toon')
-rw-r--r--engines/toon/movie.cpp2
-rw-r--r--engines/toon/toon.cpp49
-rw-r--r--engines/toon/toon.h3
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;
};