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
492
493
494
495
496
497
498
499
500
|
/* ScummVM - Scumm Interpreter
* Copyright (C) 2006 The ScummVM project
*
* 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 PARALLACTION_H
#define PARALLACTION_H
#include "engines/engine.h"
#include "parallaction/defs.h"
#include "parallaction/inventory.h"
#include "parallaction/parser.h"
#include "parallaction/disk.h"
#include "parallaction/zone.h"
#include "common/str.h"
#include "gui/dialog.h"
#include "gui/widget.h"
namespace GUI {
class ListWidget;
class CommandSender;
}
namespace Parallaction {
enum {
kDebugDisk = 1 << 0,
kDebugWalk = 1 << 1,
kDebugLocation = 1 << 2,
kDebugDialogue = 1 << 3,
kDebugGraphics = 1 << 4,
kDebugJobs = 1 << 5,
kDebugInput = 1 << 6
};
enum {
GF_DEMO = 1 << 0
};
// high values mean high priority
enum {
kPriority0 = 0,
kPriority1 = 1,
kPriority2 = 2,
kPriority3 = 3,
kPriority4 = 4,
kPriority5 = 5,
kPriority6 = 6,
kPriority7 = 7,
kPriority8 = 8,
kPriority9 = 9,
kPriority10 = 10,
kPriority11 = 11,
kPriority12 = 12,
kPriority13 = 13,
kPriority14 = 14,
kPriority15 = 15,
kPriority16 = 16,
kPriority17 = 17,
kPriority18 = 18,
kPriority19 = 19,
kPriority20 = 20,
kPriority21 = 21
};
enum {
kMouseNone = 0,
kMouseLeftUp = 1,
kMouseLeftDown = 2,
kMouseRightUp = 3,
kMouseRightDown = 4
};
enum ParallactionGameType {
GType_Nippon = 1,
GType_BRA
};
struct PARALLACTIONGameDescription;
struct Job;
typedef void (*JobFn)(void*, Job*);
struct Job : public Node {
uint16 _count; // # of executions left
uint16 _tag; // used for ordering
uint16 _finished;
void * _parm;
JobFn _fn;
public:
Job() : _count(0), _tag(0), _finished(0), _parm(NULL), _fn(NULL) {
}
};
struct Credit {
const char *_role;
const char *_name;
};
typedef void (*callable)(void*);
extern uint16 _mouseButtons;
extern uint16 _score;
extern uint16 _language;
extern Zone *_activeZone;
extern uint32 _engineFlags;
extern callable _callables[];
extern Node _zones;
extern Node _animations;
extern uint32 _localFlags[];
extern Command *_forwardedCommands[];
extern char _forwardedAnimationNames[][20];
extern uint16 _numForwards;
extern char _soundFile[];
extern char _slideText[][40];
extern uint16 _introSarcData3; // sarcophagus stuff to be saved
extern uint16 _introSarcData2; // sarcophagus stuff to be saved
extern char _saveData1[];
extern byte _mouseHidden;
extern uint32 _commandFlags;
extern const char *_instructionNamesRes[];
extern const char *_commandsNamesRes[];
extern const char *_dinoName;
extern const char *_donnaName;
extern const char *_doughName;
extern const char *_drkiName;
extern const char *_minidinoName;
extern const char *_minidonnaName;
extern const char *_minidoughName;
extern const char *_minidrkiName;
// Various ways of detecting character modes used to exist
// inside the engine, so they have been unified in the two
// following macros.
// Mini characters are those used in far away shots, like
// the highway scenery, while Dummy characters are a mere
// workaround to keep the engine happy when showing slides.
// As a sidenote, standard sized characters' names start
// with a lowercase 'd'.
#define IS_MINI_CHARACTER(s) (((s)[0] == 'm'))
#define IS_DUMMY_CHARACTER(s) (((s)[0] == 'D'))
#define PATH_LEN 200
void waitUntilLeftClick();
void addNode(Node *list, Node *n);
void removeNode(Node *n);
void freeNodeList(Node *list);
void jobRemovePickedItem(void*, Job *j);
void jobDisplayDroppedItem(void*, Job *j);
void jobToggleDoor(void*, Job *j);
void jobEraseAnimations(void *arg_0, Job *j);
void jobWalk(void*, Job *j);
void jobRunScripts(void*, Job *j);
void jobDisplayAnimations(void*, Job *j);
void jobDisplayLabel(void *parm, Job *j);
void jobWaitRemoveJob(void *parm, Job *j);
void jobShowInventory(void *parm, Job *j);
void jobHideInventory(void *parm, Job *j);
void jobEraseLabel(void *parm, Job *j);
enum EngineFlags {
kEngineQuit = (1 << 0),
kEnginePauseJobs = (1 << 1),
kEngineInventory = (1 << 2),
kEngineWalking = (1 << 3),
kEngineChangeLocation = (1 << 4),
kEngineMouse = (1 << 5),
kEngineDragging = (1 << 6),
kEngineTransformedDonna = (1 << 7)
};
enum {
kEvNone = 0,
kEvEnterZone = 1,
kEvExitZone = 2,
kEvAction = 3,
kEvOpenInventory = 4,
kEvCloseInventory = 5,
kEvHoverInventory = 6,
kEvWalk = 7,
kEvQuitGame = 1000,
kEvSaveGame = 2000,
kEvLoadGame = 4000
};
enum {
kCursorArrow = -1
};
class Gfx;
class Menu;
class MidiPlayer;
struct Location {
Common::Point _startPosition;
uint16 _startFrame;
Node _walkNodes;
char _name[100];
Command *_aCommands;
Command *_commands;
char *_comment;
char *_endComment;
};
struct Character {
Animation _ani;
StaticCnv *_head;
Cnv *_talk;
Cnv *_objs;
Character() {
_talk = NULL;
// ._width = 0;
// _talk._height = 0;
// _talk._count = 0;
_head = NULL;
// _head._width = 0;
// _head._height = 0;
// _head._data0 = NULL;
// _head._data1 = NULL;
_objs = NULL;
// _objs._count = 0;
_ani._left = 150;
_ani._top = 100;
_ani._z = 10;
_ani._oldPos.x = -1000;
_ani._oldPos.y = -1000;
_ani._frame = 0;
_ani._flags = kFlagsActive | kFlagsNoName;
_ani._type = kZoneYou;
_ani._label._cnv._data0 = NULL;
_ani._label._text = strdup("yourself");
}
};
class Table {
char **_data;
uint16 _size;
uint16 _used;
bool _disposeMemory;
public:
Table(uint32 size);
Table(uint32 size, const char** data);
~Table();
void addData(const char* s);
int16 lookup(const char* s);
};
class Parallaction : public Engine {
public:
Parallaction(OSystem *syst);
~Parallaction();
int init();
int go();
void loadGame();
void saveGame();
uint16 updateInput();
void waitTime(uint32 t);
// static void initTable(const char *path, char **table);
// static void freeTable(char** table);
// static int16 searchTable(const char *s, const char **table);
void freeCommands(Command*);
void parseLocation(const char *filename);
void changeCursor(int32 index);
void changeCharacter(const char *name);
char *parseComment(Script &script);
char *parseDialogueString(Script &script);
Dialogue *parseDialogue(Script &script);
Job *addJob(JobFn fn, void *parm, uint16 tag);
void removeJob(Job *j);
void pauseJobs();
void resumeJobs();
void runJobs();
Table *_globalTable;
Table *_objectsNames;
Table *_zoneTypeNames;
Table *_zoneFlagNames;
Table *_commandsNames;
Table *_callableNames;
Table *_instructionNames;
Table *_localFlagNames;
void freeZones(Node *list);
Animation *findAnimation(const char *name);
Zone *findZone(const char *name);
Zone *hitZone(uint32 type, uint16 x, uint16 y);
void freeAnimations();
void sortAnimations();
void freeLocation();
uint16 runZone(Zone*);
void runDialogue(SpeakData*);
void freeDialogue(Dialogue *d);
void runCommands(Command *list, Zone *z = NULL);
public:
int getGameType() const;
uint32 getFeatures() const;
Common::Language getLanguage() const;
Common::Platform getPlatform() const;
private:
const PARALLACTIONGameDescription *_gameDescription;
public:
MidiPlayer *_midiPlayer;
Gfx* _gfx;
Menu* _menu;
char _characterName[30];
Disk* _disk;
char _locationNames[120][32];
int16 _currentLocationIndex;
uint16 _numLocations;
Character _char;
Location _location;
InventoryItem _activeItem;
Script *_locationScript;
Common::Point _mousePos;
Node _zones;
Node _animations;
protected: // data
struct InputData {
uint16 _event;
Common::Point _mousePos;
int16 _inventoryIndex;
Zone* _zone;
Label* _label;
};
bool _skipMenu;
// input-only
InputData _input;
bool _actionAfterWalk; // actived when the character needs to move before taking an action
// these two could/should be merged as they carry on the same duty in two member functions,
// respectively processInput and translateInput
int16 _procCurrentHoverItem;
int16 _transCurrentHoverItem;
uint32 _baseTime;
uint16 _musicData1; // only used in changeLocation
char _characterName1[50]; // only used in changeCharacter
int16 _keyDown;
Job _jobs;
Node helperNode; // used for freeZones
protected: // members
bool detectGame(void);
void initGame();
void initGlobals();
Common::String _saveFileName;
int buildSaveFileList(Common::StringList& l);
int selectSaveFile(uint16 arg_0, const char* caption, const char* button);
void doLoadGame(uint16 slot);
void doSaveGame(uint16 slot, const char* name);
void runGame();
InputData * translateInput();
void processInput(InputData*);
int16 getHoverInventoryItem(int16 x, int16 y);
uint32 getElapsedTime();
void resetTimer();
void doLocationEnterTransition();
void parseZone(Script &script, Node *list, char *name);
Animation * parseAnimation(Script &script, Node *list, char *name);
void parseScriptLine(Instruction *inst, Animation *a, LocalVariable *locals);
void parseZoneTypeBlock(Script &script, Zone *z);
void loadProgram(Animation *a, char *filename);
void changeLocation(char *location);
void showSlide(const char *name);
void pickMusic(const char *location);
void selectCharacterMusic(const char *name);
Command *parseCommands(Script &script);
void freeCharacter();
void initResources();
};
// FIXME: remove global
extern Parallaction *_vm;
class SaveLoadChooser : public GUI::Dialog {
typedef Common::String String;
typedef Common::StringList StringList;
protected:
GUI::ListWidget *_list;
GUI::ButtonWidget *_chooseButton;
GUI::GraphicsWidget *_gfxWidget;
GUI::StaticTextWidget *_date;
GUI::StaticTextWidget *_time;
GUI::StaticTextWidget *_playtime;
GUI::ContainerWidget *_container;
Parallaction *_vm;
uint8 _fillR, _fillG, _fillB;
public:
SaveLoadChooser(const String &title, const String &buttonLabel, Parallaction *engine);
~SaveLoadChooser();
virtual void handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data);
const String &getResultString() const;
void setList(const StringList& list);
int runModal();
virtual void reflowLayout();
};
} // namespace Parallaction
#endif
|