SCI: implementing kPalVary(2)

svn-id: r50085
This commit is contained in:
Martin Kiewitz 2010-06-20 17:08:39 +00:00
parent e8262d989e
commit 7ecff0a300
3 changed files with 27 additions and 11 deletions

View File

@ -653,7 +653,8 @@ reg_t kPalVary(EngineState *s, int argc, reg_t *argv) {
ticks = argv[2].toUint16();
stepStop = argc >= 4 ? argv[3].toUint16() : 64;
direction = argc >= 5 ? argv[4].toUint16() : 1;
g_sci->_gfxPalette->kernelPalVaryInit(paletteId, ticks, stepStop, direction);
if (g_sci->_gfxPalette->kernelPalVaryInit(paletteId, ticks, stepStop, direction))
return SIGNAL_REG;
warning("kPalVary(init) called with paletteId = %d, ticks = %d, stop = %d, direction = %d", paletteId, ticks, stepStop, direction);
} else {
warning("kPalVary(init) called with unsupported argc %d", argc);
@ -664,9 +665,13 @@ reg_t kPalVary(EngineState *s, int argc, reg_t *argv) {
warning("kPalVary(1) called with parameter %d (argc %d)", argv[1].toUint16(), argc);
break;
}
case 2: { // Unknown
// Called in QFG4 demo (1 parameter)
warning("kPalVary(2) called with parameter %d (argc %d)", argv[1].toUint16(), argc);
case 2: { // Get Current Step
if (argc == 1) {
int16 currentStep = g_sci->_gfxPalette->kernelPalVaryGetCurrentStep();
return make_reg(0, currentStep);
} else {
warning("kPalVary(GetCurrentStep) called with unsupported argc %d", argc);
}
break;
}
case 3: { // DeInit
@ -687,11 +692,11 @@ reg_t kPalVary(EngineState *s, int argc, reg_t *argv) {
warning("kPalVary(5) called with parameter %d (argc %d)", argv[1].toUint16(), argc);
break;
}
case 6: { // Pause
case 6: { // Pause/Resume
bool pauseState;
if (argc == 2) {
pauseState = argv[1].isNull() ? false : true;
g_sci->_gfxPalette->kernelPalVaryToggle(pauseState);
g_sci->_gfxPalette->kernelPalVaryPause(pauseState);
warning("kPalVary(pause) called with state = %d", pauseState);
} else {
warning("kPalVary(pause) called with unsupported argc %d", argc);

View File

@ -488,11 +488,11 @@ void GfxPalette::palVaryInit() {
_palVaryDirection = 0;
}
void GfxPalette::kernelPalVaryInit(GuiResourceId resourceId, uint16 ticks, uint16 stepStop, int16 direction) {
bool GfxPalette::kernelPalVaryInit(GuiResourceId resourceId, uint16 ticks, uint16 stepStop, int16 direction) {
//kernelSetFromResource(resourceId, true);
//return;
if (_palVaryResourceId != -1) // another palvary is taking place, return
return;
return false;
_palVaryResourceId = resourceId;
Resource *palResource = _resMan->findResource(ResourceId(kResourceTypePalette, resourceId), 0);
@ -513,10 +513,20 @@ void GfxPalette::kernelPalVaryInit(GuiResourceId resourceId, uint16 ticks, uint1
}
// Call signal increase every [ticks]
g_sci->getTimerManager()->installTimerProc(&palVaryCallback, 1000000 / 60 * ticks, this);
return true;
}
return false;
}
void GfxPalette::kernelPalVaryToggle(bool pause) {
int16 GfxPalette::kernelPalVaryGetCurrentStep() {
if (_palVaryDirection >= 0)
return _palVaryStep;
return -_palVaryStep;
}
void GfxPalette::kernelPalVaryPause(bool pause) {
if (_palVaryResourceId == -1)
return;
// 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
if (pause) {

View File

@ -62,8 +62,9 @@ public:
void kernelAnimateSet();
void kernelAssertPalette(GuiResourceId resourceId);
void kernelPalVaryInit(GuiResourceId resourceId, uint16 ticks, uint16 stopPercentage, int16 direction);
void kernelPalVaryToggle(bool pause);
bool kernelPalVaryInit(GuiResourceId resourceId, uint16 ticks, uint16 stopPercentage, int16 direction);
int16 kernelPalVaryGetCurrentStep();
void kernelPalVaryPause(bool pause);
void kernelPalVaryDeinit();
void palVaryUpdate();
void palVaryProcess(int signal, bool setPalette);