ScummVM API documentation
guest_additions.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef SCI_ENGINE_GUEST_ADDITIONS_H
23 #define SCI_ENGINE_GUEST_ADDITIONS_H
24 
25 #include "sci/engine/vm_types.h"
26 
27 namespace Sci {
28 
29 struct EngineState;
30 class GameFeatures;
31 class Kernel;
32 class Script;
33 class SegManager;
34 
35 enum {
36  // The in-game volumes for Phant2 use a volume range smaller than the
37  // actual master volume because movie volume needs to be controllable from
38  // the normal ScummVM launcher volume controls, but movie dialogue cannot be
39  // heard if the game audio is at the same level as movies. The game normally
40  // sets defaults so that the in-game volume is 85 and movies are 127, so we
41  // will just use 85 as the maximum volume.
42  kPhant2VolumeMax = 85,
43 
44  kRamaVolumeMax = 16,
45  kLSL6UIVolumeMax = 13,
46  kHoyle5VolumeMax = 8,
47  kLSL6HiresSubtitleFlag = 105
48 };
49 
63 public:
64  GuestAdditions(EngineState *state, GameFeatures *features, Kernel *kernel);
65 
66 #pragma mark -
67 
72  void syncSoundSettingsFromScummVM() const;
73 
78  void syncAudioOptionsFromScummVM() const;
79 
83  void reset();
84 
85 private:
86  EngineState *_state;
87  GameFeatures *_features;
88  Kernel *_kernel;
89  SegManager *_segMan;
90 
95  void invokeSelector(const reg_t objId, const Selector selector, const int argc = 0, const StackPtr argv = nullptr) const;
96 
101  bool shouldSyncAudioToScummVM() const;
102 
103 #pragma mark -
104 #pragma mark Hooks
105 
106 public:
110  void sciEngineRunGameHook();
111 
115  void writeVarHook(const int type, const int index, const reg_t value);
116 
122  bool kDoSoundMasterVolumeHook(const int volume) const;
123 
127  bool userHasControl();
128 
129 #ifdef ENABLE_SCI32
130 
133  void sciEngineInitGameHook();
134 
138  void sendSelectorHook(const reg_t sendObj, Selector &selector, reg_t *argp);
139 
145  bool audio32SetVolumeHook(const int16 channelIndex, const int16 volume) const;
146 
150  void kDoSoundSetVolumeHook(const reg_t soundObj, const int16 volume) const;
151 
155  void instantiateScriptHook(Script &script, const bool ignoreDelayedRestore = false) const;
156 
160  void segManSaveLoadScriptHook(Script &script) const;
161 #endif
162 
166  bool kGetEventHook() const;
167 
171  bool kWaitHook() const;
172 
173 #ifdef ENABLE_SCI32
174 
177  bool kPlayDuckPlayVMDHook() const;
178 #endif
179 
180 #pragma mark -
181 #pragma mark Integrated save & restore
182 
183 public:
189  void patchGameSaveRestore() const;
190 
191 private:
196  void patchGameSaveRestoreSCI16() const;
197 
198 #ifdef ENABLE_SCI32
199 public:
207  reg_t kScummVMSaveLoad(EngineState *s, int argc, reg_t *argv) const;
208 
209 private:
214  void patchGameSaveRestoreSCI32(Script &script) const;
215 
219  void patchGameSaveRestoreTorin(Script &script) const;
220 
224  void patchGameSaveRestorePhant2(Script &script) const;
225 
229  void patchGameSaveRestoreRama(Script &script) const;
230 
235  void patchSRDialogDoit(Script &script, const char *const objectName, const byte *patchData, const int patchSize, const int *uint16Offsets = nullptr, const uint numOffsets = 0) const;
236 
241  reg_t promptSaveRestoreDefault(EngineState *s, int argc, reg_t *argv) const;
242 
247  reg_t promptSaveRestoreTorin(EngineState *s, int argc, reg_t *argv) const;
248 
253  reg_t promptSaveRestorePhant2(EngineState *s, int argc, reg_t *argv) const;
254 
259  reg_t promptSaveRestoreRama(EngineState *s, int argc, reg_t *argv) const;
260 
265  reg_t promptSaveRestoreHoyle5(EngineState *s, int argc, reg_t *argv) const;
266 
267 public:
277  int runSaveRestore(const bool isSave, const reg_t outDescription, const int forcedSaveId = -1) const;
278  int runSaveRestore(const bool isSave, Common::String &outDescription, const int forcedSaveId = -1) const;
279 #endif
280 
281 #pragma mark -
282 #pragma mark Restore from launcher
283 
284 private:
289  bool restoreFromLauncher() const;
290 
291 #ifdef ENABLE_SCI32
292 
296  mutable bool _restoring;
297 #endif
298 
299 #pragma mark -
300 #pragma mark Message type sync
301 
302 private:
307  bool _messageTypeSynced;
308 
313  void syncMessageTypeFromScummVM() const;
314 
319  void syncMessageTypeFromScummVMUsingDefaultStrategy() const;
320 
321 #ifdef ENABLE_SCI32
322 
326  void syncMessageTypeFromScummVMUsingShiversStrategy() const;
327 
332  void syncMessageTypeFromScummVMUsingLSL6HiresStrategy() const;
333 #endif
334 
339  void syncMessageTypeToScummVM(const int index, const reg_t value);
340 
345  void syncMessageTypeToScummVMUsingDefaultStrategy(const int index, const reg_t value);
346 
347 #ifdef ENABLE_SCI32
348 
352  void syncMessageTypeToScummVMUsingShiversStrategy(const int index, const reg_t value);
353 
358  void syncMessageTypeToScummVMUsingLSL6HiresStrategy(const reg_t sendObj, Selector &selector, reg_t *argp);
359 #endif
360 
361 #pragma mark -
362 #pragma mark Master volume sync
363 
364 private:
369  void syncMasterVolumeFromScummVM() const;
370 
375  void syncMasterVolumeToScummVM(const int16 masterVolume) const;
376 
377 #pragma mark -
378 #pragma mark Globals volume sync
379 
380 private:
385  void syncAudioVolumeGlobalsFromScummVM() const;
386 
387  void syncLSL6VolumeFromScummVM(const int16 musicVolume) const;
388 
389 #ifdef ENABLE_SCI32
390 
394  void syncGK1StartupVolumeFromScummVM(const int index, const reg_t value) const;
395 
400  void syncGK1VolumeFromScummVM(const int16 musicVolume, const int16 dacVolume) const;
401 
402  void syncGK2VolumeFromScummVM(const int16 musicVolume) const;
403  void syncHoyle5VolumeFromScummVM(const int16 musicVolume) const;
404  void syncPhant2VolumeFromScummVM(const int16 masterVolume) const;
405  void syncRamaVolumeFromScummVM(const int16 musicVolume) const;
406  void syncTorinVolumeFromScummVM(const int16 musicVolume, const int16 sfxVolume, const int16 speechVolume) const;
407 #endif
408 
413  void syncAudioVolumeGlobalsToScummVM(const int index, const reg_t value) const;
414 
415 #ifdef ENABLE_SCI32
416 
419  void syncGK1AudioVolumeToScummVM(const reg_t soundObj, const int16 volume) const;
420 
421 #pragma mark -
422 #pragma mark Audio UI sync
423 
424 private:
430  void syncInGameUI(const int16 musicVolume, const int16 sfxVolume) const;
431 
432  void syncGK1UI() const;
433  void syncGK2UI() const;
434  void syncHoyle5UI(const int16 musicVolume) const;
435 #endif
436  void syncLSL6UI(const int16 musicVolume) const;
437 #ifdef ENABLE_SCI32
438  void syncMGDXUI(const int16 musicVolume) const;
439  void syncPhant1UI(const int16 oldMusicVolume, const int16 musicVolume, reg_t &musicGlobal, const int16 oldDacVolume, const int16 dacVolume, reg_t &dacGlobal) const;
440  void syncPhant2UI(const int16 masterVolume) const;
441  void syncPQ4UI(const int16 musicVolume) const;
442  void syncPQSWATUI() const;
443  void syncQFG4UI(const int16 musicVolume) const;
444  void syncRamaUI(const int16 musicVolume) const;
445  void syncShivers1UI(const int16 dacVolume) const;
446  void syncSQ6UI() const;
447  void syncTorinUI(const int16 musicVolume, const int16 sfxVolume, const int16 speechVolume) const;
448 
449 #pragma mark -
450 #pragma mark Talk speed sync
451 
452 private:
456  void syncTextSpeedFromScummVM() const;
457 
461  void syncTextSpeedToScummVM(const int index, const reg_t value) const;
462 #endif
463 };
464 
465 } // End of namespace Sci
466 
467 #endif // SCI_ENGINE_GUEST_ADDITIONS_H
Definition: state.h:100
void syncSoundSettingsFromScummVM() const
Definition: str.h:59
void syncAudioOptionsFromScummVM() const
Definition: kernel.h:157
bool kDoSoundMasterVolumeHook(const int volume) const
Definition: script.h:71
bool kGetEventHook() const
bool kWaitHook() const
Definition: console.h:28
Definition: seg_manager.h:48
Definition: guest_additions.h:62
void patchGameSaveRestore() const
Definition: features.h:56
Definition: vm_types.h:39
void writeVarHook(const int type, const int index, const reg_t value)