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
|
/* 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"
// This include is here temporarily while the engine is being refactored.
#include "hugo/game.h"
#define HUGO_DAT_VER_MAJ 0 // 1 byte
#define HUGO_DAT_VER_MIN 18 // 1 byte
#define DATAALIGNMENT 4
namespace Common {
class RandomSource;
}
namespace Hugo {
enum GameType {
kGameTypeNone = 0,
kGameTypeHugo1,
kGameTypeHugo2,
kGameTypeHugo3
};
enum HugoebugChannels {
kDebugSchedule = 1 << 0,
kDebugEngine = 1 << 1,
kDebugDisplay = 1 << 2,
kDebugMouse = 1 << 3,
kDebugParser = 1 << 4,
kDebugFile = 1 << 5,
kDebugRoute = 1 << 6,
kDebugInventory = 1 << 7
};
enum HugoGameFeatures {
GF_PACKED = (1 << 0) // Database
};
struct HugoGameDescription;
class FileManager;
class Scheduler;
class Screen;
class MouseHandler;
class InventoryHandler;
class Parser;
class Route;
class SoundHandler;
class IntroHandler;
class HugoEngine : public Engine {
public:
HugoEngine(OSystem *syst, const HugoGameDescription *gd);
~HugoEngine();
byte _numVariant;
byte _gameVariant;
byte _maxInvent;
byte _numBonuses;
byte _soundSilence;
byte _soundTest;
byte _tunesNbr;
uint16 _numScreens;
object_t *_hero;
byte *_screen_p;
byte _heroImage;
byte *_palette;
byte *_introX;
byte *_introY;
byte *_screenStates;
char **_textData;
char **_stringtData;
char **_screenNames;
char **_textEngine;
char **_textIntro;
char **_textMouse;
char **_textParser;
char **_textSchedule;
char **_textUtil;
char ***_arrayNouns;
char ***_arrayVerbs;
uint16 **_arrayReqs;
hotspot_t *_hotspots;
int16 *_invent;
uses_t *_uses;
background_t *_catchallList;
background_t **_backgroundObjects;
point_t *_points;
cmd **_cmdList;
uint16 **_screenActs;
object_t *_objects;
act **_actListArr;
int16 *_defltTunes;
uint16 _look;
uint16 _take;
uint16 _drop;
uint16 _numObj;
uint16 _alNewscrIndex;
Common::RandomSource *_rnd;
const char *_episode;
const char *_picDir;
char _initFilename[20];
char _saveFilename[20];
const HugoGameDescription *_gameDescription;
uint32 getFeatures() const;
GameType getGameType() const;
Common::Platform getPlatform() const;
bool isPacked() const;
// Temporary, until the engine is fully objectified.
static HugoEngine &get() {
assert(s_Engine != NULL);
return *s_Engine;
}
FileManager &file() {
return *_fileManager;
}
Scheduler &scheduler() {
return *_scheduler;
}
Screen &screen() {
return *_screen;
}
MouseHandler &mouse() {
return *_mouseHandler;
}
InventoryHandler &inventory() {
return *_inventoryHandler;
}
Parser &parser() {
return *_parser;
}
Route &route() {
return *_route;
}
SoundHandler &sound() {
return *_soundHandler;
}
IntroHandler &intro() {
return *_introHandler;
}
void initGame(const HugoGameDescription *gd);
void initGamePart(const HugoGameDescription *gd);
bool loadHugoDat();
int getMouseX() const {
return _mouseX;
}
int getMouseY() const {
return _mouseY;
}
void initStatus();
void readObjectImages();
void readUIFImages();
void updateImages();
void moveObjects();
void useObject(int16 objId);
bool findObjectSpace(object_t *obj, int16 *destx, int16 *desty);
int16 findObject(uint16 x, uint16 y);
void lookObject(object_t *obj);
void storeBoundary(int x1, int x2, int y);
void clearBoundary(int x1, int x2, int y);
void endGame();
void readScreenFiles(int screen);
void setNewScreen(int screen);
void initNewScreenDisplay();
void screenActions(int screen);
void shutdown();
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;
}
protected:
// Engine APIs
Common::Error run();
private:
int _mouseX;
int _mouseY;
byte _paletteSize;
byte _introXSize;
status_t _status; // Game status structure
static HugoEngine *s_Engine;
// 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;
FileManager *_fileManager;
Scheduler *_scheduler;
Screen *_screen;
MouseHandler *_mouseHandler;
InventoryHandler *_inventoryHandler;
Parser *_parser;
Route *_route;
SoundHandler *_soundHandler;
IntroHandler *_introHandler;
int _score; // Holds current score
int _maxscore; // Holds maximum score
char **loadTextsVariante(Common::File &in, uint16 *arraySize);
char ***loadTextsArray(Common::File &in);
uint16 **loadLongArray(Common::File &in);
char **loadTexts(Common::File &in);
void freeTexts(char **ptr);
void initPlaylist(bool playlist[MAX_TUNES]);
void initConfig(inst_t action);
void initialize();
int deltaX(int x1, int x2, int vx, int y);
int deltaY(int x1, int x2, int vy, int y);
void processMaze();
//int y2comp (const void *a, const void *b);
char *useBG(char *name);
void freeObjects();
void boundaryCollision(object_t *obj);
void calcMaxScore();
void initMachine();
void runMachine();
static int y2comp(const void *a, const void *b);
};
} // End of namespace Hugo
#endif // Hugo_H
|