diff options
author | Paul Gilbert | 2014-11-07 22:09:09 -0500 |
---|---|---|
committer | Paul Gilbert | 2014-12-12 22:24:34 -0500 |
commit | dc218d53ef9d9b6de11e26e1b793204d416fc9db (patch) | |
tree | 89bc2ad30076b0554c7f0ef62a64b2dc98ea58ea /engines | |
parent | 63bacba2d906f650e702ba544c5a49528452b5b2 (diff) | |
download | scummvm-rg350-dc218d53ef9d9b6de11e26e1b793204d416fc9db.tar.gz scummvm-rg350-dc218d53ef9d9b6de11e26e1b793204d416fc9db.tar.bz2 scummvm-rg350-dc218d53ef9d9b6de11e26e1b793204d416fc9db.zip |
ACCESS: Merge the sound resource and priority lists
Diffstat (limited to 'engines')
-rw-r--r-- | engines/access/access.cpp | 10 | ||||
-rw-r--r-- | engines/access/amazon/amazon_game.cpp | 10 | ||||
-rw-r--r-- | engines/access/amazon/amazon_scripts.cpp | 1 | ||||
-rw-r--r-- | engines/access/martian/martian_game.cpp | 1 | ||||
-rw-r--r-- | engines/access/scripts.cpp | 14 | ||||
-rw-r--r-- | engines/access/sound.cpp | 19 | ||||
-rw-r--r-- | engines/access/sound.h | 11 |
7 files changed, 35 insertions, 31 deletions
diff --git a/engines/access/access.cpp b/engines/access/access.cpp index a3cadc1025..f04a5dec88 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -245,8 +245,9 @@ void AccessEngine::speakText(ASurface *s, const Common::String &msg) { _events->waitKeyMouse(); } else { for (;;) { - _sound->_soundTable[0] = _sound->loadSound(_narateFile + 99, _sndSubFile); - _sound->_soundPriority[0] = 1; + _sound->freeSounds(); + Resource *sound = _sound->loadSound(_narateFile + 99, _sndSubFile); + _sound->_soundTable.push_back(SoundEntry(sound, 1)); _sound->playSound(0); _scripts->cmdFreeSound(); @@ -287,8 +288,9 @@ void AccessEngine::speakText(ASurface *s, const Common::String &msg) { } for (;;) { - _sound->_soundTable[0] = _sound->loadSound(_narateFile + 99, _sndSubFile); - _sound->_soundPriority[0] = 1; + _sound->freeSounds(); + Resource *res = _sound->loadSound(_narateFile + 99, _sndSubFile); + _sound->_soundTable.push_back(SoundEntry(res, 1)); _sound->playSound(0); _scripts->cmdFreeSound(); diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index 8270eaee6b..9801df7f3c 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -132,10 +132,7 @@ void AmazonEngine::doTitle() { _events->hideCursor(); _sound->queueSound(0, 98, 30); - _sound->_soundPriority[0] = 1; - _sound->queueSound(1, 98, 8); - _sound->_soundPriority[1] = 1; _files->_loadPalFlag = false; _files->loadScreen(0, 3); @@ -404,14 +401,13 @@ void AmazonEngine::startChapter(int chapter) { _timers[20]._timer = 500; _timers[20]._initTm = 500; _timers[20]._flag++; + _sound->freeSounds(); - _sound->_soundTable[0] = _sound->loadSound(115, 0); - _sound->_soundPriority[0] = 1; + _sound->_soundTable.push_back(SoundEntry(_sound->loadSound(115, 0), 1)); _sound->playSound(0); _sound->freeSounds(); - _sound->_soundTable[0] = _sound->loadSound(115, 1); - _sound->_soundPriority[0] = 1; + _sound->_soundTable.push_back(SoundEntry(_sound->loadSound(115, 1), 1)); _sound->playSound(0); _sound->freeSounds(); diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp index 5d9f2d9436..12902081b7 100644 --- a/engines/access/amazon/amazon_scripts.cpp +++ b/engines/access/amazon/amazon_scripts.cpp @@ -116,7 +116,6 @@ void AmazonScripts::mWhile1() { _sequence = 2200; _vm->_sound->queueSound(0, 14, 15); - _vm->_sound->_soundPriority[0] = 1; do { cLoop(); diff --git a/engines/access/martian/martian_game.cpp b/engines/access/martian/martian_game.cpp index 2f11d8b858..1c135930f3 100644 --- a/engines/access/martian/martian_game.cpp +++ b/engines/access/martian/martian_game.cpp @@ -96,7 +96,6 @@ void MartianEngine::doTitle() { _events->hideCursor(); _sound->queueSound(0, 98, 30); - _sound->_soundPriority[0] = 1; _files->_loadPalFlag = false; _files->loadScreen(0, 3); diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index 6c4c37491f..bf58a20eef 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -707,15 +707,14 @@ void Scripts::cmdLoadSound() { int idx = _data->readSint16LE(); _vm->_sound->_soundTable.clear(); - _vm->_sound->_soundPriority.clear(); - _vm->_sound->_soundTable.push_back(_vm->_files->loadFile(_vm->_extraCells[idx]._vidSound)); - _vm->_sound->_soundPriority.push_back(1); + Resource *sound = _vm->_files->loadFile(_vm->_extraCells[idx]._vidSound); + _vm->_sound->_soundTable.push_back(SoundEntry(sound, 1)); } void Scripts::cmdFreeSound() { SoundManager &sound = *_vm->_sound; - if (sound._soundTable.size() > 0 && sound._soundTable[0]) { + if (sound._soundTable.size() > 0 && sound._soundTable[0]._res) { // Keep doing char display loop if playing sound for it do { if (_vm->_flags[236] == 1) @@ -725,8 +724,8 @@ void Scripts::cmdFreeSound() { } while (!_vm->shouldQuit() && sound._playingSound); // Free the sound - delete sound._soundTable[0]; - sound._soundTable[0] = nullptr; + delete sound._soundTable[0]._res; + sound._soundTable.remove_at(0); } } @@ -766,8 +765,7 @@ void Scripts::cmdDead() { _vm->_screen->forceFadeOut(); cmdFreeSound(); - _vm->_sound->_soundTable[0] = _vm->_files->loadFile(98, 44); - _vm->_sound->_soundPriority[1] = 1; + _vm->_sound->_soundTable.push_back(SoundEntry(_vm->_files->loadFile(98, 44), 1)); _vm->_screen->clearScreen(); _vm->_screen->setPanel(3); diff --git a/engines/access/sound.cpp b/engines/access/sound.cpp index dd8cf16189..075bfc005e 100644 --- a/engines/access/sound.cpp +++ b/engines/access/sound.cpp @@ -44,14 +44,17 @@ SoundManager::~SoundManager() { void SoundManager::clearSounds() { for (uint i = 0; i < _soundTable.size(); ++i) - delete _soundTable[i]; + delete _soundTable[i]._res; _soundTable.clear(); - _soundPriority.clear(); } void SoundManager::queueSound(int idx, int fileNum, int subfile) { - delete _soundTable[idx]; - _soundTable[idx] = _vm->_files->loadFile(fileNum, subfile); + if (idx >= (int)_soundTable.size()) + _soundTable.resize(idx + 1); + + delete _soundTable[idx]._res; + _soundTable[idx]._res = _vm->_files->loadFile(fileNum, subfile); + _soundTable[idx]._priority = 1; } Resource *SoundManager::loadSound(int fileNum, int subfile) { @@ -59,8 +62,8 @@ Resource *SoundManager::loadSound(int fileNum, int subfile) { } void SoundManager::playSound(int soundIndex) { - int priority = _soundPriority[soundIndex]; - playSound(_soundTable[soundIndex], priority); + int priority = _soundTable[soundIndex]._priority; + playSound(_soundTable[soundIndex]._res, priority); } void SoundManager::playSound(Resource *res, int priority) { @@ -76,8 +79,8 @@ void SoundManager::loadSounds(Common::Array<RoomInfo::SoundIdent> &sounds) { clearSounds(); for (uint i = 0; i < sounds.size(); ++i) { - _soundTable.push_back(loadSound(sounds[i]._fileNum, sounds[i]._subfile)); - _soundPriority.push_back(sounds[i]._priority); + Resource *sound = loadSound(sounds[i]._fileNum, sounds[i]._subfile); + _soundTable.push_back(SoundEntry(sound, sounds[i]._priority)); } } diff --git a/engines/access/sound.h b/engines/access/sound.h index c1b3981997..2456ba7753 100644 --- a/engines/access/sound.h +++ b/engines/access/sound.h @@ -33,6 +33,14 @@ namespace Access { class AccessEngine; +struct SoundEntry { + Resource *_res; + int _priority; + + SoundEntry() { _res = nullptr; _priority = 0; } + SoundEntry(Resource *res, int priority) { _res = res; _priority = priority; } +}; + class SoundManager { private: AccessEngine *_vm; @@ -45,8 +53,7 @@ private: void stopSound(); public: - Common::Array<Resource *> _soundTable; - Common::Array<int> _soundPriority; + Common::Array<SoundEntry> _soundTable; Resource *_music; Resource *_tempMusic; bool _musicRepeat; |