aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorTorbjörn Andersson2008-11-09 13:20:43 +0000
committerTorbjörn Andersson2008-11-09 13:20:43 +0000
commitdb3438f2c9f7cf1f745eb5f7c3b05c0399f846cf (patch)
tree4e8670797894b76ffa8fff607a6e9b51fd5e1f98 /engines
parent85c1d35ae378bd149670ac2c0fa928b7234eb50d (diff)
downloadscummvm-rg350-db3438f2c9f7cf1f745eb5f7c3b05c0399f846cf.tar.gz
scummvm-rg350-db3438f2c9f7cf1f745eb5f7c3b05c0399f846cf.tar.bz2
scummvm-rg350-db3438f2c9f7cf1f745eb5f7c3b05c0399f846cf.zip
Allow pausing during cutscene movies. (This will need an update to the mixer's
getSoundElapsedTime() function to work better.) svn-id: r34954
Diffstat (limited to 'engines')
-rw-r--r--engines/sword2/animation.cpp25
-rw-r--r--engines/sword2/animation.h6
-rw-r--r--engines/sword2/function.cpp9
-rw-r--r--engines/sword2/logic.cpp18
-rw-r--r--engines/sword2/logic.h4
-rw-r--r--engines/sword2/sword2.cpp4
6 files changed, 52 insertions, 14 deletions
diff --git a/engines/sword2/animation.cpp b/engines/sword2/animation.cpp
index 1452cc61dc..8c4faf4082 100644
--- a/engines/sword2/animation.cpp
+++ b/engines/sword2/animation.cpp
@@ -75,6 +75,7 @@ MoviePlayer::MoviePlayer(Sword2Engine *vm, const char *name) {
_name = strdup(name);
_mixer = _vm->_mixer;
_system = _vm->_system;
+ _pauseTicks = 0;
_textSurface = NULL;
_bgSoundStream = NULL;
_ticks = 0;
@@ -98,6 +99,10 @@ MoviePlayer::~MoviePlayer() {
free(_name);
}
+uint32 MoviePlayer::getTick() {
+ return _system->getMillis() - _pauseTicks;
+}
+
void MoviePlayer::updatePalette(byte *pal, bool packed) {
byte palette[4 * 256];
byte *p = palette;
@@ -167,7 +172,7 @@ bool MoviePlayer::checkSkipFrame() {
if ((_mixer->getSoundElapsedTime(_bgSoundHandle) * 12) / 1000 < _currentFrame + 1)
return false;
} else {
- if (_system->getMillis() <= _ticks)
+ if (getTick() <= _ticks)
return false;
}
@@ -192,9 +197,9 @@ bool MoviePlayer::syncFrame() {
// so that we can still fall back on the no-sound sync case for
// the subsequent frames.
- _ticks = _system->getMillis();
+ _ticks = getTick();
} else {
- while (_system->getMillis() < _ticks) {
+ while (getTick() < _ticks) {
_system->delayMillis(10);
}
}
@@ -392,7 +397,7 @@ void MoviePlayer::play(SequenceTextInfo *textList, uint32 numLines, int32 leadIn
savePalette();
_framesSkipped = 0;
- _ticks = _system->getMillis();
+ _ticks = getTick();
_bgSoundStream = Audio::AudioStream::openStreamFile(_name);
if (_bgSoundStream) {
@@ -497,6 +502,16 @@ void MoviePlayer::play(SequenceTextInfo *textList, uint32 numLines, int32 leadIn
restorePalette();
}
+void MoviePlayer::pauseMovie(bool pause) {
+ _mixer->pauseHandle(_bgSoundHandle, pause);
+
+ if (pause) {
+ _pauseStartTick = _system->getMillis();
+ } else {
+ _pauseTicks += (_system->getMillis() - _pauseStartTick);
+ }
+}
+
#ifdef USE_ZLIB
///////////////////////////////////////////////////////////////////////////////
@@ -840,7 +855,7 @@ bool MoviePlayerDummy::decodeFrame() {
bool MoviePlayerDummy::syncFrame() {
if ((_numSpeechLines == 0 || _currentFrame < _firstSpeechFrame) && !_mixer->isSoundHandleActive(_bgSoundHandle)) {
- _ticks = _system->getMillis();
+ _ticks = getTick();
return false;
}
diff --git a/engines/sword2/animation.h b/engines/sword2/animation.h
index fd1a1b6e78..7946ea227b 100644
--- a/engines/sword2/animation.h
+++ b/engines/sword2/animation.h
@@ -82,6 +82,9 @@ protected:
uint32 _ticks;
+ uint32 _pauseStartTick;
+ uint32 _pauseTicks;
+
uint _currentFrame;
byte *_frameBuffer;
int _frameWidth, _frameHeight;
@@ -100,6 +103,8 @@ protected:
uint32 _currentText;
+ uint32 getTick();
+
void savePalette();
void restorePalette();
@@ -125,6 +130,7 @@ public:
virtual bool load();
bool userInterrupt();
void play(SequenceTextInfo *textList, uint32 numLines, int32 leadIn, int32 leadOut);
+ void pauseMovie(bool pause);
};
class MoviePlayerDummy : public MoviePlayer {
diff --git a/engines/sword2/function.cpp b/engines/sword2/function.cpp
index 31b799386f..4c08614575 100644
--- a/engines/sword2/function.cpp
+++ b/engines/sword2/function.cpp
@@ -2139,15 +2139,16 @@ int32 Logic::fnPlaySequence(int32 *params) {
// pause sfx during sequence
_vm->_sound->pauseFx();
- MoviePlayer *player = makeMoviePlayer(_vm, filename);
+ _moviePlayer = makeMoviePlayer(_vm, filename);
- if (player->load()) {
- player->play(_sequenceTextList, _sequenceTextLines, _smackerLeadIn, _smackerLeadOut);
+ if (_moviePlayer->load()) {
+ _moviePlayer->play(_sequenceTextList, _sequenceTextLines, _smackerLeadIn, _smackerLeadOut);
}
_sequenceTextLines = 0;
- delete player;
+ delete _moviePlayer;
+ _moviePlayer = NULL;
// unpause sound fx again, in case we're staying in same location
_vm->_sound->unpauseFx();
diff --git a/engines/sword2/logic.cpp b/engines/sword2/logic.cpp
index 9ff7e6b45f..79bf544ec3 100644
--- a/engines/sword2/logic.cpp
+++ b/engines/sword2/logic.cpp
@@ -38,10 +38,10 @@
namespace Sword2 {
Logic::Logic(Sword2Engine *vm) :
- _vm(vm), _kills(0), _currentRunList(0), _smackerLeadIn(0),
- _smackerLeadOut(0), _sequenceTextLines(0), _speechTime(0), _animId(0),
- _speechAnimType(0), _leftClickDelay(0), _rightClickDelay(0),
- _officialTextNumber(0), _speechTextBlocNo(0) {
+ _vm(vm), _kills(0), _currentRunList(0), _moviePlayer(0),
+ _smackerLeadIn(0), _smackerLeadOut(0), _sequenceTextLines(0),
+ _speechTime(0), _animId(0), _speechAnimType(0), _leftClickDelay(0),
+ _rightClickDelay(0), _officialTextNumber(0), _speechTextBlocNo(0) {
_scriptVars = NULL;
memset(_eventList, 0, sizeof(_eventList));
@@ -274,4 +274,14 @@ void Logic::resetKillList() {
_kills = 0;
}
+/**
+ * Pause or unpause the currently playing cutscene movie, if any.
+ * @param pause true if pausing, false if unpausing
+ */
+
+void Logic::pauseMovie(bool pause) {
+ if (_moviePlayer)
+ _moviePlayer->pauseMovie(pause);
+}
+
} // End of namespace Sword2
diff --git a/engines/sword2/logic.h b/engines/sword2/logic.h
index 0093b85436..b98b369982 100644
--- a/engines/sword2/logic.h
+++ b/engines/sword2/logic.h
@@ -77,6 +77,8 @@ private:
EventUnit _eventList[MAX_events];
+ MoviePlayer *_moviePlayer;
+
// Resource id of the wav to use as lead-in/lead-out from smacker
uint32 _smackerLeadIn;
uint32 _smackerLeadOut;
@@ -310,6 +312,8 @@ public:
void logicReplace(uint32 new_script);
void logicOne(uint32 new_script);
void resetKillList();
+
+ void pauseMovie(bool pause);
};
} // End of namespace Sword2
diff --git a/engines/sword2/sword2.cpp b/engines/sword2/sword2.cpp
index 83235e1bde..0ce5175fa4 100644
--- a/engines/sword2/sword2.cpp
+++ b/engines/sword2/sword2.cpp
@@ -744,7 +744,7 @@ void Sword2Engine::sleepUntil(uint32 time) {
void Sword2Engine::pauseEngineIntern(bool pause) {
if (pause) {
// FIXME: We should never disallow pausing, and we need to do
- // something about pausing during cutscene moves, credits, etc.
+ // something about pausing during credits, etc.
// Don't allow Pause while screen fading or while black
if (_screen->getFadeStatus() != RDFADE_NONE)
@@ -752,6 +752,7 @@ void Sword2Engine::pauseEngineIntern(bool pause) {
_sound->pauseAllSound();
_mouse->pauseEngine(true);
+ _logic->pauseMovie(true);
#ifdef SWORD2_DEBUG
// Don't dim it if we're single-stepping through frames
@@ -766,6 +767,7 @@ void Sword2Engine::pauseEngineIntern(bool pause) {
_gamePaused = true;
} else {
_mouse->pauseEngine(false);
+ _logic->pauseMovie(false);
_sound->unpauseAllSound();
_screen->dimPalette(false);