Limit volume range to 0 - 255

svn-id: r46554
This commit is contained in:
Filippos Karapetis 2009-12-25 14:02:28 +00:00
parent c03e7c8586
commit ec5c42e1f3
2 changed files with 4 additions and 2 deletions

View File

@ -472,7 +472,7 @@ uint16 SciMusic::soundGetMasterVolume() {
//---------------------------------------------
void SciMusic::soundSetMasterVolume(uint16 vol) {
vol = vol & 0xF; // 0..15
vol = vol * Audio::Mixer::kMaxMixerVolume / 0xF;
vol = (vol * Audio::Mixer::kMaxMixerVolume / 0xF) & 0xFF; // 0...255
// TODO:balance volume to prevent music to be too loud
_pMixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, vol);
_pMixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, vol);

View File

@ -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);
uint32 objVol = GET_SEL32V(_segMan, obj, vol) & 0xFF;
if (objVol != _music->_playList[slot]->volume)
_music->soundSetVolume(_music->_playList[slot], objVol);
uint32 objPrio = GET_SEL32V(_segMan, obj, vol);
@ -821,6 +821,8 @@ void SoundCommandParser::cmdSetHandleVolume(reg_t obj, int16 value) {
return;
}
value = value & 0xFF; // 0...255
if (_music->_playList[slot]->volume != value) {
_music->_playList[slot]->volume = value;
_music->soundSetVolume(_music->_playList[slot], value);