ScummVM API documentation
hugo.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 HUGO_HUGO_H
23 #define HUGO_HUGO_H
24 
25 #include "common/text-to-speech.h"
26 
27 #include "engines/engine.h"
28 
29 // This include is here temporarily while the engine is being refactored.
30 #include "hugo/game.h"
31 #include "hugo/detection.h"
32 
33 #define HUGO_DAT_VER_MAJ 0 // 1 byte
34 #define HUGO_DAT_VER_MIN 42 // 1 byte
35 #define DATAALIGNMENT 4
36 
37 namespace Common {
38 class SeekableReadStream;
39 class RandomSource;
40 }
41 
55 namespace Hugo {
56 
57 static const int kSavegameVersion = 6;
58 static const int kInvDx = 32; // Width of an inventory icon
59 static const int kInvDy = 32; // Height of inventory icon
60 static const int kMaxTunes = 16; // Max number of tunes
61 static const int kStepDx = 5; // Num pixels moved in x by HERO per step
62 static const int kStepDy = 4; // Num pixels moved in y by HERO per step
63 static const int kXPix = 320; // Width of pcx background file
64 static const int kYPix = 200; // Height of pcx background file
65 static const int kViewSizeX = kXPix; // Width of window view
66 static const int kViewSizeY = 192; // Height of window view. In original game: 184
67 static const int kDibOffY = 0; // Offset into dib SrcY (old status line area). In original game: 8
68 static const int kCompLineSize = 40; // number of bytes in a compressed line
69 static const int kMaxLineSize = kCompLineSize - 2; // Max length of user input line
70 static const int kMaxTextRows = 25; // Number of text lines in display
71 static const int kMaxBoxChar = kMaxLineSize * kMaxTextRows; // Max chars on screen
72 static const int kOvlSize = kCompLineSize * kYPix; // Size of an overlay file
73 static const int kStateDontCare = 0xFF; // Any state allowed in command verb
74 static const int kHeroIndex = 0; // In all enums, HERO is the first element
75 static const int kArrowNumb = 2; // Number of arrows (left/right)
76 static const int kLeftArrow = -2; // Cursor over Left arrow in inventory icon bar
77 static const int kRightArrow = -3; // Cursor over Right arrow in inventory icon bar
78 static const int kMaxPath = 256; // Max length of a full path name
79 static const int kHeroMaxWidth = 24; // Maximum width of hero
80 static const int kHeroMinWidth = 16; // Minimum width of hero
81 
82 typedef char Command[kMaxLineSize + 8]; // Command line (+spare for prompt,cursor)
83 
84 struct Config { // User's config (saved)
85  bool _musicFl; // State of Music button/menu item
86  bool _soundFl; // State of Sound button/menu item
87  bool _turboFl; // State of Turbo button/menu item
88  bool _playlist[kMaxTunes]; // Tune playlist
89 };
90 
91 typedef byte Icondib[kXPix * kInvDy]; // Icon bar dib
92 typedef byte Viewdib[(long)kXPix * kYPix]; // Viewport dib
93 typedef byte Overlay[kOvlSize]; // Overlay file
94 
95 enum HUGOAction {
96  kActionNone,
97  kActionEscape,
98  kActionMoveTop,
99  kActionMoveBottom,
100  kActionMoveLeft,
101  kActionMoveRight,
102  kActionMoveTopRight,
103  kActionMoveTopLeft,
104  kActionMoveBottomRight,
105  kActionMoveBottomLeft,
106  kActionUserHelp,
107  kActionToggleSound,
108  kActionRepeatLine,
109  kActionSaveGame,
110  kActionRestoreGame,
111  kActionNewGame,
112  kActionInventory,
113  kActionToggleTurbo
114 };
115 
116 enum HugoDebugChannels {
117  kDebugSchedule = 1,
118  kDebugEngine,
119  kDebugDisplay,
120  kDebugMouse,
121  kDebugParser,
122  kDebugFile,
123  kDebugRoute,
124  kDebugInventory,
125  kDebugObject,
126  kDebugMusic,
127 };
128 
129 enum HugoRegistered {
130  kRegShareware = 0,
131  kRegRegistered,
132  kRegFreeware
133 };
134 
138 enum Istate {kInventoryOff, kInventoryUp, kInventoryDown, kInventoryActive};
139 
143 enum Vstate {kViewIdle, kViewIntroInit, kViewIntro, kViewPlay, kViewInvent, kViewExit};
144 
154 enum {kPriorityForeground, kPriorityBackground, kPriorityFloating, kPriorityOverOverlay};
155 
159 enum Dupdate {kDisplayInit, kDisplayAdd, kDisplayDisplay, kDisplayRestore};
160 
164 enum Priority {kSoundPriorityLow, kSoundPriorityMedium, kSoundPriorityHigh};
165 
166 // Strings used by the engine
167 enum seqTextEngine {
168  kEsAdvertise = 0
169 };
170 
171 struct Status { // Game status (not saved)
172  bool _storyModeFl; // Game is telling story - no commands
173  bool _gameOverFl; // Game is over - hero knobbled
174  bool _lookFl; // Toolbar "look" button pressed
175  bool _recallFl; // Toolbar "recall" button pressed
176  bool _newScreenFl; // New screen just loaded in dib_a
177  bool _godModeFl; // Allow DEBUG features in live version
178  bool _showBoundariesFl; // Flag used to show and hide boundaries,
179  // used by the console
180  bool _doQuitFl;
181  bool _skipIntroFl;
182  bool _helpFl;
183  uint32 _tick; // Current time in ticks
184  Vstate _viewState; // View state machine
185  int16 _song; // Current song
186 };
187 
191 struct Hotspot {
192  int _screenIndex; // Screen in which hotspot appears
193  int _x1, _y1, _x2, _y2; // Bounding box of hotspot
194  uint16 _actIndex; // Actions to carry out if a 'hit'
195  int16 _viewx, _viewy, _direction; // Used in auto-route mode
196 };
197 
198 class FileManager;
199 class Scheduler;
200 class Screen;
201 class MouseHandler;
202 class InventoryHandler;
203 class Parser;
204 class Route;
205 class SoundHandler;
206 class IntroHandler;
207 class ObjectHandler;
208 class TextHandler;
209 class TopMenu;
210 class HugoConsole;
211 
212 class HugoEngine : public Engine {
213 public:
214  HugoEngine(OSystem *syst, const HugoGameDescription *gd);
215  ~HugoEngine() override;
216 
217  OSystem *_system;
218 
219  byte _numVariant;
220  byte _gameVariant;
221  int8 _soundSilence;
222  int8 _soundTest;
223  int8 _tunesNbr;
224  uint16 _numScreens;
225  uint16 _numStates;
226  int8 _normalTPS; // Number of ticks (frames) per second.
227  // 8 for Win versions, 9 for DOS versions
228  Object *_hero;
229  byte *_screenPtr;
230  byte _heroImage;
231  byte *_screenStates;
232  Command _line; // Line of user text input
233  Config _config; // User's config
234  int16 *_defltTunes;
235  uint16 _look;
236  uint16 _take;
237  uint16 _drop;
238 
239  Maze _maze; // Maze control structure
240  hugoBoot _boot; // Boot info structure
241 
242  Common::RandomSource *_rnd;
243 
244  const char *_episode;
245  Common::Path _picDir;
246 
247  Command _statusLine;
248  Command _scoreLine;
249 
250 #ifdef USE_TTS
251  bool _voiceScoreLine;
252  bool _voiceSoundSetting;
253  bool _queueAllVoicing;
254  int _previousScore;
255 
256  Common::String _previousSaid;
257 #endif
258 
259  const HugoGameDescription *_gameDescription;
260  uint32 getFeatures() const;
261  const char *getGameId() const;
262 
263  GameType getGameType() const;
264  Common::Platform getPlatform() const;
265  bool isPacked() const;
266 
267  // Used by the qsort function
268  static HugoEngine &get() {
269  assert(s_Engine != nullptr);
270  return *s_Engine;
271  }
272 
273  bool canLoadGameStateCurrently(Common::U32String *msg = nullptr) override;
274  bool canSaveGameStateCurrently(Common::U32String *msg = nullptr) override;
275  bool loadHugoDat();
276 
277  int8 getTPS() const;
278 
279  void initGame(const HugoGameDescription *gd);
280  void initGamePart(const HugoGameDescription *gd);
281  void endGame();
282  void gameOverMsg();
283  void initStatus();
284  void readScreenFiles(const int screen);
285  void setNewScreen(const int screen);
286  void shutdown();
287  void syncSoundSettings() override;
288 
289  Status &getGameStatus();
290  int getScore() const;
291  void setScore(const int newScore);
292  void adjustScore(const int adjustment);
293  int getMaxScore() const;
294  void setMaxScore(const int newScore);
295  Common::Error saveGameState(int slot, const Common::String &desc, bool isAutosave = false) override;
296  Common::Error loadGameState(int slot) override;
297  bool hasFeature(EngineFeature f) const override;
298  const char *getCopyrightString() const;
299 
300  Common::String getSaveStateName(int slot) const override;
301  uint16 **loadLongArray(Common::SeekableReadStream &in);
302 
303 #ifdef USE_TTS
304  void sayText(const Common::String &text, Common::TextToSpeechManager::Action action = Common::TextToSpeechManager::INTERRUPT);
305 #endif
306 
307  FileManager *_file;
308  Scheduler *_scheduler;
309  Screen *_screen;
310  MouseHandler *_mouse;
311  InventoryHandler *_inventory;
312  Parser *_parser;
313  Route *_route;
314  SoundHandler *_sound;
315  IntroHandler *_intro;
316  ObjectHandler *_object;
317  TextHandler *_text;
318  TopMenu *_topMenu;
319 
320 protected:
321 
322  // Engine APIs
323  Common::Error run() override;
324 
325 private:
326  static const int kTurboTps = 16; // This many in turbo mode
327 
328  Status _status; // Game status structure
329  uint32 _lastTime;
330  uint32 _curTime;
331 
332  static HugoEngine *s_Engine;
333 
334  GameType _gameType;
335  Common::Platform _platform;
336  bool _packedFl;
337 
338  int _score; // Holds current score
339  int _maxscore; // Holds maximum score
340 
341  void initPlaylist(bool playlist[kMaxTunes]);
342  void initConfig();
343  void initialize();
344  void initMachine();
345  void calcMaxScore();
346  void resetConfig();
347  void runMachine();
348 
349 };
350 
351 } // End of namespace Hugo
352 
353 #endif // HUGO_HUGO_H
Definition: console.h:27
Definition: str.h:59
Definition: object.h:47
EngineFeature
Definition: engine.h:260
Definition: error.h:81
Definition: dialogs.h:72
Definition: detection.h:50
Definition: hugo.h:191
Definition: random.h:44
Definition: display.h:43
Dupdate
Definition: hugo.h:159
Definition: path.h:52
Definition: hugo.h:171
Definition: stream.h:745
Definition: mouse.h:40
Definition: schedule.h:516
Definition: text.h:26
Definition: inventory.h:38
Definition: intro.h:42
Definition: console.h:31
Definition: parser.h:78
Definition: ustr.h:57
Definition: route.h:46
Definition: algorithm.h:29
Vstate
Definition: hugo.h:143
Definition: game.h:85
Priority
Definition: hugo.h:164
Definition: default_display_client.h:65
Definition: file.h:46
Definition: game.h:102
Definition: hugo.h:212
Definition: sound.h:64
Definition: game.h:142
Definition: system.h:163
Definition: engine.h:146
Istate
Definition: hugo.h:138
Definition: hugo.h:84
Platform
Definition: platform.h:46