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 HugoDebugChannels {
94  kDebugSchedule = 1 << 0,
95  kDebugEngine = 1 << 1,
96  kDebugDisplay = 1 << 2,
97  kDebugMouse = 1 << 3,
98  kDebugParser = 1 << 4,
99  kDebugFile = 1 << 5,
100  kDebugRoute = 1 << 6,
101  kDebugInventory = 1 << 7,
102  kDebugObject = 1 << 8,
103  kDebugMusic = 1 << 9
104 };
105 
106 enum HugoRegistered {
107  kRegShareware = 0,
108  kRegRegistered,
109  kRegFreeware
110 };
111 
115 enum Istate {kInventoryOff, kInventoryUp, kInventoryDown, kInventoryActive};
116 
120 enum Vstate {kViewIdle, kViewIntroInit, kViewIntro, kViewPlay, kViewInvent, kViewExit};
121 
131 enum {kPriorityForeground, kPriorityBackground, kPriorityFloating, kPriorityOverOverlay};
132 
136 enum Dupdate {kDisplayInit, kDisplayAdd, kDisplayDisplay, kDisplayRestore};
137 
141 enum Priority {kSoundPriorityLow, kSoundPriorityMedium, kSoundPriorityHigh};
142 
143 // Strings used by the engine
144 enum seqTextEngine {
145  kEsAdvertise = 0
146 };
147 
148 struct Status { // Game status (not saved)
149  bool _storyModeFl; // Game is telling story - no commands
150  bool _gameOverFl; // Game is over - hero knobbled
151  bool _lookFl; // Toolbar "look" button pressed
152  bool _recallFl; // Toolbar "recall" button pressed
153  bool _newScreenFl; // New screen just loaded in dib_a
154  bool _godModeFl; // Allow DEBUG features in live version
155  bool _showBoundariesFl; // Flag used to show and hide boundaries,
156  // used by the console
157  bool _doQuitFl;
158  bool _skipIntroFl;
159  bool _helpFl;
160  uint32 _tick; // Current time in ticks
161  Vstate _viewState; // View state machine
162  int16 _song; // Current song
163 };
164 
168 struct Hotspot {
169  int _screenIndex; // Screen in which hotspot appears
170  int _x1, _y1, _x2, _y2; // Bounding box of hotspot
171  uint16 _actIndex; // Actions to carry out if a 'hit'
172  int16 _viewx, _viewy, _direction; // Used in auto-route mode
173 };
174 
175 class FileManager;
176 class Scheduler;
177 class Screen;
178 class MouseHandler;
179 class InventoryHandler;
180 class Parser;
181 class Route;
182 class SoundHandler;
183 class IntroHandler;
184 class ObjectHandler;
185 class TextHandler;
186 class TopMenu;
187 class HugoConsole;
188 
189 class HugoEngine : public Engine {
190 public:
191  HugoEngine(OSystem *syst, const HugoGameDescription *gd);
192  ~HugoEngine() override;
193 
194  OSystem *_system;
195 
196  byte _numVariant;
197  byte _gameVariant;
198  int8 _soundSilence;
199  int8 _soundTest;
200  int8 _tunesNbr;
201  uint16 _numScreens;
202  uint16 _numStates;
203  int8 _normalTPS; // Number of ticks (frames) per second.
204  // 8 for Win versions, 9 for DOS versions
205  Object *_hero;
206  byte *_screenPtr;
207  byte _heroImage;
208  byte *_screenStates;
209  Command _line; // Line of user text input
210  Config _config; // User's config
211  int16 *_defltTunes;
212  uint16 _look;
213  uint16 _take;
214  uint16 _drop;
215 
216  Maze _maze; // Maze control structure
217  hugoBoot _boot; // Boot info structure
218 
219  Common::RandomSource *_rnd;
220 
221  const char *_episode;
222  Common::Path _picDir;
223 
224  Command _statusLine;
225  Command _scoreLine;
226 
227  const HugoGameDescription *_gameDescription;
228  uint32 getFeatures() const;
229  const char *getGameId() const;
230 
231  GameType getGameType() const;
232  Common::Platform getPlatform() const;
233  bool isPacked() const;
234 
235  // Used by the qsort function
236  static HugoEngine &get() {
237  assert(s_Engine != nullptr);
238  return *s_Engine;
239  }
240 
241  bool canLoadGameStateCurrently(Common::U32String *msg = nullptr) override;
242  bool canSaveGameStateCurrently(Common::U32String *msg = nullptr) override;
243  bool loadHugoDat();
244 
245  int8 getTPS() const;
246 
247  void initGame(const HugoGameDescription *gd);
248  void initGamePart(const HugoGameDescription *gd);
249  void endGame();
250  void gameOverMsg();
251  void initStatus();
252  void readScreenFiles(const int screen);
253  void setNewScreen(const int screen);
254  void shutdown();
255  void syncSoundSettings() override;
256 
257  Status &getGameStatus();
258  int getScore() const;
259  void setScore(const int newScore);
260  void adjustScore(const int adjustment);
261  int getMaxScore() const;
262  void setMaxScore(const int newScore);
263  Common::Error saveGameState(int slot, const Common::String &desc, bool isAutosave = false) override;
264  Common::Error loadGameState(int slot) override;
265  bool hasFeature(EngineFeature f) const override;
266  const char *getCopyrightString() const;
267 
268  Common::String getSaveStateName(int slot) const override;
269  uint16 **loadLongArray(Common::SeekableReadStream &in);
270 
271  FileManager *_file;
272  Scheduler *_scheduler;
273  Screen *_screen;
274  MouseHandler *_mouse;
275  InventoryHandler *_inventory;
276  Parser *_parser;
277  Route *_route;
278  SoundHandler *_sound;
279  IntroHandler *_intro;
280  ObjectHandler *_object;
281  TextHandler *_text;
282  TopMenu *_topMenu;
283 
284 protected:
285 
286  // Engine APIs
287  Common::Error run() override;
288 
289 private:
290  static const int kTurboTps = 16; // This many in turbo mode
291 
292  Status _status; // Game status structure
293  uint32 _lastTime;
294  uint32 _curTime;
295 
296  static HugoEngine *s_Engine;
297 
298  GameType _gameType;
299  Common::Platform _platform;
300  bool _packedFl;
301 
302  int _score; // Holds current score
303  int _maxscore; // Holds maximum score
304 
305  void initPlaylist(bool playlist[kMaxTunes]);
306  void initConfig();
307  void initialize();
308  void initMachine();
309  void calcMaxScore();
310  void resetConfig();
311  void runMachine();
312 
313 };
314 
315 } // End of namespace Hugo
316 
317 #endif // HUGO_HUGO_H
Definition: console.h:27
Definition: str.h:59
Definition: object.h:47
EngineFeature
Definition: engine.h:250
Definition: error.h:84
Definition: dialogs.h:72
Definition: detection.h:50
Definition: hugo.h:168
Definition: random.h:44
Definition: display.h:43
Dupdate
Definition: hugo.h:136
Definition: path.h:52
Definition: hugo.h:148
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:120
Definition: game.h:85
Priority
Definition: hugo.h:141
Definition: default_display_client.h:65
Definition: file.h:46
Definition: game.h:102
Definition: hugo.h:189
Definition: sound.h:64
Definition: game.h:142
Definition: system.h:167
Definition: engine.h:143
Istate
Definition: hugo.h:115
Definition: hugo.h:82
Platform
Definition: platform.h:46