diff options
Diffstat (limited to 'engines/mads/sound.cpp')
-rw-r--r-- | engines/mads/sound.cpp | 36 |
1 files changed, 31 insertions, 5 deletions
diff --git a/engines/mads/sound.cpp b/engines/mads/sound.cpp index d0aa770a4d..7b9388eee3 100644 --- a/engines/mads/sound.cpp +++ b/engines/mads/sound.cpp @@ -8,12 +8,12 @@ * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. - + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. @@ -36,9 +36,19 @@ SoundManager::SoundManager(MADSEngine *vm, Audio::Mixer *mixer) { _pollSoundEnabled = false; _soundPollFlag = false; _newSoundsPaused = false; + _masterVolume = 255; _opl = OPL::Config::create(); _opl->init(11025); + + // Validate sound files + switch (_vm->getGameID()) { + case GType_RexNebular: + Nebular::ASound::validate(); + break; + default: + break; + } } SoundManager::~SoundManager() { @@ -53,6 +63,9 @@ SoundManager::~SoundManager() { void SoundManager::init(int sectionNumber) { assert(sectionNumber > 0 && sectionNumber < 10); + if (_driver != nullptr) + delete _driver; + switch (_vm->getGameID()) { case GType_RexNebular: switch (sectionNumber) { @@ -85,15 +98,18 @@ void SoundManager::init(int sectionNumber) { break; default: _driver = nullptr; - break; + return; } break; default: warning("SoundManager: Unknown game"); _driver = nullptr; - break; + return; } + + // Set volume for newly loaded driver + _driver->setVolume(_masterVolume); } void SoundManager::closeDriver() { @@ -129,12 +145,22 @@ void SoundManager::startQueuedCommands() { } } +void SoundManager::setVolume(int volume) { + _masterVolume = volume; + + if (_driver) + _driver->setVolume(volume); +} + void SoundManager::command(int commandId, int param) { if (_newSoundsPaused) { if (_queuedCommands.size() < 8) _queuedCommands.push(commandId); } else if (_driver) { - _driver->command(commandId, param); + // Note: I don't know any way to identify music commands versus sfx + // commands, so if sfx is mute, then so is music + if (_vm->_soundFlag) + _driver->command(commandId, param); } } |