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
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
|
/* 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.
*
*/
/*
* This code is based on Labyrinth of Time code with assistance of
*
* Copyright (c) 1993 Terra Nova Development
* Copyright (c) 2004 The Wyrmkeep Entertainment Co.
*
*/
#ifndef LAB_LAB_H
#define LAB_LAB_H
#include "common/system.h"
#include "common/random.h"
#include "common/rect.h"
#include "common/savefile.h"
#include "engines/engine.h"
#include "engines/savestate.h"
#include "lab/console.h"
#include "lab/image.h"
#include "lab/labsets.h"
struct ADGameDescription;
namespace Lab {
struct MapData;
struct Action;
struct CloseData;
struct Button;
struct IntuiMessage;
struct InventoryData;
struct RoomData;
struct Rule;
struct TextFont;
struct ViewData;
class Anim;
class DisplayMan;
class EventManager;
class Image;
class Music;
class Resource;
class TilePuzzle;
class Utils;
struct SaveGameHeader {
byte _version;
SaveStateDescriptor _descr;
uint16 _roomNumber;
uint16 _direction;
};
enum GameFeatures {
GF_LOWRES = 1 << 0,
GF_WINDOWS_TRIAL = 1 << 1
};
typedef Common::List<Button *> ButtonList;
struct CrumbData {
uint16 _roomNum;
uint16 _direction;
};
#define MAX_CRUMBS 128
typedef CloseData *CloseDataPtr;
typedef Common::List<Rule> RuleList;
enum Direction {
kDirectionNorth,
kDirectionSouth,
kDirectionEast,
kDirectionWest
};
enum MainButton {
kButtonNone = -1,
kButtonPickup,
kButtonUse,
kButtonOpen,
kButtonClose,
kButtonLook,
kButtonInventory,
kButtonLeft,
kButtonForward,
kButtonRight,
kButtonMap
};
class LabEngine : public Engine {
private:
bool _interfaceOff;
bool _isCrumbWaiting;
bool _lastTooLong;
bool _lastPage;
bool _mainDisplay;
bool _noUpdateDiff;
bool _quitLab;
byte *_blankJournal;
int _lastWaitTOFTicks;
uint16 _direction;
uint16 _highPalette[20];
uint16 _journalPage;
uint16 _maxRooms;
uint16 _monitorPage;
uint16 _monitorButtonHeight;
uint32 _extraGameFeatures;
Common::String _journalText;
Common::String _journalTextTitle;
Common::String _nextFileName;
Common::String _newFileName;
Common::String _monitorTextFilename;
CloseDataPtr _closeDataPtr;
ButtonList _journalButtonList;
ButtonList _mapButtonList;
Image *_imgMap, *_imgRoom, *_imgUpArrowRoom, *_imgDownArrowRoom, *_imgBridge;
Image *_imgHRoom, *_imgVRoom, *_imgMaze, *_imgHugeMaze, *_imgPath;
Image *_imgMapX[4];
InventoryData *_inventory;
MapData *_maps;
Image *_monitorButton;
Image *_journalBackImage;
TextFont *_journalFont;
public:
bool _alternate;
bool _droppingCrumbs;
bool _followingCrumbs;
bool _followCrumbsFast;
bool _isCrumbTurning;
bool _isHiRes;
int _roomNum;
uint16 _highestCondition;
uint16 _manyRooms;
uint16 _numCrumbs;
uint16 _numInv;
uint32 _crumbTimestamp;
Common::String _curFileName;
Anim *_anim;
CrumbData _breadCrumbs[MAX_CRUMBS];
DisplayMan *_graphics;
EventManager *_event;
ButtonList _invButtonList;
ButtonList _moveButtonList;
Image *_invImages[10];
Image *_moveImages[20];
LargeSet *_conditions, *_roomsFound;
Music *_music;
Resource *_resource;
RoomData *_rooms;
TextFont *_msgFont;
TilePuzzle *_tilePuzzle;
Utils *_utils;
Console *_console;
GUI::Debugger *getDebugger() { return _console; }
public:
LabEngine(OSystem *syst, const ADGameDescription *gameDesc);
~LabEngine();
virtual Common::Error run();
void go();
const ADGameDescription *_gameDescription;
Common::Platform getPlatform() const;
uint32 getFeatures() const;
bool hasFeature(EngineFeature f) const;
Common::String generateSaveFileName(uint slot);
void changeVolume(int delta);
uint16 getDirection() { return _direction; }
/**
* Returns the current picture name.
*/
Common::String getPictName(CloseDataPtr *closePtrList);
uint16 getQuarters();
void setDirection(uint16 direction) { _direction = direction; };
void setQuarters(uint16 quarters);
void updateMusicAndEvents();
void waitTOF();
private:
/**
* Checks whether all the conditions in a condition list are met.
*/
bool checkConditions(int16 *condition);
/**
* Decrements the current inventory number.
*/
void decIncInv(uint16 *CurInv, bool dec);
/**
* Processes the action list.
*/
void doActions(Action *actionList, CloseDataPtr *closePtrList);
/**
* Goes through the rules if an action is taken.
*/
bool doActionRule(Common::Point pos, int16 action, int16 roomNum, CloseDataPtr *closePtrList);
/**
* Does the work for doActionRule.
*/
bool doActionRuleSub(int16 action, int16 roomNum, CloseDataPtr closePtr, CloseDataPtr *setCloseList, bool allowDefaults);
/**
* Checks whether the close up is one of the special case closeups.
*/
bool doCloseUp(CloseDataPtr closePtr);
/**
* Goes through the rules if the user tries to go forward.
*/
bool doGoForward(CloseDataPtr *closePtrList);
/**
* Does the journal processing.
*/
void doJournal();
/**
* Goes through the rules if the user tries to go to the main view
*/
bool doMainView(CloseDataPtr *closePtrList);
/**
* Does the map processing.
*/
void doMap(uint16 curRoom);
/**
* Does what's necessary for the monitor.
*/
void doMonitor(const Common::String background, const Common::String textfile, bool isinteractive, Common::Rect textRect);
/**
* Does the things to properly set up the detective notes.
*/
void doNotes();
/**
* Does the work for doActionRule.
*/
bool doOperateRuleSub(int16 itemNum, int16 roomNum, CloseDataPtr closePtr, CloseDataPtr *setCloseList, bool allowDefaults);
/**
* Goes through the rules if the user tries to operate an item on an object.
*/
bool doOperateRule(Common::Point pos, int16 ItemNum, CloseDataPtr *closePtrList);
/**
* Goes through the rules if the user tries to turn.
*/
bool doTurn(uint16 from, uint16 to, CloseDataPtr *closePtrList);
/**
* If the user hits the "Use" button; things that can get used on themselves.
*/
bool doUse(uint16 curInv);
/**
* Does the things to properly set up the old west newspaper. Assumes that
* OpenHiRes already called.
*/
void doWestPaper();
/**
* Draws the current direction to the screen.
*/
void drawDirection(CloseDataPtr closePtr);
/**
* Draws the journal from page x.
*/
void drawJournal(uint16 wipenum, bool needFade);
/**
* Draws the text to the back journal screen to the appropriate Page number
*/
void drawJournalText();
/**
* Draws the map
*/
void drawMap(uint16 curRoom, uint16 curMsg, uint16 floorNum, bool fadeIn);
/**
* Draws the text for the monitor.
*/
void drawMonText(const char *text, TextFont *monitorFont, Common::Rect textRect, bool isinteractive);
/**
* Draws a room map.
*/
void drawRoomMap(uint16 curRoom, bool drawMarkFl);
/**
* Draws the message for the room.
*/
void drawRoomMessage(uint16 curInv, CloseDataPtr closePtr);
void drawStaticMessage(byte index);
/**
* Eats all the available messages.
*/
void eatMessages();
/**
* Goes through the list of closeups to find a match.
* @note Known bug here. If there are two objects that have closeups, and
* some of the closeups have the same hit boxes, then this returns the first
* occurrence of the object with the same hit box.
*/
CloseDataPtr findClosePtrMatch(CloseDataPtr closePtr, CloseDataPtr closePtrList);
/**
* Checks if a floor has been visited.
*/
bool floorVisited(uint16 floorNum);
/**
* New code to allow quick(er) return navigation in game.
*/
MainButton followCrumbs();
void freeMapData();
void freeScreens();
bool fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Common::Point tmpPos,
uint16 &curInv, IntuiMessage *curMsg, bool &forceDraw, uint16 buttonId, uint16 &actionMode);
/**
* Gets the current inventory name.
*/
Common::String getInvName(uint16 curInv);
/**
* Returns the floor to show when the down arrow is pressed
* @note The original did not show all the visited floors, but we do
*/
uint16 getLowerFloor(uint16 floorNum);
/**
* Gets an object, if any, from the user's click on the screen.
*/
CloseData *getObject(Common::Point pos, CloseDataPtr closePtr);
/**
* Returns the floor to show when the up arrow is pressed
* @note The original did not show all the visited floors, but we do
*/
uint16 getUpperFloor(uint16 floorNum);
/**
* Gets the current ViewDataPointer.
*/
ViewData *getViewData(uint16 roomNum, uint16 direction);
/**
* Turns the interface off.
*/
void interfaceOff();
/**
* Turns the interface on.
*/
void interfaceOn();
/**
* Loads in the data for the journal.
*/
void loadJournalData();
/**
* Loads in the map data.
*/
void loadMapData();
/**
* The main game loop.
*/
void mainGameLoop();
void showLab2Teaser();
void mayShowCrumbIndicator();
void mayShowCrumbIndicatorOff();
/**
* Permanently flips the imagery of a button.
*/
void perFlipButton(uint16 buttonId);
/**
* process a arrow button movement.
*/
uint16 processArrow(uint16 curDirection, uint16 arrow);
/**
* Processes user input.
*/
void processJournal();
/**
* Processes the map.
*/
void processMap(uint16 curRoom);
/**
* Processes user input.
*/
void processMonitor(const char *ntext, TextFont *monitorFont, bool isInteractive, Common::Rect textRect);
/**
* Figures out what a room's coordinates should be.
*/
Common::Rect roomCoords(uint16 curRoom);
bool saveRestoreGame();
/**
* Sets the current close up data.
*/
void setCurrentClose(Common::Point pos, CloseDataPtr *closePtrList, bool useAbsoluteCoords);
/**
* Takes the currently selected item.
*/
bool takeItem(Common::Point pos, CloseDataPtr *closePtrList);
/**
* Does the turn page wipe.
*/
void turnPage(bool fromLeft);
bool processKey(IntuiMessage *curMsg, uint32 &msgClass, uint16 &qualifier, Common::Point &curPos, uint16 &curInv, bool &forceDraw, uint16 code);
void processMainButton(uint16 &curInv, uint16 &lastInv, uint16 &oldDirection, bool &forceDraw, uint16 buttonId, uint16 &actionMode);
void processAltButton(uint16 &curInv, uint16 &lastInv, uint16 buttonId, uint16 &actionMode);
void performAction(uint16 actionMode, Common::Point curPos, uint16 &curInv);
private:
/**
* Writes the game out to disk.
*/
bool saveGame(int slot, const Common::String desc);
/**
* Reads the game from disk.
*/
bool loadGame(int slot);
void writeSaveGameHeader(Common::OutSaveFile *out, const Common::String &saveName);
};
bool readSaveGameHeader(Common::InSaveFile *in, SaveGameHeader &header);
} // End of namespace Lab
#endif // LAB_LAB_H
|