Ticket #8265: bs2_fade_server.diff

File bs2_fade_server.diff, 3.7 KB (added by eriktorbjorn, 17 years ago)

Patch against a July 28 CVS snapshot

  • scummvm/bs2/driver/palette.cpp

    diff -ur ScummVM-cvs20030728/scummvm/bs2/driver/palette.cpp ScummVM-cvs20030728+hack/scummvm/bs2/driver/palette.cpp
    old new  
    154154//#include "ddraw.h"
    155155
    156156#include "stdafx.h"
     157#include "common/util.h"
    157158#include "driver96.h"
    158159#include "d_draw.h"
     160#include "../sword2.h"
    159161
    160162#define PALTABLESIZE 64*64*64
    161163
     
    407409}
    408410
    409411
    410 void FadeServer(void)
     412void FadeServer(void *engine)
    411413
    412414{
    413         warning("stub FadeServer");
     415        BS2State *bs2 = (BS2State *) engine;
     416        int32 currentTime;
     417        int16 fadeMultiplier;
     418        int16 i;
     419
     420        StackLock lock(bs2->_paletteMutex);
     421
     422        switch (fadeStatus) {
     423                case RDFADE_UP:
     424                        currentTime = SVM_timeGetTime();
     425                        if (currentTime >= fadeStartTime + fadeTotalTime) {
     426                                fadeStatus = RDFADE_NONE;
     427                                bs2->_system->set_palette((const byte *) palCopy, 0, 256);
     428                        } else {
     429                                fadeMultiplier = (int16) (((int32) (currentTime - fadeStartTime) * 256) / fadeTotalTime);
     430                                for (i=0; i<256; i++) {
     431                                        fadePalette[i][0] = (palCopy[i][0] * fadeMultiplier) >> 8;
     432                                        fadePalette[i][1] = (palCopy[i][1] * fadeMultiplier) >> 8;
     433                                        fadePalette[i][2] = (palCopy[i][2] * fadeMultiplier) >> 8;
     434                                }
     435                                bs2->_system->set_palette((const byte *) fadePalette, 0, 256);
     436                        }
     437                        break;
     438
     439                case RDFADE_DOWN:
     440                        currentTime = SVM_timeGetTime();
     441                        if (currentTime >= fadeStartTime + fadeTotalTime) {
     442                                memset(fadePalette, 0, sizeof(fadePalette));
     443                                fadeStatus = RDFADE_BLACK;
     444                        } else {
     445                                fadeMultiplier = (int16) (((int32) (fadeTotalTime - (currentTime - fadeStartTime)) * 256) / fadeTotalTime);
     446                                for (i=0; i<256; i++) {
     447                                        fadePalette[i][0] = (palCopy[i][0] * fadeMultiplier) >> 8;
     448                                        fadePalette[i][1] = (palCopy[i][1] * fadeMultiplier) >> 8;
     449                                        fadePalette[i][2] = (palCopy[i][2] * fadeMultiplier) >> 8;
     450                                }
     451                        }
     452                        bs2->_system->set_palette((const byte *) fadePalette, 0, 256);
     453                        break;
     454        }
     455
    414456/*
    415457        int32 currentTime;
    416458        int16 fadeMultiplier;
  • scummvm/bs2/driver/palette.h

    diff -ur ScummVM-cvs20030728/scummvm/bs2/driver/palette.h ScummVM-cvs20030728+hack/scummvm/bs2/driver/palette.h
    old new  
    5959extern uint8 paletteMatch[64*64*64];
    6060
    6161extern int32 RestorePalette(void);
    62 extern void FadeServer(void);
     62extern void FadeServer(void *engine);
    6363
    6464
    6565#endif
  • scummvm/bs2/sword2.cpp

    diff -ur ScummVM-cvs20030728/scummvm/bs2/sword2.cpp ScummVM-cvs20030728+hack/scummvm/bs2/sword2.cpp
    old new  
    2424
    2525#include "stdafx.h"
    2626#include "driver/driver96.h"
     27#include "driver/palette.h"
    2728#include "common/gameDetector.h"
     29#include "common/timer.h"
    2830#include "build_display.h"
    2931#include "console.h"
    3032#include "controls.h"
     
    258260
    259261        Zdebug("CALLING: InitialiseWindow");
    260262        // rv = InitialiseWindow(hInstance, hPrevInstance, lpCmdLine, nCmdShow, "Revolution");
     263
     264        _paletteMutex = _system->create_mutex();
     265        _timer->installProcedure(FadeServer, 40000 / 25);
     266
    261267        rv = RD_OK;
    262268        Zdebug("RETURNED with rv = %.8x", rv);
    263269        if (rv != RD_OK)
  • scummvm/bs2/sword2.h

    diff -ur ScummVM-cvs20030728/scummvm/bs2/sword2.h ScummVM-cvs20030728+hack/scummvm/bs2/sword2.h
    old new  
    6060                GameDetector *_detector;
    6161                uint32 _features;
    6262                byte _gameId;
     63                OSystem::MutexRef _paletteMutex;
    6364        private:
    6465                bool _quit;
    6566};