mirror of
https://github.com/scummvm/scummvm.git
synced 2026-06-20 05:45:29 +00:00
SCI: implemented kPalVary(reverse) for pharkas, although there is a bug somewhere, not working 100%
svn-id: r50089
This commit is contained in:
@@ -647,7 +647,7 @@ reg_t kPalVary(EngineState *s, int argc, reg_t *argv) {
|
||||
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 @@ reg_t kPalVary(EngineState *s, int argc, reg_t *argv) {
|
||||
}
|
||||
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) {
|
||||
|
||||
@@ -380,7 +380,7 @@ void MessageState::outputString(reg_t buf, const Common::String &str) {
|
||||
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)
|
||||
|
||||
@@ -486,9 +486,16 @@ void GfxPalette::palVaryInit() {
|
||||
_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 @@ bool GfxPalette::kernelPalVaryInit(GuiResourceId resourceId, uint16 ticks, uint1
|
||||
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::kernelPalVaryPause(bool pause) {
|
||||
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 @@ void GfxPalette::palVaryProcess(int signal, bool setPalette) {
|
||||
_palVaryStep = _palVaryStepStop;
|
||||
} else {
|
||||
if (_palVaryStep < _palVaryStepStop) {
|
||||
if (!signal)
|
||||
if (signal)
|
||||
_palVaryStep = _palVaryStepStop;
|
||||
}
|
||||
}
|
||||
@@ -588,11 +607,11 @@ void GfxPalette::palVaryProcess(int signal, bool setPalette) {
|
||||
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;
|
||||
|
||||
@@ -62,7 +62,8 @@ public:
|
||||
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 @@ public:
|
||||
|
||||
private:
|
||||
void palVaryInit();
|
||||
void palVaryInstallTimer();
|
||||
static void palVaryCallback(void *refCon);
|
||||
void palVaryIncreaseSignal();
|
||||
|
||||
@@ -87,9 +89,10 @@ private:
|
||||
GuiResourceId _palVaryResourceId;
|
||||
Palette _palVaryOriginPalette;
|
||||
Palette _palVaryTargetPalette;
|
||||
uint16 _palVaryStep;
|
||||
uint16 _palVaryStepStop;
|
||||
int16 _palVaryStep;
|
||||
int16 _palVaryStepStop;
|
||||
int16 _palVaryDirection;
|
||||
uint16 _palVaryTicks;
|
||||
int _palVaryPaused;
|
||||
int _palVarySignal;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user