aboutsummaryrefslogtreecommitdiff
path: root/engines/tinsel/faders.cpp
diff options
context:
space:
mode:
authorFilippos Karapetis2008-12-01 20:35:36 +0000
committerFilippos Karapetis2008-12-01 20:35:36 +0000
commitaf945ac7881ae7e414f004bd0e99e8c3b5d76be9 (patch)
tree72e9c6fd43406e2021973b4f163ab4faa10143fb /engines/tinsel/faders.cpp
parentf10f151ff742801e12534bb052bd89419bf906cb (diff)
downloadscummvm-rg350-af945ac7881ae7e414f004bd0e99e8c3b5d76be9.tar.gz
scummvm-rg350-af945ac7881ae7e414f004bd0e99e8c3b5d76be9.tar.bz2
scummvm-rg350-af945ac7881ae7e414f004bd0e99e8c3b5d76be9.zip
Merged the tinsel 2 engine with tinsel 1. Both Discworld 1 and Discworld 2 should be completable
svn-id: r35196
Diffstat (limited to 'engines/tinsel/faders.cpp')
-rw-r--r--engines/tinsel/faders.cpp87
1 files changed, 78 insertions, 9 deletions
diff --git a/engines/tinsel/faders.cpp b/engines/tinsel/faders.cpp
index 0018727ccb..0233dbcf4a 100644
--- a/engines/tinsel/faders.cpp
+++ b/engines/tinsel/faders.cpp
@@ -24,11 +24,14 @@
* Palette Fader and Flasher processes.
*/
-#include "tinsel/pid.h" // list of all process IDs
-#include "tinsel/sched.h" // scheduler defs
+#include "tinsel/actors.h"
#include "tinsel/faders.h" // fader defs
#include "tinsel/handle.h"
#include "tinsel/palette.h" // Palette Manager defs
+#include "tinsel/pid.h" // list of all process IDs
+#include "tinsel/sched.h" // scheduler defs
+#include "tinsel/sysvar.h"
+#include "tinsel/tinsel.h"
namespace Tinsel {
@@ -40,9 +43,7 @@ struct FADE {
// fixed point fade multiplier tables
//const long fadeout[] = {0xf000, 0xd000, 0xb000, 0x9000, 0x7000, 0x5000, 0x3000, 0x1000, 0, -1};
-const long fadeout[] = {0xd000, 0xa000, 0x7000, 0x4000, 0x1000, 0, -1};
//const long fadein[] = {0, 0x1000, 0x3000, 0x5000, 0x7000, 0x9000, 0xb000, 0xd000, 0x10000L, -1};
-const long fadein[] = {0, 0x1000, 0x4000, 0x7000, 0xa000, 0xd000, 0x10000L, -1};
/**
* Scale 'colour' by the fixed point colour multiplier 'colourMult'
@@ -70,8 +71,18 @@ static COLORREF ScaleColour(COLORREF colour, uint32 colourMult) {
*/
static void FadePalette(COLORREF *pNew, COLORREF *pOrig, int numColours, uint32 mult) {
for (int i = 0; i < numColours; i++, pNew++, pOrig++) {
- // apply multiplier to RGB components
- *pNew = ScaleColour(*pOrig, mult);
+ if (!TinselV2)
+ // apply multiplier to RGB components
+ *pNew = ScaleColour(*pOrig, mult);
+ else if (i == (TalkColour() - 1)) {
+ *pNew = GetTalkColourRef();
+ *pNew = ScaleColour(*pNew, mult);
+ } else if (SysVar(SV_TAGCOLOUR) && i == (SysVar(SV_TAGCOLOUR) - 1)) {
+ *pNew = GetTagColorRef();
+ *pNew = ScaleColour(*pNew, mult);
+ } else {
+ *pNew = ScaleColour(*pOrig, mult);
+ }
}
}
@@ -89,10 +100,14 @@ static void FadeProcess(CORO_PARAM, const void *param) {
CORO_END_CONTEXT(_ctx);
// get the fade data structure - copied to process when it was created
- FADE *pFade = (FADE *)param;
+ const FADE *pFade = (const FADE *)param;
CORO_BEGIN_CODE(_ctx);
+ if (TinselV2)
+ // Note that this palette is being faded
+ FadingPalette(pFade->pPalQ, true);
+
// get pointer to palette - reduce pointer indirection a bit
_ctx->pPalette = (PALETTE *)LockMem(pFade->pPalQ->hPal);
@@ -100,8 +115,12 @@ static void FadeProcess(CORO_PARAM, const void *param) {
// go through all multipliers in table - until a negative entry
// fade palette using next multiplier
- FadePalette(_ctx->fadeRGB, _ctx->pPalette->palRGB,
- FROM_LE_32(_ctx->pPalette->numColours), (uint32) *_ctx->pColMult);
+ if (TinselV2)
+ FadePalette(_ctx->fadeRGB, pFade->pPalQ->palRGB,
+ FROM_LE_32(pFade->pPalQ->numColours), (uint32) *_ctx->pColMult);
+ else
+ FadePalette(_ctx->fadeRGB, _ctx->pPalette->palRGB,
+ FROM_LE_32(_ctx->pPalette->numColours), (uint32) *_ctx->pColMult);
// send new palette to video DAC
UpdateDACqueue(pFade->pPalQ->posInDAC, FROM_LE_32(_ctx->pPalette->numColours), _ctx->fadeRGB);
@@ -110,6 +129,10 @@ static void FadeProcess(CORO_PARAM, const void *param) {
CORO_SLEEP(1);
}
+ if (TinselV2)
+ // Note that this palette is being faded
+ FadingPalette(pFade->pPalQ, false);
+
CORO_END_CODE;
}
@@ -122,6 +145,13 @@ static void FadeProcess(CORO_PARAM, const void *param) {
static void Fader(const long multTable[], SCNHANDLE noFadeTable[]) {
PALQ *pPal; // palette manager iterator
+ if (TinselV2) {
+ // The is only ever one cuncurrent fade
+ // But this could be a fade out and the fade in is still going!
+ g_scheduler->killMatchingProcess(PID_FADER);
+ NoFadingPalettes();
+ }
+
// create a process for each palette in the palette queue
for (pPal = GetNextPalette(NULL); pPal != NULL; pPal = GetNextPalette(pPal)) {
bool bFade = true;
@@ -156,20 +186,59 @@ static void Fader(const long multTable[], SCNHANDLE noFadeTable[]) {
/**
* Fades a list of palettes down to black.
+ * 'noFadeTable' is a NULL terminated list of palettes not to fade.
+ */
+void FadeOutMedium(SCNHANDLE noFadeTable[]) {
+ // Fixed point fade multiplier table
+ static const long fadeout[] = {0xea00, 0xd000, 0xb600, 0x9c00,
+ 0x8200, 0x6800, 0x4e00, 0x3400, 0x1a00, 0, -1};
+
+ // call generic fader
+ Fader(fadeout, noFadeTable);
+}
+
+/**
+ * Fades a list of palettes down to black.
* @param noFadeTable A NULL terminated list of palettes not to fade.
*/
void FadeOutFast(SCNHANDLE noFadeTable[]) {
+ // Fixed point fade multiplier table
+ static const long fadeout[] = {0xd000, 0xa000, 0x7000, 0x4000, 0x1000, 0, -1};
+
// call generic fader
Fader(fadeout, noFadeTable);
}
/**
* Fades a list of palettes from black to their current colours.
+ * 'noFadeTable' is a NULL terminated list of palettes not to fade.
+ */
+void FadeInMedium(SCNHANDLE noFadeTable[]) {
+ // Fade multiplier table
+ static const long fadein[] = {0, 0x1a00, 0x3400, 0x4e00, 0x6800,
+ 0x8200, 0x9c00, 0xb600, 0xd000, 0xea00, 0x10000L, -1};
+
+ // call generic fader
+ Fader(fadein, noFadeTable);
+}
+
+/**
+ * Fades a list of palettes from black to their current colours.
* @param noFadeTable A NULL terminated list of palettes not to fade.
*/
void FadeInFast(SCNHANDLE noFadeTable[]) {
+ // Fade multiplier table
+ static const long fadein[] = {0, 0x1000, 0x4000, 0x7000, 0xa000, 0xd000, 0x10000L, -1};
+
// call generic fader
Fader(fadein, noFadeTable);
}
+void PokeInTagColour(void) {
+ if (SysVar(SV_TAGCOLOUR)) {
+ static COLORREF c = GetActorRGB(-1);
+ UpdateDACqueue(SysVar(SV_TAGCOLOUR), 1, &c);
+ }
+}
+
} // end of namespace Tinsel