diff options
Diffstat (limited to 'engines/tsage')
-rw-r--r-- | engines/tsage/resources.cpp | 4 | ||||
-rw-r--r-- | engines/tsage/sound.cpp | 46 | ||||
-rw-r--r-- | engines/tsage/sound.h | 20 |
3 files changed, 40 insertions, 30 deletions
diff --git a/engines/tsage/resources.cpp b/engines/tsage/resources.cpp index 676d319ba9..d24c564a1f 100644 --- a/engines/tsage/resources.cpp +++ b/engines/tsage/resources.cpp @@ -66,7 +66,9 @@ uint16 MemoryManager::allocate(uint32 size) { byte *MemoryManager::allocate2(uint32 size) { uint32 idx = allocate(size); - return lock(idx); + byte *result = lock(idx); + Common::set_to(result, result + size, 0); + return result; } byte *MemoryManager::lock(uint32 handle) { diff --git a/engines/tsage/sound.cpp b/engines/tsage/sound.cpp index 329a1ea321..c66b428950 100644 --- a/engines/tsage/sound.cpp +++ b/engines/tsage/sound.cpp @@ -678,7 +678,7 @@ void SoundManager::_sfSetMasterVol(int volume) { } void SoundManager::_sfExtractTrackInfo(trackInfoStruct *trackInfo, const byte *soundData, int groupNum) { - trackInfo->count = 0; + trackInfo->_count = 0; const byte *p = soundData + READ_LE_UINT16(soundData + 8); uint32 v; @@ -688,14 +688,14 @@ void SoundManager::_sfExtractTrackInfo(trackInfoStruct *trackInfo, const byte *s p += 6; for (int idx = 0; idx < count; ++idx) { - if (trackInfo->count == 16) { - trackInfo->count = -1; + if (trackInfo->_count == 16) { + trackInfo->_count = -1; return; } - trackInfo->rlbList[trackInfo->count] = READ_LE_UINT16(p); - trackInfo->arr2[trackInfo->count] = READ_LE_UINT16(p + 2); - ++trackInfo->count; + trackInfo->_rlbList[trackInfo->_count] = READ_LE_UINT16(p); + trackInfo->_arr2[trackInfo->_count] = READ_LE_UINT16(p + 2); + ++trackInfo->_count; p += 4; } } @@ -829,9 +829,9 @@ Sound::Sound() { _volume4 = 0; _timeIndex = 0; _field26 = 0; - _trackInfo.count = 0; + _trackInfo._count = 0; _primed = false; - _field26C = 0; + _isEmpty = false; _field26E = NULL; } @@ -862,6 +862,7 @@ void Sound::_prime(int soundNum, bool queFlag) { if (_soundNum != -1) { // Sound number specified + _isEmpty = false; _field26E = NULL; byte *soundData = _resourceManager->getResource(RES_SOUND, soundNum, 0); _globals->_soundManager.checkResVersion(soundData); @@ -870,18 +871,19 @@ void Sound::_prime(int soundNum, bool queFlag) { _loop = _globals->_soundManager.extractLoop(soundData); _globals->_soundManager.extractTrackInfo(&_trackInfo, soundData, _groupNum); - for (int idx = 0; idx < _trackInfo.count; ++idx) { - _handleList[idx] = _resourceManager->getResource(RES_SOUND, soundNum, _trackInfo.rlbList[idx]); + for (int idx = 0; idx < _trackInfo._count; ++idx) { + _trackInfo._handleList[idx] = _resourceManager->getResource(RES_SOUND, soundNum, _trackInfo._rlbList[idx]); } DEALLOCATE(soundData); } else { // No sound specified + _isEmpty = true; _groupNum = 0; _soundPriority = 0; _loop = 0; - _trackInfo.count = 0; - _handleList[0] = ALLOCATE(200); + _trackInfo._count = 0; + _trackInfo._handleList[0] = ALLOCATE(200); _field26E = ALLOCATE(200); } @@ -893,17 +895,17 @@ void Sound::_prime(int soundNum, bool queFlag) { void Sound::_unPrime() { if (_primed) { - if (_field26C) { - DEALLOCATE(_handleList[0]); + if (_isEmpty) { + DEALLOCATE(_trackInfo._handleList[0]); DEALLOCATE(_field26E); _field26E = NULL; } else { - for (int idx = 0; idx < _trackInfo.count; ++idx) { - DEALLOCATE(_handleList[idx]); + for (int idx = 0; idx < _trackInfo._count; ++idx) { + DEALLOCATE(_trackInfo._handleList[idx]); } } - _trackInfo.count = 0; + _trackInfo._count = 0; _globals->_soundManager.removeFromSoundList(this); _primed = false; @@ -912,13 +914,13 @@ void Sound::_unPrime() { } void Sound::orientAfterDriverChange() { - if (!_field26C) { + if (!_isEmpty) { int timeIndex = getTimeIndex(); - for (int idx = 0; idx < _trackInfo.count; ++idx) - DEALLOCATE(_handleList[idx]); + for (int idx = 0; idx < _trackInfo._count; ++idx) + DEALLOCATE(_trackInfo._handleList[idx]); - _trackInfo.count = 0; + _trackInfo._count = 0; _primed = false; _prime(_soundNum, true); setTimeIndex(timeIndex); @@ -926,7 +928,7 @@ void Sound::orientAfterDriverChange() { } void Sound::orientAfterRestore() { - if (_field26C) { + if (_isEmpty) { int timeIndex = getTimeIndex(); _primed = false; _prime(_soundNum, true); diff --git a/engines/tsage/sound.h b/engines/tsage/sound.h index 145282c499..0f361e00bd 100644 --- a/engines/tsage/sound.h +++ b/engines/tsage/sound.h @@ -37,9 +37,18 @@ class Sound; #define ADLIB_DRIVER_NUM 3 struct trackInfoStruct { - int count; - int rlbList[SOUND_ARR_SIZE]; - int arr2[SOUND_ARR_SIZE]; + int _count; + int _rlbList[SOUND_ARR_SIZE]; + int _arr2[SOUND_ARR_SIZE]; + byte *_handleList[SOUND_ARR_SIZE]; + int field82[SOUND_ARR_SIZE]; + int field92[SOUND_ARR_SIZE]; + int fielda2[SOUND_ARR_SIZE]; + int fieldb2[SOUND_ARR_SIZE]; + int fieldf2[SOUND_ARR_SIZE]; + int field132[SOUND_ARR_SIZE]; + int field152[SOUND_ARR_SIZE]; + }; enum SoundDriverStatus {SNDSTATUS_FAILED = 0, SNDSTATUS_DETECTED = 1, SNDSTATUS_SKIPPED = 2}; @@ -254,11 +263,8 @@ public: int _fieldC8[SOUND_ARR_SIZE]; int _fieldE8[SOUND_ARR_SIZE]; trackInfoStruct _trackInfo; - byte *_handleList[75]; - int _field266; - int _field268; bool _primed; - int _field26C; + bool _isEmpty; byte *_field26E; public: Sound(); |