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
|
/* 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_ZONE_H
#define PARALLACTION_ZONE_H
#include "parallaction/defs.h"
namespace Parallaction {
enum ZoneTypes {
kZoneExamine = 1, // zone displays comment if activated
kZoneDoor = 2, // zone activated on click (after some walk if needed)
kZoneGet = 4, // for pickable items
kZoneMerge = 8, // tags items which can be merged in inventory
kZoneTaste = 0x10, // NEVER USED
kZoneHear = 0x20, // NEVER USED: they ran out of time before integrating sfx
kZoneFeel = 0x40, // NEVER USED
kZoneSpeak = 0x80, // tags NPCs the character can talk with
kZoneNone = 0x100, // used to prevent parsing on peculiar Animations
kZoneTrap = 0x200, // zone activated when character enters
kZoneYou = 0x400, // marks the character
kZoneCommand = 0x800
};
enum ZoneFlags {
kFlagsClosed = 1, // Zone: door is closed / switch is off
kFlagsActive = 2, // Zone/Animation: object is visible
kFlagsRemove = 4, // Zone/Animation: object is soon to be removed
kFlagsActing = 8, // Animation: script execution is active
kFlagsLocked = 0x10, // Zone: door or switch cannot be toggled
kFlagsFixed = 0x20, // Zone: Zone item cannot be picked up
kFlagsNoName = 0x40, // Zone with no name (used to prevent some kEvEnterZone events)
kFlagsNoMasked = 0x80, // Animation is to be drawn ignoring z buffer
kFlagsLooping = 0x100, // Animation: script is to be executed repeatedly
kFlagsAdded = 0x200, // NEVER USED in Nippon Safes
kFlagsCharacter = 0x400, //
kFlagsNoWalk = 0x800 // Zone: character doesn't need to walk towards object to interact
};
#define NUM_ANSWERS 5
struct Question {
char* _text;
char* _answers[NUM_ANSWERS];
uint16 _mood;
uint16 _answer_moods[NUM_ANSWERS];
union {
Question* _questions[NUM_ANSWERS];
char* _names[NUM_ANSWERS];
} _following;
Command* _commands[NUM_ANSWERS];
uint32 _noFlags[NUM_ANSWERS];
uint32 _yesFlags[NUM_ANSWERS];
Question() {
_text = NULL;
_mood = 0;
for (uint32 i = 0; i < NUM_ANSWERS; i++) {
_answers[i] = NULL;
_answer_moods[i] = 0;
_following._questions[i] = NULL;
_commands[i] = NULL;
_noFlags[i] = 0;
_yesFlags[i] = 0;
}
}
};
struct GetData { // size = 24
uint32 _icon;
StaticCnv _cnv;
byte *_backup;
uint16 field_14; // unused
uint16 field_16; // unused
GetData() {
_icon = 0;
_backup = NULL;
}
};
struct SpeakData { // size = 36
char _name[32];
Dialogue *_dialogue;
SpeakData() {
_name[0] = '\0';
_dialogue = NULL;
}
};
struct ExamineData { // size = 28
StaticCnv _cnv;
uint16 _opBase; // unused
uint16 field_12; // unused
char* _description;
char* _filename;
ExamineData() {
_opBase = 0;
_description = NULL;
_filename = NULL;
}
};
struct DoorData { // size = 28
char* _location;
Cnv _cnv;
byte* _background;
Common::Point _startPos;
uint16 _startFrame;
DoorData() {
_location = NULL;
_background = NULL;
_startFrame = 0;
}
};
struct HearData { // size = 20
char _name[20];
HearData() {
_name[0] = '\0';
}
};
struct MergeData { // size = 12
uint32 _obj1;
uint32 _obj2;
uint32 _obj3;
MergeData() {
_obj1 = _obj2 = _obj3 = 0;
}
};
struct TypeData {
GetData *get;
SpeakData *speak;
ExamineData *examine;
DoorData *door;
HearData *hear;
MergeData *merge;
TypeData() {
get = NULL;
speak = NULL;
examine = NULL;
door = NULL;
hear = NULL;
merge = NULL;
}
};
struct Label {
char* _text;
StaticCnv _cnv;
Label() {
_text = NULL;
}
};
struct Zone : public Node {
int16 _left;
int16 _top;
int16 _right;
int16 _bottom;
int16 _oldLeft;
int16 _oldTop;
uint32 _type;
uint32 _flags;
Label _label;
uint16 field_2C; // unused
uint16 field_2E; // unused
TypeData u;
Command *_commands;
Common::Point _moveTo;
Zone() {
_left = _top = _right = _bottom = 0;
_oldLeft = _oldTop = 0;
_type = 0;
_flags = 0;
_commands = NULL;
}
void getRect(Common::Rect& r) const {
r.left = _left;
r.right = _right;
r.top = _top;
r.bottom = _bottom;
}
void translate(int16 x, int16 y) {
_left += x;
_right += x;
_top += y;
_bottom += y;
}
uint16 width() const {
return _right - _left;
}
uint16 height() const {
return _bottom - _top;
}
};
struct LocalVariable {
int16 _value;
int16 _min;
int16 _max;
LocalVariable() {
_value = 0;
_min = -10000;
_max = 10000;
}
};
union LValue {
int16 _value;
int16* _pvalue;
LocalVariable* _local;
LValue() {
_local = NULL;
}
};
enum InstructionFlags {
kInstUsesLiteral = 1,
kInstUsesLocal = 2,
kInstMod = 4,
kInstMaskedPut = 8
};
struct Instruction : public Node {
uint32 _index;
uint32 _flags;
struct {
Animation *_a;
Zone *_z;
uint32 _index;
LValue _loopCounter;
} _opBase;
LValue _opA;
LValue _opB;
Instruction() {
_index = 0;
_flags = 0;
_opBase._a = NULL;
}
};
struct Program : public Node {
LocalVariable *_locals;
uint16 _loopCounter;
Instruction *_ip;
Instruction *_loopStart;
Program() {
_locals = NULL;
_loopCounter = 0;
_ip = NULL;
_loopStart = NULL;
}
};
struct Animation {
Zone _zone;
Program *_program;
Cnv _cnv;
int16 _frame;
uint16 field_50; // unused
int16 _z;
uint16 field_54; // unused
uint16 field_56; // unused
uint16 field_58; // unused
uint16 field_5A; // unused
uint16 field_5C; // unused
uint16 field_5E; // unused
Animation() {
// FIXME: temporary hack until Animation become a subclass of Zone
_zone._left = _zone._top = _zone._right = _zone._bottom = 0;
_zone._oldLeft = _zone._oldTop = 0;
_zone._type = 0;
_zone._flags = 0;
_zone._commands = NULL;
_program = NULL;
_frame = 0;
_z = 0;
}
uint16 width() const {
return _cnv._width;
}
uint16 height() const {
return _cnv._height;
}
uint16 getFrameNum() {
return _cnv._count;
}
byte* getFrameData(uint32 index) {
return _cnv.getFramePtr(index);
}
};
uint16 runZone(Zone *z);
void dropItem(uint16 v);
int16 pickupItem(Zone *z);
uint16 checkDoor();
void loadProgram(Animation *, char *filename);
} // namespace Parallaction
#endif
|