diff options
| -rw-r--r-- | engines/sci/engine/savegame.cpp | 4 | ||||
| -rw-r--r-- | engines/sci/engine/savegame.h | 3 | ||||
| -rw-r--r-- | engines/sci/resource.h | 2 | ||||
| -rw-r--r-- | engines/sci/resource_audio.cpp | 4 | ||||
| -rw-r--r-- | engines/sci/sound/music.cpp | 2 | ||||
| -rw-r--r-- | engines/sci/sound/music.h | 1 | ||||
| -rw-r--r-- | engines/sci/sound/soundcmd.cpp | 26 | 
7 files changed, 30 insertions, 12 deletions
| diff --git a/engines/sci/engine/savegame.cpp b/engines/sci/engine/savegame.cpp index eee4c49729..61f8058e45 100644 --- a/engines/sci/engine/savegame.cpp +++ b/engines/sci/engine/savegame.cpp @@ -621,6 +621,10 @@ void MusicEntry::saveLoadWithSerializer(Common::Serializer &s) {  		s.syncAsByte(playBed);  	else if (s.isLoading())  		playBed = false; +	if (s.getVersion() >= 33) +		s.syncAsByte(overridePriority); +	else if (s.isLoading()) +		overridePriority = false;  	// pMidiParser and pStreamAud will be initialized when the  	// sound list is reconstructed in gamestate_restore() diff --git a/engines/sci/engine/savegame.h b/engines/sci/engine/savegame.h index be6d05cdc5..7f482ed0a1 100644 --- a/engines/sci/engine/savegame.h +++ b/engines/sci/engine/savegame.h @@ -37,6 +37,7 @@ struct EngineState;   *   * Version - new/changed feature   * ============================= + *      33 - new overridePriority flag in MusicEntry   *      32 - new playBed flag in MusicEntry   *      31 - priority for sound effects/music is now a signed int16, instead of a byte   *      30 - synonyms @@ -57,7 +58,7 @@ struct EngineState;   */  enum { -	CURRENT_SAVEGAME_VERSION = 32, +	CURRENT_SAVEGAME_VERSION = 33,  	MINIMUM_SAVEGAME_VERSION = 14  }; diff --git a/engines/sci/resource.h b/engines/sci/resource.h index 62f3c584ac..ef48998b04 100644 --- a/engines/sci/resource.h +++ b/engines/sci/resource.h @@ -596,6 +596,7 @@ public:  	Track *getDigitalTrack();  	int getChannelFilterMask(int hardwareMask, bool wantsRhythm);  	byte getInitialVoiceCount(byte channel); +	byte getSoundPriority() const { return _soundPriority; }  private:  	SciVersion _soundVersion; @@ -603,6 +604,7 @@ private:  	Track *_tracks;  	Resource *_innerResource;  	ResourceManager *_resMan; +	byte _soundPriority;  };  } // End of namespace Sci diff --git a/engines/sci/resource_audio.cpp b/engines/sci/resource_audio.cpp index c775f502c5..3a43774492 100644 --- a/engines/sci/resource_audio.cpp +++ b/engines/sci/resource_audio.cpp @@ -579,6 +579,7 @@ SoundResource::SoundResource(uint32 resourceNr, ResourceManager *resMan, SciVers  		return;  	_innerResource = resource; +	_soundPriority = 0xFF;  	byte *data, *data2;  	byte *dataEnd; @@ -725,6 +726,9 @@ SoundResource::SoundResource(uint32 resourceNr, ResourceManager *resMan, SciVers  					data += 6;  				}  			} else { +				// The first byte of the 0xF0 track's channel list is priority +				_soundPriority = *data; +  				// Skip over digital track  				data += 6;  			} diff --git a/engines/sci/sound/music.cpp b/engines/sci/sound/music.cpp index 2b73bcf8b3..dab02c9eb7 100644 --- a/engines/sci/sound/music.cpp +++ b/engines/sci/sound/music.cpp @@ -340,6 +340,7 @@ void SciMusic::soundInitSnd(MusicEntry *pSnd) {  			pSnd->soundType = Audio::Mixer::kSFXSoundType;  			pSnd->hCurrentAud = Audio::SoundHandle();  			pSnd->playBed = false; +			pSnd->overridePriority = false;  		} else {  			// play MIDI track  			Common::StackLock lock(_mutex); @@ -387,6 +388,7 @@ void SciMusic::soundInitSnd(MusicEntry *pSnd) {  			pSnd->loop = 0;  			pSnd->hold = -1;  			pSnd->playBed = false; +			pSnd->overridePriority = false;  			pSnd->pMidiParser->loadMusic(track, pSnd, channelFilterMask, _soundVersion);  			pSnd->reverb = pSnd->pMidiParser->getSongReverb(); diff --git a/engines/sci/sound/music.h b/engines/sci/sound/music.h index 1347177054..8770748c3d 100644 --- a/engines/sci/sound/music.h +++ b/engines/sci/sound/music.h @@ -88,6 +88,7 @@ public:  	int16 hold;  	int8 reverb;  	bool playBed; +	bool overridePriority; // Use soundObj's priority instead of resource's  	int16 pauseCounter;  	uint sampleLoopCounter; diff --git a/engines/sci/sound/soundcmd.cpp b/engines/sci/sound/soundcmd.cpp index 47ab9bdc71..682c88f382 100644 --- a/engines/sci/sound/soundcmd.cpp +++ b/engines/sci/sound/soundcmd.cpp @@ -184,7 +184,15 @@ void SoundCommandParser::processPlaySound(reg_t obj, bool playBed) {  	}  	musicSlot->loop = readSelectorValue(_segMan, obj, SELECTOR(loop)); -	musicSlot->priority = readSelectorValue(_segMan, obj, SELECTOR(priority)); + +	// Get song priority from either obj or soundRes +	byte resourcePriority = musicSlot->soundRes->getSoundPriority(); +	if (!musicSlot->overridePriority && resourcePriority != 0xFF) { +		musicSlot->priority = resourcePriority; +	} else { +		musicSlot->priority = readSelectorValue(_segMan, obj, SELECTOR(priority)); +	} +  	// Reset hold when starting a new song. kDoSoundSetHold is always called after  	// kDoSoundPlay to set it properly, if needed. Fixes bug #3413589.  	musicSlot->hold = -1; @@ -677,23 +685,19 @@ reg_t SoundCommandParser::kDoSoundSetPriority(int argc, reg_t *argv, reg_t acc)  	}  	if (value == -1) { -		uint16 resourceId = musicSlot->resourceId; +		musicSlot->overridePriority = false; +		musicSlot->priority = 0; -		// Set priority from the song data -		Resource *song = _resMan->findResource(ResourceId(kResourceTypeSound, resourceId), 0); -		if (song->data[0] == 0xf0) -			_music->soundSetPriority(musicSlot, song->data[1]); -		else -			warning("kDoSound(setPriority): Attempt to unset song priority when there is no built-in value"); +		// NB: It seems SSCI doesn't actually reset the priority here. -		//pSnd->prio=0;field_15B=0  		writeSelectorValue(_segMan, obj, SELECTOR(flags), readSelectorValue(_segMan, obj, SELECTOR(flags)) & 0xFD);  	} else {  		// Scripted priority +		musicSlot->overridePriority = true; -		//pSnd->field_15B=1;  		writeSelectorValue(_segMan, obj, SELECTOR(flags), readSelectorValue(_segMan, obj, SELECTOR(flags)) | 2); -		//DoSOund(0xF,hobj,w) + +		_music->soundSetPriority(musicSlot, value);  	}  	return acc;  } | 
