[Scummvm-git-logs] scummvm master -> 75b36c6fd8ba6b322b9293d9366c9b7282442ec3

bluegr bluegr at gmail.com
Fri Aug 13 21:03:26 UTC 2021


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

Summary:
75b36c6fd8 SCUMM: DiMUSE: Implement actual setVolume and setPan constraints


Commit: 75b36c6fd8ba6b322b9293d9366c9b7282442ec3
    https://github.com/scummvm/scummvm/commit/75b36c6fd8ba6b322b9293d9366c9b7282442ec3
Author: Andrea Boscarino (andywinxp at gmail.com)
Date: 2021-08-14T00:03:23+03:00

Commit Message:
SCUMM: DiMUSE: Implement actual setVolume and setPan constraints

Changed paths:
    engines/scumm/imuse_digi/dimuse.cpp
    engines/scumm/imuse_digi/dimuse_script.cpp
    engines/scumm/imuse_digi/dimuse_track.cpp


diff --git a/engines/scumm/imuse_digi/dimuse.cpp b/engines/scumm/imuse_digi/dimuse.cpp
index a91e53bf51..2d07e1e83d 100644
--- a/engines/scumm/imuse_digi/dimuse.cpp
+++ b/engines/scumm/imuse_digi/dimuse.cpp
@@ -445,11 +445,9 @@ void IMuseDigital::callback() {
 						// Just in case the speakingActor is not being set...
 						// This allows for a fallback to pan = 64 (center) and volume = 127 (full)
 						if (track->speakingActor != nullptr) {
-							effVol = track->speakingActor->_talkVolume;
-							// Even though we fixed this in IMuseDigital::setVolume(),
-							// some sounds might be started without even calling that function
-							if (effVol > 127)
-								effVol /= 2;
+							if (track->speakingActor->_talkVolume >= 0 && track->speakingActor->_talkVolume <= 127)
+								effVol = track->speakingActor->_talkVolume;
+
 							effVol = int(round(effVol * 1.04));
 							effPan = (track->speakingActor->_talkPan != 64) ? 2 * track->speakingActor->_talkPan - 127 : 0;
 						}
diff --git a/engines/scumm/imuse_digi/dimuse_script.cpp b/engines/scumm/imuse_digi/dimuse_script.cpp
index 2625db9b26..d15a62b721 100644
--- a/engines/scumm/imuse_digi/dimuse_script.cpp
+++ b/engines/scumm/imuse_digi/dimuse_script.cpp
@@ -56,10 +56,12 @@ void IMuseDigital::parseScriptCmds(int cmd, int b, int c, int d, int e, int f, i
 			setPriority(soundId, d);
 			break;
 		case 0x600: // set volume
-			setVolume(soundId, d);
+			if (d >= 0 && d <= 127)
+				setVolume(soundId, d);
 			break;
 		case 0x700: // set pan
-			setPan(soundId, d);
+			if (d >= 0 && d <= 127)
+				setPan(soundId, d);
 			break;
 		default:
 			warning("IMuseDigital::doCommand SetParam DEFAULT command %d", sub_cmd);
diff --git a/engines/scumm/imuse_digi/dimuse_track.cpp b/engines/scumm/imuse_digi/dimuse_track.cpp
index 4354988cc8..e074819ad2 100644
--- a/engines/scumm/imuse_digi/dimuse_track.cpp
+++ b/engines/scumm/imuse_digi/dimuse_track.cpp
@@ -178,8 +178,17 @@ int IMuseDigital::startSound(int soundId, const char *soundName, int soundType,
 			if (_vm->_actorToPrintStrFor != 0xFF && _vm->_actorToPrintStrFor != 0) {
 				Actor *a = _vm->derefActor(_vm->_actorToPrintStrFor, "IMuseDigital::startSound");
 				freq = (freq * a->_talkFrequency) / 256;
-				track->pan = a->_talkPan;
-				track->vol = a->_talkVolume * 1000;
+
+				if (a->_talkPan >= 0 && a->_talkPan <= 127)
+					track->pan = a->_talkPan;
+				else
+					track->pan = 64;
+
+				if (a->_talkVolume >= 0 && a->_talkVolume <= 127)
+					track->vol = a->_talkVolume * 1000;
+				else
+					track->vol = 127 * 1000;
+
 				// Keep track of the current actor in COMI:
 				// This is necessary since pan and volume settings for actors
 				// are often changed AFTER the speech sound is started,
@@ -261,9 +270,6 @@ void IMuseDigital::setVolume(int soundId, int volume) {
 	Common::StackLock lock(_mutex, "IMuseDigital::setVolume()");
 	debug(5, "IMuseDigital::setVolume(%d, %d)", soundId, volume);
 
-	if (_vm->_game.id == GID_CMI && volume > 127)
-		volume = volume / 2;
-
 	for (int l = 0; l < MAX_DIGITAL_TRACKS; l++) {
 		Track *track = _track[l];
 		if (track->used && !track->toBeRemoved && (track->soundId == soundId)) {
@@ -303,15 +309,6 @@ void IMuseDigital::setPan(int soundId, int pan) {
 	Common::StackLock lock(_mutex, "IMuseDigital::setPan()");
 	debug(5, "IMuseDigital::setPan(%d, %d)", soundId, pan);
 
-	// Sometimes, COMI scumm scripts try to set pan values in the range 0-255
-	// instead of 0-128. I sincerely have no idea why and what exactly is the
-	// correct way of handling these cases (does it happen on a sound by sound basis?).
-	// Until someone properly reverse engineers the engine, this fix works fine for
-	// those sounds (e.g. the cannon fire SFX in Part 1 minigame, the bell sound
-	// in Plunder Town).
-	if (_vm->_game.id == GID_CMI && pan > 127)
-		pan = pan / 2;
-
 	for (int l = 0; l < MAX_DIGITAL_TRACKS; l++) {
 		Track *track = _track[l];
 		if (track->used && !track->toBeRemoved && (track->soundId == soundId)) {




More information about the Scummvm-git-logs mailing list