diff options
author | Jonathan Gray | 2003-07-31 14:51:02 +0000 |
---|---|---|
committer | Jonathan Gray | 2003-07-31 14:51:02 +0000 |
commit | 6822552a1080dc0f43bbe78e3fadef257bf09672 (patch) | |
tree | 741d94ecc52bc6f5aab4af2d1679377f40c82e64 /sword2 | |
parent | 1b52e9f19cec1693dc9331b0d503aff07f507427 (diff) | |
download | scummvm-rg350-6822552a1080dc0f43bbe78e3fadef257bf09672.tar.gz scummvm-rg350-6822552a1080dc0f43bbe78e3fadef257bf09672.tar.bz2 scummvm-rg350-6822552a1080dc0f43bbe78e3fadef257bf09672.zip |
slightly changed version of erik's implmentation of FadeServer
svn-id: r9328
Diffstat (limited to 'sword2')
-rw-r--r-- | sword2/driver/d_draw.h | 3 | ||||
-rw-r--r-- | sword2/driver/palette.cpp | 54 | ||||
-rw-r--r-- | sword2/driver/palette.h | 2 | ||||
-rw-r--r-- | sword2/sword2.cpp | 7 | ||||
-rw-r--r-- | sword2/sword2.h | 1 |
5 files changed, 59 insertions, 8 deletions
diff --git a/sword2/driver/d_draw.h b/sword2/driver/d_draw.h index 0c4302bfaa..cc2ed6532f 100644 --- a/sword2/driver/d_draw.h +++ b/sword2/driver/d_draw.h @@ -69,6 +69,7 @@ extern "C" { #endif //#include "ddraw.h" +#include "driver96.h" // Bits defining hardware and emulation capabilities. #define RDCAPS_BLTSTRETCH 1 @@ -80,7 +81,7 @@ extern uint8 *lpPalette; // palette extern uint8 *lpBackBuffer; // back surface extern uint8 *lpPrimarySurface; // DirectDraw front buffer. extern uint8 *lpDD2; // DirectDraw2 object -extern BOOL bFullScreen; // Defines whether the app is running in full screen mode or not. +extern BOOL bFullScreen; // Defines whether the app is running in full screen mode or not. //extern DDCOLORKEY blackColorKey; // transparent pixel for color key blitting. extern uint8 blackColorKey; // transparent pixel for color key blitting. extern int32 dxHalCaps; // Hardware capabilities. diff --git a/sword2/driver/palette.cpp b/sword2/driver/palette.cpp index eb13b349db..a969399554 100644 --- a/sword2/driver/palette.cpp +++ b/sword2/driver/palette.cpp @@ -151,11 +151,13 @@ #include <stdio.h> //#include <mmsystem.h> -//#include "ddraw.h" -#include "stdafx.h" -#include "driver96.h" +#include "common/util.h" +#include "common/engine.h" #include "d_draw.h" +#include "driver96.h" +#include "stdafx.h" +#include "../sword2.h" #define PALTABLESIZE 64*64*64 @@ -350,7 +352,7 @@ int32 SetPalette(int16 startEntry, int16 noEntries, uint8 *colourTable, uint8 fa int32 DimPalette(void) { - warning("stub DimpPalette"); + warning("stub DimPalette"); /* uint8 *p; uint32 i; @@ -407,10 +409,50 @@ uint8 GetFadeStatus(void) } -void FadeServer(void) +void FadeServer(void *) { - warning("stub FadeServer"); + int32 currentTime; + int16 fadeMultiplier; + int16 i; + + StackLock lock(g_sword2->_paletteMutex); + + switch (fadeStatus) { + case RDFADE_UP: + currentTime = SVM_timeGetTime(); + if (currentTime >= fadeStartTime + fadeTotalTime) { + fadeStatus = RDFADE_NONE; + g_sword2->_syst->set_palette((const byte *) palCopy, 0, 256); + } else { + fadeMultiplier = (int16) (((int32) (currentTime - fadeStartTime) * 256) / fadeTotalTime); + for (i=0; i<256; i++) { + fadePalette[i][0] = (palCopy[i][0] * fadeMultiplier) >> 8; + fadePalette[i][1] = (palCopy[i][1] * fadeMultiplier) >> 8; + fadePalette[i][2] = (palCopy[i][2] * fadeMultiplier) >> 8; + } + g_sword2->_syst->set_palette((const byte *) fadePalette, 0, 256); + } + break; + + case RDFADE_DOWN: + currentTime = SVM_timeGetTime(); + if (currentTime >= fadeStartTime + fadeTotalTime) { + memset(fadePalette, 0, sizeof(fadePalette)); + fadeStatus = RDFADE_BLACK; + } else { + fadeMultiplier = (int16) (((int32) (fadeTotalTime - (currentTime - fadeStartTime)) * 256) / fadeTotalTime); + for (i=0; i<256; i++) { + fadePalette[i][0] = (palCopy[i][0] * fadeMultiplier) >> 8; + fadePalette[i][1] = (palCopy[i][1] * fadeMultiplier) >> 8; + fadePalette[i][2] = (palCopy[i][2] * fadeMultiplier) >> 8; + } + } + g_sword2->_syst->set_palette((const byte *) fadePalette, 0, 256); + break; + } + + /* int32 currentTime; int16 fadeMultiplier; diff --git a/sword2/driver/palette.h b/sword2/driver/palette.h index 3e26bd89a2..0f6cdcf843 100644 --- a/sword2/driver/palette.h +++ b/sword2/driver/palette.h @@ -59,7 +59,7 @@ extern uint8 paletteMatch[64*64*64]; extern int32 RestorePalette(void); -extern void FadeServer(void); +extern void FadeServer(void *); #endif diff --git a/sword2/sword2.cpp b/sword2/sword2.cpp index 9c82ae4eff..dfb66b5176 100644 --- a/sword2/sword2.cpp +++ b/sword2/sword2.cpp @@ -24,7 +24,9 @@ #include "stdafx.h" #include "driver/driver96.h" +#include "driver/palette.h" #include "common/gameDetector.h" +#include "common/timer.h" #include "build_display.h" #include "console.h" #include "controls.h" @@ -268,6 +270,11 @@ void Sword2State::go() return; } + _paletteMutex = _syst->create_mutex(); + _timer->installProcedure(&FadeServer, 40000 / 25); + + + Zdebug("CALLING: InitialiseDisplay"); // rv = InitialiseDisplay(640, 480, 8, RD_FULLSCREEN); _syst->init_size(640, 480); diff --git a/sword2/sword2.h b/sword2/sword2.h index 42ad3109ab..972d23d711 100644 --- a/sword2/sword2.h +++ b/sword2/sword2.h @@ -62,6 +62,7 @@ class Sword2State : public Engine { uint32 _features; byte _gameId; Sword2Sound *_sound; + OSystem::MutexRef _paletteMutex; // put in a gfx class? private: bool _quit; }; |