From 666d3815ec39db7116f8140a8e470565238636f3 Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Sat, 2 Jul 2011 14:55:36 -0400 Subject: SCUMM: Don't have MoviePlayer inherit from SmackerDecoder --- engines/scumm/he/animation_he.cpp | 61 +++++++++++++++++++++++++++----------- engines/scumm/he/animation_he.h | 35 +++++++++++++--------- engines/scumm/he/script_v100he.cpp | 2 +- engines/scumm/he/script_v90he.cpp | 2 +- 4 files changed, 66 insertions(+), 34 deletions(-) (limited to 'engines/scumm') diff --git a/engines/scumm/he/animation_he.cpp b/engines/scumm/he/animation_he.cpp index 74183c24d3..95a8a701bb 100644 --- a/engines/scumm/he/animation_he.cpp +++ b/engines/scumm/he/animation_he.cpp @@ -26,27 +26,32 @@ #include "scumm/he/intern_he.h" #include "audio/audiostream.h" +#include "video/smk_decoder.h" namespace Scumm { -MoviePlayer::MoviePlayer(ScummEngine_v90he *vm, Audio::Mixer *mixer) - : SmackerDecoder(mixer), _vm(vm), _mixer(mixer) { - +MoviePlayer::MoviePlayer(ScummEngine_v90he *vm, Audio::Mixer *mixer) : _vm(vm) { + _video = new Video::SmackerDecoder(mixer); _flags = 0; _wizResNum = 0; } +MoviePlayer::~MoviePlayer() { + delete _video; +} + int MoviePlayer::getImageNum() { - if (!isVideoLoaded()) + if (!_video->isVideoLoaded()) return 0; + return _wizResNum; } int MoviePlayer::load(const char *filename, int flags, int image) { - if (isVideoLoaded()) - close(); + if (_video->isVideoLoaded()) + _video->close(); - if (!loadFile(filename)) { + if (!_video->loadFile(filename)) { warning("Failed to load video file %s", filename); return -1; } @@ -54,7 +59,7 @@ int MoviePlayer::load(const char *filename, int flags, int image) { debug(1, "Playing video %s", filename); if (flags & 2) - _vm->_wiz->createWizEmptyImage(image, 0, 0, getWidth(), getHeight()); + _vm->_wiz->createWizEmptyImage(image, 0, 0, _video->getWidth(), _video->getHeight()); _flags = flags; _wizResNum = image; @@ -62,14 +67,14 @@ int MoviePlayer::load(const char *filename, int flags, int image) { } void MoviePlayer::copyFrameToBuffer(byte *dst, int dstType, uint x, uint y, uint pitch) { - uint h = getHeight(); - uint w = getWidth(); + uint h = _video->getHeight(); + uint w = _video->getWidth(); - const Graphics::Surface *surface = decodeNextFrame(); + const Graphics::Surface *surface = _video->decodeNextFrame(); byte *src = (byte *)surface->pixels; - if (hasDirtyPalette()) - _vm->setPaletteFromPtr(getPalette(), 256); + if (_video->hasDirtyPalette()) + _vm->setPaletteFromPtr(_video->getPalette(), 256); if (_vm->_game.features & GF_16BIT_COLOR) { dst += y * pitch + x * 2; @@ -101,7 +106,7 @@ void MoviePlayer::copyFrameToBuffer(byte *dst, int dstType, uint x, uint y, uint } void MoviePlayer::handleNextFrame() { - if (!isVideoLoaded()) + if (!_video->isVideoLoaded()) return; VirtScreen *pvs = &_vm->_virtscr[kMainVirtScreen]; @@ -115,17 +120,37 @@ void MoviePlayer::handleNextFrame() { } else if (_flags & 1) { copyFrameToBuffer(pvs->getBackPixels(0, 0), kDstScreen, 0, 0, pvs->pitch); - Common::Rect imageRect(getWidth(), getHeight()); + Common::Rect imageRect(_video->getWidth(), _video->getHeight()); _vm->restoreBackgroundHE(imageRect); } else { copyFrameToBuffer(pvs->getPixels(0, 0), kDstScreen, 0, 0, pvs->pitch); - Common::Rect imageRect(getWidth(), getHeight()); + Common::Rect imageRect(_video->getWidth(), _video->getHeight()); _vm->markRectAsDirty(kMainVirtScreen, imageRect); } - if (endOfVideo()) - close(); + if (_video->endOfVideo()) + _video->close(); +} + +void MoviePlayer::close() { + _video->close(); +} + +int MoviePlayer::getWidth() const { + return _video->getWidth(); +} + +int MoviePlayer::getHeight() const { + return _video->getHeight(); +} + +int MoviePlayer::getFrameCount() const { + return _video->getFrameCount(); +} + +int MoviePlayer::getCurFrame() const { + return _video->endOfVideo() ? -1 : _video->getCurFrame() + 1; } } // End of namespace Scumm diff --git a/engines/scumm/he/animation_he.h b/engines/scumm/he/animation_he.h index b3405fead0..7fa31a195d 100644 --- a/engines/scumm/he/animation_he.h +++ b/engines/scumm/he/animation_he.h @@ -23,34 +23,41 @@ #if !defined(SCUMM_HE_ANIMATION_H) && defined(ENABLE_HE) #define SCUMM_HE_ANIMATION_H -#include "video/smk_decoder.h" - #include "audio/mixer.h" +namespace Video { + class VideoDecoder; +} + namespace Scumm { class ScummEngine_v90he; -class MoviePlayer : public Video::SmackerDecoder { - ScummEngine_v90he *_vm; - - Audio::Mixer *_mixer; - - Audio::SoundHandle _bgSound; - Audio::AudioStream *_bgSoundStream; - - char baseName[40]; - uint32 _flags; - uint32 _wizResNum; - +class MoviePlayer { public: MoviePlayer(ScummEngine_v90he *vm, Audio::Mixer *mixer); + ~MoviePlayer(); int getImageNum(); int load(const char *filename, int flags, int image = 0); void copyFrameToBuffer(byte *dst, int dstType, uint x, uint y, uint pitch); void handleNextFrame(); + + void close(); + int getWidth() const; + int getHeight() const; + int getFrameCount() const; + int getCurFrame() const; + +private: + ScummEngine_v90he *_vm; + + Video::VideoDecoder *_video; + + char baseName[40]; + uint32 _flags; + uint32 _wizResNum; }; } // End of namespace Scumm diff --git a/engines/scumm/he/script_v100he.cpp b/engines/scumm/he/script_v100he.cpp index e057ab524a..5a9172ff8a 100644 --- a/engines/scumm/he/script_v100he.cpp +++ b/engines/scumm/he/script_v100he.cpp @@ -2933,7 +2933,7 @@ void ScummEngine_v100he::o100_getVideoData() { break; case 73: pop(); - push(_moviePlay->endOfVideo() ? -1 : (_moviePlay->getCurFrame() + 1)); + push(_moviePlay->getCurFrame()); break; case 84: pop(); diff --git a/engines/scumm/he/script_v90he.cpp b/engines/scumm/he/script_v90he.cpp index 6b632d8ff2..66a0a34d16 100644 --- a/engines/scumm/he/script_v90he.cpp +++ b/engines/scumm/he/script_v90he.cpp @@ -1460,7 +1460,7 @@ void ScummEngine_v90he::o90_getVideoData() { break; case 52: // Get current frame pop(); - push(_moviePlay->endOfVideo() ? -1 : (_moviePlay->getCurFrame() + 1)); + push(_moviePlay->getCurFrame()); break; case 63: // Get image number pop(); -- cgit v1.2.3