SCUMM: Don't have MoviePlayer inherit from SmackerDecoder

This commit is contained in:
Matthew Hoops 2011-07-02 14:55:36 -04:00
parent f7efd3fe2a
commit 666d3815ec
4 changed files with 66 additions and 34 deletions

View File

@ -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

View File

@ -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

View File

@ -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();

View File

@ -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();