mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-14 05:38:56 +00:00
Added skeleton code for sfScriptFade. Work is still needed in Gfx::palFade though, so it still doesn't work
svn-id: r28702
This commit is contained in:
parent
300ea0184a
commit
1c065b1e14
@ -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;
|
||||
}
|
||||
|
@ -113,6 +113,7 @@ enum EventOps {
|
||||
// PALETTE events
|
||||
kEventPalToBlack = 1,
|
||||
kEventBlackToPal = 2,
|
||||
kEventPalFade = 3,
|
||||
// TRANSITION events
|
||||
kEventDissolve = 1,
|
||||
kEventDissolveBGMask = 2,
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user