aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFilippos Karapetis2009-12-29 01:36:54 +0000
committerFilippos Karapetis2009-12-29 01:36:54 +0000
commitdbbe7fd7f8e79632c1966872cbbc40e914b48e21 (patch)
treed81a379c02dbbe902094b4b887180ffb2b3fe21e
parenta6aa3d6363b95422581eef80958246154b9b98be (diff)
downloadscummvm-rg350-dbbe7fd7f8e79632c1966872cbbc40e914b48e21.tar.gz
scummvm-rg350-dbbe7fd7f8e79632c1966872cbbc40e914b48e21.tar.bz2
scummvm-rg350-dbbe7fd7f8e79632c1966872cbbc40e914b48e21.zip
SCI/new music code: Fixed loading of saved games. Also, stopped sounds are no longer paused
svn-id: r46700
-rw-r--r--engines/sci/sfx/music.cpp39
-rw-r--r--engines/sci/sfx/music.h4
2 files changed, 33 insertions, 10 deletions
diff --git a/engines/sci/sfx/music.cpp b/engines/sci/sfx/music.cpp
index 9d002da929..3edc06990f 100644
--- a/engines/sci/sfx/music.cpp
+++ b/engines/sci/sfx/music.cpp
@@ -43,6 +43,9 @@ SciMusic::SciMusic(SciVersion soundVersion)
// Reserve some space in the playlist, to avoid expensive insertion
// operations
_playList.reserve(10);
+
+ _segMan = ((SciEngine *)g_engine)->getEngineState()->_segMan; // HACK
+ _resMan = ((SciEngine *)g_engine)->getEngineState()->resMan; // HACK
}
SciMusic::~SciMusic() {
@@ -109,14 +112,12 @@ void SciMusic::clearPlayList() {
}
void SciMusic::stopAll() {
- SegManager *segMan = ((SciEngine *)g_engine)->getEngineState()->_segMan; // HACK
-
const MusicList::iterator end = _playList.end();
for (MusicList::iterator i = _playList.begin(); i != end; ++i) {
if (_soundVersion <= SCI_VERSION_0_LATE)
- PUT_SEL32V(segMan, (*i)->soundObj, state, kSoundStopped);
+ PUT_SEL32V(_segMan, (*i)->soundObj, state, kSoundStopped);
else
- PUT_SEL32V(segMan, (*i)->soundObj, signal, SIGNAL_OFFSET);
+ PUT_SEL32V(_segMan, (*i)->soundObj, signal, SIGNAL_OFFSET);
(*i)->dataInc = 0;
soundStop(*i);
@@ -318,6 +319,9 @@ void SciMusic::soundInitSnd(MusicEntry *pSnd) {
pSnd->pMidiParser->setMidiDriver(_pMidiDrv);
pSnd->pMidiParser->setTimerRate(_dwTempo);
}
+
+ pSnd->pauseCounter = 0;
+
// Find out what channels to filter for SCI0
channelFilterMask = pSnd->soundRes->getChannelFilterMask(_pMidiDrv->getPlayMask(_soundVersion));
pSnd->pMidiParser->loadMusic(track, pSnd, channelFilterMask, _soundVersion);
@@ -449,7 +453,7 @@ void SciMusic::soundKill(MusicEntry *pSnd) {
void SciMusic::soundPause(MusicEntry *pSnd) {
pSnd->pauseCounter++;
- if (pSnd->status == kSoundPaused)
+ if (pSnd->status != kSoundPlaying)
return;
pSnd->status = kSoundPaused;
if (pSnd->pStreamAud)
@@ -493,22 +497,37 @@ void SciMusic::printPlayList(Console *con) {
}
void SciMusic::reconstructPlayList(int savegame_version) {
- SegManager *segMan = ((SciEngine *)g_engine)->getEngineState()->_segMan; // HACK
- ResourceManager *resMan = ((SciEngine *)g_engine)->getEngineState()->resMan; // HACK
+ // Stop the music driver
+ if (_pMidiDrv) {
+ _pMidiDrv->close();
+ delete _pMidiDrv;
+ }
+
+ Common::StackLock lock(_mutex);
+
+ // Reinit the music driver
+ init();
const MusicList::iterator end = _playList.end();
for (MusicList::iterator i = _playList.begin(); i != end; ++i) {
if (savegame_version < 14) {
if (_soundVersion >= SCI_VERSION_1_EARLY) {
- (*i)->dataInc = GET_SEL32V(segMan, (*i)->soundObj, dataInc);
- (*i)->volume = GET_SEL32V(segMan, (*i)->soundObj, vol);
+ (*i)->dataInc = GET_SEL32V(_segMan, (*i)->soundObj, dataInc);
+ (*i)->volume = GET_SEL32V(_segMan, (*i)->soundObj, vol);
} else {
(*i)->volume = 100;
}
}
- (*i)->soundRes = new SoundResource((*i)->resnum, resMan, _soundVersion);
+ (*i)->soundRes = new SoundResource((*i)->resnum, _resMan, _soundVersion);
soundInitSnd(*i);
+ if ((*i)->pMidiParser)
+ (*i)->pMidiParser->jumpToTick((*i)->ticker);
+ // Replay all paused sounds - a lot of games pause sounds while saving, so
+ // we need to restore the correct sound state
+ if ((*i)->status == kSoundPaused) {
+ soundPlay(*i);
+ }
}
}
diff --git a/engines/sci/sfx/music.h b/engines/sci/sfx/music.h
index 0c648aac25..3fe136f48f 100644
--- a/engines/sci/sfx/music.h
+++ b/engines/sci/sfx/music.h
@@ -57,6 +57,7 @@ enum SoundStatus {
};
class MidiParser_SCI;
+class SegManager;
class MusicEntry
#ifndef USE_OLD_MUSIC_FUNCTIONS
@@ -195,6 +196,9 @@ private:
MusicList _playList;
bool _soundOn;
bool _inCriticalSection;
+
+ SegManager *_segMan;
+ ResourceManager *_resMan;
};
} // End of namespace Sci