ScummVM API documentation
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
sci.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_SCI_H
23 #define SCI_SCI_H
24 
25 #include "engines/engine.h"
26 #include "common/macresman.h"
27 #include "common/util.h"
28 #include "common/random.h"
29 #include "sci/engine/vm_types.h" // for Selector
30 #include "sci/debug.h" // for DebugState
31 #include "sci/detection.h" // Shared code between detection and engine
32 
33 struct ADGameDescription;
34 
45 namespace Sci {
46 
47 struct EngineState;
48 class Vocabulary;
49 class ResourceManager;
50 class Kernel;
51 class GameFeatures;
52 class GuestAdditions;
53 class Console;
54 class AudioPlayer;
55 class SoundCommandParser;
56 class EventManager;
57 class SegManager;
58 class ScriptPatcher;
59 class Sync;
60 
61 class GfxAnimate;
62 class GfxCache;
63 class GfxCompare;
64 class GfxControls16;
65 class GfxControls32;
66 class GfxCoordAdjuster16;
67 class GfxCursor;
68 class GfxMacFontManager;
69 class GfxMacIconBar;
70 class GfxMenu;
71 class GfxPaint16;
72 class GfxPaint32;
73 class GfxPalette;
74 class GfxPalette32;
75 class GfxRemap;
76 class GfxRemap32;
77 class GfxPorts;
78 class GfxScreen;
79 class GfxText16;
80 class GfxText32;
81 class GfxTransitions;
82 class SciTTS;
83 
84 #ifdef ENABLE_SCI32
85 class GfxFrameout;
86 class Audio32;
87 class Video32;
88 class GfxTransitions32;
89 class GfxCursor32;
90 #endif
91 
94  kDebugLevelError = 1,
95  kDebugLevelNodes,
96  kDebugLevelGraphics,
97  kDebugLevelStrings,
98  kDebugLevelMemory,
99  kDebugLevelFuncCheck,
100  kDebugLevelBresen,
101  kDebugLevelSound,
102  kDebugLevelBaseSetter,
103  kDebugLevelParser,
104  kDebugLevelSaid,
105  kDebugLevelFile,
106  kDebugLevelTime,
107  kDebugLevelRoom,
108  kDebugLevelAvoidPath,
109  kDebugLevelDclImplode,
110  kDebugLevelVM,
111  kDebugLevelScripts,
112  kDebugLevelGC,
113  kDebugLevelResMan,
114  kDebugLevelOnStartup,
115  kDebugLevelDebugMode,
116  kDebugLevelPatcher,
117  kDebugLevelWorkarounds,
118  kDebugLevelVideo,
119  kDebugLevelGame,
120 };
121 
122 
124 enum kLanguage {
125  K_LANG_NONE = 0,
126  K_LANG_ENGLISH = 1,
127  K_LANG_FRENCH = 33,
128  K_LANG_SPANISH = 34,
129  K_LANG_ITALIAN = 39,
130  K_LANG_GERMAN = 49,
131  K_LANG_JAPANESE = 81,
132  K_LANG_PORTUGUESE = 351
133 };
134 
135 class SciEngine : public Engine {
136  friend class Console;
137 public:
138  SciEngine(OSystem *syst, const ADGameDescription *desc, SciGameId gameId);
139  ~SciEngine() override;
140 
141  // Engine APIs
142  Common::Error run() override;
143  bool hasFeature(EngineFeature f) const override;
144  void pauseEngineIntern(bool pause) override;
145  void severeError();
146  Console *getSciDebugger();
147  Common::Error loadGameState(int slot) override;
148  Common::Error saveGameState(int slot, const Common::String &desc, bool isAutosave = false) override;
149  bool canLoadGameStateCurrently(Common::U32String *msg = nullptr) override;
150  bool canSaveGameStateCurrently(Common::U32String *msg = nullptr) override;
151  void syncSoundSettings() override;
152  void updateSoundMixerVolumes();
153  uint32 getTickCount();
154  void setTickCount(const uint32 ticks);
155  void errorString(const char *buf1, char *buf2, int size) override;
156 
182  int getAutosaveSlot() const override { return -1; }
183 
184  const SciGameId &getGameId() const { return _gameId; }
185  const char *getGameIdStr() const;
186  Common::Language getLanguage() const;
187 
193  bool isLanguageRTL() const;
194 
197  bool isDemo() const;
198  bool isCD() const;
199  bool useHiresGraphics() const;
200 
205  bool isBE() const;
206 
207  bool hasParser() const;
208 
210  bool hasMacFonts() const;
211 
213  bool hasMacIconBar() const;
214 
220  bool hasMacSaveRestoreDialogs() const;
221 
222  inline ResourceManager *getResMan() const { return _resMan; }
223  inline ScriptPatcher *getScriptPatcher() const { return _scriptPatcher; }
224  inline Kernel *getKernel() const { return _kernel; }
225  inline EngineState *getEngineState() const { return _gamestate; }
226  inline Vocabulary *getVocabulary() const { return _vocabulary; }
227  inline EventManager *getEventManager() const { return _eventMan; }
228  inline reg_t getGameObject() const { return _gameObjectAddress; } // Gets the game object VM address
229 
230  Common::RandomSource &getRNG() { return _rng; }
231 
232  Common::String getSavegameName(int nr) const;
233  Common::String getSavegamePattern() const;
234 
237 
239  Common::String wrapFilename(const Common::String &name) const;
240 
242  Common::String unwrapFilename(const Common::String &name) const;
243 
245  const char *getGameObjectName();
246 
252  int inQfGImportRoom() const;
253 
255  void showQfgImportMessageBox() const;
256 
261  void sleep(uint32 msecs);
262 
263  void scriptDebug();
264  bool checkExportBreakpoint(uint16 script, uint16 pubfunct);
265  bool checkSelectorBreakpoint(BreakpointType breakpointType, reg_t send_obj, int selector);
266  bool checkAddressBreakpoint(const reg_t &address);
267 
268 public:
269  bool checkKernelBreakpoint(const Common::String &name);
270 
282  Common::String strSplitLanguage(const char *str, uint16 *splitLanguage, const char *sep = "\r----------\r");
283  Common::String strSplit(const char *str, const char *sep = "\r----------\r") {
284  return strSplitLanguage(str, NULL, sep);
285  }
286 
287  kLanguage getSciLanguage();
288  void setSciLanguage(kLanguage lang);
289  void setSciLanguage();
290 
291  Common::String getSciLanguageString(const Common::String &str, kLanguage requestedLanguage, kLanguage *secondaryLanguage = nullptr, uint16 *languageSplitter = nullptr) const;
292 
293  // Check if vocabulary needs to get switched (in multilingual parser games)
294  void checkVocabularySwitch();
295 
296  // Initializes ports and paint16 for non-sci32 games, also sets default palette
297  void initGraphics();
298 
299  // Suggest to download the GK2 subtitles patch
300  // in the future, we might refactor it to something more generic, if needed
301  void suggestDownloadGK2SubTitlesPatch();
302 
303 public:
304  GfxAnimate *_gfxAnimate; // Animate for 16-bit gfx
305  GfxCache *_gfxCache;
306  GfxCompare *_gfxCompare;
307  GfxControls16 *_gfxControls16; // Controls for 16-bit gfx
308  GfxCoordAdjuster16 *_gfxCoordAdjuster; // Coordinate adjuster for 16-bit gfx
309  GfxCursor *_gfxCursor; // 16-bit cursor
310  GfxMenu *_gfxMenu; // Menu for 16-bit gfx
311  GfxPalette *_gfxPalette16;
312  GfxRemap *_gfxRemap16; // Remapping for the QFG4 demo
313  GfxPaint16 *_gfxPaint16; // Painting in 16-bit gfx
314  GfxPorts *_gfxPorts; // Port management for 16-bit gfx
315  GfxScreen *_gfxScreen; // Screen class for 16-bit
316  GfxText16 *_gfxText16;
317  GfxTransitions *_gfxTransitions; // transitions between screens for 16-bit gfx
318  GfxMacIconBar *_gfxMacIconBar; // Mac Icon Bar manager
319  GfxMacFontManager *_gfxMacFontManager; // null when not applicable
320  SciTTS *_tts;
321 
322 #ifdef ENABLE_SCI32
323  GfxControls32 *_gfxControls32; // Controls for 32-bit gfx
324  GfxPalette32 *_gfxPalette32; // Palette for 32-bit gfx
325  GfxRemap32 *_gfxRemap32; // Remapping for 32-bit gfx
326  GfxPaint32 *_gfxPaint32; // Painting in 32-bit gfx
327  GfxText32 *_gfxText32;
328 
329  Audio32 *_audio32;
330  Video32 *_video32;
331  GfxFrameout *_gfxFrameout; // kFrameout and the like for 32-bit gfx
332  GfxTransitions32 *_gfxTransitions32;
333  GfxCursor32 *_gfxCursor32;
334 #endif
335 
336  AudioPlayer *_audio;
337  Sync *_sync;
338  SoundCommandParser *_soundCmd;
339  GameFeatures *_features;
340  GuestAdditions *_guestAdditions;
341 
342  opcode_format (*_opcode_formats)[4];
343 
344  DebugState _debugState;
345  uint32 _speedThrottleDelay; // kGameIsRestarting maximum delay
346 
347  Common::MacResManager *getMacExecutable() { return &_macExecutable; }
348 
349 private:
358  bool initGame();
359 
367  void runGame();
368 
375  void initStackBaseWithSelector(Selector selector);
376 
383  void loadMacExecutable();
384 
392  void loadMacFonts();
393 
403  bool gameHasFanMadePatch();
404 
409  void setLauncherLanguage();
410 
411  const ADGameDescription *_gameDescription;
412  const SciGameId _gameId;
413  ResourceManager *_resMan;
414  ScriptPatcher *_scriptPatcher;
415  EngineState *_gamestate;
416  Kernel *_kernel;
417  Vocabulary *_vocabulary;
418  int16 _vocabularyLanguage;
419  EventManager *_eventMan;
420  reg_t _gameObjectAddress;
421  Console *_console;
423  Common::MacResManager _macExecutable;
424  bool _useHiresGraphics; // user-option for GK1, KQ6, PQ4
425  bool _inErrorString;
426 };
427 
434 extern SciEngine *g_sci;
435 
436 } // End of namespace Sci
437 
438 #endif // SCI_SCI_H
Definition: paint16.h:37
Definition: frameout.h:42
Definition: state.h:100
Definition: macresman.h:125
BreakpointType
Definition: debug.h:31
Common::String getFilePrefix() const
Definition: ports.h:52
Definition: str.h:59
EngineFeature
Definition: engine.h:253
Definition: debug.h:74
Definition: error.h:84
bool isLanguageRTL() const
Definition: macfont.h:78
void sleep(uint32 msecs)
Definition: advancedDetector.h:163
Definition: text32.h:53
Definition: random.h:44
Definition: compare.h:34
SciEngine * g_sci
Definition: remap32.h:234
Common::Error saveGameState(int slot, const Common::String &desc, bool isAutosave=false) override
int getAutosaveSlot() const override
Definition: sci.h:182
Common::Error run() override
Definition: kernel.h:157
void syncSoundSettings() override
from ScummVM to the game
Definition: remap.h:35
Definition: menu.h:80
Definition: vocabulary.h:189
bool hasFeature(EngineFeature f) const override
bool hasMacFonts() const
void showQfgImportMessageBox() const
Common::String wrapFilename(const Common::String &name) const
Common::Error loadGameState(int slot) override
Definition: resource.h:327
Definition: animate.h:87
Definition: audio32.h:174
Common::String unwrapFilename(const Common::String &name) const
bool canSaveGameStateCurrently(Common::U32String *msg=nullptr) override
Definition: palette16.h:41
bool hasMacSaveRestoreDialogs() const
Definition: sync.h:44
Definition: palette32.h:234
Definition: coordadjuster.h:37
Definition: ustr.h:57
kDebugLevels
Definition: sci.h:93
Common::Platform getPlatform() const
const char * getGameObjectName()
Definition: cache.h:38
Definition: audio.h:55
kLanguage
Definition: sci.h:124
Definition: console.h:28
bool canLoadGameStateCurrently(Common::U32String *msg=nullptr) override
bool isBE() const
Definition: script_patches.h:91
void pauseEngineIntern(bool pause) override
Definition: text16.h:45
Definition: cursor.h:55
Definition: controls16.h:53
Definition: guest_additions.h:62
Definition: transitions32.h:215
void initGraphics(int width, int height)
Definition: controls32.h:389
Definition: tts.h:30
Common::String strSplitLanguage(const char *str, uint16 *splitLanguage, const char *sep="\---------\)
bool hasMacIconBar() const
Definition: screen.h:70
Definition: soundcmd.h:36
Definition: maciconbar.h:36
Definition: system.h:161
Definition: transitions.h:62
Definition: event.h:151
Definition: sci.h:135
Definition: features.h:56
Definition: vm_types.h:39
Definition: engine.h:144
int inQfGImportRoom() const
void errorString(const char *buf1, char *buf2, int size) override
Platform
Definition: platform.h:46
Definition: video32.h:792
Definition: console.h:36
Definition: paint32.h:42
Definition: cursor32.h:34
Language
Definition: language.h:45