[Scummvm-git-logs] scummvm branch-2-9 -> f60e0a42eb8377ddd87fa9d634bacd8b322c5741

sluicebox noreply at scummvm.org
Thu Nov 28 18:11:25 UTC 2024


This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
ba3632dfd9 SCI: Fix SCI1 kDoAudio language inaccuracies
f60e0a42eb AGI: Add detection entry for KQ6 AGI Demake


Commit: ba3632dfd9f7b82633b1e2ed690c05327641d888
    https://github.com/scummvm/scummvm/commit/ba3632dfd9f7b82633b1e2ed690c05327641d888
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2024-11-28T10:10:38-08:00

Commit Message:
SCI: Fix SCI1 kDoAudio language inaccuracies

- Replaces KQ5 FM-Towns workaround with generic initialization.
- Separates SCI1 audio language from unrelated engine components.
  Confirmed in disassembly.
- Improves accuracy of error handling and return values.

Changed paths:
    engines/sci/engine/ksound.cpp
    engines/sci/engine/state.cpp
    engines/sci/resource/resource.h
    engines/sci/resource/resource_audio.cpp


diff --git a/engines/sci/engine/ksound.cpp b/engines/sci/engine/ksound.cpp
index 8b9e7e54d0f..d219d0460b4 100644
--- a/engines/sci/engine/ksound.cpp
+++ b/engines/sci/engine/ksound.cpp
@@ -174,13 +174,15 @@ reg_t kDoAudio(EngineState *s, int argc, reg_t *argv) {
 	if (g_sci->_features->usesCdTrack()) {
 		if (g_sci->getGameId() == GID_MOTHERGOOSE256) {
 			// The CD audio version of Mothergoose256 CD is unique with a
-			// custom interpreter for its audio. English is only in the CD
-			// audio track while the other four languages are only in audio
-			// resource files. This is transparent to the scripts which are
-			// the same in all versions. The interpreter detected when
-			// English was selected and used CD audio in that case.
-			if (g_sci->getSciLanguage() == K_LANG_ENGLISH &&
-				argv[0].toUint16() != kSciAudioLanguage) {
+			// custom interpreter. Instead of using AUDIO001 files for English,
+			// the interpreter is hard-coded to use CD audio when the language
+			// is set to English. Otherwise, it uses the normal kDoAudio code
+			// to use AUDIO### files for the other four languages
+			// This is transparent to the scripts; they are the same as in the
+			// version that uses AUDIO001 for English and not CD Audio.
+			int audioLanguage = g_sci->getResMan()->getAudioLanguage();
+			bool english = (audioLanguage == K_LANG_NONE) || (audioLanguage == K_LANG_ENGLISH);
+			if (english && argv[0].toUint16() != kSciAudioLanguage) {
 				return kDoCdAudio(s, argc, argv);
 			}
 		} else {
@@ -273,42 +275,58 @@ reg_t kDoAudio(EngineState *s, int argc, reg_t *argv) {
 		break;
 	}
 	case kSciAudioLanguage:
-		// In SCI1.1: tests for digital audio support
 		if (getSciVersion() == SCI_VERSION_1_1) {
+			// SCI1.1: tests for digital audio support
 			debugC(kDebugLevelSound, "kDoAudio: audio capability test");
 			return make_reg(0, 1);
 		} else {
-			int16 language = argv[1].toSint16();
-
-			// 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) {
-				// 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();
+			// SCI1: sets audio language, queries current language
+			int newLanguage = argv[1].toSint16();
+			int previousLanguage = g_sci->getResMan()->getAudioLanguage();
+
+			// Handle the CD audio version of Mothergoose256 CD.
+			// See above; when the language is English, kDoCdAudio is used
+			// for all subops except this one.
+			if (g_sci->_features->usesCdTrack()) {
+				// Unload language audio to indicate that the current language is
+				// English, and return success. There are no English audio files.
+				if (newLanguage == K_LANG_ENGLISH) {
+					g_sci->getResMan()->unloadAudioLanguage();
+					debugC(kDebugLevelSound, "kDoAudio: set language to %d", newLanguage);
+					return make_reg(0, newLanguage);
+				}
+				if (previousLanguage == K_LANG_NONE) {
+					previousLanguage = K_LANG_ENGLISH;
+				}
 			}
 
-			debugC(kDebugLevelSound, "kDoAudio: set language to %d", language);
-
-			if (language != -1)
-				g_sci->getResMan()->setAudioLanguage(language);
-
-			kLanguage kLang = g_sci->getSciLanguage();
-			if (g_sci->_features->usesCdTrack() && language == K_LANG_ENGLISH) {
-				// Mothergoose 256 CD has a multi-lingual version with English only on CD audio,
-				// so setAudioLanguage() will fail because there are no English resource files.
-				// The scripts cycle through languages to test which are available for the main
-				// menu, so setting English must succeed. This was handled by a custom interpreter.
-				kLang = K_LANG_ENGLISH;
+			if (newLanguage == -1) {
+				if (previousLanguage == K_LANG_NONE) {
+					// Initialize default language, fall back on English.
+					// The original interpreter had a language global with a hard-coded initial value.
+					// For example, KQ5 PC was set to English, FM-Towns was set Japanese.
+					// We initialize from getSciLanguage() to use our own default, or the launcher language
+					int initialLanguage = g_sci->getSciLanguage();
+					if (!g_sci->getResMan()->setAudioLanguage(initialLanguage) && initialLanguage != K_LANG_ENGLISH) {
+						initialLanguage = K_LANG_ENGLISH;
+						g_sci->getResMan()->setAudioLanguage(initialLanguage);
+					}
+					debugC(kDebugLevelSound, "kDoAudio: initialized language to %d", initialLanguage);
+					return make_reg(0, initialLanguage);
+				} else {
+					debugC(kDebugLevelSound, "kDoAudio: current language: %d", previousLanguage);
+					return make_reg(0, previousLanguage);
+				}
 			}
-			g_sci->setSciLanguage(kLang);
 
-			return make_reg(0, kLang);
+			if (g_sci->getResMan()->setAudioLanguage(newLanguage)) {
+				debugC(kDebugLevelSound, "kDoAudio: set language to %d", newLanguage);
+				return make_reg(0, newLanguage);
+			} else {
+				g_sci->getResMan()->setAudioLanguage(previousLanguage);
+				debugC(kDebugLevelSound, "kDoAudio: error setting language: %d, using: %d", newLanguage, previousLanguage);
+				return make_reg(0, previousLanguage);
+			}
 		}
 		break;
 	case kSciAudioCD:
diff --git a/engines/sci/engine/state.cpp b/engines/sci/engine/state.cpp
index c7f9dbdd68f..6956e758844 100644
--- a/engines/sci/engine/state.cpp
+++ b/engines/sci/engine/state.cpp
@@ -299,11 +299,7 @@ Common::String SciEngine::getSciLanguageString(const Common::String &str, kLangu
 }
 
 kLanguage SciEngine::getSciLanguage() {
-	kLanguage lang = (kLanguage)_resMan->getAudioLanguage();
-	if (lang != K_LANG_NONE)
-		return lang;
-
-	lang = K_LANG_ENGLISH;
+	kLanguage lang = K_LANG_ENGLISH;
 
 	if (SELECTOR(printLang) != -1) {
 		lang = (kLanguage)readSelectorValue(_gamestate->_segMan, _gameObjectAddress, SELECTOR(printLang));
diff --git a/engines/sci/resource/resource.h b/engines/sci/resource/resource.h
index 04aa9e2000d..70b3cf1dc90 100644
--- a/engines/sci/resource/resource.h
+++ b/engines/sci/resource/resource.h
@@ -407,7 +407,8 @@ public:
 	 */
 	bool hasResourceType(ResourceType type);
 
-	void setAudioLanguage(int language);
+	bool setAudioLanguage(int language);
+	void unloadAudioLanguage();
 	int getAudioLanguage() const;
 	void changeAudioDirectory(const Common::Path &path);
 	void changeMacAudioDirectory(const Common::Path &path);
diff --git a/engines/sci/resource/resource_audio.cpp b/engines/sci/resource/resource_audio.cpp
index 8965570fd0d..f53641cb3a2 100644
--- a/engines/sci/resource/resource_audio.cpp
+++ b/engines/sci/resource/resource_audio.cpp
@@ -700,42 +700,22 @@ int ResourceManager::readAudioMapSCI1(ResourceSource *map, bool unload) {
 	return 0;
 }
 
-void ResourceManager::setAudioLanguage(int language) {
+bool ResourceManager::setAudioLanguage(int language) {
 	if (_audioMapSCI1) {
 		if (_audioMapSCI1->_volumeNumber == language) {
 			// This language is already loaded
-			return;
+			return true;
 		}
 
-		// We already have a map loaded, so we unload it first
-		if (readAudioMapSCI1(_audioMapSCI1, true) != SCI_ERROR_NONE) {
-			_hasBadResources = true;
-		}
-
-		// Remove all volumes that use this map from the source list
-		Common::List<ResourceSource *>::iterator it = _sources.begin();
-		while (it != _sources.end()) {
-			ResourceSource *src = *it;
-			if (src->findVolume(_audioMapSCI1, src->_volumeNumber)) {
-				it = _sources.erase(it);
-				delete src;
-			} else {
-				++it;
-			}
-		}
-
-		// Remove the map itself from the source list
-		_sources.remove(_audioMapSCI1);
-		delete _audioMapSCI1;
-
-		_audioMapSCI1 = nullptr;
+		// We already have a map loaded, so we unload it and its sources
+		unloadAudioLanguage();
 	}
 
 	Common::Path filename(Common::String::format("AUDIO%03d", language));
 	Common::Path fullname = filename.append(".MAP");
 	if (!Common::File::exists(fullname)) {
 		warning("No audio map found for language %i", language);
-		return;
+		return false;
 	}
 
 	_audioMapSCI1 = addSource(new ExtAudioMapResourceSource(fullname, language));
@@ -752,6 +732,36 @@ void ResourceManager::setAudioLanguage(int language) {
 	}
 
 	scanNewSources();
+	return true;
+}
+
+void ResourceManager::unloadAudioLanguage() {
+	if (_audioMapSCI1 == nullptr) {
+		return;
+	}
+
+	// Unload the map
+	if (readAudioMapSCI1(_audioMapSCI1, true) != SCI_ERROR_NONE) {
+		_hasBadResources = true;
+	}
+
+	// Remove all volumes that use this map from the source list
+	Common::List<ResourceSource *>::iterator it = _sources.begin();
+	while (it != _sources.end()) {
+		ResourceSource *src = *it;
+		if (src->findVolume(_audioMapSCI1, src->_volumeNumber)) {
+			it = _sources.erase(it);
+			delete src;
+		} else {
+			++it;
+		}
+	}
+
+	// Remove the map itself from the source list
+	_sources.remove(_audioMapSCI1);
+	delete _audioMapSCI1;
+
+	_audioMapSCI1 = nullptr;
 }
 
 int ResourceManager::getAudioLanguage() const {


Commit: f60e0a42eb8377ddd87fa9d634bacd8b322c5741
    https://github.com/scummvm/scummvm/commit/f60e0a42eb8377ddd87fa9d634bacd8b322c5741
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2024-11-28T10:10:50-08:00

Commit Message:
AGI: Add detection entry for KQ6 AGI Demake

Trac #15527

Changed paths:
    engines/agi/detection_tables.h


diff --git a/engines/agi/detection_tables.h b/engines/agi/detection_tables.h
index 2e2a24ee708..520db710649 100644
--- a/engines/agi/detection_tables.h
+++ b/engines/agi/detection_tables.h
@@ -989,6 +989,7 @@ static const AGIGameDescription gameDescriptions[] = {
 	FANMADE_L("Jõulumaa (v0.05)", "53982ecbfb907e41392b3961ad1c3475", Common::ET_EST),
 	FANMADE("Kings Quest 2  - Breast Intentions (v2.0 Mar 26)", "a25d7379d281b1b296d4785df90a8e78"),
 	FANMADE("Kings Quest 2  - Breast Intentions (v2.0 Aug 16)", "6b4f796d0421d2e12e501b511962e03a"),
+	FANMADE("King's Quest VI AGI Demake (2024-08-30)", "f7f498943de42913604da34cb9f5e0d1"),
 	FANMADE("Lasse Holm: The Quest for Revenge (v1.0)", "f9fbcc8a4ef510bfbb92423296ff4abb"),
 	FANMADE("Lawman for Hire", "c78b28bfd3767dd455b992cd8b7854fa"),
 	FANMADE("Lefty Goes on Vacation (Not in The Right Place)", "ccdc49a33870310b01f2c48b8a1f3c34"),




More information about the Scummvm-git-logs mailing list