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
|
/* 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$
*
*/
// Scene management module private header file
#ifndef SAGA_SCENE_H
#define SAGA_SCENE_H
#include "saga/font.h"
#include "saga/list.h"
#include "saga/actor.h"
#include "saga/interface.h"
namespace Saga {
//#define SCENE_DEBUG // for scene debugging
#define SCENE_DOORS_MAX 16
#define NO_CHAPTER_CHANGE -2
class ObjectMap;
struct Event;
enum SceneFlags {
kSceneFlagISO = 1,
kSceneFlagShowCursor = 2
};
struct BGInfo {
Rect bounds;
byte *buffer;
size_t bufferLength;
};
typedef int (SceneProc) (int, void *);
enum SCENE_PROC_PARAMS {
SCENE_BEGIN = 0,
SCENE_END
};
// Resource type numbers
enum SAGAResourceTypes {
SAGA_UNKNOWN,
SAGA_ACTOR,
SAGA_OBJECT,
SAGA_BG_IMAGE,
SAGA_BG_MASK,
SAGA_STRINGS,
SAGA_OBJECT_MAP,
SAGA_ACTION_MAP,
SAGA_ISO_IMAGES,
SAGA_ISO_MAP,
SAGA_ISO_PLATFORMS,
SAGA_ISO_METATILES,
SAGA_ENTRY,
SAGA_ANIM,
SAGA_ISO_MULTI,
SAGA_PAL_ANIM,
SAGA_FACES,
SAGA_PALETTE
};
#define SAGA_RESLIST_ENTRY_LEN 4
struct SceneResourceData {
uint32 resourceId;
int resourceType;
byte *buffer;
size_t size;
bool invalid;
};
#define SAGA_SCENE_DESC_LEN 16
struct SceneDescription {
int16 flags;
int16 resourceListResourceId;
int16 endSlope;
int16 beginSlope;
uint16 scriptModuleNumber;
uint16 sceneScriptEntrypointNumber;
uint16 startScriptEntrypointNumber;
int16 musicResourceId;
SceneResourceData *resourceList;
size_t resourceListCount;
};
struct SceneEntry {
Location location;
int facing;
};
struct SceneEntryList {
SceneEntry *entryList;
int entryListCount;
const SceneEntry * getEntry(int index) {
if ((index < 0) || (index >= entryListCount)) {
error("SceneEntryList::getEntry wrong index (%d)", index);
}
return &entryList[index];
}
void freeMem() {
free(entryList);
memset(this, 0, sizeof(*this));
}
SceneEntryList() {
memset(this, 0, sizeof(*this));
}
~SceneEntryList() {
freeMem();
}
};
struct SceneImage {
int loaded;
int w;
int h;
int p;
byte *buf;
size_t buf_len;
byte *res_buf;
size_t res_len;
PalEntry pal[256];
};
enum SceneTransitionType {
kTransitionNoFade,
kTransitionFade
};
enum SceneLoadFlags {
kLoadByResourceId,
kLoadBySceneNumber,
kLoadByDescription
};
struct LoadSceneParams {
int32 sceneDescriptor;
SceneLoadFlags loadFlag;
SceneDescription* sceneDescription;
SceneProc *sceneProc;
bool sceneSkipTarget;
SceneTransitionType transitionType;
int actorsEntrance;
int chapter;
};
typedef Common::List<LoadSceneParams> SceneQueueList;
///// IHNM-specific stuff
#define IHNM_PALFADE_TIME 1000
#define IHNM_INTRO_FRAMETIME 80
#define IHNM_DGLOGO_TIME 8000
#define IHNM_TITLE_TIME_GM 28750
#define IHNM_TITLE_TIME_FM 19500
///// ITE-specific stuff
#define ITE_INTRO_FRAMETIME 90
#define INTRO_CAPTION_Y 170
#define INTRO_DE_CAPTION_Y 160
#define VOICE_PAD 50
#define VOICE_LETTERLEN 90
#define PALETTE_FADE_DURATION 1000
#define DISSOLVE_DURATION 3000
#define LOGO_DISSOLVE_DURATION 1000
#define CREDIT_DURATION1 4000
struct IntroDialogue {
uint32 i_voice_rn;
const char *i_str;
};
struct IntroCredit {
Common::Language lang;
int game;
int type;
const char *string;
};
class Scene {
public:
Scene(SagaEngine *vm);
~Scene();
// Console functions
void cmdActionMapInfo();
void cmdObjectMapInfo();
void cmdSceneChange(int argc, const char **argv);
void startScene();
void creditsScene();
void nextScene();
void skipScene();
void endScene();
void restoreScene();
void queueScene(LoadSceneParams *sceneQueue) {
_sceneQueue.push_back(*sceneQueue);
}
void draw();
int getFlags() const { return _sceneDescription.flags; }
int getScriptModuleNumber() const { return _sceneDescription.scriptModuleNumber; }
bool isInIntro() { return !_inGame; }
const Rect& getSceneClip() const { return _sceneClip; }
void getBGMaskInfo(int &width, int &height, byte *&buffer, size_t &bufferLength);
int isBGMaskPresent() { return _bgMask.loaded; }
int getBGMaskType(const Point &testPoint) {
uint offset;
if (!_bgMask.loaded) {
return 0;
}
offset = testPoint.x + testPoint.y * _bgMask.w;
#ifdef SCENE_DEBUG
if (offset >= _bgMask.buf_len) {
error("Scene::getBGMaskType offset 0x%X exceed bufferLength 0x%X", offset, (int)_bgMask.buf_len);
}
#endif
return (_bgMask.buf[offset] >> 4) & 0x0f;
}
bool validBGMaskPoint(const Point &testPoint) {
#ifdef SCENE_DEBUG
if (!_bgMask.loaded) {
error("Scene::validBGMaskPoint _bgMask not loaded");
}
#endif
return !((testPoint.x < 0) || (testPoint.x >= _bgMask.w) ||
(testPoint.y < 0) || (testPoint.y >= _bgMask.h));
}
bool canWalk(const Point &testPoint);
bool offscreenPath(Point &testPoint);
void setDoorState(int doorNumber, int doorState) {
#ifdef SCENE_DEBUG
if ((doorNumber < 0) || (doorNumber >= SCENE_DOORS_MAX))
error("Scene::setDoorState wrong doorNumber");
#endif
_sceneDoors[doorNumber] = doorState;
}
int getDoorState(int doorNumber) {
#ifdef SCENE_DEBUG
if ((doorNumber < 0) || (doorNumber >= SCENE_DOORS_MAX))
error("Scene::getDoorState wrong doorNumber");
#endif
return _sceneDoors[doorNumber];
}
void initDoorsState();
void getBGInfo(BGInfo &bgInfo);
void getBGPal(PalEntry *&pal) {
pal = (PalEntry *)_bg.pal;
}
void getSlopes(int &beginSlope, int &endSlope);
void clearSceneQueue(void) {
_sceneQueue.clear();
}
void changeScene(int16 sceneNumber, int actorsEntrance, SceneTransitionType transitionType, int chapter = NO_CHAPTER_CHANGE);
bool isSceneLoaded() const { return _sceneLoaded; }
int getSceneResourceId(int sceneNumber) {
#ifdef SCENE_DEBUG
if ((sceneNumber < 0) || (sceneNumber >= _sceneCount)) {
error("getSceneResourceId: wrong sceneNumber %i", sceneNumber);
}
#endif
return _sceneLUT[sceneNumber];
}
int currentProtag() const { return _currentProtag; }
void setProtag(int pr) { _currentProtag = pr; }
int currentSceneNumber() const { return _sceneNumber; }
int currentChapterNumber() const { return _chapterNumber; }
void setChapterNumber(int ch) { _chapterNumber = ch; }
int getOutsetSceneNumber() const { return _outsetSceneNumber; }
int currentSceneResourceId() const { return _sceneResourceId; }
int getCurrentMusicTrack() const { return _currentMusicTrack; }
void setCurrentMusicTrack(int tr) { _currentMusicTrack = tr; }
int getCurrentMusicRepeat() const { return _currentMusicRepeat; }
void setCurrentMusicRepeat(int rp) { _currentMusicRepeat = rp; }
bool haveChapterPointsChanged() const { return _chapterPointsChanged; }
void setChapterPointsChanged(bool cp) { _chapterPointsChanged = cp; }
void cutawaySkip() {
if (_vm->_scene->isInIntro())
_vm->_framesEsc = 2;
else
_vm->_framesEsc = 1;
}
void drawTextList(Surface *ds);
int getHeight(bool speech = false) const {
if (_vm->getGameType() == GType_IHNM && _vm->_scene->currentChapterNumber() == 8 && !speech)
return _vm->getDisplayInfo().logicalHeight;
else
return _vm->getDisplayInfo().sceneHeight;
}
void clearPlacard();
void showPsychicProfile(const char *text);
void clearPsychicProfile();
void showIHNMDemoSpecialScreen();
bool isNonInteractiveIHNMDemoPart() {
return _vm->getGameId() == GID_IHNM_DEMO && (_sceneNumber >= 144 && _sceneNumber <= 149);
}
private:
void loadScene(LoadSceneParams *loadSceneParams);
void loadSceneDescriptor(uint32 resourceId);
void loadSceneResourceList(uint32 resourceId);
void loadSceneEntryList(const byte* resourcePointer, size_t resourceLength);
void processSceneResources();
void getResourceTypes(SAGAResourceTypes *&types, int &typesCount);
SagaEngine *_vm;
ResourceContext *_sceneContext;
int *_sceneLUT;
int _sceneCount;
SceneQueueList _sceneQueue;
bool _sceneLoaded;
int _currentProtag;
int _sceneNumber;
int _chapterNumber;
int _outsetSceneNumber;
int _sceneResourceId;
int _currentMusicTrack;
int _currentMusicRepeat;
bool _chapterPointsChanged;
bool _inGame;
bool _loadDescription;
SceneDescription _sceneDescription;
size_t _resourceListCount;
SceneResourceData *_resourceList;
SceneProc *_sceneProc;
SceneImage _bg;
SceneImage _bgMask;
Common::Rect _sceneClip;
int _sceneDoors[SCENE_DOORS_MAX];
public:
ObjectMap *_actionMap;
ObjectMap *_objectMap;
SceneEntryList _entryList;
StringsTable _sceneStrings;
TextList _textList;
private:
int IHNMStartProc();
int IHNMCreditsProc();
int ITEStartProc();
void IHNMLoadCutaways();
bool checkKey();
bool playTitle(int title, int time, int mode = kPanelVideo);
bool playLoopingTitle(int title, int seconds);
public:
static int SC_IHNMIntroMovieProc1(int param, void *refCon);
static int SC_IHNMIntroMovieProc2(int param, void *refCon);
static int SC_IHNMIntroMovieProc3(int param, void *refCon);
static int SC_IHNMCreditsMovieProc(int param, void *refCon);
private:
int IHNMIntroMovieProc1(int param);
int IHNMIntroMovieProc2(int param);
int IHNMIntroMovieProc3(int param);
int IHNMCreditsMovieProc(int param);
public:
static int SC_ITEIntroAnimProc(int param, void *refCon);
static int SC_ITEIntroCave1Proc(int param, void *refCon);
static int SC_ITEIntroCave2Proc(int param, void *refCon);
static int SC_ITEIntroCave3Proc(int param, void *refCon);
static int SC_ITEIntroCave4Proc(int param, void *refCon);
static int SC_ITEIntroValleyProc(int param, void *refCon);
static int SC_ITEIntroTreeHouseProc(int param, void *refCon);
static int SC_ITEIntroFairePathProc(int param, void *refCon);
static int SC_ITEIntroFaireTentProc(int param, void *refCon);
private:
Event *ITEQueueDialogue(Event *q_event, int n_dialogues, const IntroDialogue dialogue[]);
Event *ITEQueueCredits(int delta_time, int duration, int n_credits, const IntroCredit credits[]);
int ITEIntroAnimProc(int param);
int ITEIntroCave1Proc(int param);
int ITEIntroCave2Proc(int param);
int ITEIntroCave3Proc(int param);
int ITEIntroCave4Proc(int param);
int ITEIntroValleyProc(int param);
int ITEIntroTreeHouseProc(int param);
int ITEIntroFairePathProc(int param);
int ITEIntroFaireTentProc(int param);
};
} // End of namespace Saga
#endif
|