aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Schickel2009-06-21 19:00:50 +0000
committerJohannes Schickel2009-06-21 19:00:50 +0000
commit76eee406d63b7f614bd3f6e8e5e3f70aff97c921 (patch)
tree62e0d722da395b1bfb048f454f830286da4fb369
parent5b0b0051c15ff23ed8daf801d4b56cbaadf2f101 (diff)
downloadscummvm-rg350-76eee406d63b7f614bd3f6e8e5e3f70aff97c921.tar.gz
scummvm-rg350-76eee406d63b7f614bd3f6e8e5e3f70aff97c921.tar.bz2
scummvm-rg350-76eee406d63b7f614bd3f6e8e5e3f70aff97c921.zip
Cleanup: Change LoL code to use KYRA volume handling.
svn-id: r41730
-rw-r--r--engines/kyra/gui_lol.cpp33
-rw-r--r--engines/kyra/kyra_v1.cpp4
-rw-r--r--engines/kyra/kyra_v1.h5
-rw-r--r--engines/kyra/lol.cpp12
-rw-r--r--engines/kyra/lol.h7
-rw-r--r--engines/kyra/script_lol.cpp2
-rw-r--r--engines/kyra/script_tim.cpp2
-rw-r--r--engines/kyra/sequences_lol.cpp18
-rw-r--r--engines/kyra/sound_lol.cpp11
-rw-r--r--engines/kyra/text_lol.cpp4
10 files changed, 51 insertions, 47 deletions
diff --git a/engines/kyra/gui_lol.cpp b/engines/kyra/gui_lol.cpp
index 93ee589891..dcd9727824 100644
--- a/engines/kyra/gui_lol.cpp
+++ b/engines/kyra/gui_lol.cpp
@@ -1564,6 +1564,7 @@ int LoLEngine::clickedOptions(Button *button) {
gui_toggleButtonDisplayMode(76, 0);
+ bool speechWasEnabled = speechEnabled();
_gui->runMenu(_gui->_mainMenu);
_updateFlags &= 0xfffb;
@@ -1575,8 +1576,8 @@ int LoLEngine::clickedOptions(Button *button) {
gui_drawPlayField();
- if (!_speechVolume)
- _configVoice |= 1;
+ if (speechWasEnabled && !textEnabled() && (!speechEnabled() || getVolume(kVolumeSpeech) == 2))
+ _configVoice = 0;
writeSettings();
@@ -2352,10 +2353,10 @@ int GUI_LoL::runMenu(Menu &menu) {
printMenuText(getMenuItemLabel(_currentMenu->item[i]), _currentMenu->x + _currentMenu->item[i].labelX, _currentMenu->y + _currentMenu->item[i].labelY, _currentMenu->item[i].textColor, 0, 10);
- int status = (i == 1) ? _vm->_musicVolume : ((i == 2) ? _vm->_sfxVolume : _vm->_speechVolume);
+ int volume = _vm->getVolume((KyraEngine_v1::kVolumeEntry)(i - 1));
_screen->drawShape(_screen->_curPage, _vm->_gameShapes[85], tX , tY, 0, 0x10);
_screen->drawShape(_screen->_curPage, _vm->_gameShapes[87], tX + 2 + oX[1], tY, 0, 0x10);
- _screen->drawShape(_screen->_curPage, _vm->_gameShapes[86], tX + 2 + oX[1] + status, tY, 0, 0x10);
+ _screen->drawShape(_screen->_curPage, _vm->_gameShapes[86], tX + oX[1] + volume, tY, 0, 0x10);
}
_screen->updateScreen();
@@ -2669,30 +2670,33 @@ int GUI_LoL::clickedAudioMenu(Button *button) {
}
int tX = button->x;
- int *status = (button->arg == 3) ? &_vm->_musicVolume : ((button->arg == 4) ? &_vm->_sfxVolume : &_vm->_speechVolume);
- int statusOld = *status;
+ int oldVolume = _vm->getVolume((KyraEngine_v1::kVolumeEntry)(button->arg - 3));
+ int newVolume = oldVolume;
if (button->index == 0) {
- *status -= 10;
+ newVolume -= 10;
tX += 10;
} else if (button->index == 1) {
- *status = _vm->_mouseX - (tX + 7);
+ newVolume = _vm->_mouseX - (tX + 7);
} else if (button->index == 2) {
- *status += 10;
+ newVolume += 10;
tX -= 114;
}
- *status = CLIP(*status, 0, 100);
+ newVolume = CLIP(newVolume, 2, 102);
- _screen->drawShape(0, _vm->_gameShapes[87], tX + 2 + statusOld, button->y, 0, 0x10);
- _screen->drawShape(0, _vm->_gameShapes[86], tX + 2 + *status, button->y, 0, 0x10);
+ if (newVolume == oldVolume)
+ return 0;
+
+ _screen->drawShape(0, _vm->_gameShapes[87], tX + oldVolume, button->y, 0, 0x10);
+ _screen->drawShape(0, _vm->_gameShapes[86], tX + newVolume, button->y, 0, 0x10);
_screen->updateScreen();
_vm->snd_stopSpeech(0);
- _vm->setVolume((KyraEngine_v1::kVolumeEntry)(button->arg - 3), *status);
+ _vm->setVolume((KyraEngine_v1::kVolumeEntry)(button->arg - 3), newVolume);
- if (*status) {
+ if (newVolume) {
if (button->arg == 4) {
_vm->snd_playSoundEffect(_sliderSfx, -1);
int16 vocIndex = (int16)READ_LE_UINT16(&_vm->_ingameSoundIndex[_sliderSfx * 2]);
@@ -2709,7 +2713,6 @@ int GUI_LoL::clickedAudioMenu(Button *button) {
continue;
break;
} while (1);
-
} else if (button->arg == 5) {
_vm->_lastSpeechId = -1;
_vm->snd_playCharacterSpeech(0x42e0, 0, 0);
diff --git a/engines/kyra/kyra_v1.cpp b/engines/kyra/kyra_v1.cpp
index fa53fde696..74b033822f 100644
--- a/engines/kyra/kyra_v1.cpp
+++ b/engines/kyra/kyra_v1.cpp
@@ -594,12 +594,12 @@ bool KyraEngine_v1::textEnabled() {
return !_flags.isTalkie || (_configVoice == 0 || _configVoice == 2);
}
-inline int convertValueToMixer(int value) {
+int KyraEngine_v1::convertValueToMixer(int value) {
value -= 2;
return (value * Audio::Mixer::kMaxMixerVolume) / 95;
}
-inline int convertValueFromMixer(int value) {
+int KyraEngine_v1::convertValueFromMixer(int value) {
return (value * 95) / Audio::Mixer::kMaxMixerVolume + 2;
}
diff --git a/engines/kyra/kyra_v1.h b/engines/kyra/kyra_v1.h
index b45f21dd89..f69d12a81a 100644
--- a/engines/kyra/kyra_v1.h
+++ b/engines/kyra/kyra_v1.h
@@ -153,7 +153,7 @@ public:
kVolumeSpeech = 2
};
- // volume reaches from 2 to 97
+ // volume reaches per default from 2 to 97
void setVolume(kVolumeEntry vol, uint8 value);
uint8 getVolume(kVolumeEntry vol);
@@ -289,6 +289,9 @@ protected:
const int8 *_trackMap;
int _trackMapSize;
+ virtual int convertValueToMixer(int value);
+ virtual int convertValueFromMixer(int value);
+
// pathfinder
virtual int findWay(int x, int y, int toX, int toY, int *moveTable, int moveTableSize);
int findSubPath(int x, int y, int toX, int toY, int *moveTable, int start, int end);
diff --git a/engines/kyra/lol.cpp b/engines/kyra/lol.cpp
index fb4f989195..d87d6eaa1b 100644
--- a/engines/kyra/lol.cpp
+++ b/engines/kyra/lol.cpp
@@ -918,10 +918,6 @@ void LoLEngine::writeSettings() {
ConfMan.set("language", Common::getLanguageCode(_flags.lang));
KyraEngine_v1::writeSettings();
-
- setVolume(kVolumeMusic, _musicVolume);
- setVolume(kVolumeSfx, _sfxVolume);
- setVolume(kVolumeSpeech, _speechVolume);
}
void LoLEngine::readSettings() {
@@ -930,12 +926,6 @@ void LoLEngine::readSettings() {
_floatingCursorsEnabled = ConfMan.getBool("floating cursors");
KyraEngine_v1::readSettings();
-
- _musicVolume = getVolume(kVolumeMusic);
- _sfxVolume = getVolume(kVolumeSfx);
- _speechVolume = getVolume(kVolumeSpeech);
- if (_speechVolume == 2)
- _speechVolume = 0;
}
void LoLEngine::update() {
@@ -1149,7 +1139,7 @@ void LoLEngine::updatePortraitSpeechAnim() {
f -= 5;
f += 7;
- if (_speechVolume) {
+ if (speechEnabled()) {
if (snd_updateCharacterSpeech() == 2)
_updatePortraitSpeechAnimDuration = 2;
else
diff --git a/engines/kyra/lol.h b/engines/kyra/lol.h
index 7e7fbf0344..0a32ec8793 100644
--- a/engines/kyra/lol.h
+++ b/engines/kyra/lol.h
@@ -446,6 +446,9 @@ private:
int _timer3Para;
// sound
+ int convertValueToMixer(int value);
+ int convertValueFromMixer(int value);
+
void loadTalkFile(int index);
void snd_playVoiceFile(int track) {}
bool snd_playCharacterSpeech(int id, int8 speaker, int);
@@ -479,10 +482,6 @@ private:
int _curTlkFile;
- int _musicVolume;
- int _sfxVolume;
- int _speechVolume;
-
char **_ingameSoundList;
int _ingameSoundListSize;
diff --git a/engines/kyra/script_lol.cpp b/engines/kyra/script_lol.cpp
index c43b5b869c..017f60a3d4 100644
--- a/engines/kyra/script_lol.cpp
+++ b/engines/kyra/script_lol.cpp
@@ -663,7 +663,7 @@ int LoLEngine::olol_getGlobalVar(EMCState *script) {
case 12:
return _drainMagic;
case 13:
- return _speechVolume;
+ return getVolume(kVolumeSpeech);
default:
break;
}
diff --git a/engines/kyra/script_tim.cpp b/engines/kyra/script_tim.cpp
index 9ffe61c043..fc80e39197 100644
--- a/engines/kyra/script_tim.cpp
+++ b/engines/kyra/script_tim.cpp
@@ -1004,7 +1004,7 @@ void TIMInterpreter_LoL::advanceToOpcode(int opcode) {
void TIMInterpreter_LoL::drawDialogueBox(int numStr, const char *s1, const char *s2, const char *s3) {
_screen->setScreenDim(5);
- if (numStr == 1 && _vm->_speechVolume) {
+ if (numStr == 1 && _vm->speechEnabled()) {
_dialogueNumButtons = 0;
_dialogueButtonString[0] = _dialogueButtonString[1] = _dialogueButtonString[2] = 0;
} else {
diff --git a/engines/kyra/sequences_lol.cpp b/engines/kyra/sequences_lol.cpp
index f2e69aadd9..b1bde04773 100644
--- a/engines/kyra/sequences_lol.cpp
+++ b/engines/kyra/sequences_lol.cpp
@@ -371,7 +371,7 @@ void LoLEngine::kingSelectionIntro() {
_sound->voicePlay("KING01", &_speechHandle);
int index = 4;
- while ((!_speechVolume || (_speechVolume && _sound->voiceIsPlaying(&_speechHandle))) && _charSelection == -1 && !shouldQuit() && !skipFlag()) {
+ while ((!speechEnabled() || (speechEnabled() && _sound->voiceIsPlaying(&_speechHandle))) && _charSelection == -1 && !shouldQuit() && !skipFlag()) {
index = MAX(index, 4);
_chargenWSA->displayFrame(_chargenFrameTable[index], 0, 113, 0, 0, 0, 0);
@@ -387,7 +387,7 @@ void LoLEngine::kingSelectionIntro() {
_system->delayMillis(10);
}
- if (_speechVolume)
+ if (speechEnabled())
index = (index + 1) % 22;
else if (++index >= 27)
break;
@@ -410,7 +410,7 @@ void LoLEngine::kingSelectionReminder() {
_sound->voicePlay("KING02", &_speechHandle);
int index = 0;
- while ((!_speechVolume || (_speechVolume && _sound->voiceIsPlaying(&_speechHandle))) && _charSelection == -1 && !shouldQuit() && index < 15) {
+ while ((!speechEnabled() || (speechEnabled() && _sound->voiceIsPlaying(&_speechHandle))) && _charSelection == -1 && !shouldQuit() && index < 15) {
_chargenWSA->displayFrame(_chargenFrameTable[index+9], 0, 113, 0, 0, 0, 0);
_screen->copyRegion(_selectionPosTable[_reminderChar1IdxTable[index]*2+0], _selectionPosTable[_reminderChar1IdxTable[index]*2+1], _charPreviews[0].x, _charPreviews[0].y, 32, 32, 4, 0);
_screen->copyRegion(_selectionPosTable[_reminderChar2IdxTable[index]*2+0], _selectionPosTable[_reminderChar2IdxTable[index]*2+1], _charPreviews[1].x, _charPreviews[1].y, 32, 32, 4, 0);
@@ -424,7 +424,7 @@ void LoLEngine::kingSelectionReminder() {
_system->delayMillis(10);
}
- if (_speechVolume)
+ if (speechEnabled())
index = (index + 1) % 22;
else if (++index >= 27)
break;
@@ -437,7 +437,7 @@ void LoLEngine::kingSelectionOutro() {
_sound->voicePlay("KING03", &_speechHandle);
int index = 0;
- while ((!_speechVolume || (_speechVolume && _sound->voiceIsPlaying(&_speechHandle))) && !shouldQuit() && !skipFlag()) {
+ while ((!speechEnabled() || (speechEnabled() && _sound->voiceIsPlaying(&_speechHandle))) && !shouldQuit() && !skipFlag()) {
index = MAX(index, 4);
_chargenWSA->displayFrame(_chargenFrameTable[index], 0, 113, 0, 0, 0, 0);
@@ -449,7 +449,7 @@ void LoLEngine::kingSelectionOutro() {
_system->delayMillis(10);
}
- if (_speechVolume)
+ if (speechEnabled())
index = (index + 1) % 22;
else if (++index >= 27)
break;
@@ -584,13 +584,13 @@ void LoLEngine::selectionCharInfoIntro(char *file) {
bool processAnim = true;
while (_charSelectionInfoResult == -1 && !shouldQuit()) {
- if (_speechVolume && !_sound->isVoicePresent(file))
+ if (speechEnabled() && !_sound->isVoicePresent(file))
break;
_sound->voicePlay(file, &_speechHandle);
int i = 0;
- while ((!_speechVolume || (_speechVolume && _sound->voiceIsPlaying(&_speechHandle))) && _charSelectionInfoResult == -1 && !shouldQuit()) {
+ while ((!speechEnabled() || (speechEnabled() && _sound->voiceIsPlaying(&_speechHandle))) && _charSelectionInfoResult == -1 && !shouldQuit()) {
_screen->drawShape(0, _screen->getPtrToShape(_screen->getCPagePtr(9), _charInfoFrameTable[i]), 11, 130, 0, 0);
_screen->updateScreen();
@@ -600,7 +600,7 @@ void LoLEngine::selectionCharInfoIntro(char *file) {
_system->delayMillis(10);
}
- if (_speechVolume || processAnim)
+ if (speechEnabled() || processAnim)
i = (i + 1) % 32;
if (i == 0)
processAnim = false;
diff --git a/engines/kyra/sound_lol.cpp b/engines/kyra/sound_lol.cpp
index f9bd7da206..c233e1af52 100644
--- a/engines/kyra/sound_lol.cpp
+++ b/engines/kyra/sound_lol.cpp
@@ -34,7 +34,7 @@
namespace Kyra {
bool LoLEngine::snd_playCharacterSpeech(int id, int8 speaker, int) {
- if (!_speechVolume)
+ if (!speechEnabled())
return false;
if (speaker < 65) {
@@ -304,6 +304,15 @@ int LoLEngine::snd_stopMusic() {
return snd_playTrack(-1);
}
+int LoLEngine::convertValueToMixer(int value) {
+ value -= 2;
+ return (value * Audio::Mixer::kMaxMixerVolume) / 100;
+}
+
+int LoLEngine::convertValueFromMixer(int value) {
+ return (value * 100) / Audio::Mixer::kMaxMixerVolume + 2;
+}
+
} // end of namespace Kyra
#endif // ENABLE_LOL
diff --git a/engines/kyra/text_lol.cpp b/engines/kyra/text_lol.cpp
index db32cdc12a..98aaef7f96 100644
--- a/engines/kyra/text_lol.cpp
+++ b/engines/kyra/text_lol.cpp
@@ -608,7 +608,7 @@ void TextDisplayer_LoL::textPageBreak() {
}
uint32 speechPartTime = 0;
- if (_vm->_speechVolume && _vm->_activeVoiceFileTotalTime && _numCharsTotal)
+ if (_vm->speechEnabled() && _vm->_activeVoiceFileTotalTime && _numCharsTotal)
speechPartTime = _vm->_system->getMillis() + ((_numCharsPrinted * _vm->_activeVoiceFileTotalTime) / _numCharsTotal);
const ScreenDim *dim = _screen->getScreenDim(_screen->curDimIndex());
@@ -643,7 +643,7 @@ void TextDisplayer_LoL::textPageBreak() {
while (!inputFlag) {
_vm->update();
- if (_vm->_speechVolume) {
+ if (_vm->speechEnabled()) {
if (((_vm->_system->getMillis() > speechPartTime) || (_vm->snd_updateCharacterSpeech() != 2)) && speechPartTime) {
loop = false;
inputFlag = 43;