ScummVM API documentation
sherlock.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 SHERLOCK_SHERLOCK_H
23 #define SHERLOCK_SHERLOCK_H
24 
25 #include "common/scummsys.h"
26 #include "common/array.h"
27 #include "common/endian.h"
28 #include "common/hash-str.h"
29 #include "common/serializer.h"
30 #include "common/random.h"
31 #include "common/savefile.h"
32 #include "common/util.h"
33 
34 #include "engines/engine.h"
35 
36 #include "sherlock/animation.h"
37 #include "sherlock/debugger.h"
38 #include "sherlock/events.h"
39 #include "sherlock/fixed_text.h"
40 #include "sherlock/inventory.h"
41 #include "sherlock/journal.h"
42 #include "sherlock/map.h"
43 #include "sherlock/music.h"
44 #include "sherlock/people.h"
45 #include "sherlock/resources.h"
46 #include "sherlock/saveload.h"
47 #include "sherlock/scene.h"
48 #include "sherlock/screen.h"
49 #include "sherlock/sound.h"
50 #include "sherlock/talk.h"
51 #include "sherlock/user_interface.h"
52 #include "sherlock/detection.h"
53 
54 namespace Sherlock {
55 
56 enum {
58  kDebugLevelAdLibDriver,
59  kDebugLevelMT32Driver,
60  kDebugLevelMusic,
61 };
62 
63 enum SHERLOCKActions {
64  kActionNone,
65  kActionSkipAnim,
66  // Scalpel specific actions
67  kActionScalpelQuit,
68  kActionScalpelScrollUp,
69  kActionScalpelScrollDown,
70  kActionScalpelDartsExit,
71  kActionScalpelSkipMovie,
72  kActionScalpelLook,
73  kActionScalpelMove,
74  kActionScalpelTalk,
75  kActionScalpelPickUp,
76  kActionScalpelOpen,
77  kActionScalpelClose,
78  kActionScalpelInventory,
79  kActionScalpelUse,
80  kActionScalpelGive,
81  kActionScalpelJournal,
82  kActionScalpelFiles,
83  kActionScalpelSetup,
84  kActionScalpelLoad,
85  kActionScalpelSave,
86  kActionScalpelJournalExit,
87  kActionScalpelJournalBack10,
88  kActionScalpelJournalAhead10,
89  kActionScalpelJournalSearch,
90  kActionScalpelJournalFirstPage,
91  kActionScalpelJournalLastPage,
92  kActionScalpelTalkExit,
93  kActionScalpelInvExit,
94  kActionScalpelInvLook,
95  kActionScalpelInvUse,
96  kActionScalpelInvGive,
97  kActionScalpelInvPageLeft,
98  kActionScalpelInvLeft,
99  kActionScalpelInvPageRight,
100  kActionScalpelInvRight,
101  kActionScalpelFilesExit,
102  kActionScalpelFilesLoad,
103  kActionScalpelFilesSave,
104  kActionScalpelFilesQuit,
105  kActionScalpelFiles1,
106  kActionScalpelFiles2,
107  kActionScalpelFiles3,
108  kActionScalpelFiles4,
109  kActionScalpelFiles5,
110  kActionScalpelFiles6,
111  kActionScalpelFiles7,
112  kActionScalpelFiles8,
113  kActionScalpelFiles9,
114  kActionScalpelQuitDialogYes,
115  kActionScalpelQuitDialogNo,
116  kActionScalpelQuitDialogSelect,
117  kActionScalpelMapSelect,
118  kActionScalpelSettingsSelect,
119  kActionScalpelSettingsExit,
120  kActionScalpelSettingsToggleMusic,
121  kActionScalpelSettingsTogglePortraits,
122  kActionScalpelSettingsChangeFontStyle,
123  kActionScalpelSettingsToggleSoundEffects,
124  kActionScalpelSettingsToggleWindowsMode,
125  kActionScalpelSettingsChangeAutohelpLoc,
126  kActionScalpelSettingsToggleVoices,
127  kActionScalpelSettingsChangeFadeMode,
128  kActionScalpelSettingsFadeByPixels,
129  kActionScalpelSettingsFadeDirectly,
130  // Tattoo specific actions
131  kActionTattooExit,
132  kActionTattooSkipProlog,
133  kActionTattooChangeSpeed,
134  kActionTattooLook,
135  kActionTattooSave,
136  kActionTattooLoad,
137  kActionTattooJournal,
138  kActionTattooInv,
139  kActionTattooOptions,
140  kActionTattooQuit,
141  kActionTattooJournalOptionsLeft,
142  kActionTattooJournalForward10,
143  kActionTattooJournalForward1,
144  kActionTattooJournalBack10,
145  kActionTattooJournalBack1,
146  kActionTattooJournalStart,
147  kActionTattooJournalEnd,
148  kActionTattooJournalSelect,
149  kActionTattooJournalOptionsRight,
150  kActionTattooJournalSearchOptionsLeft,
151  kActionTattooJournalSearchOptionsRight,
152  kActionTattooJournalSearch,
153  kActionTattooSkipDarts,
154  kActionTattooMapTopLeft,
155  kActionTattooMapBottomRight,
156  kActionTattooMapUp,
157  kActionTattooMapDown,
158  kActionTattooMapSelect,
159  kActionTattooWidgetScrollUp,
160  kActionTattooWidgetScrollPageUp,
161  kActionTattooWidgetScrollDown,
162  kActionTattooWidgetScrollPageDown,
163  kActionTattooWidgetScrollEnd,
164  kActionTattooWidgetScrollStart,
165  kActionTattooFilesNextSlot,
166  kActionTattooFilesNextPageSlot,
167  kActionTattooFilesSelect,
168  kActionTattooFilesNameLeft,
169  kActionTattooFilesNameRight,
170  kActionTattooFilesNameStart,
171  kActionTattooFilesNameEnd,
172  kActionTattooFilesNameToggleInsertMode,
173  kActionTattooFoolscapExit,
174  kActionTattooFoolscapUp,
175  kActionTattooFoolscapDown,
176  kActionTattooFoolscapLeft,
177  kActionTattooFoolscapRight,
178  kActionTattooInvExit,
179  kActionTattooOptionsSelect,
180  kActionTattooPasswordLeft,
181  kActionTattooPasswordRight,
182  kActionTattooPasswordStart,
183  kActionTattooPasswordEnd,
184  kActionTattooPasswordToggleInsertMode,
185  kActionTattooQuitDialogYes,
186  kActionTattooQuitDialogNo,
187  kActionTattooQuitDialogNextOption,
188  kActionTattooTalkNext,
189  kActionTattooTalkPrevious,
190 };
191 
192 
193 #define SHERLOCK_SCREEN_WIDTH _vm->_screen->width()
194 #define SHERLOCK_SCREEN_HEIGHT _vm->_screen->height()
195 #define SHERLOCK_SCENE_WIDTH _vm->_screen->_backBuffer1.width()
196 #define SHERLOCK_SCENE_HEIGHT (IS_SERRATED_SCALPEL ? 138 : 480)
197 #define SCENES_COUNT (IS_SERRATED_SCALPEL ? 63 : 101)
198 #define MAX_BGSHAPES (IS_SERRATED_SCALPEL ? 64 : 150)
199 
200 #define COL_INFO_FOREGROUND (IS_SERRATED_SCALPEL ? (byte)Scalpel::INFO_FOREGROUND : (byte)Tattoo::INFO_FOREGROUND)
201 #define COL_PEN_COLOR (IS_SERRATED_SCALPEL ? (byte)Scalpel::PEN_COLOR : (byte)Tattoo::PEN_COLOR)
202 #define COL_PEN_HIGHLIGHT (IS_SERRATED_SCALPEL ? 15 : 129)
203 
204 class Resource;
205 
206 class SherlockEngine : public Engine {
207 private:
211  void sceneLoop();
212 
216  void handleInput();
217 protected:
221  virtual void initialize();
222 
223  virtual void showOpening() = 0;
224 
225  virtual void startScene() {}
226 
230  bool hasFeature(EngineFeature f) const override;
231 
235  virtual void loadConfig();
236 public:
237  const SherlockGameDescription *_gameDescription;
238  Animation *_animation;
239  Debugger *_debugger;
240  Events *_events;
241  FixedText *_fixedText;
242  Inventory *_inventory;
243  Journal *_journal;
244  Map *_map;
245  Music *_music;
246  People *_people;
247  Resources *_res;
248  SaveManager *_saves;
249  Scene *_scene;
250  Screen *_screen;
251  Sound *_sound;
252  Talk *_talk;
253  UserInterface *_ui;
254  Common::RandomSource _randomSource;
255  Common::Array<bool> _flags;
256  bool _useEpilogue2;
257  int _loadGameSlot;
258  bool _canLoadSave;
259  bool _showOriginalSavesDialog;
260  bool _interactiveFl;
261  bool _isScreenDoubled;
262  bool _startupAutosave;
263 public:
264  SherlockEngine(OSystem *syst, const SherlockGameDescription *gameDesc);
265  ~SherlockEngine() override;
266 
270  Common::Error run() override;
271 
275  bool canLoadGameStateCurrently(Common::U32String *msg = nullptr) override;
276 
280  bool canSaveGameStateCurrently(Common::U32String *msg = nullptr) override;
281 
285  Common::Error loadGameState(int slot) override;
286 
290  Common::Error saveGameState(int slot, const Common::String &desc, bool isAutosave = false) override;
291 
295  void syncSoundSettings() override;
296 
300  virtual void saveConfig();
301 
305  virtual bool isDemo() const;
306 
310  GameType getGameID() const;
311 
316 
321 
325  int getRandomNumber(int limit) { return _randomSource.getRandomNumber(limit - 1); }
326 
332  bool readFlags(int flagNum);
333 
338  void setFlags(int flagNum);
339 
344  void setFlagsDirect(int flagNum);
345 
349  void synchronize(Serializer &s);
350 };
351 
352 #define IS_ROSE_TATTOO (_vm->getGameID() == GType_RoseTattoo)
353 #define IS_SERRATED_SCALPEL (_vm->getGameID() == GType_SerratedScalpel)
354 #define IS_3DO (_vm->getPlatform() == Common::kPlatform3DO)
355 
356 } // End of namespace Sherlock
357 
358 #endif
Definition: fixed_text.h:74
void synchronize(Serializer &s)
Definition: str.h:59
Common::Error saveGameState(int slot, const Common::String &desc, bool isAutosave=false) override
Definition: detection.h:34
Definition: events.h:39
EngineFeature
Definition: engine.h:260
Common::Language getLanguage() const
Definition: error.h:81
virtual void initialize()
Definition: inventory.h:78
Definition: random.h:44
Definition: talk.h:164
Definition: animation.h:29
Definition: animation.h:35
Definition: sound.h:40
uint getRandomNumber(uint max)
void setFlags(int flagNum)
Definition: scene.h:145
Definition: resources.h:83
Definition: saveload.h:59
bool canLoadGameStateCurrently(Common::U32String *msg=nullptr) override
Definition: debugger.h:35
Definition: serializer.h:79
virtual bool isDemo() const
GameType getGameID() const
bool canSaveGameStateCurrently(Common::U32String *msg=nullptr) override
virtual void loadConfig()
bool readFlags(int flagNum)
Definition: ustr.h:57
Definition: map.h:32
Common::Error loadGameState(int slot) override
Definition: sherlock.h:206
Common::Error run() override
virtual void saveConfig()
Definition: journal.h:50
int getRandomNumber(int limit)
Definition: sherlock.h:325
Definition: screen.h:39
Definition: music.h:59
Definition: system.h:163
Definition: user_interface.h:62
bool hasFeature(EngineFeature f) const override
Definition: engine.h:146
void syncSoundSettings() override
void setFlagsDirect(int flagNum)
Platform
Definition: platform.h:46
Definition: people.h:98
Common::Platform getPlatform() const
debug level for "EMCInterpreter" functions
Definition: kyra_v1.h:97
Language
Definition: language.h:45