diff options
Diffstat (limited to 'engines/drascula')
-rw-r--r-- | engines/drascula/detection.cpp | 30 | ||||
-rw-r--r-- | engines/drascula/drascula.h | 4 | ||||
-rw-r--r-- | engines/drascula/graphics.cpp | 5 | ||||
-rw-r--r-- | engines/drascula/sound.cpp | 88 |
4 files changed, 95 insertions, 32 deletions
diff --git a/engines/drascula/detection.cpp b/engines/drascula/detection.cpp index ceaadd5088..49c7b0b14c 100644 --- a/engines/drascula/detection.cpp +++ b/engines/drascula/detection.cpp @@ -87,7 +87,7 @@ static const DrasculaGameDescription gameDescriptions[] = { Common::EN_ANY, Common::kPlatformDOS, GF_PACKED, - GUIO0() + GUIO1(GUIO_LINKSPEECHTOSFX) }, }, @@ -104,7 +104,7 @@ static const DrasculaGameDescription gameDescriptions[] = { Common::FR_FRA, Common::kPlatformDOS, GF_PACKED, - GUIO0() + GUIO1(GUIO_LINKSPEECHTOSFX) }, }, @@ -121,7 +121,7 @@ static const DrasculaGameDescription gameDescriptions[] = { Common::FR_FRA, Common::kPlatformDOS, GF_PACKED, - GUIO0() + GUIO1(GUIO_LINKSPEECHTOSFX) }, }, @@ -138,7 +138,7 @@ static const DrasculaGameDescription gameDescriptions[] = { Common::DE_DEU, Common::kPlatformDOS, GF_PACKED, - GUIO0() + GUIO1(GUIO_LINKSPEECHTOSFX) }, }, @@ -151,7 +151,7 @@ static const DrasculaGameDescription gameDescriptions[] = { Common::IT_ITA, Common::kPlatformDOS, GF_PACKED, - GUIO0() + GUIO1(GUIO_LINKSPEECHTOSFX) }, }, @@ -168,7 +168,7 @@ static const DrasculaGameDescription gameDescriptions[] = { Common::IT_ITA, Common::kPlatformDOS, GF_PACKED, - GUIO0() + GUIO1(GUIO_LINKSPEECHTOSFX) }, }, @@ -181,7 +181,7 @@ static const DrasculaGameDescription gameDescriptions[] = { Common::ES_ESP, Common::kPlatformDOS, GF_PACKED, - GUIO0() + GUIO1(GUIO_LINKSPEECHTOSFX) }, }, @@ -198,7 +198,7 @@ static const DrasculaGameDescription gameDescriptions[] = { Common::ES_ESP, Common::kPlatformDOS, GF_PACKED, - GUIO0() + GUIO1(GUIO_LINKSPEECHTOSFX) }, }, @@ -213,7 +213,7 @@ static const DrasculaGameDescription gameDescriptions[] = { Common::EN_ANY, Common::kPlatformDOS, ADGF_NO_FLAGS, - GUIO0() + GUIO1(GUIO_LINKSPEECHTOSFX) }, }, @@ -226,7 +226,7 @@ static const DrasculaGameDescription gameDescriptions[] = { Common::FR_FRA, Common::kPlatformDOS, ADGF_NO_FLAGS, - GUIO0() + GUIO1(GUIO_LINKSPEECHTOSFX) }, }, @@ -239,7 +239,7 @@ static const DrasculaGameDescription gameDescriptions[] = { Common::FR_FRA, Common::kPlatformDOS, ADGF_NO_FLAGS, - GUIO0() + GUIO1(GUIO_LINKSPEECHTOSFX) }, }, @@ -252,7 +252,7 @@ static const DrasculaGameDescription gameDescriptions[] = { Common::DE_DEU, Common::kPlatformDOS, ADGF_NO_FLAGS, - GUIO0() + GUIO1(GUIO_LINKSPEECHTOSFX) }, }, @@ -265,7 +265,7 @@ static const DrasculaGameDescription gameDescriptions[] = { Common::IT_ITA, Common::kPlatformDOS, ADGF_NO_FLAGS, - GUIO0() + GUIO1(GUIO_LINKSPEECHTOSFX) }, }, @@ -278,7 +278,7 @@ static const DrasculaGameDescription gameDescriptions[] = { Common::IT_ITA, Common::kPlatformDOS, ADGF_NO_FLAGS, - GUIO0() + GUIO1(GUIO_LINKSPEECHTOSFX) }, }, @@ -291,7 +291,7 @@ static const DrasculaGameDescription gameDescriptions[] = { Common::ES_ESP, Common::kPlatformDOS, ADGF_NO_FLAGS, - GUIO0() + GUIO1(GUIO_LINKSPEECHTOSFX) }, }, diff --git a/engines/drascula/drascula.h b/engines/drascula/drascula.h index c879a83db7..5265324d91 100644 --- a/engines/drascula/drascula.h +++ b/engines/drascula/drascula.h @@ -325,6 +325,8 @@ public: virtual ~DrasculaEngine(); virtual bool hasFeature(EngineFeature f) const; + virtual void syncSoundSettings(); + Common::RandomSource *_rnd; const DrasculaGameDescription *_gameDescription; uint32 getFeatures() const; @@ -488,7 +490,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/graphics.cpp b/engines/drascula/graphics.cpp index 09ff3c6429..dfe012a2ef 100644 --- a/engines/drascula/graphics.cpp +++ b/engines/drascula/graphics.cpp @@ -196,6 +196,11 @@ void DrasculaEngine::copyRect(int xorg, int yorg, int xdes, int ydes, int width, dest += xdes + ydes * 320; src += xorg + yorg * 320; + assert(xorg >= 0); + assert(yorg >= 0); + assert(xorg + width <= 320); + assert(yorg + height <= 200); + int ptr = 0; for (y = 0; y < height; y++) { for (x = 0; x < width; x++) { diff --git a/engines/drascula/sound.cpp b/engines/drascula/sound.cpp index 62ec796678..70916caffe 100644 --- a/engines/drascula/sound.cpp +++ b/engines/drascula/sound.cpp @@ -34,13 +34,48 @@ 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); +void DrasculaEngine::syncSoundSettings() { + // Sync the engine with the config manager + + bool mute = false; + if (ConfMan.hasKey("mute")) + mute = ConfMan.getBool("mute"); + + // We need to handle the speech mute separately here. This is because the + // engine code should be able to rely on all speech sounds muted when the + // user specified subtitles only mode, which results in "speech_mute" to + // be set to "true". The global mute setting has precedence over the + // speech mute setting though. + bool speechMute = mute; + if (!speechMute) + speechMute = ConfMan.getBool("speech_mute"); + + _mixer->muteSoundType(Audio::Mixer::kPlainSoundType, mute); + _mixer->muteSoundType(Audio::Mixer::kSFXSoundType, mute); + _mixer->muteSoundType(Audio::Mixer::kSpeechSoundType, speechMute); + _mixer->muteSoundType(Audio::Mixer::kMusicSoundType, mute); + + int voiceVolume = ConfMan.getInt("speech_volume"); + int musicVolume = ConfMan.getInt("music_volume"); + // If the music and voice volume are correct, don't change anything. + // Otherwise compute the master volume using an approximation of sqrt(max) * 16 which would result in the master + // volume being the same value as the max of music and voice. + if (_mixer->getVolumeForSoundType(Audio::Mixer::kSpeechSoundType) != voiceVolume || _mixer->getVolumeForSoundType(Audio::Mixer::kMusicSoundType) != musicVolume) { + int masterVolume = MAX(musicVolume, voiceVolume) * 2 / 3 + 86; + _mixer->setVolumeForSoundType(Audio::Mixer::kPlainSoundType, masterVolume); + _mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, voiceVolume); + _mixer->setVolumeForSoundType(Audio::Mixer::kSpeechSoundType, voiceVolume); + _mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, musicVolume); + } +} + +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 +88,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 +134,25 @@ 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); + ConfMan.setInt("speech_volume", voiceVolume); + ConfMan.setInt("sfx_volume", voiceVolume); + + musicVolume = (masterVolume + 1) * (musicVolume + 1) - 1; + _mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, musicVolume); + ConfMan.setInt("music_volume", musicVolume); } } |