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