aboutsummaryrefslogtreecommitdiff
path: root/engines/drascula
diff options
context:
space:
mode:
authorThierry Crozat2017-02-11 03:38:35 +0000
committerThierry Crozat2017-02-11 14:38:34 +0000
commitf7e5f01b859c82a812a9a1466974ea18b4a8b204 (patch)
tree659e315e15232a28544cfee10f45adafd60eaa0d /engines/drascula
parente64e3888163b6f5cce0a8e298eb4379b66426bff (diff)
downloadscummvm-rg350-f7e5f01b859c82a812a9a1466974ea18b4a8b204.tar.gz
scummvm-rg350-f7e5f01b859c82a812a9a1466974ea18b4a8b204.tar.bz2
scummvm-rg350-f7e5f01b859c82a812a9a1466974ea18b4a8b204.zip
DRASCULA: Add handling of the master volume
Diffstat (limited to 'engines/drascula')
-rw-r--r--engines/drascula/drascula.h2
-rw-r--r--engines/drascula/sound.cpp50
2 files changed, 35 insertions, 17 deletions
diff --git a/engines/drascula/drascula.h b/engines/drascula/drascula.h
index c879a83db7..e66220f9c6 100644
--- a/engines/drascula/drascula.h
+++ b/engines/drascula/drascula.h
@@ -488,7 +488,7 @@ public:
void addKeyToBuffer(Common::KeyState& key);
void flushKeyBuffer();
void selectVerb(int);
- void updateVolume(Audio::Mixer::SoundType soundType, int prevVolume);
+ int updateVolume(int prevVolume, int prevVolumeY);
void volumeControls();
bool saveLoadScreen();
diff --git a/engines/drascula/sound.cpp b/engines/drascula/sound.cpp
index 62ec796678..ef60bcc36a 100644
--- a/engines/drascula/sound.cpp
+++ b/engines/drascula/sound.cpp
@@ -34,13 +34,13 @@
namespace Drascula {
-void DrasculaEngine::updateVolume(Audio::Mixer::SoundType soundType, int prevVolume) {
- int vol = _mixer->getVolumeForSoundType(soundType) / 16;
- if (_mouseY < prevVolume && vol < 15)
- vol++;
- if (_mouseY > prevVolume && vol > 0)
- vol--;
- _mixer->setVolumeForSoundType(soundType, vol * 16);
+int DrasculaEngine::updateVolume(int prevVolume, int prevVolumeY) {
+ prevVolumeY += 10;
+ if (_mouseY < prevVolumeY && prevVolume < 15)
+ prevVolume++;
+ if (_mouseY > prevVolumeY && prevVolume > 0)
+ prevVolume--;
+ return prevVolume;
}
void DrasculaEngine::volumeControls() {
@@ -53,10 +53,22 @@ void DrasculaEngine::volumeControls() {
setCursor(kCursorCrosshair);
showCursor();
+ // The engine has three volume controls: master, SFx/Speech and Music.
+ // ScummVM doesn't have a master volume, so we abuse the kPlainSoundType to store it.
+ // In drascula, we only use the kMusicSoundType and kSpeechSoundType to play sounds.
+ // For consistency with the ScummVM options dialog we also set the kSFXSoundType volume
+ // to the same value as the kMusicSoundType value, but we don't actually use it.
+
+ // The engines uses masterVolume, voiceVolume and musicVolume between 0 and 15.
+ // We store in the mixer:
+ // - masterVolume * 16 in kPlainSoundType
+ // - (masterVolume + 1) * (voiceVolume + 1) - 1 in both kSpeechSoundType and kSFXSoundType
+ // - (masterVolume + 1) * (musicVolume + 1) - 1 in kMusicSoundType
+
while (!shouldQuit()) {
int masterVolume = CLIP((_mixer->getVolumeForSoundType(Audio::Mixer::kPlainSoundType) / 16), 0, 15);
- int voiceVolume = CLIP((_mixer->getVolumeForSoundType(Audio::Mixer::kSpeechSoundType) / 16), 0, 15);
- int musicVolume = CLIP((_mixer->getVolumeForSoundType(Audio::Mixer::kMusicSoundType) / 16), 0, 15);
+ int voiceVolume = CLIP(((_mixer->getVolumeForSoundType(Audio::Mixer::kSpeechSoundType) + 1) / (masterVolume + 1) - 1), 0, 15);
+ int musicVolume = CLIP(((_mixer->getVolumeForSoundType(Audio::Mixer::kMusicSoundType) + 1) / (masterVolume + 1) - 1), 0, 15);
int masterVolumeY = 72 + 61 - masterVolume * 4;
int voiceVolumeY = 72 + 61 - voiceVolume * 4;
@@ -87,16 +99,22 @@ void DrasculaEngine::volumeControls() {
if (_leftMouseButton == 1) {
delay(100);
if (_mouseX > 80 && _mouseX < 121) {
- updateVolume(Audio::Mixer::kPlainSoundType, masterVolumeY);
+ masterVolume = updateVolume(masterVolume, masterVolumeY);
+ _mixer->setVolumeForSoundType(Audio::Mixer::kPlainSoundType, masterVolume * 16);
}
- if (_mouseX > 136 && _mouseX < 178) {
- updateVolume(Audio::Mixer::kSpeechSoundType, voiceVolumeY);
- }
+ if (_mouseX > 136 && _mouseX < 178)
+ voiceVolume = updateVolume(voiceVolume, voiceVolumeY);
- if (_mouseX > 192 && _mouseX < 233) {
- updateVolume(Audio::Mixer::kMusicSoundType, musicVolumeY);
- }
+ if (_mouseX > 192 && _mouseX < 233)
+ musicVolume = updateVolume(musicVolume, musicVolumeY);
+
+ voiceVolume = (masterVolume + 1) * (voiceVolume + 1) - 1;
+ _mixer->setVolumeForSoundType(Audio::Mixer::kSpeechSoundType, voiceVolume);
+ _mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, voiceVolume);
+
+ musicVolume = (masterVolume + 1) * (musicVolume + 1) - 1;
+ _mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, musicVolume);
}
}