diff options
author | Paul Gilbert | 2011-05-24 20:07:41 +1000 |
---|---|---|
committer | Paul Gilbert | 2011-05-24 20:07:41 +1000 |
commit | d52e69d82c650ab711668835da178a0f04e9e5f3 (patch) | |
tree | 0632c0a58dde48c4609d7aca1d4d6eea2ea7a139 | |
parent | 687d033d28f9d85b29f1f0edfcfb1751e1a92031 (diff) | |
download | scummvm-rg350-d52e69d82c650ab711668835da178a0f04e9e5f3.tar.gz scummvm-rg350-d52e69d82c650ab711668835da178a0f04e9e5f3.tar.bz2 scummvm-rg350-d52e69d82c650ab711668835da178a0f04e9e5f3.zip |
TSAGE: Added some extra code for volume control and start on rethinking voice types
-rw-r--r-- | engines/tsage/sound.cpp | 113 | ||||
-rw-r--r-- | engines/tsage/sound.h | 21 |
2 files changed, 119 insertions, 15 deletions
diff --git a/engines/tsage/sound.cpp b/engines/tsage/sound.cpp index 270325e284..878710b0f8 100644 --- a/engines/tsage/sound.cpp +++ b/engines/tsage/sound.cpp @@ -373,6 +373,29 @@ void SoundManager::_sfProcessFading() { //TODO } +void SoundManager::_sfUpdateVoiceStructs() { + for (int voiceIndex = 0; voiceIndex < SOUND_ARR_SIZE; ++voiceIndex) { + VoiceStruct *vs = sfManager()._voiceStructPtrs[voiceIndex]; + + for (uint idx = 0; idx < vs->_entries.size(); ++idx) { + VoiceStructEntry &vse = vs->_entries[idx]; + + if (vs->_voiceType == VOICETYPE_0) { + vse._field4 = vse._fieldC; + vse._field6 = vse._fieldE; + vse._field8 = vse._field10; + vse._field9 = vse._field11; + vse._fieldA = vse._field12; + } else { + vse._field8 = vse._fieldE; + vse._fieldA = vse._field10; + vse._fieldC = vse._field12; + vse._fieldD = vse._field13; + } + } + } +} + /*--------------------------------------------------------------------------*/ void SoundManager::saveNotifier(bool postFlag) { @@ -498,13 +521,11 @@ void SoundManager::_sfRethinkSoundDrivers() { sfManager()._voiceStructPtrs[idx] = vs; if (!flag) { - vs->_field0 = 0; + vs->_voiceType = VOICETYPE_0; vs->_field1 = total; -// offset = 2; } else { - vs->_field0 = 1; + vs->_voiceType = VOICETYPE_1; vs->_field1 = vs->_field2 = total; -// offset = 4; } for (Common::List<SoundDriver *>::iterator i = sfManager()._installedDrivers.begin(); @@ -561,7 +582,56 @@ void SoundManager::_sfRethinkSoundDrivers() { } void SoundManager::_sfRethinkVoiceTypes() { - + ++sfManager()._suspendCtr; + _sfDereferenceAll(); + + for (int voiceIndex = 0; voiceIndex < SOUND_ARR_SIZE; ++voiceIndex) { + VoiceStruct *vs = sfManager()._voiceStructPtrs[voiceIndex]; + if (!vs) + continue; + + if (vs->_voiceType == VOICETYPE_0) { + for (uint idx = 0; idx < vs->_entries.size(); ++idx) { + VoiceStructEntry &vse = vs->_entries[idx]; + vse._field14 = vse._field4; + vse._field16 = vse._field6; + vse._field18 = vse._field8; + vse._field19 = vse._field9; + vse._field1A = vse._fieldA; + vse._field4 = 0; + vse._field6 = 0; + vse._field8 = 0; + vse._field9 = 0; + vse._fieldA = 0; + vse._fieldC = 0; + vse._fieldE = 0; + vse._field10 = 0; + vse._field11 = 0; + vse._field12 = 0; + } + } else { + for (uint idx = 0; idx < vs->_entries.size(); ++idx) { + VoiceStructEntry &vse = vs->_entries[idx]; + vse._field14 = vse._field8; + vse._field16 = vse._fieldA; + vse._field18 = vse._fieldC; + vse._field19 = vse._fieldD; + vse._field8 = 0; + vse._fieldA = 0; + vse._fieldC = 0; + vse._fieldD = 0; + vse._fieldE = 0; + vse._field10 = 0; + vse._field12 = 0; + } + } + } + + int var2 = 0; + for (Common::List<Sound *>::iterator playIterator = sfManager()._playList.begin(); + playIterator != sfManager()._playList.end(); ++playIterator) { + + } } void SoundManager::_sfUpdateVolume(Sound *sound) { @@ -606,7 +676,7 @@ void SoundManager::_sfSetMasterVol(int volume) { for (Common::List<SoundDriver *>::iterator i = _globals->_soundManager._installedDrivers.begin(); i != _globals->_soundManager._installedDrivers.end(); ++i) { - (*i)->setVolume(volume); + (*i)->setMasterVolume(volume); } } } @@ -660,7 +730,7 @@ bool SoundManager::_sfInstallDriver(SoundDriver *driver) { _sfExtractGroupMask(); _sfRethinkSoundDrivers(); - driver->setVolume(sfManager()._volume); + driver->setMasterVolume(sfManager()._volume); return true; } @@ -713,13 +783,27 @@ bool SoundManager::_sfDoRemoveFromPlayList(Sound *sound) { void SoundManager::_sfDoUpdateVolume(Sound *sound) { ++_globals->_soundManager._suspendCtr; - for (int idx = 0; idx < 16; ++idx) { - /* - Sound *snd = sfManager()._voiceStructPtrs[idx]; - if (!snd) + for (int voiceIndex = 0; voiceIndex < SOUND_ARR_SIZE; ++voiceIndex) { + VoiceStruct *vs = sfManager()._voiceStructPtrs[voiceIndex]; + if (!vs) continue; -*/ - // TODO: More stuff + + for (uint idx = 0; idx < vs->_entries.size(); ++idx) { + VoiceStructEntry &vse = vs->_entries[idx]; + SoundDriver *driver = vse._driver; + + if (vs->_voiceType == VOICETYPE_0) { + if (!vse._field4 && !vse._field6) { + int vol = sound->_volume * sound->_field48[vse._field8] / 127; + driver->setVolume0(voiceIndex, vse._field0, 7, vol); + } + } else { + if (!vse._field8 && !vse._fieldA) { + int vol = sound->_volume * sound->_field48[vse._fieldC] / 127; + driver->setVolume1(voiceIndex, vse._field0, 7, vol); + } + } + } } --_globals->_soundManager._suspendCtr; @@ -1074,6 +1158,9 @@ SoundDriver::SoundDriver() { const byte adlib_group_data[] = { 1, 1, 9, 1, 0xff }; AdlibSoundDriver::AdlibSoundDriver() { + _minVersion = 0x102; + + _groupData.groupMask = 1; _groupData.v1 = 0x46; _groupData.v2 = 0; diff --git a/engines/tsage/sound.h b/engines/tsage/sound.h index aaaaf5842d..29fafe79ba 100644 --- a/engines/tsage/sound.h +++ b/engines/tsage/sound.h @@ -80,8 +80,10 @@ public: virtual bool open() { return true; } virtual void close() {} virtual const GroupData *getGroupData() = 0; - virtual void setVolume(int volume) {} + virtual void setMasterVolume(int volume) {} virtual void installPatchBank(const byte *data) {} + virtual void setVolume0(int channel, int v2, int v3, int volume) {} + virtual void setVolume1(int channel, int v2, int v3, int volume) {} virtual void poll() {} }; @@ -96,11 +98,25 @@ struct VoiceStructEntry { int _fieldA; int _fieldC; int _fieldD; + int _fieldE; + int _field10; + int _field11; + int _field12; + int _field13; + int _field14; + int _field16; + int _field18; + int _field19; + + int _field1A; + int _field1B; }; +enum VoiceType {VOICETYPE_0 = 0, VOICETYPE_1 = 1}; + class VoiceStruct { public: - int _field0; + VoiceType _voiceType; int _field1; int _field2; @@ -198,6 +214,7 @@ public: static void _sfDoUpdateVolume(Sound *sound); static void _sfSoundServer(); static void _sfProcessFading(); + static void _sfUpdateVoiceStructs(); }; class Sound: public EventHandler { |