Ticket #8168: cmi-smushtest2.diff

File cmi-smushtest2.diff, 5.0 KB (added by eriktorbjorn, 18 years ago)

Patch against a January 29 CVS snapshot

  • scummvm/scumm/smush/brenderer.cpp

    diff -ur ScummVM-cvs20030129/scummvm/scumm/smush/brenderer.cpp ScummVM-cvs20030129+hack/scummvm/scumm/smush/brenderer.cpp
    old new  
    6767}
    6868
    6969bool BaseRenderer::flipFrame() {
    70         save();
     70        save(getFrame());
    7171        return true;
    7272}
    7373
  • scummvm/scumm/smush/brenderer.h

    diff -ur ScummVM-cvs20030129/scummvm/scumm/smush/brenderer.h ScummVM-cvs20030129+hack/scummvm/scumm/smush/brenderer.h
    old new  
    3636private:
    3737        Palette _pal;           //!< The current palette
    3838        char * _data;           //!< The current frame buffer
    39         int32 _frame;                   //!< The current frame number
    40         int32 _nbframes;                //!< The number of frames in the animation
    41         int32 _width;                   //!< The current frame's width
     39        int32 _frame;           //!< The current frame number
     40        int32 _nbframes;        //!< The number of frames in the animation
     41        bool _frameSkip;        //!< The player is skipping frames to catch up
     42        int32 _width;           //!< The current frame's width
    4243        int32 _height;          //!< The current frame's height
    4344        const char * _fname;    //!< The filename of the animation being played
    4445protected:
     
    5455        void setFrame(int32 f) { _frame = f; }; //!< allows to change the frame number
    5556public:
    5657        int32 getFrame() const { return _frame; };      //!< accessor for current frame number
     58        bool frameSkip() { return _frameSkip; };
     59        void setFrameSkip(bool skip) { _frameSkip = skip; };
    5760        BaseRenderer();
    5861        virtual ~BaseRenderer();
    5962
     
    7679protected:
    7780        void save(int32 frame = -1) {};
    7881public:
    79         NullRenderer() {};
     82        NullRenderer() { setFrameSkip(false); };
    8083        virtual ~NullRenderer() {};
    8184        bool wait(int32 ms) { return true; };
    8285};
  • scummvm/scumm/smush/scumm_renderer.cpp

    diff -ur ScummVM-cvs20030129/scummvm/scumm/smush/scumm_renderer.cpp ScummVM-cvs20030129+hack/scummvm/scumm/smush/scumm_renderer.cpp
    old new  
    203203        _pending_updates(0) {
    204204}
    205205
    206 static ScummRenderer * s_renderer;
    207 
    208 static void smush_handler(void * engine) {
    209         s_renderer->update();
    210 }
    211 
    212206Mixer * ScummRenderer::getMixer() {
    213207        if(_smixer == 0) {
    214208                _smixer = new ScummMixer(_scumm->_mixer);
    215209                if(!_smixer) error("unable to allocate a smush mixer");
    216210                _smixer->_silentMixer = _scumm->_silentDigitalImuse;
    217                 s_renderer = this;
    218                 _scumm->_timer->installProcedure(&smush_handler, _insaneSpeed);
    219211        }
    220212        return _smixer;
    221213}
     
    224216        _scumm->_insaneState = false;
    225217        _scumm->exitCutscene();
    226218        if(_smixer) {
    227                 _scumm->_timer->releaseProcedure(&smush_handler);
    228219                delete _smixer;
    229220                _smixer = 0;
    230221        }
     
    240231}
    241232
    242233bool ScummRenderer::wait(int32 ms) {
    243         // Because waitForTimer() also is the function that checks for user
    244         // input we always want to call it at least once between frames, or
    245         // the user may become unable to interrupt the movie.
    246         do {
    247                 _scumm->waitForTimer(1);
    248         } while(_pending_updates <= 0);
    249234        return true;
    250235}
    251236
     
    277262}
    278263
    279264void ScummRenderer::save(int32 frame) {
     265        int32 elapsed_time, frame_time;
     266
    280267        int width = MIN(getWidth(), _scumm->_realWidth);
    281268        int height = MIN(getHeight(), _scumm->_realHeight);
     269
     270        if (frame == 0) {
     271                _startTime = _scumm->_system->get_msecs();
     272                elapsed_time = frame_time = 0;
     273                setFrameSkip(false);
     274        } else {
     275                elapsed_time = _scumm->_system->get_msecs() - _startTime;
     276                frame_time = (frame * _insaneSpeed) / 1000;
     277        }
     278
     279        if (frame_time <= elapsed_time) {
     280                // Don't wait -- just check for user input.
     281                _scumm->waitForTimer(0);
     282        } else {
     283                _scumm->waitForTimer(frame_time - elapsed_time);
     284        }
    282285       
     286        // If the movie is lagging too far behind, skip frames in an attempt
     287        // to catch up.
    283288
    284         // In theory, this will always be true. In reality, there may be
    285         // several pending updates because the computer wasn't fast enough to
    286         // process them all. In that case, skip the frame to catch up.
    287         if (--_pending_updates <= 0) {
     289        if (elapsed_time - frame_time > 200)
     290                setFrameSkip(true);
     291
     292        if (!frameSkip()) {
    288293                _scumm->_system->copy_rect((const byte *)data(), getWidth(), 0, 0, width, height);
    289294                _scumm->_system->update_screen();
    290295        } else {
    291296                warning("ScummRenderer: Skipping frame %d to catch up", getFrame());
    292297        }
     298
     299        if (elapsed_time - frame_time < 100)
     300                setFrameSkip(false);
     301
    293302        _scumm->processKbd();
    294303}
    295304
  • scummvm/scumm/smush/scumm_renderer.h

    diff -ur ScummVM-cvs20030129/scummvm/scumm/smush/scumm_renderer.h ScummVM-cvs20030129+hack/scummvm/scumm/smush/scumm_renderer.h
    old new  
    4646        ScummMixer * _smixer;
    4747        uint32 _insaneSpeed;
    4848        volatile int _pending_updates;
     49        uint32 _startTime;
    4950public:
    5051        ScummRenderer(Scumm * scumm, uint32 speed);
    5152        virtual ~ScummRenderer();