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