diff options
author | Torbjörn Andersson | 2007-03-02 17:30:29 +0000 |
---|---|---|
committer | Torbjörn Andersson | 2007-03-02 17:30:29 +0000 |
commit | cee6c45be62d13f2e9deaea0e18df9f530553c2e (patch) | |
tree | 91c03b5d19043c2e1ad2360a9e43ba61d36a7c3a | |
parent | cfe86c096d6b4823f9489f2fedc928163b0b4c09 (diff) | |
download | scummvm-rg350-cee6c45be62d13f2e9deaea0e18df9f530553c2e.tar.gz scummvm-rg350-cee6c45be62d13f2e9deaea0e18df9f530553c2e.tar.bz2 scummvm-rg350-cee6c45be62d13f2e9deaea0e18df9f530553c2e.zip |
Applied my own patch #1672572, after discussing it with Fingolfin. We no longer
store mixer flags in our savegames. Instead, we store different flags which
just happen to have the exact same values as the mixer flags have right now.
This should keep savegames working even if the mixer flags ever change.
svn-id: r25928
-rw-r--r-- | engines/scumm/imuse_digi/dimuse.cpp | 29 | ||||
-rw-r--r-- | engines/scumm/imuse_digi/dimuse.h | 20 | ||||
-rw-r--r-- | engines/scumm/imuse_digi/dimuse_track.cpp | 16 |
3 files changed, 49 insertions, 16 deletions
diff --git a/engines/scumm/imuse_digi/dimuse.cpp b/engines/scumm/imuse_digi/dimuse.cpp index c249dd57a9..e844363043 100644 --- a/engines/scumm/imuse_digi/dimuse.cpp +++ b/engines/scumm/imuse_digi/dimuse.cpp @@ -76,6 +76,21 @@ IMuseDigital::~IMuseDigital() { free(_audioNames); } +int32 IMuseDigital::makeMixerFlags(int32 flags) { + int32 mixerFlags = 0; + if (flags & kFlagUnsigned) + mixerFlags |= Audio::Mixer::FLAG_UNSIGNED; + if (flags & kFlag16Bits) + mixerFlags |= Audio::Mixer::FLAG_16BITS; + if (flags & kFlagLittleEndian) + mixerFlags |= Audio::Mixer::FLAG_LITTLE_ENDIAN; + if (flags & kFlagStereo) + mixerFlags |= Audio::Mixer::FLAG_STEREO; + if (flags & kFlagReverseStereo) + mixerFlags |= Audio::Mixer::FLAG_REVERSE_STEREO; + return mixerFlags; +} + void IMuseDigital::resetState() { _curMusicState = 0; _curMusicSeq = 0; @@ -122,7 +137,7 @@ void IMuseDigital::saveOrLoad(Serializer *ser) { MKLINE(Track, soundType, sleInt32, VER(31)), MKLINE(Track, iteration, sleInt32, VER(31)), MKLINE(Track, mod, sleInt32, VER(31)), - MKLINE(Track, mixerFlags, sleInt32, VER(31)), + MKLINE(Track, flags, sleInt32, VER(31)), MK_OBSOLETE(Track, mixerVol, sleInt32, VER(31), VER(42)), MK_OBSOLETE(Track, mixerPan, sleInt32, VER(31), VER(42)), MKLINE(Track, compressed, sleByte, VER(45)), @@ -171,25 +186,25 @@ void IMuseDigital::saveOrLoad(Serializer *ser) { int channels = _sound->getChannels(track->soundHandle); int freq = _sound->getFreq(track->soundHandle); track->iteration = freq * channels; - track->mixerFlags = 0; + track->flags = 0; if (channels == 2) - track->mixerFlags = Audio::Mixer::FLAG_STEREO | Audio::Mixer::FLAG_REVERSE_STEREO; + track->flags = kFlagStereo | kFlagReverseStereo; if ((bits == 12) || (bits == 16)) { - track->mixerFlags |= Audio::Mixer::FLAG_16BITS; + track->flags |= kFlag16Bits; track->iteration *= 2; } else if (bits == 8) { - track->mixerFlags |= Audio::Mixer::FLAG_UNSIGNED; + track->flags |= kFlagUnsigned; } else error("IMuseDigital::saveOrLoad(): Can't handle %d bit samples", bits); #ifdef SCUMM_LITTLE_ENDIAN if (track->compressed) - track->mixerFlags |= Audio::Mixer::FLAG_LITTLE_ENDIAN; + track->flags |= kFlagLittleEndian; #endif track->stream2 = NULL; - track->stream = Audio::makeAppendableAudioStream(freq, track->mixerFlags); + track->stream = Audio::makeAppendableAudioStream(freq, makeMixerFlags(track->flags)); const int pan = (track->pan != 64) ? 2 * track->pan - 127 : 0; const int vol = track->vol / 1000; diff --git a/engines/scumm/imuse_digi/dimuse.h b/engines/scumm/imuse_digi/dimuse.h index f3e4e608fc..e2c2e6ecdf 100644 --- a/engines/scumm/imuse_digi/dimuse.h +++ b/engines/scumm/imuse_digi/dimuse.h @@ -44,6 +44,23 @@ struct imuseComiTable; class Serializer; class ScummEngine_v7; +// These flag bits correspond exactly to the sound mixer flags of March 2007. +// We don't want to use the mixer flags directly, because then our saved games +// will break in interesting ways if the mixer flags are ever assigned new +// values. Now they should keep working, as long as these flags don't change. + +enum { + kFlagUnsigned = 1 << 0, + kFlag16Bits = 1 << 1, + kFlagLittleEndian = 1 << 2, + kFlagStereo = 1 << 3, + kFlagReverseStereo = 1 << 4 + + // Not used by Digital iMUSE + // kFlagAutoFree = 1 << 5, + // kFlagLoop = 1 << 6 +}; + class IMuseDigital : public MusicEngine { private: @@ -76,7 +93,7 @@ private: int32 soundType; int32 iteration; int32 mod; - int32 mixerFlags; + int32 flags; ImuseDigiSndMgr::soundStruct *soundHandle; Audio::SoundHandle handle; @@ -104,6 +121,7 @@ private: int32 _curMusicSeq; int32 _curMusicCue; + int32 makeMixerFlags(int32 flags); static void timer_handler(void *refConf); void callback(); void switchToNextRegion(Track *track); diff --git a/engines/scumm/imuse_digi/dimuse_track.cpp b/engines/scumm/imuse_digi/dimuse_track.cpp index 6acb2a0318..bcc5623c66 100644 --- a/engines/scumm/imuse_digi/dimuse_track.cpp +++ b/engines/scumm/imuse_digi/dimuse_track.cpp @@ -103,7 +103,7 @@ void IMuseDigital::startSound(int soundId, const char *soundName, int soundType, track->dataOffset = 0; track->regionOffset = 0; track->mod = 0; - track->mixerFlags = 0; + track->flags = 0; track->toBeRemoved = false; track->readyToRemove = false; track->soundType = soundType; @@ -143,19 +143,19 @@ void IMuseDigital::startSound(int soundId, const char *soundName, int soundType, track->iteration = freq * channels; if (channels == 2) - track->mixerFlags = Audio::Mixer::FLAG_STEREO | Audio::Mixer::FLAG_REVERSE_STEREO; + track->flags = kFlagStereo | kFlagReverseStereo; if ((bits == 12) || (bits == 16)) { - track->mixerFlags |= Audio::Mixer::FLAG_16BITS; + track->flags |= kFlag16Bits; track->iteration *= 2; } else if (bits == 8) { - track->mixerFlags |= Audio::Mixer::FLAG_UNSIGNED; + track->flags |= kFlagUnsigned; } else error("IMuseDigital::startSound(): Can't handle %d bit samples", bits); #ifdef SCUMM_LITTLE_ENDIAN if (track->compressed) - track->mixerFlags |= Audio::Mixer::FLAG_LITTLE_ENDIAN; + track->flags |= kFlagLittleEndian; #endif } @@ -177,7 +177,7 @@ void IMuseDigital::startSound(int soundId, const char *soundName, int soundType, // setup 1 second stream wrapped buffer track->stream2 = NULL; - track->stream = Audio::makeAppendableAudioStream(freq, track->mixerFlags); + track->stream = Audio::makeAppendableAudioStream(freq, makeMixerFlags(track->flags)); _mixer->playInputStream(type, &track->handle, track->stream, -1, vol, pan, false); track->started = true; } @@ -328,7 +328,7 @@ IMuseDigital::Track *IMuseDigital::cloneToFadeOutTrack(Track *track, int fadeDel fadeTrack->curRegion = track->curRegion; fadeTrack->curHookId = track->curHookId; fadeTrack->iteration = track->iteration; - fadeTrack->mixerFlags = track->mixerFlags; + fadeTrack->flags = track->flags; fadeTrack->mod = track->mod; fadeTrack->toBeRemoved = track->toBeRemoved; fadeTrack->readyToRemove = track->readyToRemove; @@ -355,7 +355,7 @@ IMuseDigital::Track *IMuseDigital::cloneToFadeOutTrack(Track *track, int fadeDel type = Audio::Mixer::kMusicSoundType; // setup 1 second stream wrapped buffer - fadeTrack->stream = Audio::makeAppendableAudioStream(_sound->getFreq(fadeTrack->soundHandle), fadeTrack->mixerFlags); + fadeTrack->stream = Audio::makeAppendableAudioStream(_sound->getFreq(fadeTrack->soundHandle), makeMixerFlags(fadeTrack->flags)); _mixer->playInputStream(type, &fadeTrack->handle, fadeTrack->stream, -1, fadeTrack->vol / 1000, fadeTrack->pan, false); fadeTrack->started = true; fadeTrack->used = true; |