diff options
author | Paweł Kołodziejski | 2006-01-27 18:04:42 +0000 |
---|---|---|
committer | Paweł Kołodziejski | 2006-01-27 18:04:42 +0000 |
commit | ecced815cc05ea448e02fead1117ebdbfc26f3f0 (patch) | |
tree | 782e882911761a835323846fb3b3ef462857fcb9 /scumm/smush/smush_player.cpp | |
parent | c0938748f66c3d2e8893426d1a2aa98d32f44de2 (diff) | |
download | scummvm-rg350-ecced815cc05ea448e02fead1117ebdbfc26f3f0.tar.gz scummvm-rg350-ecced815cc05ea448e02fead1117ebdbfc26f3f0.tar.bz2 scummvm-rg350-ecced815cc05ea448e02fead1117ebdbfc26f3f0.zip |
experimental smush code without timer callback usage
svn-id: r20233
Diffstat (limited to 'scumm/smush/smush_player.cpp')
-rw-r--r-- | scumm/smush/smush_player.cpp | 124 |
1 files changed, 47 insertions, 77 deletions
diff --git a/scumm/smush/smush_player.cpp b/scumm/smush/smush_player.cpp index 06e1af0cd8..0002e260b8 100644 --- a/scumm/smush/smush_player.cpp +++ b/scumm/smush/smush_player.cpp @@ -216,14 +216,6 @@ static StringResource *getStrings(ScummEngine *vm, const char *file, bool is_enc return sr; } -void SmushPlayer::timerCallback(void *refCon) { - ((SmushPlayer *)refCon)->parseNextFrame(); -#ifdef _WIN32_WCE - ((SmushPlayer *)refCon)->_inTimer = true; - ((SmushPlayer *)refCon)->_inTimerCount++; -#endif -} - SmushPlayer::SmushPlayer(ScummEngine_v6 *scumm, int speed) { _vm = scumm; _version = -1; @@ -251,16 +243,11 @@ SmushPlayer::SmushPlayer(ScummEngine_v6 *scumm, int speed) { _IACTpos = 0; _soundFrequency = 22050; _initDone = false; - _speed = speed; + _speed = 1000000 / speed; _insanity = false; _middleAudio = false; _skipPalette = false; _IACTstream = NULL; -#ifdef _WIN32_WCE - _inTimer = false; - _inTimerCount = 0; - _inTimerCountRedraw = ConfMan.getInt("Smush_force_redraw"); -#endif } SmushPlayer::~SmushPlayer() { @@ -286,7 +273,6 @@ void SmushPlayer::init() { _vm->gdi._numStrips = _vm->virtscr[0].w / 8; _smixer = new SmushMixer(_vm->_mixer); - Common::g_timer->installTimerProc(&timerCallback, 1000000 / _speed, this); _initDone = true; } @@ -295,8 +281,6 @@ void SmushPlayer::release() { if (!_initDone) return; - _vm->_timer->removeTimerProc(&timerCallback); - _vm->_smushVideoShouldFinish = true; for (int i = 0; i < 5; i++) { @@ -333,13 +317,11 @@ void SmushPlayer::release() { // issues, see the mentioned bug report for details. _vm->_doEffect = false; - // HACK HACK HACK: This is an *evil* trick, beware! See above for // some explanation. _vm->virtscr[0].pitch = _origPitch; _vm->gdi._numStrips = _origNumStrips; - _initDone = false; } @@ -924,9 +906,6 @@ void SmushPlayer::handleFrame(Chunk &b) { debugC(DEBUG_SMUSH, "SmushPlayer::handleFrame(%d)", _frame); _skipNext = false; - uint32 start_time, end_time; - start_time = _vm->_system->getMillis(); - if (_insanity) { _vm->_insane->procPreRendering(); } @@ -994,22 +973,9 @@ void SmushPlayer::handleFrame(Chunk &b) { _vm->_insane->procPostRendering(_dst, 0, 0, 0, _frame, _nbframes-1); } - end_time = _vm->_system->getMillis(); - - if (_width != 0 && _height != 0) { -#ifdef _WIN32_WCE - if (!_inTimer || _inTimerCount == _inTimerCountRedraw) { - updateScreen(); - _inTimerCount = 0; - } -#else - updateScreen(); -#endif - } + updateScreen(); _smixer->handleFrame(); - debugC(DEBUG_SMUSH, "Smush stats: FRME( %03d ), Limit(%d)", end_time - start_time, _speed); - _frame++; } @@ -1170,7 +1136,7 @@ void SmushPlayer::updateScreen() { #ifdef DUMP_SMUSH_FRAMES char fileName[100]; // change path below for dump png files - sprintf(fileName, "/path/to/somethere/%s%04d.png", _vm->getBaseName(), _frame); + sprintf(fileName, "/path/to/somewhere/%s%04d.png", _vm->getBaseName(), _frame); FILE *file = fopen(fileName, "wb"); if (file == NULL) error("can't open file for writing png"); @@ -1218,10 +1184,7 @@ void SmushPlayer::updateScreen() { png_destroy_write_struct(&png_ptr, &info_ptr); #endif - uint32 end_time, start_time = _vm->_system->getMillis(); _updateNeeded = true; - end_time = _vm->_system->getMillis(); - debugC(DEBUG_SMUSH, "Smush stats: updateScreen( %03d )", end_time - start_time); } void SmushPlayer::insanity(bool flag) { @@ -1274,7 +1237,6 @@ void SmushPlayer::tryCmpFile(const char *filename) { } void SmushPlayer::play(const char *filename, int32 offset, int32 startFrame) { - // Verify the specified file exists ScummFile f; _vm->openFile(f, filename); @@ -1296,55 +1258,64 @@ void SmushPlayer::play(const char *filename, int32 offset, int32 startFrame) { _seekFile = filename; _seekPos = offset; _seekFrame = startFrame; - _base = 0; + _base = NULL; setupAnim(filename); init(); + int32 lastTime, thisTime, interval = _speed, counter = _speed, diff = 0; + thisTime = _vm->_system->getMillis(); + for (;;) { - if (_warpNeeded) { - _vm->_system->warpMouse(_warpX, _warpY); - _warpNeeded = false; - } - _vm->parseEvents(); - _vm->processKbd(true); - if (_palDirtyMax >= _palDirtyMin) { - byte palette_colors[1024]; - byte *p = palette_colors; - - for (int i = _palDirtyMin; i <= _palDirtyMax; i++) { - byte *data = _pal + i * 3; - - *p++ = data[0]; - *p++ = data[1]; - *p++ = data[2]; - *p++ = 0; + if (_vm->_smushVideoShouldFinish || _vm->_quit || _vm->_saveLoadFlag) + break; + + lastTime = thisTime; + thisTime = _vm->_system->getMillis(); + interval = 1000 * (thisTime - lastTime - diff); + diff = 0; + counter -= interval; + + while (counter <= 0) { + counter += _speed; + parseNextFrame(); + + if (_warpNeeded) { + _vm->_system->warpMouse(_warpX, _warpY); + _warpNeeded = false; } + + int32 before = _vm->_system->getMillis(); + _vm->parseEvents(); + _vm->processKbd(true); + diff += _vm->_system->getMillis() - before; + + if (_palDirtyMax >= _palDirtyMin) { + byte palette_colors[1024]; + byte *p = palette_colors; + + for (int i = _palDirtyMin; i <= _palDirtyMax; i++) { + byte *data = _pal + i * 3; + + *p++ = data[0]; + *p++ = data[1]; + *p++ = data[2]; + *p++ = 0; + } - _vm->_system->setPalette(palette_colors, _palDirtyMin, _palDirtyMax - _palDirtyMin + 1); + _vm->_system->setPalette(palette_colors, _palDirtyMin, _palDirtyMax - _palDirtyMin + 1); - _palDirtyMax = -1; - _palDirtyMin = 256; + _palDirtyMax = -1; + _palDirtyMin = 256; + } } - if (_updateNeeded) { - uint32 end_time, start_time; - start_time = _vm->_system->getMillis(); + if (_updateNeeded) { _vm->_system->copyRectToScreen(_dst, _width, 0, 0, _width, _height); _vm->_system->updateScreen(); _updateNeeded = false; -#ifdef _WIN32_WCE - _inTimer = false; - _inTimerCount = 0; -#endif - - end_time = _vm->_system->getMillis(); - - debugC(DEBUG_SMUSH, "Smush stats: BackendUpdateScreen( %03d )", end_time - start_time); - } - if (_vm->_smushVideoShouldFinish || _vm->_quit || _vm->_saveLoadFlag) - break; + _vm->_system->delayMillis(10); } @@ -1355,4 +1326,3 @@ void SmushPlayer::play(const char *filename, int32 offset, int32 startFrame) { } } // End of namespace Scumm - |