Ticket #2883: smush2.diff

File smush2.diff, 4.5 KB (added by eriktorbjorn, 17 years ago)

Updated (and hopefully working) patch.

  • engines/scumm/intern.h

     
    589589         */
    590590        bool _smushVideoShouldFinish;
    591591
    592         /** This flag is a hack to allow the pause dialog to pause SMUSH playback, too. */
    593         bool _smushPaused;
    594 
    595592        bool _smushActive;
    596593
    597594        Insane *_insane;
  • engines/scumm/scumm.cpp

     
    773773
    774774        _smushFrameRate = 0;
    775775        _smushVideoShouldFinish = false;
    776         _smushPaused = false;
    777776        _smushActive = false;
    778777        _insaneRunning = false;
    779778        _smixer = NULL;
     
    20982097
    20992098#ifndef DISABLE_SCUMM_7_8
    21002099int ScummEngine_v7::runDialog(Dialog &dialog) {
    2101         bool oldSmushPaused = _smushPaused;
    2102         _smushPaused = true;
    2103 
     2100        _splayer->pause();
    21042101        int result = ScummEngine::runDialog(dialog);
    2105 
    2106         _smushPaused = oldSmushPaused;
    2107 
     2102        _splayer->unpause();
    21082103        return result;
    21092104}
    21102105#endif
  • engines/scumm/smush/smush_player.cpp

     
    2727#include "common/config-manager.h"
    2828#include "common/file.h"
    2929#include "common/system.h"
    30 #include "common/timer.h"
    3130#include "common/util.h"
    3231
    3332#include "graphics/cursorman.h"
     
    220219        return sr;
    221220}
    222221
    223 void SmushPlayer::timerCallback(void *refCon) {
    224         SmushPlayer *sp = (SmushPlayer *)refCon;
    225         sp->parseNextFrame();
     222void SmushPlayer::timerCallback() {
     223        parseNextFrame();
    226224#ifdef _WIN32_WCE
    227         sp->_inTimer = true;
    228         sp->_inTimerCount++;
     225        _inTimer = true;
     226        _inTimerCount++;
    229227#endif
    230228#ifdef __SYMBIAN32__
    231229        if (sp->_closeOnTextTick) {
     
    267265        _skipPalette = false;
    268266        _IACTstream = NULL;
    269267        _smixer = _vm->_smixer;
     268        _paused = false;
     269        _pauseStartTime = 0;
     270        _pauseTime = 0;
    270271#ifdef _WIN32_WCE
    271272        _inTimer = false;
    272273        _inTimerCount = 0;
     
    307308        _vm->_mixer->stopHandle(_IACTchannel);
    308309        _vm->_smixer->stop();
    309310
    310         _vm->_timer->installTimerProc(&timerCallback, 1000000 / _speed, this);
    311 
    312311        _initDone = true;
    313312}
    314313
     
    322321                User::After(15624);
    323322        }
    324323#endif
    325         _vm->_timer->removeTimerProc(&timerCallback);
    326324
    327325        _vm->_smushVideoShouldFinish = true;
    328326
     
    10751073
    10761074        Chunk *sub;
    10771075
    1078         if (_vm->_smushPaused)
    1079                 return;
    1080 
    10811076        if (_seekPos >= 0) {
    10821077                if (_smixer)
    10831078                        _smixer->stop();
     
    12741269#endif
    12751270}
    12761271
     1272void SmushPlayer::pause() {
     1273        if (!_paused) {
     1274                _paused = true;
     1275                _pauseStartTime = _vm->_system->getMillis();
     1276        }
     1277}
     1278
     1279void SmushPlayer::unpause() {
     1280        if (_paused) {
     1281                _paused = false;
     1282                _pauseTime += (_vm->_system->getMillis() - _pauseStartTime);
     1283                _pauseStartTime = 0;
     1284        }
     1285}
     1286
    12771287void SmushPlayer::play(const char *filename, int32 speed, int32 offset, int32 startFrame) {
    1278 
    12791288        // Verify the specified file exists
    12801289        ScummFile f;
    12811290        _vm->openFile(f, filename);
     
    13021311        setupAnim(filename);
    13031312        init(speed);
    13041313
     1314        uint32 startTime = _vm->_system->getMillis();
     1315
     1316        _pauseTime = 0;
     1317        uint frameNo = 0;
     1318
    13051319        for (;;) {
     1320                uint32 now = _vm->_system->getMillis() - _pauseTime;
     1321                uint32 elapsed = now - startTime;
     1322
     1323                // TODO: Sync to elapsed sound playing time, if possible.
     1324                // TODO: Frame skipping. (Decode, but don't update screen.)
     1325
     1326                if (elapsed >= (frameNo * 1000) / _speed) {
     1327                        timerCallback();
     1328                }
     1329
    13061330                if (_warpNeeded) {
    13071331                        _vm->_system->warpMouse(_warpX, _warpY);
    13081332                        _warpNeeded = false;
     
    13451369                        _inTimer = false;
    13461370                        _inTimerCount = 0;
    13471371#endif
     1372                        frameNo++;
    13481373                }
    13491374                if (_endOfFile)
    13501375                        break;
  • engines/scumm/smush/smush_player.h

     
    9797        SmushPlayer(ScummEngine_v7 *scumm);
    9898        ~SmushPlayer();
    9999
     100        void pause();
     101        void unpause();
     102
    100103        void play(const char *filename, int32 speed, int32 offset = 0, int32 startFrame = 0);
    101104        void release();
    102105        void warpMouse(int x, int y, int buttons);
     
    106109        int _width, _height;
    107110
    108111        int _origPitch, _origNumStrips;
     112        bool _paused;
     113        uint32 _pauseStartTime;
     114        uint32 _pauseTime;
    109115
    110116        void insanity(bool);
    111117        void setPalette(const byte *palette);
     
    139145        void handleDeltaPalette(Chunk &);
    140146        void readPalette(byte *, Chunk &);
    141147
    142         static void timerCallback(void *ptr);
     148        void timerCallback();
    143149};
    144150
    145151} // End of namespace Scumm