diff options
author | Martin Kiewitz | 2010-01-04 16:44:58 +0000 |
---|---|---|
committer | Martin Kiewitz | 2010-01-04 16:44:58 +0000 |
commit | 01eb329be2df445f3374f8183bec5d9031450062 (patch) | |
tree | 3e27875288bb996af067653dd4cb0b77a74c4b63 /engines/sci/gui | |
parent | 8cc690935a8fbd236c1b854ce281b3abb7b0a759 (diff) | |
download | scummvm-rg350-01eb329be2df445f3374f8183bec5d9031450062.tar.gz scummvm-rg350-01eb329be2df445f3374f8183bec5d9031450062.tar.bz2 scummvm-rg350-01eb329be2df445f3374f8183bec5d9031450062.zip |
SCI: kPalette / animate adjustments to behave more like sierra sci, also doesnt crash in island of brain anymore
svn-id: r46975
Diffstat (limited to 'engines/sci/gui')
-rw-r--r-- | engines/sci/gui/gui.cpp | 10 | ||||
-rw-r--r-- | engines/sci/gui/gui.h | 3 | ||||
-rw-r--r-- | engines/sci/gui/gui_palette.cpp | 54 | ||||
-rw-r--r-- | engines/sci/gui/gui_palette.h | 2 |
4 files changed, 48 insertions, 21 deletions
diff --git a/engines/sci/gui/gui.cpp b/engines/sci/gui/gui.cpp index 4451dfa940..47d32e27c5 100644 --- a/engines/sci/gui/gui.cpp +++ b/engines/sci/gui/gui.cpp @@ -573,12 +573,16 @@ void SciGui::paletteSetIntensity(uint16 fromColor, uint16 toColor, uint16 intens _palette->setIntensity(fromColor, toColor, intensity, setPalette); } -void SciGui::paletteAnimate(uint16 fromColor, uint16 toColor, int16 speed) { +bool SciGui::paletteAnimate(uint16 fromColor, uint16 toColor, int16 speed) { // we are also called on Amiga as well, but for colors above 32, so it doesnt make sense if (!_s->resMan->isVGA()) - return; + return false; + + return _palette->animate(fromColor, toColor, speed); +} - _palette->animate(fromColor, toColor, speed); +void SciGui::paletteAnimateSet() { + _palette->setOnScreen(); } void SciGui::shakeScreen(uint16 shakeCount, uint16 directions) { diff --git a/engines/sci/gui/gui.h b/engines/sci/gui/gui.h index ee1604d25b..59f9b8b36e 100644 --- a/engines/sci/gui/gui.h +++ b/engines/sci/gui/gui.h @@ -116,7 +116,8 @@ public: virtual void paletteUnsetFlag(uint16 fromColor, uint16 toColor, uint16 flag); virtual int16 paletteFind(uint16 r, uint16 g, uint16 b); virtual void paletteSetIntensity(uint16 fromColor, uint16 toColor, uint16 intensity, bool setPalette); - virtual void paletteAnimate(uint16 fromColor, uint16 toColor, int16 speed); + virtual bool paletteAnimate(uint16 fromColor, uint16 toColor, int16 speed); + virtual void paletteAnimateSet(); virtual void shakeScreen(uint16 shakeCount, uint16 directions); diff --git a/engines/sci/gui/gui_palette.cpp b/engines/sci/gui/gui_palette.cpp index 68b9777286..320221b1aa 100644 --- a/engines/sci/gui/gui_palette.cpp +++ b/engines/sci/gui/gui_palette.cpp @@ -296,37 +296,59 @@ void SciGuiPalette::setIntensity(uint16 fromColor, uint16 toColor, uint16 intens setOnScreen(); } -void SciGuiPalette::animate(byte fromColor, byte toColor, int speed) { +// Returns true, if palette got changed +bool SciGuiPalette::animate(byte fromColor, byte toColor, int speed) { GuiColor col; - int len = toColor - fromColor - 1; + byte colorNr; + int16 colorCount; uint32 now = g_system->getMillis() * 60 / 1000; // search for sheduled animations with the same 'from' value - int sz = _schedules.size(); - for (int i = 0; i < sz; i++) { - if (_schedules[i].from == fromColor) { - if (_schedules[i].schedule < now) { + // schedule animation... + int scheduleCount = _schedules.size(); + int scheduleNr; + for (scheduleNr = 0; scheduleNr < scheduleCount; scheduleNr++) { + if (_schedules[scheduleNr].from == fromColor) + break; + } + if (scheduleNr == scheduleCount) { + // adding a new schedule + GuiPalSchedule newSchedule; + newSchedule.from = fromColor; + newSchedule.schedule = now + ABS(speed); + _schedules.push_back(newSchedule); + scheduleCount++; + } + + for (scheduleNr = 0; scheduleNr < scheduleCount; scheduleNr++) { + if (_schedules[scheduleNr].from == fromColor) { + if (_schedules[scheduleNr].schedule <= now) { if (speed > 0) { + // TODO: Not really sure about this, sierra sci seems to do exactly this here col = _sysPalette.colors[fromColor]; - memmove(&_sysPalette.colors[fromColor], &_sysPalette.colors[fromColor + 1], len * sizeof(GuiColor)); + if (fromColor < toColor) { + colorCount = toColor - fromColor - 1; + memmove(&_sysPalette.colors[fromColor], &_sysPalette.colors[fromColor + 1], colorCount * sizeof(GuiColor)); + } _sysPalette.colors[toColor - 1] = col; } else { col = _sysPalette.colors[toColor - 1]; - memmove(&_sysPalette.colors[fromColor + 1], &_sysPalette.colors[fromColor], len * sizeof(GuiColor)); + if (fromColor < toColor) { + colorCount = toColor - fromColor - 1; + memmove(&_sysPalette.colors[fromColor + 1], &_sysPalette.colors[fromColor], colorCount * sizeof(GuiColor)); + } _sysPalette.colors[fromColor] = col; } // removing schedule - _schedules.remove_at(i); + _schedules[scheduleNr].schedule = now + ABS(speed); + // TODO: Not sure when sierra actually removes a schedule + //_schedules.remove_at(scheduleNr); + return true; } - setOnScreen(); - return; + return false; } } - // adding a new schedule - GuiPalSchedule newSchedule; - newSchedule.from = fromColor; - newSchedule.schedule = now + ABS(speed); - _schedules.push_back(newSchedule); + return false; } // palVary diff --git a/engines/sci/gui/gui_palette.h b/engines/sci/gui/gui_palette.h index ea63f7fe0f..f3eca7448d 100644 --- a/engines/sci/gui/gui_palette.h +++ b/engines/sci/gui/gui_palette.h @@ -50,7 +50,7 @@ public: void setFlag(uint16 fromColor, uint16 toColor, uint16 flag); void unsetFlag(uint16 fromColor, uint16 toColor, uint16 flag); void setIntensity(uint16 fromColor, uint16 toColor, uint16 intensity, bool setPalette); - void animate(byte fromColor, byte toColor, int speed); + bool animate(byte fromColor, byte toColor, int speed); GuiPalette _sysPalette; |