From bc0b82acd52b71fd0a8c61a597447c7072a5fe6b Mon Sep 17 00:00:00 2001 From: Martin Kiewitz Date: Wed, 24 Feb 2016 00:51:50 +0100 Subject: [PATCH] SCI: Fix FM-Towns audio language selection This first of all combines both detection entries and makes it possible so that the user can directly choose English or Japanese without having to add the game twice. But it also fixes the in-game option to switch between English and Japanese. Prior to this commit it was only possible to for example switch from Japanese to English once, but it was not possible to switch back without quitting the game and starting it again. --- engines/sci/detection_tables.h | 15 ++------------- engines/sci/engine/ksound.cpp | 11 +++++++++-- engines/sci/sci.cpp | 28 +++++++++++++++++++++++----- 3 files changed, 34 insertions(+), 20 deletions(-) diff --git a/engines/sci/detection_tables.h b/engines/sci/detection_tables.h index af4937f724b7..2fd433240bb5 100644 --- a/engines/sci/detection_tables.h +++ b/engines/sci/detection_tables.h @@ -1531,13 +1531,7 @@ static const struct ADGameDescription SciGameDescriptions[] = { {"resource.000", 0, "71afd220d46bde1109c58e6acc0f3a01", 469094}, {"resource.001", 0, "72a569f46f1abf2d9d2b1526ad3799c3", 12808839}, AD_LISTEND}, - Common::EN_ANY, Common::kPlatformFMTowns, 0, GUIO2(GUIO_NOASPECT, GUIO_MIDITOWNS) }, - {"kq5", "", { - {"resource.map", 0, "20c7cd248ff1a349ed354568eebd972b", 12733}, - {"resource.000", 0, "71afd220d46bde1109c58e6acc0f3a01", 469094}, - {"resource.001", 0, "72a569f46f1abf2d9d2b1526ad3799c3", 12808839}, - AD_LISTEND}, - Common::JA_JPN, Common::kPlatformFMTowns, 0, GUIO2(GUIO_NOASPECT, GUIO_MIDITOWNS) }, + Common::JA_JPN, Common::kPlatformFMTowns, ADGF_ADDENGLISH, GUIO3(GUIO_NOASPECT, GAMEOPTION_ORIGINAL_SAVELOAD, GUIO_MIDITOWNS) }, // King's Quest 5 - Japanese PC-98 Floppy 0.000.015 (supplied by omer_mor in bug report #3073583) {"kq5", "", { @@ -2601,12 +2595,7 @@ static const struct ADGameDescription SciGameDescriptions[] = { {"resource.map", 0, "b11e971ccd2040bebba59dfb409a08ef", 5772}, {"resource.001", 0, "d49625d9b8005ec01c852f8322a82867", 4330713}, AD_LISTEND}, - Common::EN_ANY, Common::kPlatformFMTowns, 0, GUIO4(GUIO_NOASPECT, GAMEOPTION_PREFER_DIGITAL_SFX, GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_FB01_MIDI) }, - {"mothergoose256", "", { - {"resource.map", 0, "b11e971ccd2040bebba59dfb409a08ef", 5772}, - {"resource.001", 0, "d49625d9b8005ec01c852f8322a82867", 4330713}, - AD_LISTEND}, - Common::JA_JPN, Common::kPlatformFMTowns, 0, GUIO4(GUIO_NOASPECT, GAMEOPTION_PREFER_DIGITAL_SFX, GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_FB01_MIDI) }, + Common::JA_JPN, Common::kPlatformFMTowns, ADGF_ADDENGLISH, GUIO4(GUIO_NOASPECT, GAMEOPTION_PREFER_DIGITAL_SFX, GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_FB01_MIDI) }, #ifdef ENABLE_SCI32 // Mixed-Up Mother Goose Deluxe - English Windows/DOS CD (supplied by markcoolio in bug report #2723810) diff --git a/engines/sci/engine/ksound.cpp b/engines/sci/engine/ksound.cpp index 032191e4c1a1..efc35c3d5259 100644 --- a/engines/sci/engine/ksound.cpp +++ b/engines/sci/engine/ksound.cpp @@ -206,8 +206,15 @@ reg_t kDoAudio(EngineState *s, int argc, reg_t *argv) { // athrxx: It seems from disasm that the original KQ5 FM-Towns loads a default language (Japanese) audio map at the beginning // right after loading the video and audio drivers. The -1 language argument in here simply means that the original will stick // with Japanese. Instead of doing that we switch to the language selected in the launcher. - if (g_sci->getPlatform() == Common::kPlatformFMTowns && language == -1) - language = (g_sci->getLanguage() == Common::JA_JPN) ? K_LANG_JAPANESE : K_LANG_ENGLISH; + if (g_sci->getPlatform() == Common::kPlatformFMTowns && language == -1) { + // FM-Towns calls us to get the current language / also set the default language + // This doesn't just happen right at the start, but also when the user clicks on the Sierra logo in the game menu + // It uses the result of this call to either show "English Voices" or "Japanese Voices". + + // Language should have been set by setLauncherLanguage() already (or could have been modified by the scripts). + // Get this language setting, so that the chosen language will get set for resource manager. + language = g_sci->getSciLanguage(); + } debugC(kDebugLevelSound, "kDoAudio: set language to %d", language); diff --git a/engines/sci/sci.cpp b/engines/sci/sci.cpp index 1232b6559bd0..afade24a592e 100644 --- a/engines/sci/sci.cpp +++ b/engines/sci/sci.cpp @@ -897,12 +897,30 @@ int SciEngine::inQfGImportRoom() const { void SciEngine::setLauncherLanguage() { if (_gameDescription->flags & ADGF_ADDENGLISH) { // If game is multilingual - if (Common::parseLanguage(ConfMan.get("language")) == Common::EN_ANY) { + Common::Language chosenLanguage = Common::parseLanguage(ConfMan.get("language")); + uint16 languageToSet = 0; + + switch (chosenLanguage) { + case Common::EN_ANY: // and English was selected as language - if (SELECTOR(printLang) != -1) // set text language to English - writeSelectorValue(_gamestate->_segMan, _gameObjectAddress, SELECTOR(printLang), K_LANG_ENGLISH); - if (SELECTOR(parseLang) != -1) // and set parser language to English as well - writeSelectorValue(_gamestate->_segMan, _gameObjectAddress, SELECTOR(parseLang), K_LANG_ENGLISH); + languageToSet = K_LANG_ENGLISH; + break; + case Common::JA_JPN: { + // Set Japanese for FM-Towns games + // KQ5 on FM-Towns has no initial language set + if (g_sci->getPlatform() == Common::kPlatformFMTowns) { + languageToSet = K_LANG_JAPANESE; + } + } + default: + break; + } + + if (languageToSet) { + if (SELECTOR(printLang) != -1) // set text language + writeSelectorValue(_gamestate->_segMan, _gameObjectAddress, SELECTOR(printLang), languageToSet); + if (SELECTOR(parseLang) != -1) // and set parser language as well + writeSelectorValue(_gamestate->_segMan, _gameObjectAddress, SELECTOR(parseLang), languageToSet); } } }