diff options
author | Paul Gilbert | 2011-05-07 14:13:52 +1000 |
---|---|---|
committer | Paul Gilbert | 2011-05-24 21:25:49 +1000 |
commit | 3457253f03cd5a57281735360fc600f0fe831298 (patch) | |
tree | 5b3a609a46f57112cdaf6bcb6631ef764c925f55 /engines | |
parent | 1d866e57491bbc703d13a406e09336b732212c2b (diff) | |
download | scummvm-rg350-3457253f03cd5a57281735360fc600f0fe831298.tar.gz scummvm-rg350-3457253f03cd5a57281735360fc600f0fe831298.tar.bz2 scummvm-rg350-3457253f03cd5a57281735360fc600f0fe831298.zip |
TSAGE: Implemented more _sf methods
Diffstat (limited to 'engines')
-rw-r--r-- | engines/tsage/sound.cpp | 92 | ||||
-rw-r--r-- | engines/tsage/sound.h | 7 |
2 files changed, 87 insertions, 12 deletions
diff --git a/engines/tsage/sound.cpp b/engines/tsage/sound.cpp index e08885a51a..062fb6dda8 100644 --- a/engines/tsage/sound.cpp +++ b/engines/tsage/sound.cpp @@ -89,7 +89,7 @@ Common::List<SoundDriverEntry> &SoundManager::buildDriverList(bool detectFlag) { } void SoundManager::installConfigDrivers() { - + installDriver(ADLIB_DRIVER_NUM); } Common::List<SoundDriverEntry> &SoundManager::getDriverList(bool detectFlag) { @@ -324,6 +324,10 @@ void SoundManager::listenerSynchronize(Serializer &s) { /*--------------------------------------------------------------------------*/ +SoundManager &SoundManager::sfManager() { + return _globals->_soundManager; +} + void SoundManager::_soSetTimeIndex(int timeIndex) { warning("TODO: _soSetTimeIndex"); } @@ -341,12 +345,19 @@ int SoundManager::_sfDetermineGroup(const byte *soundData) { return 0; } -void SoundManager::_sfAddToPlayList(Sound*soundData) { - +void SoundManager::_sfAddToPlayList(Sound *sound) { + ++sfManager()._suspendCtr; + _sfDoAddToPlayList(sound); + sound->_field6 = 0; + _sfRethinkVoiceTypes(); + --sfManager()._suspendCtr; } void SoundManager::_sfRemoveFromPlayList(Sound *sound) { - + ++sfManager()._suspendCtr; + if (_sfDoRemoveFromPlayList(sound)) + _sfRethinkVoiceTypes(); + --sfManager()._suspendCtr; } bool SoundManager::_sfIsOnPlayList(Sound *sound) { @@ -363,23 +374,35 @@ void SoundManager::_sfRethinkVoiceTypes() { void SoundManager::_sfUpdateVolume(Sound *sound) { _sfDereferenceAll(); - sub_233EE(sound); + _sfDoUpdateVolume(sound); } void SoundManager::_sfDereferenceAll() { - -} - -void SoundManager::sub_233EE(Sound *sound) { - + // Orignal used handles for both the driver list and voiceStructPtrs list. This method then refreshed + // pointer lists based on the handles. Since in ScummVM we're just using pointers directly, this + // method doesn't need any implementation } void SoundManager::_sfUpdatePriority(Sound *sound) { + ++_globals->_soundManager._suspendCtr; + int tempPriority = (sound->_priority2 == 255) ? sound->_soundPriority : sound->_priority; + if (sound->_priority != tempPriority) { + sound->_priority = tempPriority; + if (_sfDoRemoveFromPlayList(sound)) { + _sfDoAddToPlayList(sound); + _sfRethinkVoiceTypes(); + } + } + + --_globals->_soundManager._suspendCtr; } void SoundManager::_sfUpdateLoop(Sound *sound) { - + if (sound->_loopFlag2) + sound->_loopFlag = sound->_loop; + else + sound->_loopFlag = sound->_loopFlag2; } void SoundManager::_sfSetMasterVol(int volume) { @@ -447,6 +470,53 @@ void SoundManager::_sfInstallPatchBank(const byte *bankData) { } +/** + * Adds the specified sound in the playing sound list, inserting in order of priority + */ +void SoundManager::_sfDoAddToPlayList(Sound *sound) { + ++sfManager()._suspendCtr; + + Common::List<Sound *>::iterator i = sfManager()._playList.begin(); + while ((i != sfManager()._playList.end()) && (sound->_priority > (*i)->_priority)) + ++i; + + sfManager()._playList.insert(i, sound); + --sfManager()._suspendCtr; +} + +/** + * Removes the specified sound from the play list + */ +bool SoundManager::_sfDoRemoveFromPlayList(Sound *sound) { + ++sfManager()._suspendCtr; + + bool result = false; + for (Common::List<Sound *>::iterator i = sfManager()._playList.begin(); i != sfManager()._playList.end(); ++i) { + if (*i == sound) { + result = true; + sfManager()._playList.erase(i); + break; + } + } + + --sfManager()._suspendCtr; + return result; +} + +void SoundManager::_sfDoUpdateVolume(Sound *sound) { + ++_globals->_soundManager._suspendCtr; + + for (int idx = 0; idx < 16; ++idx) { + Sound *snd = sfManager()._voiceStructPtrs[idx]; + if (!snd) + continue; + + // TODO: More stuff + } + + --_globals->_soundManager._suspendCtr; +} + /*--------------------------------------------------------------------------*/ Sound::Sound() { diff --git a/engines/tsage/sound.h b/engines/tsage/sound.h index f52edc121b..26c26817a5 100644 --- a/engines/tsage/sound.h +++ b/engines/tsage/sound.h @@ -85,6 +85,7 @@ public: int _field89[SOUND_ARR_SIZE]; uint16 _groupList[SOUND_ARR_SIZE]; int _fieldE9[SOUND_ARR_SIZE]; + Sound *_voiceStructPtrs[SOUND_ARR_SIZE]; public: SoundManager(); ~SoundManager(); @@ -129,6 +130,7 @@ public: void unloadSound(int soundNum); // _so methods + static SoundManager &sfManager(); static void _sfTerminate(); static void _soSetTimeIndex(int timeIndex); static int _sfDetermineGroup(const byte *soundData); @@ -138,7 +140,6 @@ public: static void _sfRethinkVoiceTypes(); static void _sfUpdateVolume(Sound *sound); static void _sfDereferenceAll(); - static void sub_233EE(Sound *sound); static void _sfUpdatePriority(Sound *sound); static void _sfUpdateLoop(Sound *sound); static void _sfSetMasterVol(int volume); @@ -147,6 +148,9 @@ public: static bool _sfInstallDriver(SoundDriver *driver); static void _sfUnInstallDriver(SoundDriver *driver); static void _sfInstallPatchBank(const byte *bankData); + static void _sfDoAddToPlayList(Sound *sound); + static bool _sfDoRemoveFromPlayList(Sound *sound); + static void _sfDoUpdateVolume(Sound *sound); }; class Sound: public EventHandler { @@ -155,6 +159,7 @@ private: void _unPrime(); void orientAfterRestore(); public: + int _field0; int _field6; int _soundNum; int _groupNum; |