diff options
| author | Torbjörn Andersson | 2003-10-29 07:53:05 +0000 |
|---|---|---|
| committer | Torbjörn Andersson | 2003-10-29 07:53:05 +0000 |
| commit | d7bd7d44b83fb3dce91567fd0d241758ea706b78 (patch) | |
| tree | 52294c5c40f09427fa6730c68f201d8b3b8fade7 /sword2/driver | |
| parent | 494d5269a2a0274a58e6bb30f211383cdaf5465f (diff) | |
| download | scummvm-rg350-d7bd7d44b83fb3dce91567fd0d241758ea706b78.tar.gz scummvm-rg350-d7bd7d44b83fb3dce91567fd0d241758ea706b78.tar.bz2 scummvm-rg350-d7bd7d44b83fb3dce91567fd0d241758ea706b78.zip | |
Use the ScummVM config manager instead of a separate BS2-specific config
file, plus some other cleanup. I don't know how the config manager decides
if/when to save the settings to file, but we can worry about that later.
svn-id: r11001
Diffstat (limited to 'sword2/driver')
| -rw-r--r-- | sword2/driver/d_sound.cpp | 79 | ||||
| -rw-r--r-- | sword2/driver/d_sound.h | 27 |
2 files changed, 60 insertions, 46 deletions
diff --git a/sword2/driver/d_sound.cpp b/sword2/driver/d_sound.cpp index cc8df01562..ca776e1118 100644 --- a/sword2/driver/d_sound.cpp +++ b/sword2/driver/d_sound.cpp @@ -36,9 +36,9 @@ #include "sound/audiostream.h" #include "sound/mixer.h" #include "sound/rate.h" +#include "sword2/sword2.h" #include "sword2/driver/driver96.h" #include "sword2/driver/d_sound.h" -#include "sword2/sword2.h" namespace Sword2 { @@ -130,10 +130,10 @@ static void premix_proc(void *param, int16 *data, uint len) { Sound::Sound(SoundMixer *mixer) { _mutex = g_system->create_mutex(); - _soundOn = 0; - _speechStatus = 0; - _fxPaused = 0; - _speechPaused = 0; + _soundOn = false; + _speechStatus = false; + _fxPaused = false; + _speechPaused = false; _speechVol = 14; _fxVol = 14; _speechMuted = 0; @@ -146,7 +146,7 @@ Sound::Sound(SoundMixer *mixer) { memset(_fx, 0, sizeof(_fx)); _soundHandleSpeech = 0; - _soundOn = 1; + _soundOn = true; _converter = makeRateConverter(_music[0].getRate(), _mixer->getOutputRate(), _music[0].isStereo(), false); @@ -411,13 +411,13 @@ int32 Sound::playCompSpeech(const char *filename, uint32 speechid, uint8 vol, in // Start the speech playing - _speechPaused = 1; + _speechPaused = true; uint32 flags = SoundMixer::FLAG_16BITS | SoundMixer::FLAG_AUTOFREE; _mixer->playRaw(&_soundHandleSpeech, data16, bufferSize, 22050, flags, -1, volume, p); - _speechStatus = 1; + _speechStatus = true; } // DipMusic(); @@ -435,7 +435,7 @@ int32 Sound::stopSpeech(void) { if (_speechStatus) { g_engine->_mixer->stopHandle(_soundHandleSpeech); - _speechStatus = 0; + _speechStatus = false; return RD_OK; } return RDERR_SPEECHNOTPLAYING; @@ -453,7 +453,7 @@ int32 Sound::getSpeechStatus(void) { return RDSE_SAMPLEPLAYING; if (!_soundHandleSpeech) { - _speechStatus = 0; + _speechStatus = false; return RDSE_SAMPLEFINISHED; } return RDSE_SAMPLEPLAYING; @@ -465,7 +465,11 @@ int32 Sound::getSpeechStatus(void) { */ void Sound::setSpeechVolume(uint8 volume) { + if (volume > 14) + volume = 14; + _speechVol = volume; + if (_soundHandleSpeech != 0 && !_speechMuted && getSpeechStatus() == RDSE_SAMPLEPLAYING) { g_engine->_mixer->setChannelVolume(_soundHandleSpeech, 16 * _speechVol); } @@ -481,11 +485,11 @@ uint8 Sound::getSpeechVolume() { /** * Mutes/Unmutes the speech. - * @param mute If mute is 0, restore the volume to the last set master level. - * Otherwise the speech is muted (volume 0). + * @param mute If mute is false, restore the volume to the last set master + * level. Otherwise the speech is muted (volume 0). */ -void Sound::muteSpeech(uint8 mute) { +void Sound::muteSpeech(bool mute) { _speechMuted = mute; if (getSpeechStatus() == RDSE_SAMPLEPLAYING) { @@ -496,10 +500,10 @@ void Sound::muteSpeech(uint8 mute) { } /** - * @return the speech's mute state, 1 if mute, 0 if not mute + * @return the speech's mute state, true if mute, false if not mute */ -uint8 Sound::isSpeechMute(void) { +bool Sound::isSpeechMute(void) { return _speechMuted; } @@ -509,7 +513,7 @@ uint8 Sound::isSpeechMute(void) { void Sound::pauseSpeech(void) { if (getSpeechStatus() == RDSE_SAMPLEPLAYING) { - _speechPaused = 1; + _speechPaused = true; g_engine->_mixer->pauseHandle(_soundHandleSpeech, true); } } @@ -520,7 +524,7 @@ void Sound::pauseSpeech(void) { void Sound::unpauseSpeech(void) { if (_speechPaused) { - _speechPaused = 0; + _speechPaused = false; g_engine->_mixer->pauseHandle(_soundHandleSpeech, false); } } @@ -649,7 +653,7 @@ int32 Sound::playFx(int32 id, uint8 *data, uint8 vol, int8 pan, uint8 type) { _fx[i]._flags |= SoundMixer::FLAG_LOOP; else _fx[i]._flags &= ~SoundMixer::FLAG_LOOP; - + _fx[i]._volume = vol; // Start the sound effect playing @@ -722,11 +726,16 @@ int32 Sound::setFxIdVolumePan(int32 id, uint8 vol, int8 pan) { if (i == MAXFX) return RDERR_FXNOTOPEN; + if (vol > 14) + vol = 14; + _fx[i]._volume = vol; + if (!_fxMuted) { - g_engine->_mixer->setChannelVolume(_fx[i]._handle, vol * _fxVol); + g_engine->_mixer->setChannelVolume(_fx[i]._handle, _fx[i]._volume * _fxVol); g_engine->_mixer->setChannelPan(_fx[i]._handle, panTable[pan + 16]); } + return RD_OK; } @@ -807,7 +816,7 @@ void Sound::pauseFx(void) { } else _fx[i]._paused = false; } - _fxPaused = 1; + _fxPaused = true; } } @@ -821,7 +830,7 @@ void Sound::pauseFxForSequence(void) { _fx[i]._paused = false; } } - _fxPaused = 1; + _fxPaused = true; } } @@ -832,7 +841,7 @@ void Sound::unpauseFx(void) { g_engine->_mixer->pauseHandle(_fx[i]._handle, false); } } - _fxPaused = 0; + _fxPaused = false; } } @@ -851,6 +860,9 @@ uint8 Sound::getFxVolume() { */ void Sound::setFxVolume(uint8 volume) { + if (volume > 14) + volume = 14; + _fxVol = volume; // Now update the volume of any fxs playing @@ -862,11 +874,11 @@ void Sound::setFxVolume(uint8 volume) { /** * Mutes/Unmutes the sound effects. - * @param mute If mute is 0, restore the volume to the last set master level. - * Otherwise the sound effects are muted (volume 0). + * @param mute If mute is false, restore the volume to the last set master + * level. Otherwise the sound effects are muted (volume 0). */ -void Sound::muteFx(uint8 mute) { +void Sound::muteFx(bool mute) { _fxMuted = mute; // Now update the volume of any fxs playing @@ -880,10 +892,10 @@ void Sound::muteFx(uint8 mute) { } /** - * @return the sound effects's mute state, 1 if mute, 0 if not mute + * @return the sound effects's mute state, true if mute, false if not mute */ -uint8 Sound::isFxMute(void) { +bool Sound::isFxMute(void) { return _fxMuted; } @@ -1117,6 +1129,9 @@ void Sound::unpauseMusic(void) { */ void Sound::setMusicVolume(uint8 volume) { + if (volume > 16) + volume = 16; + _musicVol = volume; } @@ -1130,19 +1145,19 @@ uint8 Sound::getMusicVolume() { /** * Mutes/Unmutes the music. - * @param mute If mute is 0, restore the volume to the last set master level. - * Otherwise the music is muted (volume 0). + * @param mute If mute is false, restore the volume to the last set master + * level. Otherwise the music is muted (volume 0). */ -void Sound::muteMusic(uint8 mute) { +void Sound::muteMusic(bool mute) { _musicMuted = mute; } /** - * @return the music's mute state, 1 if mute, 0 if not mute + * @return the music's mute state, true if mute, false if not mute */ -uint8 Sound::isMusicMute(void) { +bool Sound::isMusicMute(void) { return _musicMuted; } diff --git a/sword2/driver/d_sound.h b/sword2/driver/d_sound.h index 9c5b045821..3b30b80ebd 100644 --- a/sword2/driver/d_sound.h +++ b/sword2/driver/d_sound.h @@ -79,19 +79,18 @@ private: FxHandle _fx[MAXFX]; MusicHandle _music[MAXMUS + 1]; + bool _soundOn; + bool _speechStatus; + bool _speechPaused; + bool _fxPaused; + bool _musicMuted; + bool _speechMuted; + bool _fxMuted; uint8 _musicVol; - - uint8 _soundOn; - uint8 _speechStatus; - uint8 _fxPaused; - uint8 _speechPaused; uint8 _speechVol; uint8 _fxVol; - uint8 _speechMuted; - uint8 _fxMuted; PlayingSoundHandle _soundHandleSpeech; - uint8 _musicMuted; int32 getFxIndex(int32 id); int32 dipMusic(); @@ -127,16 +126,16 @@ public: uint8 getFxVolume(void); uint8 getSpeechVolume(void); uint8 getMusicVolume(void); - uint8 isMusicMute(void); - uint8 isFxMute(void); - uint8 isSpeechMute(void); + bool isMusicMute(void); + bool isFxMute(void); + bool isSpeechMute(void); void stopMusic(void); void setFxVolume(uint8 vol); void setSpeechVolume(uint8 vol); void setMusicVolume(uint8 vol); - void muteMusic(uint8 mute); - void muteFx(uint8 mute); - void muteSpeech(uint8 mute); + void muteMusic(bool mute); + void muteFx(bool mute); + void muteSpeech(bool mute); int32 isFxOpen(int32 id); int32 setFxIdVolumePan(int32 id, uint8 vol, int8 pan); int32 setFxIdVolume(int32 id, uint8 vol); |
