SCI: Use sound resource priority by default for songs

SCI1 sound resources can have an embedded priority. We now use that by
default, unless an explicit DoSound/SetPriority call overrides it.
Thanks waltervn.

This fixes relative priority of songs in at least PQ3 room 29.

Also increase savegame version to 33.
This commit is contained in:
Willem Jan Palenstijn
2015-02-15 14:05:36 +01:00
parent 0018bb0f6f
commit 5028487038
7 changed files with 30 additions and 12 deletions
+4
View File
@@ -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()
+2 -1
View File
@@ -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
};
+2
View File
@@ -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
+4
View File
@@ -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;
}
+2
View File
@@ -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();
+1
View File
@@ -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;
+15 -11
View File
@@ -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;
}