ScummVM API documentation
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);
283  Common::String strSplit(const char *str, const char *sep) {
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 public:
300  GfxAnimate *_gfxAnimate; // Animate for 16-bit gfx
301  GfxCache *_gfxCache;
302  GfxCompare *_gfxCompare;
303  GfxControls16 *_gfxControls16; // Controls for 16-bit gfx
304  GfxCoordAdjuster16 *_gfxCoordAdjuster; // Coordinate adjuster for 16-bit gfx
305  GfxCursor *_gfxCursor; // 16-bit cursor
306  GfxMenu *_gfxMenu; // Menu for 16-bit gfx
307  GfxPalette *_gfxPalette16;
308  GfxRemap *_gfxRemap16; // Remapping for the QFG4 demo
309  GfxPaint16 *_gfxPaint16; // Painting in 16-bit gfx
310  GfxPorts *_gfxPorts; // Port management for 16-bit gfx
311  GfxScreen *_gfxScreen; // Screen class for 16-bit
312  GfxText16 *_gfxText16;
313  GfxTransitions *_gfxTransitions; // transitions between screens for 16-bit gfx
314  GfxMacIconBar *_gfxMacIconBar; // Mac Icon Bar manager
315  GfxMacFontManager *_gfxMacFontManager; // null when not applicable
316  SciTTS *_tts;
317 
318 #ifdef ENABLE_SCI32
319  GfxControls32 *_gfxControls32; // Controls for 32-bit gfx
320  GfxPalette32 *_gfxPalette32; // Palette for 32-bit gfx
321  GfxRemap32 *_gfxRemap32; // Remapping for 32-bit gfx
322  GfxPaint32 *_gfxPaint32; // Painting in 32-bit gfx
323  GfxText32 *_gfxText32;
324 
325  Audio32 *_audio32;
326  Video32 *_video32;
327  GfxFrameout *_gfxFrameout; // kFrameout and the like for 32-bit gfx
328  GfxTransitions32 *_gfxTransitions32;
329  GfxCursor32 *_gfxCursor32;
330 #endif
331 
332  AudioPlayer *_audio;
333  Sync *_sync;
334  SoundCommandParser *_soundCmd;
335  GameFeatures *_features;
336  GuestAdditions *_guestAdditions;
337 
338  opcode_format (*_opcode_formats)[4];
339 
340  DebugState _debugState;
341  uint32 _speedThrottleDelay; // kGameIsRestarting maximum delay
342 
343  Common::MacResManager *getMacExecutable() { return &_macExecutable; }
344 
345 private:
354  bool initGame();
355 
363  void runGame();
364 
371  void initStackBaseWithSelector(Selector selector);
372 
379  void loadMacExecutable();
380 
388  void loadMacFonts();
389 
399  bool gameHasFanMadePatch();
400 
405  void setLauncherLanguage();
406 
407  const ADGameDescription *_gameDescription;
408  const SciGameId _gameId;
409  ResourceManager *_resMan;
410  ScriptPatcher *_scriptPatcher;
411  EngineState *_gamestate;
412  Kernel *_kernel;
413  Vocabulary *_vocabulary;
414  int16 _vocabularyLanguage;
415  EventManager *_eventMan;
416  reg_t _gameObjectAddress;
417  Console *_console;
419  Common::MacResManager _macExecutable;
420  bool _useHiresGraphics; // user-option for GK1, KQ6, PQ4
421  bool _inErrorString;
422 };
423 
430 extern SciEngine *g_sci;
431 
432 } // End of namespace Sci
433 
434 #endif // SCI_SCI_H
Definition: paint16.h:37
Definition: frameout.h:42
Definition: state.h:100
Definition: macresman.h:126
BreakpointType
Definition: debug.h:31
Common::String getFilePrefix() const
Definition: ports.h:52
Definition: str.h:59
EngineFeature
Definition: engine.h:258
Definition: debug.h:80
Definition: error.h:81
bool isLanguageRTL() const
Definition: macfont.h:78
void sleep(uint32 msecs)
Definition: advancedDetector.h:164
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:188
Common::String strSplitLanguage(const char *str, uint16 *splitLanguage, const char *sep)
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
bool hasMacIconBar() const
Definition: screen.h:70
Definition: soundcmd.h:36
Definition: maciconbar.h:36
Definition: system.h:164
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:93
Definition: video32.h:792
Definition: console.h:36
Definition: paint32.h:42
Definition: cursor32.h:34
Language
Definition: language.h:45