Ticket #8168: cmi-smushtest.diff

File cmi-smushtest.diff, 3.3 KB (added by eriktorbjorn, 17 years ago)

Patch against a January 29 CVS snapshot

  • scummvm/scumm/smush/scumm_renderer.cpp

    diff -ur ScummVM-cvs20030128/scummvm/scumm/smush/scumm_renderer.cpp ScummVM-cvs20030128+hack/scummvm/scumm/smush/scumm_renderer.cpp
    old new  
    200200        _scumm(scumm),
    201201        _smixer(0),
    202202        _insaneSpeed(speed),
    203         _pending_updates(0) {
     203        _pending_updates(0),
     204        _startTime(_scumm->_system->get_msecs()) {
    204205}
    205206
    206 static ScummRenderer * s_renderer;
     207uint32 ScummRenderer::getElapsedTime() {
     208        return _scumm->_system->get_msecs() - _startTime;
     209}
    207210
    208 static void smush_handler(void * engine) {
    209         s_renderer->update();
     211uint32 ScummRenderer::getFrameTime() {
     212        return (getFrame() * _insaneSpeed) / 1000;
    210213}
    211214
    212215Mixer * ScummRenderer::getMixer() {
     
    214217                _smixer = new ScummMixer(_scumm->_mixer);
    215218                if(!_smixer) error("unable to allocate a smush mixer");
    216219                _smixer->_silentMixer = _scumm->_silentDigitalImuse;
    217                 s_renderer = this;
    218                 _scumm->_timer->installProcedure(&smush_handler, _insaneSpeed);
    219220        }
    220221        return _smixer;
    221222}
     
    224225        _scumm->_insaneState = false;
    225226        _scumm->exitCutscene();
    226227        if(_smixer) {
    227                 _scumm->_timer->releaseProcedure(&smush_handler);
    228228                delete _smixer;
    229229                _smixer = 0;
    230230        }
     
    240240}
    241241
    242242bool 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);
    249         return true;
     243        int32 elapsed_time, frame_time;
     244
     245        elapsed_time = getElapsedTime();
     246        frame_time = getFrameTime();
     247
     248        if (frame_time < elapsed_time) {
     249                // Don't wait -- just check for user input.
     250                _scumm->waitForTimer(0);
     251        } else {
     252                _scumm->waitForTimer(frame_time - elapsed_time);
     253        }
     254        return true;
    250255}
    251256
    252257bool ScummRenderer::startDecode(const char * fname, int32 version, int32 nbframes) {
     
    277282}
    278283
    279284void ScummRenderer::save(int32 frame) {
     285        int32 elapsed_time, frame_time;
     286
    280287        int width = MIN(getWidth(), _scumm->_realWidth);
    281288        int height = MIN(getHeight(), _scumm->_realHeight);
    282        
     289
     290        elapsed_time = getElapsedTime();
     291        frame_time = getFrameTime();
    283292
    284293        // In theory, this will always be true. In reality, there may be
    285294        // 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) {
     295        // process them all. If we lag too far behind, skip frames in an
     296        // attempt to catch up.
     297
     298        if (elapsed_time - frame_time < 200) {
    288299                _scumm->_system->copy_rect((const byte *)data(), getWidth(), 0, 0, width, height);
    289300                _scumm->_system->update_screen();
    290301        } else {
  • scummvm/scumm/smush/scumm_renderer.h

    diff -ur ScummVM-cvs20030128/scummvm/scumm/smush/scumm_renderer.h ScummVM-cvs20030128+hack/scummvm/scumm/smush/scumm_renderer.h
    old new  
    4646        ScummMixer * _smixer;
    4747        uint32 _insaneSpeed;
    4848        volatile int _pending_updates;
     49        uint32 _startTime;
     50        uint32 getElapsedTime();
     51        uint32 getFrameTime();
    4952public:
    5053        ScummRenderer(Scumm * scumm, uint32 speed);
    5154        virtual ~ScummRenderer();