[Scummvm-cvs-logs] SF.net SVN: scummvm:[50089] scummvm/trunk/engines/sci
m_kiewitz at users.sourceforge.net
m_kiewitz at users.sourceforge.net
Sun Jun 20 20:20:05 CEST 2010
Revision: 50089
http://scummvm.svn.sourceforge.net/scummvm/?rev=50089&view=rev
Author: m_kiewitz
Date: 2010-06-20 18:20:05 +0000 (Sun, 20 Jun 2010)
Log Message:
-----------
SCI: implemented kPalVary(reverse) for pharkas, although there is a bug somewhere, not working 100%
Modified Paths:
--------------
scummvm/trunk/engines/sci/engine/kgraphics.cpp
scummvm/trunk/engines/sci/engine/message.cpp
scummvm/trunk/engines/sci/graphics/palette.cpp
scummvm/trunk/engines/sci/graphics/palette.h
Modified: scummvm/trunk/engines/sci/engine/kgraphics.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kgraphics.cpp 2010-06-20 17:20:22 UTC (rev 50088)
+++ scummvm/trunk/engines/sci/engine/kgraphics.cpp 2010-06-20 18:20:05 UTC (rev 50089)
@@ -647,7 +647,7 @@
case 0: { // Init
GuiResourceId paletteId;
uint16 ticks, stepStop;
- int16 direction;
+ uint16 direction;
if ((argc >= 3) && (argc <= 5)) {
paletteId = argv[1].toUint16();
ticks = argv[2].toUint16();
@@ -661,9 +661,20 @@
}
break;
}
- case 1: { // Unknown
- warning("kPalVary(1) called with parameter %d (argc %d)", argv[1].toUint16(), argc);
- break;
+ case 1: { // Reverse
+ int16 ticks, stepStop, direction;
+
+ if ((argc >= 1) && (argc <= 4)) {
+ ticks = argc >= 2 ? argv[1].toUint16() : -1;
+ stepStop = argc >= 3 ? argv[2].toUint16() : 0;
+ direction = argc >= 4 ? argv[3].toSint16() : -1;
+
+ int16 result = g_sci->_gfxPalette->kernelPalVaryReverse(ticks, stepStop, direction);
+ warning("kPalVary(reverse) called with ticks = %d, stop = %d, direction = %d", ticks, stepStop, direction);
+ return make_reg(0, result);
+ } else {
+ warning("kPalVary(1) called with parameter %d (argc %d)", argv[1].toUint16(), argc);
+ }
}
case 2: { // Get Current Step
if (argc == 1) {
Modified: scummvm/trunk/engines/sci/engine/message.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/message.cpp 2010-06-20 17:20:22 UTC (rev 50088)
+++ scummvm/trunk/engines/sci/engine/message.cpp 2010-06-20 18:20:05 UTC (rev 50089)
@@ -380,7 +380,7 @@
if ((unsigned)buffer_r.maxSize >= str.size() + 1) {
_segMan->strcpy(buf, str.c_str());
} else {
- error("Message: buffer %04x:%04x invalid or too small to hold the following text of %i bytes: '%s'", PRINT_REG(buf), str.size() + 1, str.c_str());
+ warning("Message: buffer %04x:%04x invalid or too small to hold the following text of %i bytes: '%s'", PRINT_REG(buf), str.size() + 1, str.c_str());
// Set buffer to empty string if possible
if (buffer_r.maxSize > 0)
Modified: scummvm/trunk/engines/sci/graphics/palette.cpp
===================================================================
--- scummvm/trunk/engines/sci/graphics/palette.cpp 2010-06-20 17:20:22 UTC (rev 50088)
+++ scummvm/trunk/engines/sci/graphics/palette.cpp 2010-06-20 18:20:05 UTC (rev 50089)
@@ -486,9 +486,16 @@
_palVaryStep = 0;
_palVaryStepStop = 0;
_palVaryDirection = 0;
+ _palVaryTicks = 0;
}
-bool GfxPalette::kernelPalVaryInit(GuiResourceId resourceId, uint16 ticks, uint16 stepStop, int16 direction) {
+void GfxPalette::palVaryInstallTimer() {
+ int16 ticks = _palVaryTicks > 0 ? _palVaryTicks : 1;
+ // Call signal increase every [ticks]
+ g_sci->getTimerManager()->installTimerProc(&palVaryCallback, 1000000 / 60 * ticks, this);
+}
+
+bool GfxPalette::kernelPalVaryInit(GuiResourceId resourceId, uint16 ticks, uint16 stepStop, uint16 direction) {
//kernelSetFromResource(resourceId, true);
//return;
if (_palVaryResourceId != -1) // another palvary is taking place, return
@@ -503,21 +510,36 @@
memcpy(&_palVaryOriginPalette, &_sysPalette, sizeof(Palette));
_palVarySignal = 0;
+ _palVaryTicks = ticks;
_palVaryStep = 1;
_palVaryStepStop = stepStop;
_palVaryDirection = direction;
- if (!ticks) {
- // if no ticks are given, jump directly to destination
+ // if no ticks are given, jump directly to destination
+ if (!_palVaryTicks)
_palVaryDirection = stepStop;
- ticks = 1;
- }
- // Call signal increase every [ticks]
- g_sci->getTimerManager()->installTimerProc(&palVaryCallback, 1000000 / 60 * ticks, this);
+ palVaryInstallTimer();
return true;
}
return false;
}
+int16 GfxPalette::kernelPalVaryReverse(int16 ticks, uint16 stepStop, int16 direction) {
+ if (_palVaryResourceId == -1)
+ return 0;
+
+ if (_palVaryStep > 64)
+ _palVaryStep = 64;
+ if (ticks != -1)
+ _palVaryTicks = ticks;
+ _palVaryStepStop = stepStop;
+ _palVaryDirection = direction != -1 ? -direction : -_palVaryDirection;
+
+ if (!_palVaryTicks)
+ _palVaryDirection = _palVaryStepStop - _palVaryStep;
+ palVaryInstallTimer();
+ return kernelPalVaryGetCurrentStep();
+}
+
int16 GfxPalette::kernelPalVaryGetCurrentStep() {
if (_palVaryDirection >= 0)
return _palVaryStep;
@@ -540,9 +562,6 @@
void GfxPalette::kernelPalVaryDeinit() {
g_sci->getTimerManager()->removeTimerProc(&palVaryCallback);
- // HACK: just set the target palette
- //kernelSetFromResource(_palVaryResourceId, true);
-
_palVaryResourceId = -1; // invalidate the target palette
}
@@ -573,7 +592,7 @@
_palVaryStep = _palVaryStepStop;
} else {
if (_palVaryStep < _palVaryStepStop) {
- if (!signal)
+ if (signal)
_palVaryStep = _palVaryStepStop;
}
}
@@ -588,11 +607,11 @@
for (int colorNr = 1; colorNr < 255; colorNr++) {
inbetween.used = _sysPalette.colors[colorNr].used;
color = _palVaryTargetPalette.colors[colorNr].r - _palVaryOriginPalette.colors[colorNr].r;
- inbetween.r = ((color * _palVaryStep) >> 6) + _palVaryOriginPalette.colors[colorNr].r;
+ inbetween.r = ((color * _palVaryStep) / 64) + _palVaryOriginPalette.colors[colorNr].r;
color = _palVaryTargetPalette.colors[colorNr].g - _palVaryOriginPalette.colors[colorNr].g;
- inbetween.g = ((color * _palVaryStep) >> 6) + _palVaryOriginPalette.colors[colorNr].g;
+ inbetween.g = ((color * _palVaryStep) / 64) + _palVaryOriginPalette.colors[colorNr].g;
color = _palVaryTargetPalette.colors[colorNr].b - _palVaryOriginPalette.colors[colorNr].b;
- inbetween.b = ((color * _palVaryStep) >> 6) + _palVaryOriginPalette.colors[colorNr].b;
+ inbetween.b = ((color * _palVaryStep) / 64) + _palVaryOriginPalette.colors[colorNr].b;
if (memcmp(&inbetween, &_sysPalette.colors[colorNr], sizeof(Sci::Color))) {
_sysPalette.colors[colorNr] = inbetween;
Modified: scummvm/trunk/engines/sci/graphics/palette.h
===================================================================
--- scummvm/trunk/engines/sci/graphics/palette.h 2010-06-20 17:20:22 UTC (rev 50088)
+++ scummvm/trunk/engines/sci/graphics/palette.h 2010-06-20 18:20:05 UTC (rev 50089)
@@ -62,7 +62,8 @@
void kernelAnimateSet();
void kernelAssertPalette(GuiResourceId resourceId);
- bool kernelPalVaryInit(GuiResourceId resourceId, uint16 ticks, uint16 stopPercentage, int16 direction);
+ bool kernelPalVaryInit(GuiResourceId resourceId, uint16 ticks, uint16 stepStop, uint16 direction);
+ int16 kernelPalVaryReverse(int16 ticks, uint16 stepStop, int16 direction);
int16 kernelPalVaryGetCurrentStep();
void kernelPalVaryPause(bool pause);
void kernelPalVaryDeinit();
@@ -73,6 +74,7 @@
private:
void palVaryInit();
+ void palVaryInstallTimer();
static void palVaryCallback(void *refCon);
void palVaryIncreaseSignal();
@@ -87,9 +89,10 @@
GuiResourceId _palVaryResourceId;
Palette _palVaryOriginPalette;
Palette _palVaryTargetPalette;
- uint16 _palVaryStep;
- uint16 _palVaryStepStop;
+ int16 _palVaryStep;
+ int16 _palVaryStepStop;
int16 _palVaryDirection;
+ uint16 _palVaryTicks;
int _palVaryPaused;
int _palVarySignal;
};
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