aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFilippos Karapetis2009-12-25 15:24:35 +0000
committerFilippos Karapetis2009-12-25 15:24:35 +0000
commit586ec94df9d450f1f57372e48960a6e07b40f45b (patch)
treeae4700162663f65066dddef9d8d168be1d11421f
parentec5c42e1f303973e48afcfe4509a1d053e6154ae (diff)
downloadscummvm-rg350-586ec94df9d450f1f57372e48960a6e07b40f45b.tar.gz
scummvm-rg350-586ec94df9d450f1f57372e48960a6e07b40f45b.tar.bz2
scummvm-rg350-586ec94df9d450f1f57372e48960a6e07b40f45b.zip
Adjusted volume clipping
svn-id: r46555
-rw-r--r--engines/sci/sfx/music.cpp3
-rw-r--r--engines/sci/sfx/soundcmd.cpp6
2 files changed, 4 insertions, 5 deletions
diff --git a/engines/sci/sfx/music.cpp b/engines/sci/sfx/music.cpp
index b47c65bd4c..70762c237c 100644
--- a/engines/sci/sfx/music.cpp
+++ b/engines/sci/sfx/music.cpp
@@ -472,8 +472,7 @@ uint16 SciMusic::soundGetMasterVolume() {
//---------------------------------------------
void SciMusic::soundSetMasterVolume(uint16 vol) {
vol = vol & 0xF; // 0..15
- vol = (vol * Audio::Mixer::kMaxMixerVolume / 0xF) & 0xFF; // 0...255
- // TODO:balance volume to prevent music to be too loud
+ vol = vol * Audio::Mixer::kMaxMixerVolume / 0xF;
_pMixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, vol);
_pMixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, vol);
_pMixer->setVolumeForSoundType(Audio::Mixer::kSpeechSoundType, vol);
diff --git a/engines/sci/sfx/soundcmd.cpp b/engines/sci/sfx/soundcmd.cpp
index c41857ca9f..b4773bd984 100644
--- a/engines/sci/sfx/soundcmd.cpp
+++ b/engines/sci/sfx/soundcmd.cpp
@@ -287,7 +287,7 @@ void SoundCommandParser::cmdInitHandle(reg_t obj, int16 value) {
newSound->soundObj = obj;
newSound->loop = GET_SEL32V(_segMan, obj, loop) == 0xFFFF ? 1 : 0;
newSound->prio = GET_SEL32V(_segMan, obj, pri) & 0xFF;
- newSound->volume = GET_SEL32V(_segMan, obj, vol) & 0xFF;
+ newSound->volume = CLIP<int>(GET_SEL32V(_segMan, obj, vol), 0, Audio::Mixer::kMaxChannelVolume);
newSound->dataInc = 0;
newSound->pStreamAud = 0;
newSound->pMidiParser = 0;
@@ -659,7 +659,7 @@ void SoundCommandParser::cmdUpdateHandle(reg_t obj, int16 value) {
}
_music->_playList[slot]->loop = (GET_SEL32V(_segMan, obj, loop) == 0xFFFF ? 1 : 0);
- uint32 objVol = GET_SEL32V(_segMan, obj, vol) & 0xFF;
+ uint32 objVol = CLIP<int>(GET_SEL32V(_segMan, obj, vol), 0, 255);
if (objVol != _music->_playList[slot]->volume)
_music->soundSetVolume(_music->_playList[slot], objVol);
uint32 objPrio = GET_SEL32V(_segMan, obj, vol);
@@ -821,7 +821,7 @@ void SoundCommandParser::cmdSetHandleVolume(reg_t obj, int16 value) {
return;
}
- value = value & 0xFF; // 0...255
+ value = CLIP<int>(value, 0, Audio::Mixer::kMaxChannelVolume);
if (_music->_playList[slot]->volume != value) {
_music->_playList[slot]->volume = value;