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 44 // 1 byte
35#define DATAALIGNMENT 4
36
37namespace Common {
38class SeekableReadStream;
39class RandomSource;
40}
41
55namespace Hugo {
56
57static const int kSavegameVersion = 6;
58static const int kInvDx = 32; // Width of an inventory icon
59static const int kInvDy = 32; // Height of inventory icon
60static const int kMaxTunes = 16; // Max number of tunes
61static const int kStepDx = 5; // Num pixels moved in x by HERO per step
62static const int kStepDy = 4; // Num pixels moved in y by HERO per step
63static const int kXPix = 320; // Width of pcx background file
64static const int kYPix = 200; // Height of pcx background file
65static const int kViewSizeX = kXPix; // Width of window view
66static const int kViewSizeY = 192; // Height of window view. In original game: 184
67static const int kDibOffY = 0; // Offset into dib SrcY (old status line area). In original game: 8
68static const int kCompLineSize = 40; // number of bytes in a compressed line
69static const int kMaxTextCols = 40; // Number of text lines in display
70static const int kMaxTextRows = 25; // Number of text lines in display
71static const int kMaxLineSize = kMaxTextCols - 2; // Max length of user input line
72static const int kMaxBoxChar = kMaxTextCols * kMaxTextRows; // Max chars on screen
73static const int kOvlSize = kCompLineSize * kYPix; // Size of an overlay file
74static const int kStateDontCare = 0xFF; // Any state allowed in command verb
75static const int kHeroIndex = 0; // In all enums, HERO is the first element
76static const int kArrowNumb = 2; // Number of arrows (left/right)
77static const int kLeftArrow = -2; // Cursor over Left arrow in inventory icon bar
78static const int kRightArrow = -3; // Cursor over Right arrow in inventory icon bar
79static const int kMaxPath = 256; // Max length of a full path name
80static const int kHeroMaxWidth = 24; // Maximum width of hero
81static const int kHeroMinWidth = 16; // Minimum width of hero
82
83typedef char Command[kMaxLineSize + 8]; // Command line (+spare for prompt,cursor)
84
85struct 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
92typedef byte Icondib[kXPix * kInvDy]; // Icon bar dib
93typedef byte Viewdib[(long)kXPix * kYPix]; // Viewport dib
94typedef byte Overlay[kOvlSize]; // Overlay file
95
96enum 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
117enum HugoDebugChannels {
118 kDebugSchedule = 1,
119 kDebugEngine,
120 kDebugDisplay,
121 kDebugMouse,
122 kDebugParser,
123 kDebugFile,
124 kDebugRoute,
125 kDebugInventory,
126 kDebugObject,
127 kDebugMusic,
128};
129
130enum HugoRegistered {
131 kRegShareware = 0,
132 kRegRegistered,
133 kRegFreeware
134};
135
139enum Istate {kInventoryOff, kInventoryUp, kInventoryDown, kInventoryActive};
140
144enum Vstate {kViewIdle, kViewIntroInit, kViewIntro, kViewPlay, kViewInvent, kViewExit};
145
155enum {kPriorityForeground, kPriorityBackground, kPriorityFloating, kPriorityOverOverlay};
156
160enum Dupdate {kDisplayInit, kDisplayAdd, kDisplayDisplay, kDisplayRestore};
161
165enum Priority {kSoundPriorityLow, kSoundPriorityMedium, kSoundPriorityHigh};
166
167// Strings used by the engine
168enum seqTextEngine {
169 kEsAdvertise = 0
170};
171
172struct 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
192struct 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
199enum TtsOptions {
200 kTtsNoSpeech = 0,
201 kTtsSpeech = (1 << 0),
202 kTtsReplaceNewlines = ((1 << 1) | kTtsSpeech)
203};
204
205class FileManager;
206class Scheduler;
207class Screen;
208class MouseHandler;
209class InventoryHandler;
210class Parser;
211class Route;
212class SoundHandler;
213class IntroHandler;
214class ObjectHandler;
215class TextHandler;
216class TopMenu;
217class HugoConsole;
218
219class HugoEngine : public Engine {
220public:
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
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
334protected:
335
336 // Engine APIs
337 Common::Error run() override;
338
339private:
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: error.h:81
Definition: path.h:52
Definition: random.h:44
Definition: stream.h:745
Definition: str.h:59
Definition: ustr.h:57
Definition: engine.h:149
EngineFeature
Definition: engine.h:282
Definition: file.h:46
Definition: hugo.h:219
bool canLoadGameStateCurrently(Common::U32String *msg=nullptr) override
bool canSaveGameStateCurrently(Common::U32String *msg=nullptr) override
Common::String getSaveStateName(int slot) const override
bool hasFeature(EngineFeature f) const override
void syncSoundSettings() override
Common::Error saveGameState(int slot, const Common::String &desc, bool isAutosave=false) override
Common::Error loadGameState(int slot) override
Common::Error run() override
Definition: intro.h:42
Definition: inventory.h:38
Definition: mouse.h:40
Definition: object.h:47
Definition: parser.h:78
Definition: route.h:46
Definition: schedule.h:516
Definition: display.h:47
Definition: sound.h:64
Definition: text.h:26
Definition: dialogs.h:72
Definition: system.h:166
Definition: default_display_client.h:68
Platform
Definition: platform.h:93
Definition: algorithm.h:29
Definition: console.h:27
Vstate
Definition: hugo.h:144
Dupdate
Definition: hugo.h:160
Priority
Definition: hugo.h:165
Istate
Definition: hugo.h:139
Definition: hugo.h:85
Definition: hugo.h:192
Definition: detection.h:50
Definition: game.h:103
Definition: game.h:143
Definition: hugo.h:172
Definition: game.h:86
Definition: atari-screen.h:58