[Scummvm-cvs-logs] SF.net SVN: scummvm:[34954] scummvm/trunk/engines/sword2
eriktorbjorn at users.sourceforge.net
eriktorbjorn at users.sourceforge.net
Sun Nov 9 14:20:43 CET 2008
Revision: 34954
http://scummvm.svn.sourceforge.net/scummvm/?rev=34954&view=rev
Author: eriktorbjorn
Date: 2008-11-09 13:20:43 +0000 (Sun, 09 Nov 2008)
Log Message:
-----------
Allow pausing during cutscene movies. (This will need an update to the mixer's
getSoundElapsedTime() function to work better.)
Modified Paths:
--------------
scummvm/trunk/engines/sword2/animation.cpp
scummvm/trunk/engines/sword2/animation.h
scummvm/trunk/engines/sword2/function.cpp
scummvm/trunk/engines/sword2/logic.cpp
scummvm/trunk/engines/sword2/logic.h
scummvm/trunk/engines/sword2/sword2.cpp
Modified: scummvm/trunk/engines/sword2/animation.cpp
===================================================================
--- scummvm/trunk/engines/sword2/animation.cpp 2008-11-09 13:12:38 UTC (rev 34953)
+++ scummvm/trunk/engines/sword2/animation.cpp 2008-11-09 13:20:43 UTC (rev 34954)
@@ -75,6 +75,7 @@
_name = strdup(name);
_mixer = _vm->_mixer;
_system = _vm->_system;
+ _pauseTicks = 0;
_textSurface = NULL;
_bgSoundStream = NULL;
_ticks = 0;
@@ -98,6 +99,10 @@
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 @@
if ((_mixer->getSoundElapsedTime(_bgSoundHandle) * 12) / 1000 < _currentFrame + 1)
return false;
} else {
- if (_system->getMillis() <= _ticks)
+ if (getTick() <= _ticks)
return false;
}
@@ -192,9 +197,9 @@
// 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 @@
savePalette();
_framesSkipped = 0;
- _ticks = _system->getMillis();
+ _ticks = getTick();
_bgSoundStream = Audio::AudioStream::openStreamFile(_name);
if (_bgSoundStream) {
@@ -497,6 +502,16 @@
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::syncFrame() {
if ((_numSpeechLines == 0 || _currentFrame < _firstSpeechFrame) && !_mixer->isSoundHandleActive(_bgSoundHandle)) {
- _ticks = _system->getMillis();
+ _ticks = getTick();
return false;
}
Modified: scummvm/trunk/engines/sword2/animation.h
===================================================================
--- scummvm/trunk/engines/sword2/animation.h 2008-11-09 13:12:38 UTC (rev 34953)
+++ scummvm/trunk/engines/sword2/animation.h 2008-11-09 13:20:43 UTC (rev 34954)
@@ -82,6 +82,9 @@
uint32 _ticks;
+ uint32 _pauseStartTick;
+ uint32 _pauseTicks;
+
uint _currentFrame;
byte *_frameBuffer;
int _frameWidth, _frameHeight;
@@ -100,6 +103,8 @@
uint32 _currentText;
+ uint32 getTick();
+
void savePalette();
void restorePalette();
@@ -125,6 +130,7 @@
virtual bool load();
bool userInterrupt();
void play(SequenceTextInfo *textList, uint32 numLines, int32 leadIn, int32 leadOut);
+ void pauseMovie(bool pause);
};
class MoviePlayerDummy : public MoviePlayer {
Modified: scummvm/trunk/engines/sword2/function.cpp
===================================================================
--- scummvm/trunk/engines/sword2/function.cpp 2008-11-09 13:12:38 UTC (rev 34953)
+++ scummvm/trunk/engines/sword2/function.cpp 2008-11-09 13:20:43 UTC (rev 34954)
@@ -2139,15 +2139,16 @@
// 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();
Modified: scummvm/trunk/engines/sword2/logic.cpp
===================================================================
--- scummvm/trunk/engines/sword2/logic.cpp 2008-11-09 13:12:38 UTC (rev 34953)
+++ scummvm/trunk/engines/sword2/logic.cpp 2008-11-09 13:20:43 UTC (rev 34954)
@@ -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 @@
_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
Modified: scummvm/trunk/engines/sword2/logic.h
===================================================================
--- scummvm/trunk/engines/sword2/logic.h 2008-11-09 13:12:38 UTC (rev 34953)
+++ scummvm/trunk/engines/sword2/logic.h 2008-11-09 13:20:43 UTC (rev 34954)
@@ -77,6 +77,8 @@
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 @@
void logicReplace(uint32 new_script);
void logicOne(uint32 new_script);
void resetKillList();
+
+ void pauseMovie(bool pause);
};
} // End of namespace Sword2
Modified: scummvm/trunk/engines/sword2/sword2.cpp
===================================================================
--- scummvm/trunk/engines/sword2/sword2.cpp 2008-11-09 13:12:38 UTC (rev 34953)
+++ scummvm/trunk/engines/sword2/sword2.cpp 2008-11-09 13:20:43 UTC (rev 34954)
@@ -744,7 +744,7 @@
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 @@
_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 @@
_gamePaused = true;
} else {
_mouse->pauseEngine(false);
+ _logic->pauseMovie(false);
_sound->unpauseAllSound();
_screen->dimPalette(false);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list