diff options
-rw-r--r-- | engines/tsage/sound.cpp | 44 | ||||
-rw-r--r-- | engines/tsage/sound.h | 2 |
2 files changed, 25 insertions, 21 deletions
diff --git a/engines/tsage/sound.cpp b/engines/tsage/sound.cpp index 50cb76b6ba..9ed4041148 100644 --- a/engines/tsage/sound.cpp +++ b/engines/tsage/sound.cpp @@ -683,29 +683,31 @@ void SoundManager::_sfSetMasterVol(int volume) { } void SoundManager::_sfExtractTrackInfo(trackInfoStruct *trackInfo, const byte *soundData, int groupNum) { - trackInfo->_maxTrack = 0; + trackInfo->_count = 0; const byte *p = soundData + READ_LE_UINT16(soundData + 8); uint32 v; while ((v = READ_LE_UINT32(p)) != 0) { - while ((v == 0x80000000) || (v == (uint)groupNum)) { + if ((v == 0x80000000) || (v == (uint)groupNum)) { + // Found group to process int count = READ_LE_UINT16(p + 4); p += 6; for (int idx = 0; idx < count; ++idx) { - if (trackInfo->_maxTrack == 16) { - trackInfo->_maxTrack = -1; + if (trackInfo->_count == 16) { + trackInfo->_count = -1; return; } - trackInfo->_rlbList[trackInfo->_maxTrack] = READ_LE_UINT16(p); - trackInfo->_arr2[trackInfo->_maxTrack] = READ_LE_UINT16(p + 2); - ++trackInfo->_maxTrack; + trackInfo->_rlbList[trackInfo->_count] = READ_LE_UINT16(p); + trackInfo->_arr2[trackInfo->_count] = READ_LE_UINT16(p + 2); + ++trackInfo->_count; p += 4; - } + } + } else { + // Not correct group, so move to next one + p += 6 + (READ_LE_UINT16(p + 4) * 4); } - - p += 6 + (READ_LE_UINT16(p + 4) * 4); } } @@ -715,8 +717,10 @@ void SoundManager::_sfTerminate() { void SoundManager::_sfExtractGroupMask() { uint32 mask = 0; - for (int idx = 0; idx < SOUND_ARR_SIZE; ++idx) - mask |= _soundManager->_groupList[idx]; + + for (Common::List<SoundDriver *>::iterator i = sfManager()._installedDrivers.begin(); + i != sfManager()._installedDrivers.end(); ++i) + mask |= (*i)->_groupMask; _soundManager->_groupMask = mask; } @@ -834,7 +838,7 @@ Sound::Sound() { _volume4 = 0; _timeIndex = 0; _field26 = 0; - _trackInfo._maxTrack = 0; + _trackInfo._count = 0; _primed = false; _isEmpty = false; _field26E = NULL; @@ -880,7 +884,7 @@ void Sound::_prime(int soundNum, bool queFlag) { _loop = _soundManager->extractLoop(soundData); _soundManager->extractTrackInfo(&_trackInfo, soundData, _groupNum); - for (int idx = 0; idx <= _trackInfo._maxTrack; ++idx) { + for (int idx = 0; idx < _trackInfo._count; ++idx) { _trackInfo._handleList[idx] = _resourceManager->getResource(RES_SOUND, soundNum, _trackInfo._rlbList[idx]); } @@ -891,7 +895,7 @@ void Sound::_prime(int soundNum, bool queFlag) { _groupNum = 0; _soundPriority = 0; _loop = 0; - _trackInfo._maxTrack = 0; + _trackInfo._count = 0; _trackInfo._handleList[0] = ALLOCATE(200); _field26E = ALLOCATE(200); } @@ -909,12 +913,12 @@ void Sound::_unPrime() { DEALLOCATE(_field26E); _field26E = NULL; } else { - for (int idx = 0; idx <= _trackInfo._maxTrack; ++idx) { + for (int idx = 0; idx < _trackInfo._count; ++idx) { DEALLOCATE(_trackInfo._handleList[idx]); } } - _trackInfo._maxTrack = 0; + _trackInfo._count = 0; _soundManager->removeFromSoundList(this); _primed = false; @@ -926,10 +930,10 @@ void Sound::orientAfterDriverChange() { if (!_isEmpty) { int timeIndex = getTimeIndex(); - for (int idx = 0; idx <= _trackInfo._maxTrack; ++idx) + for (int idx = 0; idx < _trackInfo._count; ++idx) DEALLOCATE(_trackInfo._handleList[idx]); - _trackInfo._maxTrack = 0; + _trackInfo._count = 0; _primed = false; _prime(_soundNum, true); setTimeIndex(timeIndex); @@ -1170,7 +1174,7 @@ AdlibSoundDriver::AdlibSoundDriver() { _maxVersion = 0x10A; - _groupData.groupMask = 1; + _groupData.groupMask = 9; _groupData.v1 = 0x46; _groupData.v2 = 0; _groupData.pData = &adlib_group_data[0]; diff --git a/engines/tsage/sound.h b/engines/tsage/sound.h index 8670eca64e..eebb549a76 100644 --- a/engines/tsage/sound.h +++ b/engines/tsage/sound.h @@ -37,7 +37,7 @@ class Sound; #define ADLIB_DRIVER_NUM 3 struct trackInfoStruct { - int _maxTrack; + int _count; int _rlbList[SOUND_ARR_SIZE]; int _arr2[SOUND_ARR_SIZE]; byte *_handleList[SOUND_ARR_SIZE]; |