aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorFilippos Karapetis2007-08-23 13:56:25 +0000
committerFilippos Karapetis2007-08-23 13:56:25 +0000
commit1c065b1e1479e1320e936d9df5f95af0ae2ac20d (patch)
treed1ce3a97238832ccbeffa7526154e1639b4f9788 /engines
parent300ea0184a9b7f7ceca3e6e842d71fbc05a05a16 (diff)
downloadscummvm-rg350-1c065b1e1479e1320e936d9df5f95af0ae2ac20d.tar.gz
scummvm-rg350-1c065b1e1479e1320e936d9df5f95af0ae2ac20d.tar.bz2
scummvm-rg350-1c065b1e1479e1320e936d9df5f95af0ae2ac20d.zip
Added skeleton code for sfScriptFade. Work is still needed in Gfx::palFade though, so it still doesn't work
svn-id: r28702
Diffstat (limited to 'engines')
-rw-r--r--engines/saga/events.cpp8
-rw-r--r--engines/saga/events.h1
-rw-r--r--engines/saga/gfx.cpp81
-rw-r--r--engines/saga/gfx.h1
-rw-r--r--engines/saga/sfuncs.cpp31
5 files changed, 99 insertions, 23 deletions
diff --git a/engines/saga/events.cpp b/engines/saga/events.cpp
index 187ffedcad..92ba67eb6d 100644
--- a/engines/saga/events.cpp
+++ b/engines/saga/events.cpp
@@ -154,10 +154,12 @@ int Events::handleContinuous(Event *event) {
case kEventBlackToPal:
_vm->_gfx->blackToPal((PalEntry *)event->data, event_pc);
break;
-
case kEventPalToBlack:
_vm->_gfx->palToBlack((PalEntry *)event->data, event_pc);
break;
+ case kEventPalFade:
+ _vm->_gfx->palFade((PalEntry *)event->data, event->param, event->param2, event->param3, event->param4, event_pc);
+ break;
default:
break;
}
@@ -237,10 +239,12 @@ int Events::handleImmediate(Event *event) {
case kEventBlackToPal:
_vm->_gfx->blackToPal((PalEntry *)event->data, event_pc);
break;
-
case kEventPalToBlack:
_vm->_gfx->palToBlack((PalEntry *)event->data, event_pc);
break;
+ case kEventPalFade:
+ _vm->_gfx->palFade((PalEntry *)event->data, event->param, event->param2, event->param3, event->param4, event_pc);
+ break;
default:
break;
}
diff --git a/engines/saga/events.h b/engines/saga/events.h
index 2486525751..8401575818 100644
--- a/engines/saga/events.h
+++ b/engines/saga/events.h
@@ -113,6 +113,7 @@ enum EventOps {
// PALETTE events
kEventPalToBlack = 1,
kEventBlackToPal = 2,
+ kEventPalFade = 3,
// TRANSITION events
kEventDissolve = 1,
kEventDissolveBGMask = 2,
diff --git a/engines/saga/gfx.cpp b/engines/saga/gfx.cpp
index 92d55841bb..86160fc98d 100644
--- a/engines/saga/gfx.cpp
+++ b/engines/saga/gfx.cpp
@@ -400,6 +400,87 @@ void Gfx::blackToPal(PalEntry *srcPal, double percent) {
_system->setPalette(_currentPal, 0, PAL_ENTRIES);
}
+// Used in IHNM only
+void Gfx::palFade(PalEntry *srcPal, int16 from, int16 to, int16 start, int16 numColors, double percent) {
+ //short value, delta;
+ int i;
+ int new_entry;
+ byte *ppal;
+ PalEntry *palE;
+
+ double fpercent;
+
+ if (percent > 1.0)
+ percent = 1.0;
+
+ if (from > 256)
+ from = 256;
+ if (from < 0 )
+ from = 0;
+ if (to > 256)
+ to = 256;
+ if (to < 0)
+ to = 0;
+
+ // Exponential fade
+ fpercent = percent * percent;
+
+ fpercent = 1.0 - fpercent;
+
+ // TODO: finish this
+ //delta = (from < to) ? +1 : -1;
+ if (percent == 0.0) // only display the warning once
+ warning("TODO: Gfx::palFade");
+
+ return; // Don't do anything for now
+
+ /*
+ for (value = from; value != to+delta; value += delta) {
+ // adjust palette color
+ // delay here
+ }
+ */
+ //_vm->_frameCount++; // is this needed?
+
+ // Use the correct percentage change per frame for each palette entry
+ for (i = 0, ppal = _currentPal; i < PAL_ENTRIES; i++, ppal += 4) {
+ if (i < from || i >= from + numColors)
+ palE = &_globalPalette[i];
+ else
+ palE = &srcPal[i];
+
+ new_entry = (int)(palE->red * fpercent);
+
+ if (new_entry < 0) {
+ ppal[0] = 0;
+ } else {
+ ppal[0] = (byte) new_entry;
+ }
+
+ new_entry = (int)(palE->green * fpercent);
+
+ if (new_entry < 0) {
+ ppal[1] = 0;
+ } else {
+ ppal[1] = (byte) new_entry;
+ }
+
+ new_entry = (int)(palE->blue * fpercent);
+
+ if (new_entry < 0) {
+ ppal[2] = 0;
+ } else {
+ ppal[2] = (byte) new_entry;
+ }
+ ppal[3] = 0;
+ }
+
+ // Color 0 should always be black in IHNM
+ memset(&_currentPal[0 * 4], 0, 4);
+
+ _system->setPalette(_currentPal, 0, PAL_ENTRIES);
+}
+
void Gfx::showCursor(bool state) {
CursorMan.showMouse(state);
}
diff --git a/engines/saga/gfx.h b/engines/saga/gfx.h
index 0fa7aab742..ea1370c79d 100644
--- a/engines/saga/gfx.h
+++ b/engines/saga/gfx.h
@@ -150,6 +150,7 @@ public:
void restorePalette() { setPalette(_savedPalette, true); }
void palToBlack(PalEntry *src_pal, double percent);
void blackToPal(PalEntry *src_pal, double percent);
+ void palFade(PalEntry *srcPal, int16 from, int16 to, int16 start, int16 numColors, double percent);
void showCursor(bool state);
void setCursor(CursorType cursorType = kCursorNormal);
diff --git a/engines/saga/sfuncs.cpp b/engines/saga/sfuncs.cpp
index 0794e236e1..64d9a062fd 100644
--- a/engines/saga/sfuncs.cpp
+++ b/engines/saga/sfuncs.cpp
@@ -1956,38 +1956,27 @@ void Script::sfWaitFrames(SCRIPTFUNC_PARAMS) {
}
void Script::sfScriptFade(SCRIPTFUNC_PARAMS) {
- thread->pop(); // first pal entry, ignored (already handled by Gfx::palToBlack)
- thread->pop(); // last pal entry, ignored (already handled by Gfx::palToBlack)
+ int16 firstPalEntry = thread->pop();
+ int16 lastPalEntry = thread->pop();
int16 startingBrightness = thread->pop();
int16 endingBrightness = thread->pop();
- // delay between pal changes is always 10 (not used)
- static PalEntry cur_pal[PAL_ENTRIES];
Event event;
- short delta = (startingBrightness < endingBrightness) ? +1 : -1;
+ static PalEntry cur_pal[PAL_ENTRIES];
_vm->_gfx->getCurrentPal(cur_pal);
- // TODO: This is still wrong, probably a new event type needs to be added (kEventPalFade)
- warning("TODO: sfScriptFade");
- return;
-
- if (startingBrightness > 255)
- startingBrightness = 255;
- if (startingBrightness < 0 )
- startingBrightness = 0;
- if (endingBrightness > 255)
- endingBrightness = 255;
- if (endingBrightness < 0)
- endingBrightness = 0;
-
event.type = kEvTImmediate;
event.code = kPalEvent;
- event.op = kEventPalToBlack;
+ event.op = kEventPalFade;
event.time = 0;
- event.duration = kNormalFadeDuration - ((endingBrightness - startingBrightness) * delta);
+ event.duration = kNormalFadeDuration;
event.data = cur_pal;
+ event.param = startingBrightness;
+ event.param2 = endingBrightness;
+ event.param3 = firstPalEntry;
+ event.param4 = lastPalEntry - firstPalEntry + 1;
- _vm->_events->queue(&event);
+ _vm->_events->queue(&event);
}
void Script::sfScriptStartVideo(SCRIPTFUNC_PARAMS) {