diff options
Diffstat (limited to 'engines/toltecs/movie.cpp')
-rw-r--r-- | engines/toltecs/movie.cpp | 58 |
1 files changed, 29 insertions, 29 deletions
diff --git a/engines/toltecs/movie.cpp b/engines/toltecs/movie.cpp index 76d42ebf0a..35accb5d93 100644 --- a/engines/toltecs/movie.cpp +++ b/engines/toltecs/movie.cpp @@ -61,7 +61,7 @@ void MoviePlayer::playMovie(uint resIndex) { int16 savedCameraY = _vm->_cameraY; int16 savedGuiHeight = _vm->_guiHeight; byte moviePalette[768]; - + _vm->_isSaveAllowed = false; memset(moviePalette, 0, sizeof(moviePalette)); @@ -78,7 +78,7 @@ void MoviePlayer::playMovie(uint resIndex) { _vm->_arc->readUint32LE(); _vm->_arc->readUint32LE(); _framesPerSoundChunk = _vm->_arc->readUint32LE(); - _vm->_arc->readUint32LE(); + int rate = _vm->_arc->readUint32LE(); _vm->_sceneWidth = 640; _vm->_sceneHeight = 400; @@ -87,7 +87,7 @@ void MoviePlayer::playMovie(uint resIndex) { _vm->_cameraY = 0; _vm->_guiHeight = 0; - _audioStream = Audio::makeQueuingAudioStream(22050, false); + _audioStream = Audio::makeQueuingAudioStream(rate, false); _vm->_mixer->playStream(Audio::Mixer::kPlainSoundType, &_audioStreamHandle, _audioStream); @@ -96,49 +96,52 @@ void MoviePlayer::playMovie(uint resIndex) { fetchAudioChunks(); - uint32 lastTime = _vm->_mixer->getSoundElapsedTime(_audioStreamHandle); + byte *chunkBuffer = NULL; + uint32 chunkBufferSize = 0; + uint32 frame = 0; while (_chunkCount--) { - byte chunkType = _vm->_arc->readByte(); uint32 chunkSize = _vm->_arc->readUint32LE(); - byte *chunkBuffer = NULL; - uint32 movieOffset; debug(0, "chunkType = %d; chunkSize = %d", chunkType, chunkSize); - + // Skip audio chunks - we've already queued them in // fetchAudioChunks() above if (chunkType == kChunkAudio) { _vm->_arc->skip(chunkSize); } else { - chunkBuffer = new byte[chunkSize]; + // Only reallocate the chunk buffer if the new chunk is bigger + if (chunkSize > chunkBufferSize) { + delete[] chunkBuffer; + chunkBuffer = new byte[chunkSize]; + chunkBufferSize = chunkSize; + } + _vm->_arc->read(chunkBuffer, chunkSize); } - movieOffset = _vm->_arc->pos(); - switch (chunkType) { case kChunkFirstImage: case kChunkSubsequentImages: unpackRle(chunkBuffer, _vm->_screen->_backScreen); - // TODO: Rework this - _vm->_screen->updateShakeScreen(); _vm->_screen->_fullRefresh = true; - _vm->updateInput(); - _vm->drawScreen(); _soundChunkFramesLeft--; if (_soundChunkFramesLeft <= _framesPerSoundChunk) { fetchAudioChunks(); } - while (_vm->_mixer->getSoundElapsedTime(_audioStreamHandle) < lastTime + 111) { - g_system->delayMillis(10); + while (_vm->_mixer->getSoundElapsedTime(_audioStreamHandle) < (1000 * frame) / 9) { + if (_vm->_screen->_shakeActive && _vm->_screen->updateShakeScreen()) { + _vm->_screen->_fullRefresh = true; + } + _vm->updateInput(); + _vm->drawScreen(); + // Note: drawScreen() calls delayMillis() } - lastTime = _vm->_mixer->getSoundElapsedTime(_audioStreamHandle); - + frame++; break; case kChunkPalette: unpackPalette(chunkBuffer, moviePalette, 256, 3); @@ -150,10 +153,10 @@ void MoviePlayer::playMovie(uint resIndex) { // Already processed break; case kChunkShowSubtitle: - // TODO: Check if the text is a subtitle (last character == 0xFE). - // If so, don't show it if text display is disabled. - memcpy(_vm->_script->getSlotData(subtitleSlot), chunkBuffer, chunkSize); - _vm->_screen->updateTalkText(subtitleSlot, 0); + if (_vm->_cfgText) { + memcpy(_vm->_script->getSlotData(subtitleSlot), chunkBuffer, chunkSize); + _vm->_screen->updateTalkText(subtitleSlot, 0); + } break; case kChunkShakeScreen: // start/stop shakescreen effect if (chunkBuffer[0] == 0xFF) @@ -176,20 +179,17 @@ void MoviePlayer::playMovie(uint resIndex) { error("MoviePlayer::playMovie(%04X) Unknown chunk type %d at %08X", resIndex, chunkType, _vm->_arc->pos() - 5 - chunkSize); } - delete[] chunkBuffer; - - _vm->_arc->seek(movieOffset, SEEK_SET); - if (!handleInput()) break; - } + delete[] chunkBuffer; + _audioStream->finish(); _vm->_mixer->stopHandle(_audioStreamHandle); _vm->_arc->closeResource(); - + debug(0, "playMovie() done"); _vm->_sceneWidth = savedSceneWidth; |