ACCESS: Use loadSoundTable instead of push_back in several places

This commit is contained in:
Strangerke 2014-12-27 17:21:04 +01:00
parent 6a7834a05e
commit 576bab349c
5 changed files with 16 additions and 15 deletions

View File

@ -222,14 +222,14 @@ void AccessEngine::speakText(ASurface *s, const Common::String &msg) {
_events->clearEvents(); _events->clearEvents();
while (!shouldQuit()) { while (!shouldQuit()) {
_sound->freeSounds(); _sound->freeSounds();
Resource *sound = _sound->loadSound(_narateFile + 99, _sndSubFile); _sound->loadSoundTable(0, _narateFile + 99, _sndSubFile);
_sound->_soundTable.push_back(SoundEntry(sound, 1));
_sound->playSound(0); _sound->playSound(0);
_scripts->cmdFreeSound();
while(_sound->isSFXPlaying() && !shouldQuit()) while(_sound->isSFXPlaying() && !shouldQuit())
_events->pollEvents(); _events->pollEvents();
_scripts->cmdFreeSound();
if (_events->isKeyMousePressed()) { if (_events->isKeyMousePressed()) {
_sndSubFile += soundsLeft; _sndSubFile += soundsLeft;
break; break;
@ -257,11 +257,12 @@ void AccessEngine::speakText(ASurface *s, const Common::String &msg) {
Resource *res = _sound->loadSound(_narateFile + 99, _sndSubFile); Resource *res = _sound->loadSound(_narateFile + 99, _sndSubFile);
_sound->_soundTable.push_back(SoundEntry(res, 1)); _sound->_soundTable.push_back(SoundEntry(res, 1));
_sound->playSound(0); _sound->playSound(0);
_scripts->cmdFreeSound();
while(_sound->isSFXPlaying() && !shouldQuit()) while(_sound->isSFXPlaying() && !shouldQuit())
_events->pollEvents(); _events->pollEvents();
_scripts->cmdFreeSound();
if (_events->_leftButton) { if (_events->_leftButton) {
_events->debounceLeft(); _events->debounceLeft();
_sndSubFile += soundsLeft; _sndSubFile += soundsLeft;

View File

@ -528,8 +528,8 @@ void AmazonEngine::startChapter(int chapter) {
_sound->freeSounds(); _sound->freeSounds();
if (isCD()) { if (isCD()) {
_sound->_soundTable.push_back(SoundEntry(_sound->loadSound(115, 0), 1)); _sound->loadSoundTable(0, 115, 0);
_sound->_soundTable.push_back(SoundEntry(_sound->loadSound(115, 1), 1)); _sound->loadSoundTable(1, 115, 1);
_sound->playSound(0); _sound->playSound(0);
_sound->playSound(1); _sound->playSound(1);

View File

@ -490,12 +490,12 @@ void Opening::doTent() {
_vm->_screen->setDisplayScan(); _vm->_screen->setDisplayScan();
_vm->_screen->forceFadeOut(); _vm->_screen->forceFadeOut();
_vm->_events->hideCursor(); _vm->_events->hideCursor();
_vm->_sound->_soundTable.push_back(SoundEntry(_vm->_sound->loadSound(98, 39), 1)); _vm->_sound->loadSoundTable(0, 98, 39);
_vm->_sound->_soundTable.push_back(SoundEntry(_vm->_sound->loadSound(98, 14), 1)); _vm->_sound->loadSoundTable(1, 98, 14);
_vm->_sound->_soundTable.push_back(SoundEntry(_vm->_sound->loadSound(98, 15), 1)); _vm->_sound->loadSoundTable(2, 98, 15);
_vm->_sound->_soundTable.push_back(SoundEntry(_vm->_sound->loadSound(98, 16), 1)); _vm->_sound->loadSoundTable(3, 98, 16);
_vm->_sound->_soundTable.push_back(SoundEntry(_vm->_sound->loadSound(98, 31), 2)); _vm->_sound->loadSoundTable(4, 98, 31, 2);
_vm->_sound->_soundTable.push_back(SoundEntry(_vm->_sound->loadSound(98, 52), 2)); _vm->_sound->loadSoundTable(5, 98, 52, 2);
_vm->_sound->playSound(0); _vm->_sound->playSound(0);
_vm->_files->_setPaletteFlag = false; _vm->_files->_setPaletteFlag = false;

View File

@ -56,7 +56,7 @@ void SoundManager::clearSounds() {
} }
} }
void SoundManager::loadSoundTable(int idx, int fileNum, int subfile) { void SoundManager::loadSoundTable(int idx, int fileNum, int subfile, int priority) {
debugC(1, kDebugSound, "loadSoundTable(%d, %d, %d)", idx, fileNum, subfile); debugC(1, kDebugSound, "loadSoundTable(%d, %d, %d)", idx, fileNum, subfile);
Resource *soundResource; Resource *soundResource;
@ -67,7 +67,7 @@ void SoundManager::loadSoundTable(int idx, int fileNum, int subfile) {
delete _soundTable[idx]._res; delete _soundTable[idx]._res;
soundResource = _vm->_files->loadFile(fileNum, subfile); soundResource = _vm->_files->loadFile(fileNum, subfile);
_soundTable[idx]._res = soundResource; _soundTable[idx]._res = soundResource;
_soundTable[idx]._priority = 1; _soundTable[idx]._priority = priority;
} }
Resource *SoundManager::loadSound(int fileNum, int subfile) { Resource *SoundManager::loadSound(int fileNum, int subfile) {

View File

@ -60,7 +60,7 @@ public:
SoundManager(AccessEngine *vm, Audio::Mixer *mixer); SoundManager(AccessEngine *vm, Audio::Mixer *mixer);
~SoundManager(); ~SoundManager();
void loadSoundTable(int idx, int fileNum, int subfile); void loadSoundTable(int idx, int fileNum, int subfile, int priority = 1);
void playSound(int soundIndex); void playSound(int soundIndex);
void checkSoundQueue(); void checkSoundQueue();