From cc3b4cdf9937f3d89bb058f9af652c1b371f7222 Mon Sep 17 00:00:00 2001 From: Torbjörn Andersson Date: Sat, 26 Aug 2006 12:29:00 +0000 Subject: Now that the cutscene handling in both BS1 and BS2 has been extended to play DXA movies (the MPEG movies still work, of course), there is no longer any need for the MPEG decoder to handle sound and frame syncing. That is now the responsibility of the player, not the decoder. The obvious next step, then, would be to put that in a new player class, and have both BS1 and BS2 use that. Maybe FF as well. svn-id: r23757 --- engines/sword1/animation.cpp | 15 +++++---------- engines/sword1/animation.h | 3 +-- engines/sword2/animation.cpp | 13 ++++++------- engines/sword2/animation.h | 3 ++- 4 files changed, 14 insertions(+), 20 deletions(-) (limited to 'engines') diff --git a/engines/sword1/animation.cpp b/engines/sword1/animation.cpp index 9c02c431c3..f33277f21e 100644 --- a/engines/sword1/animation.cpp +++ b/engines/sword1/animation.cpp @@ -186,6 +186,7 @@ void MoviePlayer::play(void) { _scr->clearScreen(); _framesSkipped = 0; _ticks = _sys->getMillis(); + _bgSoundStream = Audio::AudioStream::openStreamFile(sequenceList[_id]); if (_bgSoundStream) { _snd->playInputStream(Audio::Mixer::kSFXSoundType, &_bgSoundHandle, _bgSoundStream); } @@ -318,9 +319,6 @@ bool MoviePlayerDXA::load(uint32 id) { _frameHeight = getHeight(); _frameX = (640 - _frameWidth) / 2; _frameY = (480 - _frameHeight) / 2; - if (!_bgSoundStream) { - _bgSoundStream = Audio::AudioStream::openStreamFile(sequenceList[id]); - } return true; } return false; @@ -395,8 +393,8 @@ void MoviePlayerMPEG::insertOverlay(OverlayColor *buf, uint8 *ovl, OverlayColor bool MoviePlayerMPEG::load(uint32 id) { if (MoviePlayer::load(id)) { - _anim = new AnimationState(this, _scr, _snd, _sys); - return _anim->init(sequenceList[id], _bgSoundStream); + _anim = new AnimationState(this, _scr, _sys); + return _anim->init(sequenceList[id]); } return false; } @@ -450,11 +448,8 @@ void MoviePlayerMPEG::processFrame(void) { #endif } -void MoviePlayerMPEG::syncFrame(void) { -} - -AnimationState::AnimationState(MoviePlayer *player, Screen *scr, Audio::Mixer *snd, OSystem *sys) - : BaseAnimationState(snd, sys, 640, 400), _player(player), _scr(scr) { +AnimationState::AnimationState(MoviePlayer *player, Screen *scr, OSystem *sys) + : BaseAnimationState(sys, 640, 400), _player(player), _scr(scr) { } AnimationState::~AnimationState(void) { diff --git a/engines/sword1/animation.h b/engines/sword1/animation.h index 1b484e9583..07aa5241f0 100644 --- a/engines/sword1/animation.h +++ b/engines/sword1/animation.h @@ -120,7 +120,7 @@ private: Screen *_scr; public: - AnimationState(MoviePlayer *player, Screen *scr, Audio::Mixer *snd, OSystem *sys); + AnimationState(MoviePlayer *player, Screen *scr, OSystem *sys); ~AnimationState(void); OverlayColor *giveRgbBuffer(void); @@ -149,7 +149,6 @@ protected: bool initOverlays(uint32 id); bool decodeFrame(void); void processFrame(void); - void syncFrame(void); void updateScreen(void); void handleScreenChanged(void); }; diff --git a/engines/sword2/animation.cpp b/engines/sword2/animation.cpp index 9f134621ec..bf60623f92 100644 --- a/engines/sword2/animation.cpp +++ b/engines/sword2/animation.cpp @@ -75,6 +75,7 @@ MoviePlayer::MoviePlayer(Sword2Engine *vm) { _vm = vm; _mixer = _vm->_mixer; _system = _vm->_system; + _name = NULL; _textSurface = NULL; _bgSoundStream = NULL; _ticks = 0; @@ -96,6 +97,7 @@ MoviePlayer::MoviePlayer(Sword2Engine *vm) { } MoviePlayer::~MoviePlayer() { + free(_name); } void MoviePlayer::updatePalette(byte *pal, bool packed) { @@ -278,6 +280,8 @@ bool MoviePlayer::load(const char *name, MovieTextObject *text[]) { _currentText = 0; _currentFrame = 0; + _name = strdup(name); + for (int i = 0; i < ARRAYSIZE(_movies); i++) { if (scumm_stricmp(name, _movies[i].name) == 0) { _seamless = _movies[i].seamless; @@ -335,8 +339,8 @@ void MoviePlayer::play(int32 leadIn, int32 leadOut) { #endif _framesSkipped = 0; - _ticks = _system->getMillis(); + _bgSoundStream = Audio::AudioStream::openStreamFile(_name); if (_bgSoundStream) { _mixer->playInputStream(Audio::Mixer::kSFXSoundType, &_bgSoundHandle, _bgSoundStream); @@ -504,8 +508,6 @@ bool MoviePlayerDXA::load(const char *name, MovieTextObject *text[]) { _frameX = (_vm->_screen->getScreenWide() - _frameWidth) / 2; _frameY = (_vm->_screen->getScreenDeep() - _frameHeight) / 2; - _bgSoundStream = Audio::AudioStream::openStreamFile(name); - return true; } @@ -566,11 +568,8 @@ bool MoviePlayerMPEG::decodeFrame() { return result; } -void MoviePlayerMPEG::syncFrame() { -} - AnimationState::AnimationState(Sword2Engine *vm, MoviePlayer *player) - : BaseAnimationState(vm->_mixer, vm->_system, 640, 480) { + : BaseAnimationState(vm->_system, 640, 480) { _vm = vm; _player = player; } diff --git a/engines/sword2/animation.h b/engines/sword2/animation.h index 337ee2b630..99c4231585 100644 --- a/engines/sword2/animation.h +++ b/engines/sword2/animation.h @@ -57,6 +57,8 @@ protected: Audio::Mixer *_mixer; OSystem *_system; + char *_name; + byte _originalPalette[4 * 256]; byte *_textSurface; @@ -156,7 +158,6 @@ protected: AnimationState *_anim; virtual bool decodeFrame(); - virtual void syncFrame(); #ifndef BACKEND_8BIT void handleScreenChanged(); -- cgit v1.2.3