[Scummvm-git-logs] scummvm master -> 5f9111f9ede499150522fd8c76c212a47f593295
sluicebox
22204938+sluicebox at users.noreply.github.com
Fri Jul 10 21:31:56 UTC 2020
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:
5f9111f9ed SCI: Fix LSL6 low-resolution volume synchronization
Commit: 5f9111f9ede499150522fd8c76c212a47f593295
https://github.com/scummvm/scummvm/commit/5f9111f9ede499150522fd8c76c212a47f593295
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2020-07-10T14:29:32-07:00
Commit Message:
SCI: Fix LSL6 low-resolution volume synchronization
Applies the LSL6 volume sync to the SCI16 (lo-res) versions as well as
the SCI32 (hi-res) versions.
Changed paths:
engines/sci/engine/features.cpp
engines/sci/engine/features.h
engines/sci/engine/guest_additions.cpp
engines/sci/engine/guest_additions.h
engines/sci/engine/selector.cpp
engines/sci/engine/selector.h
engines/sci/engine/vm.h
diff --git a/engines/sci/engine/features.cpp b/engines/sci/engine/features.cpp
index fad621525d..9d7e3f8994 100644
--- a/engines/sci/engine/features.cpp
+++ b/engines/sci/engine/features.cpp
@@ -575,6 +575,7 @@ bool GameFeatures::audioVolumeSyncUsesGlobals() const {
case GID_GK1:
case GID_GK2:
case GID_HOYLE5:
+ case GID_LSL6:
case GID_LSL6HIRES:
case GID_LSL7:
case GID_PHANTASMAGORIA:
diff --git a/engines/sci/engine/features.h b/engines/sci/engine/features.h
index ea478a303e..578cfb42d5 100644
--- a/engines/sci/engine/features.h
+++ b/engines/sci/engine/features.h
@@ -187,16 +187,12 @@ public:
*/
bool supportsTextSpeed() const {
switch (g_sci->getGameId()) {
-#ifdef ENABLE_SCI32
case GID_GK1:
case GID_SQ6:
return true;
-#endif
default:
- break;
+ return false;
}
-
- return false;
}
/**
diff --git a/engines/sci/engine/guest_additions.cpp b/engines/sci/engine/guest_additions.cpp
index 34d22b7d97..266113a5a5 100644
--- a/engines/sci/engine/guest_additions.cpp
+++ b/engines/sci/engine/guest_additions.cpp
@@ -64,11 +64,9 @@ GuestAdditions::GuestAdditions(EngineState *state, GameFeatures *features, Kerne
#pragma mark -
void GuestAdditions::syncSoundSettingsFromScummVM() const {
-#ifdef ENABLE_SCI32
if (_features->audioVolumeSyncUsesGlobals())
syncAudioVolumeGlobalsFromScummVM();
else
-#endif
syncMasterVolumeFromScummVM();
}
@@ -107,7 +105,8 @@ bool GuestAdditions::shouldSyncAudioToScummVM() const {
return true;
} else if (gameId == GID_SLATER && objName == "volButton") {
return true;
- } else if (gameId == GID_LSL6 && objName == "menuBar") {
+ } else if (gameId == GID_LSL6 && (objName == "menuBar" ||
+ objName == "volumeDial")) {
return true;
#ifdef ENABLE_SCI32
} else if ((gameId == GID_GK1 || gameId == GID_SQ6) && (objName == "musicBar" ||
@@ -161,33 +160,32 @@ void GuestAdditions::sciEngineRunGameHook() {
void GuestAdditions::writeVarHook(const int type, const int index, const reg_t value) {
if (type == VAR_GLOBAL) {
+ if (_features->audioVolumeSyncUsesGlobals() && shouldSyncAudioToScummVM()) {
+ syncAudioVolumeGlobalsToScummVM(index, value);
#ifdef ENABLE_SCI32
- if (getSciVersion() >= SCI_VERSION_2) {
- if (_features->audioVolumeSyncUsesGlobals() && shouldSyncAudioToScummVM()) {
- syncAudioVolumeGlobalsToScummVM(index, value);
- } else if (g_sci->getGameId() == GID_GK1) {
- syncGK1StartupVolumeFromScummVM(index, value);
- } else if (g_sci->getGameId() == GID_HOYLE5 && index == kGlobalVarHoyle5MusicVolume) {
- syncHoyle5VolumeFromScummVM((ConfMan.getInt("music_volume") + 1) * kHoyle5VolumeMax / Audio::Mixer::kMaxMixerVolume);
- } else if (g_sci->getGameId() == GID_HOYLE5 && index == kGlobalVarHoyle5ResponseTime && value.getOffset() == 0) {
- // WORKAROUND: Global 899 contains the response time value,
- // which may have values between 1 and 15. There is a script
- // bug when loading values from game.opt, where this variable
- // may be incorrectly set to 0. This makes the opponent freeze
- // while playing Backgammon and Bridge. Fix this case here, by
- // setting the correct minimum value, 1.
- // TODO: Either make this a script patch, or find out if it's
- // a bug with ScummVM when reading values from text files.
- _state->variables[VAR_GLOBAL][index].setOffset(1);
- } else if (g_sci->getGameId() == GID_RAMA && !g_sci->isDemo() && index == kGlobalVarRamaMusicVolume) {
- syncRamaVolumeFromScummVM((ConfMan.getInt("music_volume") + 1) * kRamaVolumeMax / Audio::Mixer::kMaxMixerVolume);
- }
-
- if (_features->supportsTextSpeed()) {
- syncTextSpeedToScummVM(index, value);
- }
+ } else if (g_sci->getGameId() == GID_GK1) {
+ syncGK1StartupVolumeFromScummVM(index, value);
+ } else if (g_sci->getGameId() == GID_HOYLE5 && index == kGlobalVarHoyle5MusicVolume) {
+ syncHoyle5VolumeFromScummVM((ConfMan.getInt("music_volume") + 1) * kHoyle5VolumeMax / Audio::Mixer::kMaxMixerVolume);
+ } else if (g_sci->getGameId() == GID_HOYLE5 && index == kGlobalVarHoyle5ResponseTime && value.getOffset() == 0) {
+ // WORKAROUND: Global 899 contains the response time value,
+ // which may have values between 1 and 15. There is a script
+ // bug when loading values from game.opt, where this variable
+ // may be incorrectly set to 0. This makes the opponent freeze
+ // while playing Backgammon and Bridge. Fix this case here, by
+ // setting the correct minimum value, 1.
+ // TODO: Either make this a script patch, or find out if it's
+ // a bug with ScummVM when reading values from text files.
+ _state->variables[VAR_GLOBAL][index].setOffset(1);
+ } else if (g_sci->getGameId() == GID_RAMA && !g_sci->isDemo() && index == kGlobalVarRamaMusicVolume) {
+ syncRamaVolumeFromScummVM((ConfMan.getInt("music_volume") + 1) * kRamaVolumeMax / Audio::Mixer::kMaxMixerVolume);
}
+
+ if (_features->supportsTextSpeed()) {
+ syncTextSpeedToScummVM(index, value);
#endif
+ }
+
syncMessageTypeToScummVM(index, value);
}
}
@@ -1074,7 +1072,6 @@ void GuestAdditions::syncMasterVolumeToScummVM(const int16 masterVolume) const {
g_sci->updateSoundMixerVolumes();
}
-#ifdef ENABLE_SCI32
#pragma mark -
#pragma mark Globals volume sync
@@ -1085,6 +1082,7 @@ void GuestAdditions::syncAudioVolumeGlobalsFromScummVM() const {
// audio for music do not need any extra code since that always runs
// straight through the audio mixer, which gets muted directly
switch (g_sci->getGameId()) {
+#ifdef ENABLE_SCI32
case GID_GK1: {
const int16 musicVolume = (ConfMan.getInt("music_volume") + 1) * MUSIC_VOLUME_MAX / Audio::Mixer::kMaxMixerVolume;
const int16 dacVolume = (ConfMan.getInt("sfx_volume") + 1) * Audio32::kMaxVolume / Audio::Mixer::kMaxMixerVolume;
@@ -1107,13 +1105,6 @@ void GuestAdditions::syncAudioVolumeGlobalsFromScummVM() const {
break;
}
- case GID_LSL6HIRES: {
- const int16 musicVolume = (ConfMan.getInt("music_volume") + 1) * kLSL6HiresUIVolumeMax / Audio::Mixer::kMaxMixerVolume;
- syncLSL6HiresVolumeFromScummVM(musicVolume);
- syncLSL6HiresUI(musicVolume);
- break;
- }
-
case GID_PHANTASMAGORIA: {
reg_t &musicGlobal = _state->variables[VAR_GLOBAL][kGlobalVarPhant1MusicVolume];
reg_t &dacGlobal = _state->variables[VAR_GLOBAL][kGlobalVarPhant1DACVolume];
@@ -1155,12 +1146,27 @@ void GuestAdditions::syncAudioVolumeGlobalsFromScummVM() const {
syncTorinUI(musicVolume, sfxVolume, speechVolume);
break;
}
+#endif
+
+ case GID_LSL6:
+ case GID_LSL6HIRES: {
+ const int16 musicVolume = (ConfMan.getInt("music_volume") + 1) * kLSL6UIVolumeMax / Audio::Mixer::kMaxMixerVolume;
+ syncLSL6VolumeFromScummVM(musicVolume);
+ syncLSL6UI(musicVolume);
+ break;
+ }
default:
error("Trying to sync audio volume globals in a game with no implementation");
}
}
+void GuestAdditions::syncLSL6VolumeFromScummVM(const int16 musicVolume) const {
+ _state->variables[VAR_GLOBAL][kGlobalVarLSL6MusicVolume] = make_reg(0, musicVolume);
+ g_sci->_soundCmd->setMasterVolume(ConfMan.getBool("mute") ? 0 : (musicVolume * MUSIC_MASTERVOLUME_MAX / kLSL6UIVolumeMax));
+}
+
+#ifdef ENABLE_SCI32
void GuestAdditions::syncGK1StartupVolumeFromScummVM(const int index, const reg_t value) const {
if (index == kGlobalVarGK1Music1 || index == kGlobalVarGK1Music2 ||
index == kGlobalVarGK1DAC1 || index == kGlobalVarGK1DAC2 ||
@@ -1244,11 +1250,6 @@ void GuestAdditions::syncHoyle5VolumeFromScummVM(const int16 musicVolume) const
g_sci->_soundCmd->setMasterVolume(ConfMan.getBool("mute") ? 0 : (musicVolume * MUSIC_MASTERVOLUME_MAX / kHoyle5VolumeMax));
}
-void GuestAdditions::syncLSL6HiresVolumeFromScummVM(const int16 musicVolume) const {
- _state->variables[VAR_GLOBAL][kGlobalVarLSL6HiresMusicVolume] = make_reg(0, musicVolume);
- g_sci->_soundCmd->setMasterVolume(ConfMan.getBool("mute") ? 0 : (musicVolume * MUSIC_MASTERVOLUME_MAX / kLSL6HiresUIVolumeMax));
-}
-
void GuestAdditions::syncPhant2VolumeFromScummVM(const int16 masterVolume) const {
_state->variables[VAR_GLOBAL][kGlobalVarPhant2MasterVolume] = make_reg(0, masterVolume);
_state->variables[VAR_GLOBAL][kGlobalVarPhant2SecondaryVolume] = make_reg(0, masterVolume);
@@ -1293,9 +1294,11 @@ void GuestAdditions::syncTorinVolumeFromScummVM(const int16 musicVolume, const i
}
}
}
+#endif
void GuestAdditions::syncAudioVolumeGlobalsToScummVM(const int index, const reg_t value) const {
switch (g_sci->getGameId()) {
+#ifdef ENABLE_SCI32
case GID_GK2:
if (index == kGlobalVarGK2MusicVolume) {
const int16 musicVolume = value.toSint16() * Audio::Mixer::kMaxMixerVolume / Audio32::kMaxVolume;
@@ -1312,13 +1315,6 @@ void GuestAdditions::syncAudioVolumeGlobalsToScummVM(const int index, const reg_
}
break;
- case GID_LSL6HIRES:
- if (index == kGlobalVarLSL6HiresMusicVolume) {
- const int16 musicVolume = value.toSint16() * Audio::Mixer::kMaxMixerVolume / kLSL6HiresUIVolumeMax;
- ConfMan.setInt("music_volume", musicVolume);
- }
- break;
-
case GID_PHANTASMAGORIA:
if (index == kGlobalVarPhant1MusicVolume) {
const int16 musicVolume = value.toSint16() * Audio::Mixer::kMaxMixerVolume / MUSIC_MASTERVOLUME_MAX;
@@ -1369,12 +1365,22 @@ void GuestAdditions::syncAudioVolumeGlobalsToScummVM(const int index, const reg_
}
}
break;
+#endif
+
+ case GID_LSL6:
+ case GID_LSL6HIRES:
+ if (index == kGlobalVarLSL6MusicVolume) {
+ const int16 musicVolume = value.toSint16() * Audio::Mixer::kMaxMixerVolume / kLSL6UIVolumeMax;
+ ConfMan.setInt("music_volume", musicVolume);
+ }
+ break;
default:
break;
}
}
+#ifdef ENABLE_SCI32
void GuestAdditions::syncGK1AudioVolumeToScummVM(const reg_t soundObj, int16 volume) const {
const Common::String objName = _segMan->getObjectName(soundObj);
volume = volume * Audio::Mixer::kMaxMixerVolume / MUSIC_VOLUME_MAX;
@@ -1487,20 +1493,31 @@ void GuestAdditions::syncHoyle5UI(const int16 musicVolume) const {
}
}
}
+#endif
-void GuestAdditions::syncLSL6HiresUI(const int16 musicVolume) const {
+void GuestAdditions::syncLSL6UI(const int16 musicVolume) const {
const reg_t musicDialId = _segMan->findObjectByName("volumeDial");
if (!musicDialId.isNull()) {
writeSelectorValue(_segMan, musicDialId, SELECTOR(curPos), musicVolume);
writeSelectorValue(_segMan, musicDialId, SELECTOR(cel), musicVolume);
reg_t params[] = { make_reg(0, musicVolume) };
- invokeSelector(musicDialId, SELECTOR(update), 1, params);
- if (_segMan->getObject(musicDialId)->isInserted()) {
- g_sci->_gfxFrameout->kernelUpdateScreenItem(musicDialId);
+ // volumeDial's method is doit in the lo-res version and update in hi-res
+ if (g_sci->getGameId() == GID_LSL6) {
+ invokeSelector(musicDialId, SELECTOR(doit), 1, params);
+ } else {
+ invokeSelector(musicDialId, SELECTOR(update), 1, params);
}
+#ifdef ENABLE_SCI32
+ if (g_sci->getGameId() == GID_LSL6HIRES) {
+ if (_segMan->getObject(musicDialId)->isInserted()) {
+ g_sci->_gfxFrameout->kernelUpdateScreenItem(musicDialId);
+ }
+ }
+#endif
}
}
+#ifdef ENABLE_SCI32
void GuestAdditions::syncPhant1UI(const int16 oldMusicVolume, const int16 musicVolume, reg_t &musicGlobal, const int16 oldDacVolume, const int16 dacVolume, reg_t &dacGlobal) const {
const reg_t buttonId = _segMan->findObjectByName("dacVolUp");
if (buttonId.isNull() || !_segMan->getObject(buttonId)->isInserted()) {
diff --git a/engines/sci/engine/guest_additions.h b/engines/sci/engine/guest_additions.h
index 713695261d..7cae8fb201 100644
--- a/engines/sci/engine/guest_additions.h
+++ b/engines/sci/engine/guest_additions.h
@@ -33,7 +33,6 @@ class Kernel;
class Script;
class SegManager;
-#ifdef ENABLE_SCI32
enum {
// The in-game volumes for Phant2 use a volume range smaller than the
// actual master volume because movie volume needs to be controllable from
@@ -44,11 +43,10 @@ enum {
kPhant2VolumeMax = 85,
kRamaVolumeMax = 16,
- kLSL6HiresUIVolumeMax = 13,
+ kLSL6UIVolumeMax = 13,
kHoyle5VolumeMax = 8,
kLSL6HiresSubtitleFlag = 105
};
-#endif
/**
* The GuestAdditions class hooks into the SCI virtual machine to provide
@@ -372,7 +370,6 @@ private:
*/
void syncMasterVolumeToScummVM(const int16 masterVolume) const;
-#ifdef ENABLE_SCI32
#pragma mark -
#pragma mark Globals volume sync
@@ -383,6 +380,9 @@ private:
*/
void syncAudioVolumeGlobalsFromScummVM() const;
+ void syncLSL6VolumeFromScummVM(const int16 musicVolume) const;
+
+#ifdef ENABLE_SCI32
/**
* Synchronises audio volume settings from ScummVM to GK1 at game startup
* time.
@@ -397,10 +397,10 @@ private:
void syncGK2VolumeFromScummVM(const int16 musicVolume) const;
void syncHoyle5VolumeFromScummVM(const int16 musicVolume) const;
- void syncLSL6HiresVolumeFromScummVM(const int16 musicVolume) const;
void syncPhant2VolumeFromScummVM(const int16 masterVolume) const;
void syncRamaVolumeFromScummVM(const int16 musicVolume) const;
void syncTorinVolumeFromScummVM(const int16 musicVolume, const int16 sfxVolume, const int16 speechVolume) const;
+#endif
/**
* Synchronises audio volume settings from a game to ScummVM, for games
@@ -408,6 +408,7 @@ private:
*/
void syncAudioVolumeGlobalsToScummVM(const int index, const reg_t value) const;
+#ifdef ENABLE_SCI32
/**
* Synchronises audio volume settings from GK1 to ScummVM.
*/
@@ -427,7 +428,9 @@ private:
void syncGK1UI() const;
void syncGK2UI() const;
void syncHoyle5UI(const int16 musicVolume) const;
- void syncLSL6HiresUI(const int16 musicVolume) const;
+#endif
+ void syncLSL6UI(const int16 musicVolume) const;
+#ifdef ENABLE_SCI32
void syncMGDXUI(const int16 musicVolume) const;
void syncPhant1UI(const int16 oldMusicVolume, const int16 musicVolume, reg_t &musicGlobal, const int16 oldDacVolume, const int16 dacVolume, reg_t &dacGlobal) const;
void syncPhant2UI(const int16 masterVolume) const;
diff --git a/engines/sci/engine/selector.cpp b/engines/sci/engine/selector.cpp
index 1a63b4dee1..7ea4dc5df6 100644
--- a/engines/sci/engine/selector.cpp
+++ b/engines/sci/engine/selector.cpp
@@ -171,6 +171,8 @@ void Kernel::mapSelectors() {
FIND_SELECTOR(setMotion);
FIND_SELECTOR(cycleSpeed);
FIND_SELECTOR(owner);
+ FIND_SELECTOR(curPos);
+ FIND_SELECTOR(update);
#ifdef ENABLE_SCI32
FIND_SELECTOR(data);
@@ -213,8 +215,6 @@ void Kernel::mapSelectors() {
FIND_SELECTOR(reSyncVol);
FIND_SELECTOR(set);
FIND_SELECTOR(clear);
- FIND_SELECTOR(curPos);
- FIND_SELECTOR(update);
FIND_SELECTOR(show);
FIND_SELECTOR(position);
FIND_SELECTOR(musicVolume);
diff --git a/engines/sci/engine/selector.h b/engines/sci/engine/selector.h
index 68b36b3bc2..b324be0004 100644
--- a/engines/sci/engine/selector.h
+++ b/engines/sci/engine/selector.h
@@ -137,6 +137,9 @@ struct SelectorCache {
Selector cycleSpeed;
Selector owner;
+ Selector curPos; // for LSL6 volume sync
+ Selector update; // for LSL6 volume sync
+
#ifdef ENABLE_SCI32
Selector data; // Used by Array()/String()
Selector picture; // Used to hold the picture ID for SCI32 pictures
@@ -170,8 +173,6 @@ struct SelectorCache {
Selector reSyncVol; // for Torin volume sync on restore
Selector set; // for LSL6hires subtitle sync
Selector clear; // for LSL6hires subtitle sync
- Selector curPos; // for LSL6hires volume sync
- Selector update; // for LSL6hires volume sync
Selector show; // for GK1 volume sync
Selector position; // for GK1 volume sync
Selector musicVolume; // for GK1 volume sync
diff --git a/engines/sci/engine/vm.h b/engines/sci/engine/vm.h
index f1af11a249..5fe98fe326 100644
--- a/engines/sci/engine/vm.h
+++ b/engines/sci/engine/vm.h
@@ -164,7 +164,7 @@ enum GlobalVar {
kGlobalVarRamaMusicVolume = 176, // 0 to 16
kGlobalVarPhant1MusicVolume = 187, // 0 to 15
kGlobalVarPhant1DACVolume = 188, // 0 to 127
- kGlobalVarLSL6HiresMusicVolume = 194, // 0 to 13
+ kGlobalVarLSL6MusicVolume = 194, // 0 to 13
kGlobalVarGK1DAC1 = 207, // 0 to 127
kGlobalVarPhant2CensorshipFlag = 207,
kGlobalVarGK1DAC2 = 208, // 0 to 127
More information about the Scummvm-git-logs
mailing list