[Scummvm-cvs-logs] SF.net SVN: scummvm:[46700] scummvm/trunk/engines/sci/sfx

thebluegr at users.sourceforge.net thebluegr at users.sourceforge.net
Tue Dec 29 02:36:55 CET 2009


Revision: 46700
          http://scummvm.svn.sourceforge.net/scummvm/?rev=46700&view=rev
Author:   thebluegr
Date:     2009-12-29 01:36:54 +0000 (Tue, 29 Dec 2009)

Log Message:
-----------
SCI/new music code: Fixed loading of saved games. Also, stopped sounds are no longer paused

Modified Paths:
--------------
    scummvm/trunk/engines/sci/sfx/music.cpp
    scummvm/trunk/engines/sci/sfx/music.h

Modified: scummvm/trunk/engines/sci/sfx/music.cpp
===================================================================
--- scummvm/trunk/engines/sci/sfx/music.cpp	2009-12-29 01:27:15 UTC (rev 46699)
+++ scummvm/trunk/engines/sci/sfx/music.cpp	2009-12-29 01:36:54 UTC (rev 46700)
@@ -43,6 +43,9 @@
 	// 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::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 @@
 				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::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::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);
+		}
 	}
 }
 

Modified: scummvm/trunk/engines/sci/sfx/music.h
===================================================================
--- scummvm/trunk/engines/sci/sfx/music.h	2009-12-29 01:27:15 UTC (rev 46699)
+++ scummvm/trunk/engines/sci/sfx/music.h	2009-12-29 01:36:54 UTC (rev 46700)
@@ -57,6 +57,7 @@
 };
 
 class MidiParser_SCI;
+class SegManager;
 
 class MusicEntry
 #ifndef USE_OLD_MUSIC_FUNCTIONS
@@ -195,6 +196,9 @@
 	MusicList _playList;
 	bool _soundOn;
 	bool _inCriticalSection;
+
+	SegManager *_segMan;
+	ResourceManager *_resMan;
 };
 
 } // End of namespace Sci


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