TSAGE: Updated the separation of fields from the Sound class to the trackInfoStruct structure

This commit is contained in:
Paul Gilbert 2011-05-26 20:30:30 +10:00
parent 927bb2fdc4
commit 1d19013912
3 changed files with 40 additions and 30 deletions

View File

@ -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) {

View File

@ -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);

View File

@ -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();