1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
|
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* $URL$
* $Id$
*
*/
#ifndef HUGO_H
#define HUGO_H
#include "engines/engine.h"
#include "common/file.h"
#include "hugo/console.h"
#include "hugo/menu.h"
// This include is here temporarily while the engine is being refactored.
#include "hugo/game.h"
#include "hugo/file.h"
#define HUGO_DAT_VER_MAJ 0 // 1 byte
#define HUGO_DAT_VER_MIN 41 // 1 byte
#define DATAALIGNMENT 4
namespace Common {
class RandomSource;
}
/**
* This is the namespace of the Hugo engine.
*
* Status of this engine: ???
*
* Games using this engine:
* - Hugo's House of Horror
* - Whodunit?
* - Jungle of Doom
* - Hugo's Horrific Adventure
* - Hugo's Mystery Adventure
* - Hugo's Amazon Adventure
*/
namespace Hugo {
static const int kSavegameVersion = 3;
static const int kInvDx = 32; // Width of an inventory icon
static const int kInvDy = 32; // Height of inventory icon
static const int kMaxTunes = 16; // Max number of tunes
static const int kStepDx = 5; // Num pixels moved in x by HERO per step
static const int kStepDy = 4; // Num pixels moved in y by HERO per step
static const int kXPix = 320; // Width of pcx background file
static const int kYPix = 200; // Height of pcx background file
static const int kViewSizeX = kXPix; // Width of window view
static const int kViewSizeY = 184; // Height of window view
static const int kDibOffY = 0; // Offset into dib SrcY (old status line area). In original game: 8
static const int kCompLineSize = 40; // number of bytes in a compressed line
static const int kMaxLineSize = kCompLineSize - 2; // Max length of user input line
static const int kMaxTextRows = 25; // Number of text lines in display
static const int kMaxBoxChar = kMaxLineSize * kMaxTextRows; // Max chars on screen
static const int kOvlSize = kCompLineSize * kYPix; // Size of an overlay file
static const int kStateDontCare = 0xFF; // Any state allowed in command verb
static const int kHeroIndex = 0; // In all enums, HERO is the first element
static const int kArrowNumb = 2; // Number of arrows (left/right)
static const int kLeftArrow = -2; // Cursor over Left arrow in inventory icon bar
static const int kRightArrow = -3; // Cursor over Right arrow in inventory icon bar
static const int kMaxPath = 256; // Max length of a full path name
static const int kHeroMaxWidth = 24; // Maximum width of hero
static const int kHeroMinWidth = 16; // Minimum width of hero
static const int kNumColors = 16; // Num colors to save in palette
typedef char fpath_t[kMaxPath]; // File path
typedef char command_t[kMaxLineSize + 8]; // Command line (+spare for prompt,cursor)
struct PCC_header_t { // Structure of PCX file header
byte mfctr, vers, enc, bpx;
uint16 x1, y1, x2, y2; // bounding box
uint16 xres, yres;
byte palette[3 * kNumColors]; // EGA color palette
byte vmode, planes;
uint16 bytesPerLine; // Bytes per line
byte fill2[60];
}; // Header of a PCC file
struct config_t { // User's config (saved)
bool musicFl; // State of Music button/menu item
bool soundFl; // State of Sound button/menu item
bool turboFl; // State of Turbo button/menu item
bool playlist[kMaxTunes]; // Tune playlist
};
typedef byte icondib_t[kXPix * kInvDy]; // Icon bar dib
typedef byte viewdib_t[(long)kXPix * kYPix]; // Viewport dib
typedef byte overlay_t[kOvlSize]; // Overlay file
enum GameType {
kGameTypeNone = 0,
kGameTypeHugo1,
kGameTypeHugo2,
kGameTypeHugo3
};
enum GameVariant {
kGameVariantH1Win = 0,
kGameVariantH2Win,
kGameVariantH3Win,
kGameVariantH1Dos,
kGameVariantH2Dos,
kGameVariantH3Dos
};
enum HugoDebugChannels {
kDebugSchedule = 1 << 0,
kDebugEngine = 1 << 1,
kDebugDisplay = 1 << 2,
kDebugMouse = 1 << 3,
kDebugParser = 1 << 4,
kDebugFile = 1 << 5,
kDebugRoute = 1 << 6,
kDebugInventory = 1 << 7,
kDebugObject = 1 << 8,
kDebugMusic = 1 << 9
};
/**
* Ways to dismiss a text/prompt box
*/
enum box_t {kBoxAny, kBoxOk, kBoxPrompt, kBoxYesNo};
/**
* Inventory icon bar states
*/
enum istate_t {kInventoryOff, kInventoryUp, kInventoryDown, kInventoryActive};
/**
* Game view state machine
*/
enum vstate_t {kViewIdle, kViewIntroInit, kViewIntro, kViewPlay, kViewInvent, kViewExit};
/**
* Purpose of an automatic route
*/
enum go_t {kRouteSpace, kRouteExit, kRouteLook, kRouteGet};
/**
* Enumerate whether object is foreground, background or 'floating'
* If floating, HERO can collide with it and fore/back ground is determined
* by relative y-coord of object base. This is the general case.
* If fore or background, no collisions can take place and object is either
* behind or in front of all others, although can still be hidden by the
* the overlay plane. OVEROVL means the object is FLOATING (to other
* objects) but is never hidden by the overlay plane
*/
enum {kPriorityForeground, kPriorityBackground, kPriorityFloating, kPriorityOverOverlay};
/**
* Display list functions
*/
enum dupdate_t {kDisplayInit, kDisplayAdd, kDisplayDisplay, kDisplayRestore};
/**
* Priority for sound effect
*/
enum priority_t {kSoundPriorityLow, kSoundPriorityMedium, kSoundPriorityHigh};
enum HugoGameFeatures {
GF_PACKED = (1 << 0) // Database
};
// Strings used by the engine
enum seqTextEngine {
kEsAdvertise = 0
};
struct HugoGameDescription;
struct status_t { // Game status (not saved)
bool storyModeFl; // Game is telling story - no commands
bool gameOverFl; // Game is over - hero knobbled
bool demoFl; // Game is in demo mode
bool textBoxFl; // Game is (halted) in text box
bool lookFl; // Toolbar "look" button pressed
bool recallFl; // Toolbar "recall" button pressed
bool leftButtonFl; // Left mouse button pressed
bool rightButtonFl; // Right button pressed
bool newScreenFl; // New screen just loaded in dib_a
bool jumpExitFl; // Allowed to jump to a screen exit
bool godModeFl; // Allow DEBUG features in live version
bool helpFl; // Calling WinHelp (don't disable music)
bool doQuitFl;
bool skipIntroFl;
uint32 tick; // Current time in ticks
vstate_t viewState; // View state machine
istate_t inventoryState; // Inventory icon bar state
int16 inventoryHeight; // Inventory icon bar height
int16 inventoryObjId; // Inventory object selected, or -1
int16 routeIndex; // Index into route list, or -1
go_t go_for; // Purpose of an automatic route
int16 go_id; // Index of exit of object walking to
fpath_t path; // Alternate path for saved files
int16 song; // Current song
int16 cx, cy; // Cursor position (dib coords)
// Strangerke - Suppress as related to playback
// bool playbackFl; // Game is in playback mode
// bool recordFl; // Game is in record mode
// Strangerke - Not used ?
// bool mmtimeFl; // Multimedia timer supported
// int16 screenWidth; // Desktop screen width
// uint32 saveTick; // Time of last save in ticks
// int16 saveSlot; // Current slot to save/restore game
};
/**
* Structure to define an EXIT or other collision-activated hotspot
*/
struct hotspot_t {
int screenIndex; // Screen in which hotspot appears
int x1, y1, x2, y2; // Bounding box of hotspot
uint16 actIndex; // Actions to carry out if a 'hit'
int16 viewx, viewy, direction; // Used in auto-route mode
};
class FileManager;
class Scheduler;
class Screen;
class MouseHandler;
class InventoryHandler;
class Parser;
class Route;
class SoundHandler;
class IntroHandler;
class ObjectHandler;
class TextHandler;
class HugoEngine : public Engine {
public:
HugoEngine(OSystem *syst, const HugoGameDescription *gd);
~HugoEngine();
OSystem *_system;
byte _numVariant;
byte _gameVariant;
byte _maxInvent;
byte _numBonuses;
int8 _soundSilence;
int8 _soundTest;
int8 _tunesNbr;
uint16 _numScreens;
int8 _normalTPS; // Number of ticks (frames) per second.
// 8 for Win versions, 9 for DOS versions
object_t *_hero;
byte *_screen_p;
byte _heroImage;
byte *_introX;
byte *_introY;
byte *_screenStates;
command_t _line; // Line of user text input
config_t _config; // User's config
uint16 **_arrayReqs;
hotspot_t *_hotspots;
int16 *_invent;
uses_t *_uses;
uint16 _usesSize;
background_t *_catchallList;
background_t **_backgroundObjects;
uint16 _backgroundObjectsSize;
point_t *_points;
cmd **_cmdList;
uint16 _cmdListSize;
uint16 **_screenActs;
uint16 _screenActsSize;
int16 *_defltTunes;
uint16 _look;
uint16 _take;
uint16 _drop;
GUI::Debugger *getDebugger() { return _console; }
Common::RandomSource *_rnd;
const char *_episode;
Common::String _picDir;
Common::String _saveFilename;
command_t _statusLine;
command_t _scoreLine;
const HugoGameDescription *_gameDescription;
uint32 getFeatures() const;
const char *getGameId() const;
GameType getGameType() const;
Common::Platform getPlatform() const;
bool isPacked() const;
// Temporary, until the engine is fully objectified.
static HugoEngine &get() {
assert(s_Engine != 0);
return *s_Engine;
}
bool canLoadGameStateCurrently();
bool canSaveGameStateCurrently();
bool loadHugoDat();
char *useBG(char *name);
int deltaX(int x1, int x2, int vx, int y);
int deltaY(int x1, int x2, int vy, int y);
int8 getTPS();
void initGame(const HugoGameDescription *gd);
void initGamePart(const HugoGameDescription *gd);
void boundaryCollision(object_t *obj);
void clearBoundary(int x1, int x2, int y);
void clearScreenBoundary(int x1, int x2, int y);
void endGame();
void initStatus();
void readScreenFiles(int screen);
void screenActions(int screen);
void setNewScreen(int screen);
void shutdown();
void storeBoundary(int x1, int x2, int y);
void syncSoundSettings();
int getMouseX() const {
return _mouseX;
}
int getMouseY() const {
return _mouseY;
}
overlay_t &getBoundaryOverlay() {
return _boundary;
}
overlay_t &getObjectBoundaryOverlay() {
return _objBound;
}
overlay_t &getBaseBoundaryOverlay() {
return _ovlBase;
}
overlay_t &getFirstOverlay() {
return _overlay;
}
status_t &getGameStatus() {
return _status;
}
int getScore() const {
return _score;
}
void setScore(int newScore) {
_score = newScore;
}
void adjustScore(int adjustment) {
_score += adjustment;
}
int getMaxScore() const {
return _maxscore;
}
void setMaxScore(int newScore) {
_maxscore = newScore;
}
byte getIntroSize() {
return _introXSize;
}
Common::Error saveGameState(int slot, const char *desc) {
return (_file->saveGame(slot, desc) ? Common::kWritingFailed : Common::kNoError);
}
Common::Error loadGameState(int slot) {
return (_file->restoreGame(slot) ? Common::kReadingFailed : Common::kNoError);
}
bool hasFeature(EngineFeature f) const {
return (f == kSupportsRTL) || (f == kSupportsLoadingDuringRuntime) || (f == kSupportsSavingDuringRuntime);
}
const char *getCopyrightString() { return "Copyright 1989-1997 David P Gray, All Rights Reserved."; }
FileManager *_file;
Scheduler *_scheduler;
Screen *_screen;
MouseHandler *_mouse;
InventoryHandler *_inventory;
Parser *_parser;
Route *_route;
SoundHandler *_sound;
IntroHandler *_intro;
ObjectHandler *_object;
TextHandler *_text;
TopMenu *_topMenu;
protected:
// Engine APIs
Common::Error run();
private:
static const int kTurboTps = 16; // This many in turbo mode
int _mouseX;
int _mouseY;
byte _introXSize;
status_t _status; // Game status structure
static HugoEngine *s_Engine;
HugoConsole *_console;
// The following are bit plane display overlays which mark travel boundaries,
// foreground stationary objects and baselines for those objects (used to
// determine foreground/background wrt moving objects)
// Vinterstum: These shouldn't be static, but we get weird pathfinding issues (and Valgrind warnings) without.
// Needs more investigation. Alignment issues?
static overlay_t _boundary; // Boundary overlay file
static overlay_t _overlay; // First overlay file
static overlay_t _ovlBase; // First overlay base file
static overlay_t _objBound; // Boundary file marks object baselines
GameType _gameType;
Common::Platform _platform;
bool _packedFl;
int _score; // Holds current score
int _maxscore; // Holds maximum score
uint16 **loadLongArray(Common::File &in);
void initPlaylist(bool playlist[kMaxTunes]);
void initConfig();
void initialize();
void initMachine();
void calcMaxScore();
void resetConfig();
void runMachine();
};
} // End of namespace Hugo
#endif // Hugo_H
|