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
|
/* 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 M4_GLOBALS_H
#define M4_GLOBALS_H
#include "common/array.h"
#include "common/rect.h"
#include "common/scummsys.h"
#include "common/file.h"
#include "common/ptr.h"
namespace M4 {
class MadsM4Engine;
class M4Engine;
class MadsEngine;
class ScriptInterpreter;
class ScriptFunction;
// Globals
enum WoodScriptGlobals {
kGlobTime = 0,
kGlobTimeDelta = 1,
kGlobMinY = 2,
kGlobMaxY = 3,
kGlobMinScale = 4,
kGlobMaxScale = 5,
kGlobScaler = 6,
kGlobTemp1 = 7,
kGlobTemp2 = 8,
kGlobTemp3 = 9,
kGlobTemp4 = 10,
kGlobTemp5 = 11,
kGlobTemp6 = 12,
kGlobTemp7 = 13,
kGlobTemp8 = 14,
kGlobTemp9 = 15,
kGlobTemp10 = 16,
kGlobTemp11 = 17,
kGlobTemp12 = 18,
kGlobTemp13 = 19,
kGlobTemp14 = 20,
kGlobTemp15 = 21,
kGlobTemp16 = 22,
kGlobTemp17 = 23,
kGlobTemp18 = 24,
kGlobTemp19 = 25,
kGlobTemp20 = 26,
kGlobTemp21 = 27,
kGlobTemp22 = 28,
kGlobTemp23 = 29,
kGlobTemp24 = 30,
kGlobTemp25 = 31,
kGlobTemp26 = 32,
kGlobTemp27 = 33,
kGlobTemp28 = 34,
kGlobTemp29 = 35,
kGlobTemp30 = 36,
kGlobTemp31 = 37,
kGlobTemp32 = 38
};
const uint32 SERIES_FORWARD = 0;
const uint32 SERIES_PINGPONG = 1;
const uint32 SERIES_BACKWARD = 2;
const uint32 SERIES_RANDOM = 4;
const uint32 SERIES_NO_TOSS = 8;
const uint32 SERIES_STICK = 16;
const uint32 SERIES_LOOP_TRIGGER = 32;
const uint32 SERIES_LOAD_PALETTE = 64;
const uint32 SERIES_HORZ_FLIP =128;
enum KernelTriggerType {
KT_PARSE = 1,
KT_DAEMON,
KT_PREPARSE
};
class Kernel {
private:
MadsM4Engine *_vm;
ScriptFunction *_globalDaemonFn, *_globalParserFn;
ScriptFunction *_sectionInitFn, *_sectionDaemonFn, *_sectionParserFn;
ScriptFunction *_roomInitFn, *_roomDaemonFn, *_roomPreParserFn, *_roomParserFn;
void pauseEngines();
void unpauseEngines();
public:
Kernel(MadsM4Engine *vm);
// TODO: Move to some palette/fading class
int fadeUpDuration, firstFadeColorIndex;
int minPalEntry, maxPalEntry;
bool paused;
//machine* myWalker;
bool repeatedlyCallDeamon;
bool daemonTriggerAvailable;
bool betweenRooms;
int currentSection, newSection, previousSection;
int currentRoom, newRoom, previousRoom;
int32 trigger;
KernelTriggerType triggerMode;
int32 createTrigger(int32 triggerNum);
bool sendTrigger(int32 triggerNum);
bool handleTrigger(int32 triggerNum);
void loadGlobalScriptFunctions();
void loadSectionScriptFunctions();
void loadRoomScriptFunctions();
void globalDaemon();
void globalParser();
void sectionInit();
void sectionDaemon();
void sectionParser();
void roomInit();
void roomDaemon();
void roomPreParser();
void roomParser();
void pauseGame(bool value);
};
#define TOTAL_NUM_VARIABLES 256
#define PLAYER_INVENTORY 2
enum MADSArticles {
kArticleNone = 0,
kArticleWith = 1,
kArticleTo = 2,
kArticleAt = 3,
kArticleFrom = 4,
kArticleOn = 5,
kArticleIn = 6,
kArticleUnder = 7,
kArticleBehind = 8
};
struct VocabEntry {
uint8 flags1;
uint8 flags2;
uint16 vocabId;
};
class MadsObject {
public:
MadsObject() {};
MadsObject(Common::SeekableReadStream *stream);
void load(Common::SeekableReadStream *stream);
bool isInInventory() const { return roomNumber == PLAYER_INVENTORY; };
uint16 descId;
uint16 roomNumber;
MADSArticles article;
uint8 vocabCount;
VocabEntry vocabList[3];
};
typedef Common::Array<Common::SharedPtr<MadsObject> > MadsObjectArray;
class Globals {
private:
MadsM4Engine *_vm;
public:
Globals(MadsM4Engine *vm);
virtual ~Globals() {};
bool isInterfaceVisible();
};
class M4Globals : public Globals {
private:
M4Engine *_vm;
public:
M4Globals(M4Engine *vm);
virtual ~M4Globals() {};
bool invSuppressClickSound;
};
enum RexPlayerSex { SEX_MALE = 0, SEX_FEMALE = 2, SEX_UNKNOWN = 1};
class MadsGlobals : public Globals {
private:
struct MessageItem {
uint32 id;
uint32 offset;
uint16 uncompSize;
uint16 compSize;
};
MadsEngine *_vm;
Common::Array<char* > _madsVocab;
Common::Array<char* > _madsQuotes;
Common::Array<MessageItem* > _madsMessages;
MadsObjectArray _madsObjects;
Common::List<int> _visitedScenes;
public:
MadsGlobals(MadsEngine *vm);
~MadsGlobals();
// MADS variables
int _globals[TOTAL_NUM_VARIABLES];
bool easyMouse;
bool invObjectsStill;
bool textWindowStill;
int storyMode;
bool playerSpriteChanged;
void loadMadsVocab();
uint32 getVocabSize() { return _madsVocab.size(); }
const char *getVocab(uint32 index) {
// Vocab list is 1-based, so always subtract one from index provided
assert((index > 0) && (index <= _madsVocab.size()));
return _madsVocab[index - 1];
}
void loadMadsQuotes();
uint32 getQuotesSize() { return _madsQuotes.size(); }
const char *getQuote(uint32 index) { return _madsQuotes[index]; }
void loadMadsMessagesInfo();
uint32 getMessagesSize() { return _madsMessages.size(); }
int messageIndexOf(uint32 messageId);
const char *loadMessage(uint index);
void loadMadsObjects();
uint32 getObjectsSize() { return _madsObjects.size(); }
MadsObject *getObject(uint32 index) { return _madsObjects[index].get(); }
void addVisitedScene(int sceneNumber);
bool isSceneVisited(int sceneNumber);
void removeVisitedScene(int sceneNumber);
};
#define PLAYER_FIELD_LENGTH 40
class Player {
public:
Player(MadsM4Engine *vm);
void setCommandsAllowed(bool value);
// Variables
Common::Point position; // Player's current position
int facing; // Facing direction
char verb[PLAYER_FIELD_LENGTH]; // Action strings
char noun[PLAYER_FIELD_LENGTH];
char prep[PLAYER_FIELD_LENGTH];
char object[PLAYER_FIELD_LENGTH];
Common::String assetName, shadowName;
int walkerType, shadowType;
bool needToWalk, readyToWalk, waitingForWalk;
bool commandsAllowed;
bool commandReady;
bool visible;
bool beenInRoomBefore;
bool walkerInCurrentRoom;
int32 walkerTriggerNum;
int walkFacing;
bool setCommandsAllowedFlag;
bool said(const char *word1, const char *word2 = NULL, const char *word3 = NULL);
bool saidAny(const char *word1, const char *word2, const char *word3,
const char *word4, const char *word5, const char *word6, const char *word7,
const char *word8, const char *word9, const char *word10);
private:
MadsM4Engine *_vm;
};
} // End of namespace M4
#endif
|