aboutsummaryrefslogtreecommitdiff
path: root/engines/draci
diff options
context:
space:
mode:
authorRobert Špalek2009-10-13 05:38:45 +0000
committerRobert Špalek2009-10-13 05:38:45 +0000
commitbaec8c2421c30ebee00c0e0e97de8beba3a9fc2a (patch)
treed53d3c7e094a941af1ab685d671c97fccf278db0 /engines/draci
parent7c311057c10f876cbe5053fac1943917766ae0f0 (diff)
downloadscummvm-rg350-baec8c2421c30ebee00c0e0e97de8beba3a9fc2a.tar.gz
scummvm-rg350-baec8c2421c30ebee00c0e0e97de8beba3a9fc2a.tar.bz2
scummvm-rg350-baec8c2421c30ebee00c0e0e97de8beba3a9fc2a.zip
Set all sound/subtitle-related parameters from ConfMan.
Made it intelligent so that when, for example, the dubbing file doesn't exist, we don't fail, but instead always show subtitles even if the GUI settings says dubbing only, etc. svn-id: r45002
Diffstat (limited to 'engines/draci')
-rw-r--r--engines/draci/draci.cpp11
-rw-r--r--engines/draci/game.cpp4
-rw-r--r--engines/draci/game.h8
-rw-r--r--engines/draci/script.cpp19
-rw-r--r--engines/draci/sound.cpp15
-rw-r--r--engines/draci/sound.h10
6 files changed, 51 insertions, 16 deletions
diff --git a/engines/draci/draci.cpp b/engines/draci/draci.cpp
index 8fc7046d86..4c52398737 100644
--- a/engines/draci/draci.cpp
+++ b/engines/draci/draci.cpp
@@ -173,8 +173,7 @@ int DraciEngine::init() {
}
if (!_dubbingArchive->isOpen()) {
- debugC(2, kDraciGeneralDebugLevel, "ERROR - Opening dubbing archive failed");
- return Common::kUnknownError;
+ debugC(2, kDraciGeneralDebugLevel, "WARNING - Opening dubbing archive failed");
}
_showWalkingMap = false;
@@ -331,11 +330,17 @@ void DraciEngine::pauseEngineIntern(bool pause) {
_pauseStartTime = _system->getMillis();
_anims->pauseAnimations();
+ _sound->pauseSound();
+ _sound->pauseVoice();
} else {
_anims->unpauseAnimations();
+ _sound->resumeSound();
+ _sound->resumeVoice();
// Adjust engine start time
- _engineStartTime += (_system->getMillis() - _pauseStartTime) / 1000;
+ const int delta = _system->getMillis() - _pauseStartTime;
+ _engineStartTime += delta / 1000;
+ _game->shiftSpeechTick(delta);
_pauseStartTime = 0;
}
}
diff --git a/engines/draci/game.cpp b/engines/draci/game.cpp
index a9cf42c73b..1694d81cf0 100644
--- a/engines/draci/game.cpp
+++ b/engines/draci/game.cpp
@@ -1506,6 +1506,10 @@ void Game::setSpeechTiming(uint tick, uint duration) {
_speechDuration = duration;
}
+void Game::shiftSpeechTick(int delta) {
+ _speechTick += delta;
+}
+
int Game::getEscRoom() const {
return _currentRoom._escRoom;
}
diff --git a/engines/draci/game.h b/engines/draci/game.h
index 0fca5972cb..aa7ab27ae1 100644
--- a/engines/draci/game.h
+++ b/engines/draci/game.h
@@ -79,9 +79,12 @@ enum {
kBlackPalette = -1
};
+// Constants tuned such that with ScummVM's default talkspeed 60, the speed
+// computed by equation (kBaseSpeechDuration + kSpeechTimeUnit * #characters) /
+// talkspeed is equal to the original game.
enum SpeechConstants {
- kBaseSpeechDuration = 200,
- kSpeechTimeUnit = 400
+ kBaseSpeechDuration = 12000,
+ kSpeechTimeUnit = 2640
};
/** Inventory related magical constants */
@@ -325,6 +328,7 @@ public:
void setExitLoop(int exit) { _shouldExitLoop = exit; }
void setSpeechTiming(uint tick, uint duration);
+ void shiftSpeechTick(int delta);
void updateTitle();
void updateCursor();
diff --git a/engines/draci/script.cpp b/engines/draci/script.cpp
index fdc6774e25..5f4edf07b5 100644
--- a/engines/draci/script.cpp
+++ b/engines/draci/script.cpp
@@ -697,9 +697,17 @@ void Script::talk(Common::Queue<int> &params) {
// Fetch person info
const Person *person = _vm->_game->getPerson(personID);
+ // Fetch the dubbing
+ SoundSample *sample = _vm->_sound->isMutedVoice()
+ ? NULL : _vm->_dubbingArchive->getSample(sentenceID, 0);
+
// Set the string and text colour
surface->markDirtyRect(speechFrame->getRect());
- speechFrame->setText(Common::String((const char *)f->_data+1, f->_length-1));
+ if (_vm->_sound->showSubtitles() || !sample) {
+ speechFrame->setText(Common::String((const char *)f->_data+1, f->_length-1));
+ } else {
+ speechFrame->setText("");
+ }
speechFrame->setColour(person->_fontColour);
// HACK: Some strings in the English data files are too long to fit the screen
@@ -714,7 +722,6 @@ void Script::talk(Common::Queue<int> &params) {
_vm->_game->setLoopSubstatus(kSubstatusTalk);
// Speak the dubbing if possible
- SoundSample *sample = _vm->_dubbingArchive->getSample(sentenceID, 0);
uint dubbingDuration = 0;
if (sample) {
dubbingDuration = (uint) (1000.0 * sample->_length / sample->_frequency + 500.0);
@@ -724,11 +731,9 @@ void Script::talk(Common::Queue<int> &params) {
}
// Record time
- const uint subtitleDuration = kBaseSpeechDuration +
- speechFrame->getLength() * kSpeechTimeUnit /
- (128 / 16 + 1);
- const uint duration = subtitleDuration >= dubbingDuration ?
- subtitleDuration : dubbingDuration;
+ uint subtitleDuration = (kBaseSpeechDuration + speechFrame->getLength() * kSpeechTimeUnit)
+ / _vm->_sound->talkSpeed();
+ const uint duration = MAX(subtitleDuration, dubbingDuration);
_vm->_game->setSpeechTiming(_vm->_system->getMillis(), duration);
// TODO: Implement inventory part
diff --git a/engines/draci/sound.cpp b/engines/draci/sound.cpp
index 1324d8e992..09c7aad4ca 100644
--- a/engines/draci/sound.cpp
+++ b/engines/draci/sound.cpp
@@ -49,6 +49,8 @@ void SoundArchive::openArchive(const Common::String &path) {
debugC(2, kDraciArchiverDebugLevel, "Success");
} else {
debugC(2, kDraciArchiverDebugLevel, "Error");
+ delete _f;
+ _f = NULL;
return;
}
@@ -159,7 +161,8 @@ SoundSample *SoundArchive::getSample(int i, uint freq) {
return _samples + i;
}
-Sound::Sound(Audio::Mixer *mixer) : _mixer(mixer) {
+Sound::Sound(Audio::Mixer *mixer) : _mixer(mixer), _muteSound(false), _muteVoice(false),
+ _showSubtitles(true), _talkSpeed(60) {
for (int i = 0; i < SOUND_HANDLES; i++)
_handles[i].type = kFreeHandle;
@@ -202,7 +205,7 @@ void Sound::playSoundBuffer(Audio::SoundHandle *handle, const SoundSample &buffe
}
void Sound::playSound(const SoundSample *buffer, int volume, bool loop) {
- if (!buffer)
+ if (!buffer || _muteSound)
return;
SndHandle *handle = getHandle();
@@ -231,7 +234,7 @@ void Sound::stopSound() {
}
void Sound::playVoice(const SoundSample *buffer) {
- if (!buffer)
+ if (!buffer || _muteVoice)
return;
SndHandle *handle = getHandle();
@@ -265,11 +268,15 @@ void Sound::stopAll() {
}
void Sound::setVolume() {
+ // TODO: how to retrieve "Mute All" ?
+ _muteSound = ConfMan.getBool("sfx_mute");
+ _muteVoice = ConfMan.getBool("speech_mute");
+ _showSubtitles = ConfMan.getBool("subtitles");
+ _talkSpeed = ConfMan.getInt("talkspeed");
const int soundVolume = ConfMan.getInt("sfx_volume");
const int speechVolume = ConfMan.getInt("speech_volume");
_mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, soundVolume);
_mixer->setVolumeForSoundType(Audio::Mixer::kSpeechSoundType, speechVolume);
- // TODO: make sure this sound settings works
}
} // End of namespace Draci
diff --git a/engines/draci/sound.h b/engines/draci/sound.h
index 6d63b066eb..8bbfa374ff 100644
--- a/engines/draci/sound.h
+++ b/engines/draci/sound.h
@@ -104,16 +104,21 @@ public:
void pauseSound();
void resumeSound();
void stopSound();
+ bool isMutedSound() const { return _muteSound; }
void playVoice(const SoundSample *buffer);
void pauseVoice();
void resumeVoice();
void stopVoice();
+ bool isMutedVoice() const { return _muteVoice; }
void stopAll();
void setVolume();
+ bool showSubtitles() const { return _showSubtitles; }
+ int talkSpeed() const { return _talkSpeed; }
+
private:
void playSoundBuffer(Audio::SoundHandle *handle, const SoundSample &buffer, int volume,
@@ -123,6 +128,11 @@ public:
Audio::Mixer *_mixer;
+ bool _muteSound;
+ bool _muteVoice;
+ bool _showSubtitles;
+ int _talkSpeed;
+
SndHandle _handles[SOUND_HANDLES];
};