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
|
/* 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 TOON_H
#define TOON_H
#include "engines/advancedDetector.h"
#include "engines/engine.h"
#include "graphics/surface.h"
#include "common/random.h"
#include "toon/resource.h"
#include "toon/script.h"
#include "toon/script_func.h"
#include "toon/state.h"
#include "toon/picture.h"
#include "toon/anim.h"
#include "toon/movie.h"
#include "toon/font.h"
#include "toon/text.h"
#include "toon/audio.h"
#define TOON_DAT_VER_MAJ 0 // 1 byte
#define TOON_DAT_VER_MIN 3 // 1 byte
#define TOON_SAVEGAME_VERSION 4
#define DATAALIGNMENT 4
namespace Toon {
enum ToonGameType {
GType_TOON = 1
};
enum ToonDebugChannels {
kDebugAnim = 1 << 0,
kDebugCharacter = 1 << 1,
kDebugAudio = 1 << 2,
kDebugHotspot = 1 << 3,
kDebugFont = 1 << 4,
kDebugPath = 1 << 5,
kDebugMovie = 1 << 6,
kDebugPicture = 1 << 7,
kDebugResource = 1 << 8,
kDebugState = 1 << 9,
kDebugTools = 1 << 10,
kDebugText = 1 << 11
};
class Picture;
class Movie;
class Hotspots;
class Character;
class CharacterDrew;
class CharacterFlux;
class FontRenderer;
class TextResource;
class AudioManager;
class PathFinding;
class ToonEngine : public Engine {
public:
ToonEngine(OSystem *syst, const ADGameDescription *gameDescription);
~ToonEngine();
const ADGameDescription *_gameDescription;
Common::Language _language;
byte _numVariant;
byte _gameVariant;
char **_locationDirNotVisited;
char **_locationDirVisited;
char **_specialInfoLine;
virtual Common::Error run();
virtual bool showMainmenu(bool &loadedGame);
virtual void init();
bool loadToonDat();
char **loadTextsVariante(Common::File &in);
virtual void setPaletteEntries(uint8 *palette, int32 offset, int32 num);
virtual void fixPaletteEntries(uint8 *palette, int num);
virtual void flushPalette();
virtual void parseInput();
virtual void initChapter();
virtual void initFonts();
virtual void loadScene(int32 SceneId, bool forGameLoad = false);
virtual void exitScene();
virtual void loadCursor();
virtual void setCursor(int32 type, bool inventory = false, int32 offsetX = 0, int offsetY = 0);
virtual void loadAdditionalPalette(Common::String fileName, int32 mode);
virtual void setupGeneralPalette();
virtual void render();
virtual void update(int32 timeIncrement);
virtual void doFrame();
virtual void updateAnimationSceneScripts(int32 timeElapsed);
virtual void updateCharacters(int32 timeElapsed);
virtual void setSceneAnimationScriptUpdate(bool enable);
virtual bool isUpdatingSceneAnimation();
virtual int32 getCurrentUpdatingSceneAnimation();
virtual int32 randRange(int32 minStart, int32 maxStart);
virtual void selectHotspot();
virtual void clickEvent();
virtual int32 runEventScript(int32 x, int32 y, int32 mode, int32 id, int32 scriptId);
virtual void flipScreens();
virtual void drawInfoLine();
virtual void drawConversationLine();
virtual const char *getLocationString(int32 locationId, bool alreadyVisited);
virtual int32 getScaleAtPoint(int32 x, int32 y);
virtual int32 getZAtPoint(int32 x, int32 y);
virtual int32 getLayerAtPoint(int32 x, int32 y);
virtual int32 characterTalk(int32 dialogid, bool blocking = true);
virtual int32 simpleCharacterTalk(int32 dialogid);
virtual void sayLines(int numLines, int dialogId);
virtual void haveAConversation(int32 convId);
virtual void processConversationClick(Conversation *conv, int32 status);
virtual int32 runConversationCommand(int16 **command);
virtual void prepareConversations();
virtual void drawConversationIcons();
virtual void simpleUpdate();
virtual int32 waitTicks(int32 numTicks, bool breakOnMouseClick);
virtual void copyToVirtualScreen(bool updateScreen = true);
virtual void getMouseEvent();
virtual int32 showInventory();
virtual void drawSack();
virtual void addItemToInventory(int32 item);
virtual void deleteItemFromInventory(int32 item);
virtual void replaceItemFromInventory(int32 item, int32 destItem);
virtual void rearrangeInventory();
virtual void createMouseItem(int32 item);
virtual void deleteMouseItem();
virtual void showCutaway(Common::String cutawayPicture);
virtual void hideCutaway();
virtual void drawPalette();
virtual void newGame();
virtual void playSoundWrong();
virtual void playSFX(int32 id, int32 volume);
virtual void storeRifFlags(int32 location);
virtual void restoreRifFlags(int32 location);
virtual void getTextPosition(int32 characterId, int32 *retX, int32 *retY);
virtual int32 getConversationFlag(int32 locationId, int32 param);
virtual int32 getSpecialInventoryItem(int32 item);
virtual Character *getCharacterById(int32 charId);
virtual Common::String getSavegameName(int nr);
virtual bool loadGame(int32 slot);
virtual bool saveGame(int32 slot);
virtual void fadeIn(int32 numFrames) ;
virtual void fadeOut(int32 numFrames) ;
virtual void initCharacter(int32 characterId, int32 animScriptId, int32 animToPlayId, int32 sceneAnimationId);
virtual int32 handleInventoryOnFlux(int32 itemId);
virtual int32 handleInventoryOnInventory(int32 itemDest, int32 itemSrc);
virtual int32 handleInventoryOnDrew(int32 itemId);
virtual int32 pauseSceneAnimationScript(int32 animScriptId, int32 tickToWait);
virtual void updateTimer(int32 timeIncrement);
virtual Common::String createRoomFilename(Common::String name);
virtual void createShadowLUT();
virtual void playTalkAnimOnCharacter(int32 animID, int32 characterId, bool talker);
virtual void updateScrolling(bool force, int32 timeIncrement);
virtual void enableTimer(int32 timerId);
virtual void setTimer(int32 timerId, int32 timerWait);
virtual void disableTimer(int32 timerId);
virtual void updateTimers();
virtual void makeLineNonWalkable(int32 x, int32 y, int32 x2, int32 y2);
virtual void makeLineWalkable(int32 x, int32 y, int32 x2, int32 y2);
virtual void renderInventory();
virtual void viewInventoryItem(Common::String str, int32 lineId, int32 itemDest);
virtual void storePalette();
virtual void restorePalette();
virtual const char *getSpecialConversationMusic(int32 locationId);
virtual void playRoomMusic();
Resources *resources() {
return _resources;
}
State *state() {
return _gameState;
}
Graphics::Surface &getMainSurface() {
return *_mainSurface;
}
Picture *getMask() {
return _currentMask;
}
Picture *getPicture() {
return _currentPicture;
}
AnimationManager *getAnimationManager() {
return _animationManager;
}
Movie *getMoviePlayer() {
return _moviePlayer;
}
SceneAnimation *getSceneAnimation(int32 id) {
return &_sceneAnimations[id];
}
SceneAnimationScript *getSceneAnimationScript(int32 id) {
return &_sceneAnimationScripts[id];
}
EMCInterpreter *getScript() {
return _script;
}
Hotspots *getHotspots() {
return _hotspots;
}
Character *getCharacter(int32 charId) {
return _characters[charId];
}
uint8 *getShadowLUT() {
return _shadowLUT;
}
int32 getCurrentLineToSay() {
return _currentTextLineId;
}
CharacterDrew *getDrew() {
return (CharacterDrew *)_drew;
}
CharacterFlux *getFlux() {
return (CharacterFlux *)_flux;
}
int32 getTickLength() {
return _tickLength;
}
int32 getOldMilli() {
return _oldTimer2;
}
OSystem *getSystem() {
return _system;
}
AudioManager *getAudioManager() {
return _audioManager;
}
int32 getScriptRegionNested() {
return _currentScriptRegion;
}
int32 getMouseX() {
return _mouseX;
}
int32 getMouseY() {
return _mouseY;
}
PathFinding *getPathFinding() {
return _pathFinding;
}
Common::WriteStream *getSaveBufferStream() {
return _saveBufferStream;
}
protected:
OSystem *_system;
int32 _tickLength;
Resources *_resources;
TextResource *_genericTexts;
TextResource *_roomTexts;
State *_gameState;
uint8 *_finalPalette;
uint8 *_backupPalette;
uint8 *_additionalPalette1;
uint8 *_additionalPalette2;
uint8 *_cutawayPalette;
uint8 *_universalPalette;
uint8 *_fluxPalette;
uint8 *_roomScaleData;
uint8 *_shadowLUT;
Picture *_currentPicture;
Picture *_currentMask;
Picture *_currentCutaway;
Picture *_inventoryPicture;
PathFinding *_pathFinding;
EMCInterpreter *_script;
EMCData _scriptData;
EMCState _scriptState[4];
int32 _currentScriptRegion; // script region ( nested script run )
ScriptFunc *_script_func;
SceneAnimation _sceneAnimations[64];
SceneAnimationScript _sceneAnimationScripts[64];
int32 _lastProcessedSceneScript;
bool _animationSceneScriptRunFlag;
bool _updatingSceneScriptRunFlag;
Graphics::Surface *_mainSurface;
AnimationInstance *_cursorAnimationInstance;
Animation *_cursorAnimation;
Animation *_dialogIcons;
Animation *_inventoryIcons;
Animation *_inventoryIconSlots;
int32 _cursorOffsetX;
int32 _cursorOffsetY;
char *_currentTextLine;
int32 _currentTextLineId;
int32 _currentTextLineX;
int32 _currentTextLineY;
int32 _currentTextLineCharacterId;
int32 _oldScrollValue;
AnimationManager *_animationManager;
Character *_characters[32];
Character *_drew;
Character *_flux;
Hotspots *_hotspots;
int32 _currentHotspotItem;
int32 _mouseX;
int32 _mouseY;
int32 _mouseButton;
int32 _lastMouseButton;
int32 _oldTimer;
int32 _oldTimer2;
Movie *_moviePlayer;
Common::RandomSource _rnd;
FontRenderer *_fontRenderer;
Animation *_fontToon;
Animation *_fontEZ;
AudioManager *_audioManager;
Common::MemoryWriteStreamDynamic *_saveBufferStream;
int16 *_conversationData;
bool _firstFrame;
bool _isDemo;
};
} // End of namespace Toon
#endif
|