aboutsummaryrefslogtreecommitdiff
path: root/engines/sci
diff options
context:
space:
mode:
authorMartin Kiewitz2010-06-20 15:01:31 +0000
committerMartin Kiewitz2010-06-20 15:01:31 +0000
commit7ce739f51b1556e211bffc3f82617013afe23cb8 (patch)
treeb5a09c1bb274efb69d7aef9f1ba1c432fbb02944 /engines/sci
parentf58c69e65d8dfa7ca924885d86043b84b18a522b (diff)
downloadscummvm-rg350-7ce739f51b1556e211bffc3f82617013afe23cb8.tar.gz
scummvm-rg350-7ce739f51b1556e211bffc3f82617013afe23cb8.tar.bz2
scummvm-rg350-7ce739f51b1556e211bffc3f82617013afe23cb8.zip
SCI: kPalVary - cleanup and some more code
svn-id: r50081
Diffstat (limited to 'engines/sci')
-rw-r--r--engines/sci/engine/kgraphics.cpp6
-rw-r--r--engines/sci/graphics/animate.cpp4
-rw-r--r--engines/sci/graphics/palette.cpp40
-rw-r--r--engines/sci/graphics/palette.h13
4 files changed, 45 insertions, 18 deletions
diff --git a/engines/sci/engine/kgraphics.cpp b/engines/sci/engine/kgraphics.cpp
index 344d79b9d2..da0f533709 100644
--- a/engines/sci/engine/kgraphics.cpp
+++ b/engines/sci/engine/kgraphics.cpp
@@ -652,7 +652,7 @@ reg_t kPalVary(EngineState *s, int argc, reg_t *argv) {
ticks = argv[2].toUint16();
paletteStop = argc >= 4 ? argv[3].toUint16() : 64;
paletteDirection = argc >= 5 ? argv[4].toUint16() : 1;
- g_sci->_gfxPalette->startPalVary(paletteId, ticks);
+ g_sci->_gfxPalette->kernelPalVaryInit(paletteId, ticks);
warning("kPalVary(init) called with paletteId = %d, ticks = %d, stop = %d, direction = %d", paletteId, ticks, paletteStop, paletteDirection);
} else {
warning("kPalVary(init) called with unsupported argc %d", argc);
@@ -670,7 +670,7 @@ reg_t kPalVary(EngineState *s, int argc, reg_t *argv) {
}
case 3: { // DeInit
if (argc == 1) {
- g_sci->_gfxPalette->stopPalVary();
+ g_sci->_gfxPalette->kernelPalVaryDeinit();
warning("kPalVary(deinit)");
} else {
warning("kPalVary(deinit) called with unsupported argc %d", argc);
@@ -690,7 +690,7 @@ reg_t kPalVary(EngineState *s, int argc, reg_t *argv) {
bool pauseState;
if (argc == 2) {
pauseState = argv[1].isNull() ? false : true;
- g_sci->_gfxPalette->togglePalVary(pauseState);
+ g_sci->_gfxPalette->kernelPalVaryToggle(pauseState);
warning("kPalVary(pause) called with state = %d", pauseState);
} else {
warning("kPalVary(pause) called with unsupported argc %d", argc);
diff --git a/engines/sci/graphics/animate.cpp b/engines/sci/graphics/animate.cpp
index 06054f3a19..339132a76c 100644
--- a/engines/sci/graphics/animate.cpp
+++ b/engines/sci/graphics/animate.cpp
@@ -35,6 +35,7 @@
#include "sci/graphics/cursor.h"
#include "sci/graphics/ports.h"
#include "sci/graphics/paint16.h"
+#include "sci/graphics/palette.h"
#include "sci/graphics/view.h"
#include "sci/graphics/screen.h"
#include "sci/graphics/transitions.h"
@@ -592,6 +593,9 @@ void GfxAnimate::animateShowPic() {
void GfxAnimate::kernelAnimate(reg_t listReference, bool cycle, int argc, reg_t *argv) {
byte old_picNotValid = _screen->_picNotValid;
+ if (getSciVersion() >= SCI_VERSION_1_1)
+ _palette->palVaryUpdate();
+
if (listReference.isNull()) {
disposeLastCast();
if (_screen->_picNotValid)
diff --git a/engines/sci/graphics/palette.cpp b/engines/sci/graphics/palette.cpp
index 56e2ff67a2..5a0a661a56 100644
--- a/engines/sci/graphics/palette.cpp
+++ b/engines/sci/graphics/palette.cpp
@@ -72,6 +72,8 @@ GfxPalette::GfxPalette(ResourceManager *resMan, GfxScreen *screen)
_alwaysForceRealMerge = true;
else if (g_sci->getGameId() == "pq1sci")
_alwaysForceRealMerge = true;
+
+ palVaryInit();
}
GfxPalette::~GfxPalette() {
@@ -473,7 +475,7 @@ void GfxPalette::kernelAssertPalette(GuiResourceId resourceId) {
// Saving/restoring
// need to save start and target-palette, when palVaryOn = true
-void GfxPalette::startPalVary(GuiResourceId resourceId, uint16 ticks) {
+void GfxPalette::kernelPalVaryInit(GuiResourceId resourceId, uint16 ticks) {
kernelSetFromResource(resourceId, true);
return;
@@ -481,19 +483,23 @@ void GfxPalette::startPalVary(GuiResourceId resourceId, uint16 ticks) {
return;
_palVaryResourceId = resourceId;
- _palVaryStart = g_system->getMillis();
- _palVaryEnd = _palVaryStart + ticks * 1000 / 60;
- g_sci->getTimerManager()->installTimerProc(&palVaryCallback, 1000000 / 60, this);
+ _palVarySignal = 0;
+ // Call signal increase every [ticks]
+ g_sci->getTimerManager()->installTimerProc(&palVaryCallback, 1000000 / 60 * ticks, this);
}
-void GfxPalette::togglePalVary(bool pause) {
+void GfxPalette::kernelPalVaryToggle(bool pause) {
// this call is actually counting states, so calling this 3 times with true will require calling it later
// 3 times with false to actually remove pause
-
- // TODO
+ if (pause) {
+ _palVaryPaused++;
+ } else {
+ if (_palVaryPaused)
+ _palVaryPaused--;
+ }
}
-void GfxPalette::stopPalVary() {
+void GfxPalette::kernelPalVaryDeinit() {
g_sci->getTimerManager()->removeTimerProc(&palVaryCallback);
// HACK: just set the target palette
@@ -502,12 +508,24 @@ void GfxPalette::stopPalVary() {
_palVaryResourceId = -1; // invalidate the target palette
}
+void GfxPalette::palVaryInit() {
+ _palVaryResourceId = -1;
+ _palVaryPaused = 0;
+ _palVarySignal = 0;
+}
+
void GfxPalette::palVaryCallback(void *refCon) {
- ((GfxPalette *)refCon)->doPalVary();
+ ((GfxPalette *)refCon)->palVaryIncreaseSignal();
+}
+
+void GfxPalette::palVaryIncreaseSignal() {
+ if (!_palVaryPaused)
+ _palVarySignal++;
}
-void GfxPalette::doPalVary() {
- // TODO: do palette transition here...
+// Actually do the pal vary processing
+void GfxPalette::palVaryUpdate() {
+
}
} // End of namespace Sci
diff --git a/engines/sci/graphics/palette.h b/engines/sci/graphics/palette.h
index 53eb97e6a1..af649015d5 100644
--- a/engines/sci/graphics/palette.h
+++ b/engines/sci/graphics/palette.h
@@ -62,21 +62,26 @@ public:
void kernelAnimateSet();
void kernelAssertPalette(GuiResourceId resourceId);
- void startPalVary(GuiResourceId resourceId, uint16 ticks);
- void togglePalVary(bool pause);
- void stopPalVary();
+ void kernelPalVaryInit(GuiResourceId resourceId, uint16 ticks);
+ void kernelPalVaryToggle(bool pause);
+ void kernelPalVaryDeinit();
+ void palVaryUpdate();
Palette _sysPalette;
private:
+ void palVaryInit();
static void palVaryCallback(void *refCon);
- void doPalVary();
+ void palVaryIncreaseSignal();
GfxScreen *_screen;
ResourceManager *_resMan;
+
GuiResourceId _palVaryResourceId;
uint32 _palVaryStart;
uint32 _palVaryEnd;
+ int _palVaryPaused;
+ int _palVarySignal;
bool _sysPaletteChanged;
bool _alwaysForceRealMerge;