diff options
author | Colin Snover | 2017-07-27 20:30:01 -0500 |
---|---|---|
committer | Colin Snover | 2017-07-30 19:10:50 -0500 |
commit | b13777da8cca2585b6658a53457b2043cc3e8ffc (patch) | |
tree | 98427e4aeee305b92c0e509afe66983085e464f6 /engines/sci | |
parent | ad05bfedd85b4ca560166bf95a0a2ec46df52dc8 (diff) | |
download | scummvm-rg350-b13777da8cca2585b6658a53457b2043cc3e8ffc.tar.gz scummvm-rg350-b13777da8cca2585b6658a53457b2043cc3e8ffc.tar.bz2 scummvm-rg350-b13777da8cca2585b6658a53457b2043cc3e8ffc.zip |
SCI32: Implement guest additions volume sync for Phant2
Diffstat (limited to 'engines/sci')
-rw-r--r-- | engines/sci/engine/features.cpp | 1 | ||||
-rw-r--r-- | engines/sci/engine/guest_additions.cpp | 45 | ||||
-rw-r--r-- | engines/sci/engine/guest_additions.h | 2 | ||||
-rw-r--r-- | engines/sci/engine/selector.cpp | 3 | ||||
-rw-r--r-- | engines/sci/engine/selector.h | 3 | ||||
-rw-r--r-- | engines/sci/engine/vm.h | 3 |
6 files changed, 57 insertions, 0 deletions
diff --git a/engines/sci/engine/features.cpp b/engines/sci/engine/features.cpp index e64cf9cf9f..03e8019753 100644 --- a/engines/sci/engine/features.cpp +++ b/engines/sci/engine/features.cpp @@ -576,6 +576,7 @@ bool GameFeatures::audioVolumeSyncUsesGlobals() const { case GID_LSL6HIRES: case GID_LSL7: case GID_PHANTASMAGORIA: + case GID_PHANTASMAGORIA2: case GID_TORIN: // TODO: SCI3 return true; diff --git a/engines/sci/engine/guest_additions.cpp b/engines/sci/engine/guest_additions.cpp index 0f4818d544..28b0bca428 100644 --- a/engines/sci/engine/guest_additions.cpp +++ b/engines/sci/engine/guest_additions.cpp @@ -141,6 +141,8 @@ bool GuestAdditions::shouldSyncAudioToScummVM() const { objName == "dacVolDown" || objName == "dacVolUp")) { return true; + } else if (gameId == GID_PHANTASMAGORIA2 && objName == "foo2") { + return true; } else if ((gameId == GID_LSL7 || gameId == GID_TORIN) && (objName == "oMusicScroll" || objName == "oSFXScroll" || objName == "oAudioScroll")) { @@ -819,6 +821,13 @@ void GuestAdditions::syncAudioVolumeGlobalsFromScummVM() const { break; } + case GID_PHANTASMAGORIA2: { + const int16 masterVolume = (ConfMan.getInt("sfx_volume") + 1) * Audio32::kMaxVolume / Audio::Mixer::kMaxMixerVolume; + syncPhant2VolumeFromScummVM(masterVolume); + syncPhant2UI(masterVolume); + break; + } + case GID_LSL7: case GID_TORIN: { const int16 musicVolume = (ConfMan.getInt("music_volume") + 1) * 100 / Audio::Mixer::kMaxMixerVolume; @@ -917,6 +926,16 @@ void GuestAdditions::syncLSL6HiresVolumeFromScummVM(const int16 musicVolume) con g_sci->_soundCmd->setMasterVolume(ConfMan.getBool("mute") ? 0 : (musicVolume * MUSIC_MASTERVOLUME_MAX / kLSL6HiresUIVolumeMax)); } +void GuestAdditions::syncPhant2VolumeFromScummVM(const int16 musicVolume) const { + _state->variables[VAR_GLOBAL][kGlobalVarPhant2MasterVolume] = make_reg(0, musicVolume); + + const reg_t soundsId = _state->variables[VAR_GLOBAL][kGlobalVarSounds]; + if (!soundsId.isNull()) { + reg_t params[] = { make_reg(0, SELECTOR(setVol)), make_reg(0, musicVolume) }; + invokeSelector(soundsId, SELECTOR(eachElementDo), 2, params); + } +} + void GuestAdditions::syncTorinVolumeFromScummVM(const int16 musicVolume, const int16 sfxVolume, const int16 speechVolume) const { _state->variables[VAR_GLOBAL][kGlobalVarTorinMusicVolume] = make_reg(0, musicVolume); _state->variables[VAR_GLOBAL][kGlobalVarTorinSFXVolume] = make_reg(0, sfxVolume); @@ -969,6 +988,13 @@ void GuestAdditions::syncAudioVolumeGlobalsToScummVM(const int index, const reg_ } break; + case GID_PHANTASMAGORIA2: + if (index == kGlobalVarPhant2MasterVolume) { + const int16 masterVolume = value.toSint16() * Audio::Mixer::kMaxMixerVolume / Audio32::kMaxVolume; + ConfMan.setInt("sfx_volume", masterVolume); + } + break; + case GID_LSL7: case GID_TORIN: if (index == kGlobalVarTorinMusicVolume || @@ -1129,6 +1155,25 @@ void GuestAdditions::syncPhant1UI(const int16 oldMusicVolume, const int16 musicV } } +void GuestAdditions::syncPhant2UI(const int16 musicVolume) const { + const reg_t musicVolumeScript = _segMan->findObjectByName("foo2"); + Common::Array<reg_t> scrollBars = _segMan->findObjectsByName("P2ScrollBar"); + for (uint i = 0; i < scrollBars.size(); ++i) { + if (readSelector(_segMan, scrollBars[i], SELECTOR(client)) == musicVolumeScript) { + // P2ScrollBar objects may exist without actually being on-screen; + // the easiest way to tell seems to be to look to see if it has + // non-null pointers to subviews. (The game will correctly set the + // position of the scrollbar when it first becomes visible, so this + // is fine.) + if (!readSelector(_segMan, scrollBars[i], SELECTOR(physicalBar)).isNull()) { + reg_t params[] = { make_reg(0, musicVolume), make_reg(0, 1) }; + invokeSelector(scrollBars[i], SELECTOR(move), 2, params); + break; + } + } + } +} + void GuestAdditions::syncMGDXUI(const int16 musicVolume) const { const reg_t sliderId = _segMan->findObjectByName("icon1"); if (!sliderId.isNull()) { diff --git a/engines/sci/engine/guest_additions.h b/engines/sci/engine/guest_additions.h index 79f498a04e..fd77909869 100644 --- a/engines/sci/engine/guest_additions.h +++ b/engines/sci/engine/guest_additions.h @@ -321,6 +321,7 @@ private: void syncGK2VolumeFromScummVM(const int16 musicVolume) const; void syncLSL6HiresVolumeFromScummVM(const int16 musicVolume) const; + void syncPhant2VolumeFromScummVM(const int16 masterVolume) const; void syncTorinVolumeFromScummVM(const int16 musicVolume, const int16 sfxVolume, const int16 speechVolume) const; /** @@ -350,6 +351,7 @@ private: void syncLSL6HiresUI(const int16 musicVolume) const; 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; void syncPQ4UI(const int16 musicVolume) const; void syncPQSWATUI() const; void syncQFG4UI(const int16 musicVolume) const; diff --git a/engines/sci/engine/selector.cpp b/engines/sci/engine/selector.cpp index 77405578ed..889590fc8b 100644 --- a/engines/sci/engine/selector.cpp +++ b/engines/sci/engine/selector.cpp @@ -219,6 +219,9 @@ void Kernel::mapSelectors() { FIND_SELECTOR(displayValue); FIND_SELECTOR2(new_, "new"); FIND_SELECTOR(mainCel); + FIND_SELECTOR(move); + FIND_SELECTOR(eachElementDo); + FIND_SELECTOR(physicalBar); #endif } diff --git a/engines/sci/engine/selector.h b/engines/sci/engine/selector.h index b2232625f2..850a5dc0ec 100644 --- a/engines/sci/engine/selector.h +++ b/engines/sci/engine/selector.h @@ -176,6 +176,9 @@ struct SelectorCache { Selector displayValue; // for PQ:SWAT volume sync Selector new_; // for Torin/LSL7 save/load patching Selector mainCel; // for MGDX volume sync + Selector move; // for Phant2 volume sync + Selector eachElementDo; // for Phant2 volume sync + Selector physicalBar; // for Phant2 volume sync #endif }; diff --git a/engines/sci/engine/vm.h b/engines/sci/engine/vm.h index 1ac6fed0b6..e92929e7ea 100644 --- a/engines/sci/engine/vm.h +++ b/engines/sci/engine/vm.h @@ -167,6 +167,9 @@ enum GlobalVar { kGlobalVarTorinMusicVolume = 227, // 0 to 100 kGlobalVarTorinSFXVolume = 228, // 0 to 100 kGlobalVarTorinSpeechVolume = 229, // 0 to 100 + // Phant2 labels its volume slider as "music volume" but it is actually + // a master volume that affects both music *and* sound effects + kGlobalVarPhant2MasterVolume = 236, // 0 to 127 kGlobalVarShivers1Score = 349 }; |