diff options
-rw-r--r-- | engines/agos/animation.cpp | 45 | ||||
-rw-r--r-- | engines/agos/animation.h | 3 | ||||
-rw-r--r-- | engines/scumm/he/animation_he.cpp | 8 | ||||
-rw-r--r-- | engines/sword1/animation.cpp | 2 | ||||
-rw-r--r-- | engines/sword2/animation.cpp | 2 | ||||
-rw-r--r-- | graphics/dxa_player.cpp | 43 | ||||
-rw-r--r-- | graphics/dxa_player.h | 4 |
7 files changed, 67 insertions, 40 deletions
diff --git a/engines/agos/animation.cpp b/engines/agos/animation.cpp index a482f73c98..1cbf74549d 100644 --- a/engines/agos/animation.cpp +++ b/engines/agos/animation.cpp @@ -44,6 +44,8 @@ MoviePlayer::MoviePlayer(AGOSEngine *vm, Audio::Mixer *mixer) : DXAPlayer(), _vm(vm), _mixer(mixer) { _omniTV = false; + _omniTVFile = 0; + _leftButtonDown = false; _rightButtonDown = false; @@ -103,14 +105,21 @@ bool MoviePlayer::load(const char *filename) { void MoviePlayer::playOmniTV() { // Load OmniTV video - if (!_fd.isOpen()) { - _vm->_variableArray[254] = 6747; - return; - } else { + if (_fd) { _vm->setBitFlag(42, false); _omniTV = true; startSound(); - return; + } else { + if (_omniTVFile) { + // Restore state + _fd = _omniTVFile; + _mixer->pauseHandle(_omniTVSound, false); + + _vm->setBitFlag(42, false); + _omniTV = true; + } else { + _vm->_variableArray[254] = 6747; + } } } @@ -120,7 +129,7 @@ void MoviePlayer::play() { return; } - if (!_fd.isOpen()) { + if (!_fd) { return; } @@ -161,14 +170,14 @@ void MoviePlayer::startSound() { byte *buffer; uint32 offset, size, tag; - tag = _fd.readUint32BE(); + tag = _fd->readUint32BE(); if (tag == MKID_BE('WAVE')) { - size = _fd.readUint32BE(); + size = _fd->readUint32BE(); if (_sequenceNum) { Common::File in; - _fd.seek(size, SEEK_CUR); + _fd->seek(size, SEEK_CUR); in.open((const char *)"audio.wav"); if (!in.isOpen()) { @@ -185,7 +194,7 @@ void MoviePlayer::startSound() { in.close(); } else { buffer = (byte *)malloc(size); - _fd.read(buffer, size); + _fd->read(buffer, size); } Common::MemoryReadStream stream(buffer, size); @@ -196,8 +205,13 @@ void MoviePlayer::startSound() { } if (_bgSoundStream != NULL) { - _mixer->stopHandle(_bgSound); - _mixer->playInputStream(Audio::Mixer::kSFXSoundType, &_bgSound, _bgSoundStream); + if (_omniTV) { + _mixer->stopHandle(_omniTVSound); + _mixer->playInputStream(Audio::Mixer::kSFXSoundType, &_omniTVSound, _bgSoundStream); + } else { + _mixer->stopHandle(_bgSound); + _mixer->playInputStream(Audio::Mixer::kSFXSoundType, &_bgSound, _bgSoundStream); + } } } @@ -206,8 +220,12 @@ void MoviePlayer::nextFrame() { return; if (_vm->getBitFlag(42)) { + // Save state + _omniTVFile = _fd; + _mixer->pauseHandle(_omniTVSound, true); + + _fd = 0; _omniTV = false; - closeFile(); return; } @@ -222,6 +240,7 @@ void MoviePlayer::nextFrame() { _frameNum++; } else { _omniTV = false; + _omniTVFile = 0; closeFile(); _vm->_variableArray[254] = 6747; } diff --git a/engines/agos/animation.h b/engines/agos/animation.h index 310cd0c05f..6776395ab7 100644 --- a/engines/agos/animation.h +++ b/engines/agos/animation.h @@ -44,6 +44,9 @@ class MoviePlayer : public Graphics::DXAPlayer { Audio::SoundHandle _bgSound; Audio::AudioStream *_bgSoundStream; + Audio::SoundHandle _omniTVSound; + Common::SeekableReadStream *_omniTVFile; + bool _omniTV; bool _leftButtonDown; bool _rightButtonDown; diff --git a/engines/scumm/he/animation_he.cpp b/engines/scumm/he/animation_he.cpp index da0855e1a3..3bc2f3e5d7 100644 --- a/engines/scumm/he/animation_he.cpp +++ b/engines/scumm/he/animation_he.cpp @@ -40,7 +40,7 @@ MoviePlayer::MoviePlayer(ScummEngine_v90he *vm, Audio::Mixer *mixer) } int MoviePlayer::getImageNum() { - if (!_fd.isOpen()) + if (!_fd) return 0; return _wizResNum; } @@ -48,7 +48,7 @@ int MoviePlayer::getImageNum() { int MoviePlayer::load(const char *filename, int flags, int image) { char videoName[100]; - if (_fd.isOpen()) { + if (_fd) { closeFile(); } @@ -66,7 +66,7 @@ int MoviePlayer::load(const char *filename, int flags, int image) { debug(1, "Playing video %s", videoName); // Skip sound tag - _fd.readUint32BE(); + _fd->readUint32BE(); if (flags & 2) { _vm->_wiz->createWizEmptyImage(image, 0, 0, _width, _height); @@ -85,7 +85,7 @@ int MoviePlayer::load(const char *filename, int flags, int image) { } void MoviePlayer::handleNextFrame() { - if (_fd.isOpen() == false) { + if (_fd == false) { return; } diff --git a/engines/sword1/animation.cpp b/engines/sword1/animation.cpp index d66db9347d..4aad6194e9 100644 --- a/engines/sword1/animation.cpp +++ b/engines/sword1/animation.cpp @@ -410,7 +410,7 @@ bool MoviePlayerDXA::load(uint32 id) { snprintf(filename, sizeof(filename), "%s.dxa", sequenceList[id]); if (loadFile(filename)) { // The Broken Sword games always use external audio tracks. - if (_fd.readUint32BE() != MKID_BE('NULL')) + if (_fd->readUint32BE() != MKID_BE('NULL')) return false; _frameWidth = getWidth(); _frameHeight = getHeight(); diff --git a/engines/sword2/animation.cpp b/engines/sword2/animation.cpp index 2eb24430c7..c3b20d9f57 100644 --- a/engines/sword2/animation.cpp +++ b/engines/sword2/animation.cpp @@ -518,7 +518,7 @@ bool MoviePlayerDXA::load() { if (loadFile(filename)) { // The Broken Sword games always use external audio tracks. - if (_fd.readUint32BE() != MKID_BE('NULL')) + if (_fd->readUint32BE() != MKID_BE('NULL')) return false; _frameBuffer = _vm->_screen->getScreen(); diff --git a/graphics/dxa_player.cpp b/graphics/dxa_player.cpp index 5edf526b8f..6f2bca111e 100644 --- a/graphics/dxa_player.cpp +++ b/graphics/dxa_player.cpp @@ -35,6 +35,8 @@ namespace Graphics { DXAPlayer::DXAPlayer() { + _fd = 0; + _frameBuffer1 = 0; _frameBuffer2 = 0; _scaledBuffer = 0; @@ -57,25 +59,25 @@ DXAPlayer::~DXAPlayer() { } int DXAPlayer::getWidth() { - if (!_fd.isOpen()) + if (!_fd) return 0; return _width; } int DXAPlayer::getHeight() { - if (!_fd.isOpen()) + if (!_fd) return 0; return _height; } int DXAPlayer::getCurFrame() { - if (!_fd.isOpen()) + if (!_fd) return -1; return _frameNum; } int DXAPlayer::getFrameCount() { - if (!_fd.isOpen()) + if (!_fd) return 0; return _framesCount; } @@ -84,16 +86,19 @@ bool DXAPlayer::loadFile(const char *filename) { uint32 tag; int32 frameRate; - if (!_fd.open(filename)) { + Common::File *file = new Common::File(); + if (!file->open(filename)) { return 0; } - tag = _fd.readUint32BE(); + _fd = file; + + tag = _fd->readUint32BE(); assert(tag == MKID_BE('DEXA')); - uint8 flags = _fd.readByte(); - _framesCount = _fd.readUint16BE(); - frameRate = _fd.readUint32BE(); + uint8 flags = _fd->readByte(); + _framesCount = _fd->readUint16BE(); + frameRate = _fd->readUint32BE(); if (frameRate > 0) _framesPerSec = 1000 / frameRate; @@ -107,8 +112,8 @@ bool DXAPlayer::loadFile(const char *filename) { else _frameTicks = frameRate; - _width = _fd.readUint16BE(); - _height = _fd.readUint16BE(); + _width = _fd->readUint16BE(); + _height = _fd->readUint16BE(); if (flags & 0x80) { _scaleMode = S_INTERLACED; @@ -143,10 +148,10 @@ bool DXAPlayer::loadFile(const char *filename) { } void DXAPlayer::closeFile() { - if (!_fd.isOpen()) + if (!_fd) return; - _fd.close(); + delete _fd; free(_frameBuffer1); free(_frameBuffer2); free(_scaledBuffer); @@ -478,20 +483,20 @@ void DXAPlayer::decode13(byte *data, int size, int totalSize) { void DXAPlayer::decodeNextFrame() { uint32 tag; - tag = _fd.readUint32BE(); + tag = _fd->readUint32BE(); if (tag == MKID_BE('CMAP')) { byte rgb[768]; - _fd.read(rgb, ARRAYSIZE(rgb)); + _fd->read(rgb, ARRAYSIZE(rgb)); setPalette(rgb); } - tag = _fd.readUint32BE(); + tag = _fd->readUint32BE(); if (tag == MKID_BE('FRAM')) { - byte type = _fd.readByte(); - uint32 size = _fd.readUint32BE(); + byte type = _fd->readByte(); + uint32 size = _fd->readUint32BE(); - _fd.read(_frameBuffer2, size); + _fd->read(_frameBuffer2, size); switch (type) { case 2: diff --git a/graphics/dxa_player.h b/graphics/dxa_player.h index 2b9d5f1228..b8155153c9 100644 --- a/graphics/dxa_player.h +++ b/graphics/dxa_player.h @@ -43,8 +43,6 @@ enum ScaleMode { class DXAPlayer { protected: - Common::File _fd; - byte *_frameBuffer1; byte *_frameBuffer2; byte *_scaledBuffer; @@ -63,6 +61,8 @@ public: DXAPlayer(); virtual ~DXAPlayer(); + Common::SeekableReadStream *_fd; + /** * Returns the width of the video * @return the width of the video |