[Scummvm-cvs-logs] SF.net SVN: scummvm:[46975] scummvm/trunk/engines/sci
m_kiewitz at users.sourceforge.net
m_kiewitz at users.sourceforge.net
Mon Jan 4 17:44:59 CET 2010
Revision: 46975
http://scummvm.svn.sourceforge.net/scummvm/?rev=46975&view=rev
Author: m_kiewitz
Date: 2010-01-04 16:44:58 +0000 (Mon, 04 Jan 2010)
Log Message:
-----------
SCI: kPalette / animate adjustments to behave more like sierra sci, also doesnt crash in island of brain anymore
Modified Paths:
--------------
scummvm/trunk/engines/sci/engine/kgraphics.cpp
scummvm/trunk/engines/sci/gui/gui.cpp
scummvm/trunk/engines/sci/gui/gui.h
scummvm/trunk/engines/sci/gui/gui_palette.cpp
scummvm/trunk/engines/sci/gui/gui_palette.h
scummvm/trunk/engines/sci/gui32/gui32.cpp
scummvm/trunk/engines/sci/gui32/gui32.h
Modified: scummvm/trunk/engines/sci/engine/kgraphics.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kgraphics.cpp 2010-01-04 16:18:35 UTC (rev 46974)
+++ scummvm/trunk/engines/sci/engine/kgraphics.cpp 2010-01-04 16:44:58 UTC (rev 46975)
@@ -569,12 +569,16 @@
}
case 6: { // Animate
int16 argNr;
+ bool paletteChanged = false;
for (argNr = 1; argNr < argc; argNr += 3) {
uint16 fromColor = argv[argNr].toUint16();
uint16 toColor = argv[argNr + 1].toUint16();
int16 speed = argv[argNr + 2].toSint16();
- s->_gui->paletteAnimate(fromColor, toColor, speed);
+ if (s->_gui->paletteAnimate(fromColor, toColor, speed))
+ paletteChanged = true;
}
+ if (paletteChanged)
+ s->_gui->paletteAnimateSet();
break;
}
case 7: { // Save palette to heap
@@ -963,7 +967,6 @@
// Take care of incoming events (kAnimate is called semi-regularly)
process_sound_events(s);
#endif
-
s->_gui->animate(castListReference, cycle, argc, argv);
return s->r_acc;
Modified: scummvm/trunk/engines/sci/gui/gui.cpp
===================================================================
--- scummvm/trunk/engines/sci/gui/gui.cpp 2010-01-04 16:18:35 UTC (rev 46974)
+++ scummvm/trunk/engines/sci/gui/gui.cpp 2010-01-04 16:44:58 UTC (rev 46975)
@@ -573,14 +573,18 @@
_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;
- _palette->animate(fromColor, toColor, speed);
+ return _palette->animate(fromColor, toColor, speed);
}
+void SciGui::paletteAnimateSet() {
+ _palette->setOnScreen();
+}
+
void SciGui::shakeScreen(uint16 shakeCount, uint16 directions) {
while (shakeCount--) {
if (directions & SCI_SHAKE_DIRECTION_VERTICAL)
Modified: scummvm/trunk/engines/sci/gui/gui.h
===================================================================
--- scummvm/trunk/engines/sci/gui/gui.h 2010-01-04 16:18:35 UTC (rev 46974)
+++ scummvm/trunk/engines/sci/gui/gui.h 2010-01-04 16:44:58 UTC (rev 46975)
@@ -116,7 +116,8 @@
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);
Modified: scummvm/trunk/engines/sci/gui/gui_palette.cpp
===================================================================
--- scummvm/trunk/engines/sci/gui/gui_palette.cpp 2010-01-04 16:18:35 UTC (rev 46974)
+++ scummvm/trunk/engines/sci/gui/gui_palette.cpp 2010-01-04 16:44:58 UTC (rev 46975)
@@ -296,37 +296,59 @@
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
Modified: scummvm/trunk/engines/sci/gui/gui_palette.h
===================================================================
--- scummvm/trunk/engines/sci/gui/gui_palette.h 2010-01-04 16:18:35 UTC (rev 46974)
+++ scummvm/trunk/engines/sci/gui/gui_palette.h 2010-01-04 16:44:58 UTC (rev 46975)
@@ -50,7 +50,7 @@
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;
Modified: scummvm/trunk/engines/sci/gui32/gui32.cpp
===================================================================
--- scummvm/trunk/engines/sci/gui32/gui32.cpp 2010-01-04 16:18:35 UTC (rev 46974)
+++ scummvm/trunk/engines/sci/gui32/gui32.cpp 2010-01-04 16:44:58 UTC (rev 46975)
@@ -1588,10 +1588,14 @@
#endif
}
-void SciGui32::paletteAnimate(uint16 fromColor, uint16 toColor, uint16 speed) {
+bool SciGui32::paletteAnimate(uint16 fromColor, uint16 toColor, uint16 speed) {
//warning("STUB");
+ return false;
}
+void SciGui32::paletteAnimateSet() {
+}
+
#define SHAKE_DOWN 1
#define SHAKE_RIGHT 2
Modified: scummvm/trunk/engines/sci/gui32/gui32.h
===================================================================
--- scummvm/trunk/engines/sci/gui32/gui32.h 2010-01-04 16:18:35 UTC (rev 46974)
+++ scummvm/trunk/engines/sci/gui32/gui32.h 2010-01-04 16:44:58 UTC (rev 46975)
@@ -94,7 +94,8 @@
void paletteUnsetFlag(uint16 fromColor, uint16 toColor, uint16 flag);
int16 paletteFind(uint16 r, uint16 g, uint16 b);
void paletteSetIntensity(uint16 fromColor, uint16 toColor, uint16 intensity);
- void paletteAnimate(uint16 fromColor, uint16 toColor, uint16 speed);
+ bool paletteAnimate(uint16 fromColor, uint16 toColor, uint16 speed);
+ void paletteAnimateSet();
void shakeScreen(uint16 shakeCount, uint16 directions);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list