ScummVM API documentation
scene.h
1/* ScummVM - Graphic Adventure Engine
2 *
3 * ScummVM is the legal property of its developers, whose names
4 * are too numerous to list here. Please refer to the COPYRIGHT
5 * file distributed with this source distribution.
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 */
21
22// Scene management module private header file
23
24#ifndef SAGA_SCENE_H
25#define SAGA_SCENE_H
26
27#include "saga/font.h"
28#include "saga/actor.h"
29#include "saga/interface.h"
30#include "saga/puzzle.h"
31#include "saga/events.h"
32
33// Some defines used for detection.
34#include "saga/shared_detection_defines.h"
35
36namespace Saga {
37
38//#define SCENE_DEBUG // for scene debugging
39
40#define SCENE_DOORS_MAX 16
41#define NO_CHAPTER_CHANGE -2
42
43// Scenes
44#define ITE_SCENE_INV -1
45#define ITE_SCENE_PUZZLE 26
46#define ITE_SCENE_LODGE 21
47#define ITE_SCENE_ENDCREDIT1 295
48#define ITE_SCENE_OVERMAP 226
49
50class ObjectMap;
51
52enum SceneFlags {
53 kSceneFlagISO = 1,
54 kSceneFlagShowCursor = 2
55};
56
57struct BGInfo {
58 Rect bounds;
59 byte *buffer;
60};
61
62typedef int (SceneProc) (int, void *);
63
64
65enum SCENE_PROC_PARAMS {
66 SCENE_BEGIN = 0,
67 SCENE_END
68};
69
70// Resource type numbers
71enum SAGAResourceTypes {
72 SAGA_UNKNOWN,
73 SAGA_ACTOR,
74 SAGA_OBJECT,
75 SAGA_BG_IMAGE,
76 SAGA_BG_MASK,
77 SAGA_STRINGS,
78 SAGA_OBJECT_MAP,
79 SAGA_ACTION_MAP,
80 SAGA_ISO_IMAGES,
81 SAGA_ISO_MAP,
82 SAGA_ISO_PLATFORMS,
83 SAGA_ISO_METATILES,
84 SAGA_ENTRY,
85 SAGA_ANIM,
86 SAGA_ISO_MULTI,
87 SAGA_PAL_ANIM,
88 SAGA_FACES,
89 SAGA_PALETTE
90};
91
92#define SAGA_RESLIST_ENTRY_LEN 4
93
95 uint32 resourceId;
96 int resourceType;
97 bool invalid;
98
99 SceneResourceData() : resourceId(0), resourceType(0), invalid(false) {
100 }
101};
102
104
105#define SAGA_SCENE_DESC_LEN 16
106
108 int16 flags;
109 int16 resourceListResourceId;
110 int16 endSlope;
111 int16 beginSlope;
112 uint16 scriptModuleNumber;
113 uint16 sceneScriptEntrypointNumber;
114 uint16 startScriptEntrypointNumber;
115 int16 musicResourceId;
116
117 void reset() {
118 flags = resourceListResourceId = endSlope = beginSlope = scriptModuleNumber = sceneScriptEntrypointNumber = startScriptEntrypointNumber = musicResourceId = 0;
119 }
120};
121
123 Location location;
124 uint16 facing;
125};
126
128
130 bool loaded;
131 int w;
132 int h;
133 int p;
134 ByteArray buffer;
135 PalEntry pal[256];
136
137 SceneImage() : loaded(false), w(0), h(0), p(0) {
138 memset(pal, 0, sizeof(pal));
139 }
140};
141
142
143enum SceneTransitionType {
144 kTransitionNoFade,
145 kTransitionFade
146};
147
148enum SceneLoadFlags {
149 kLoadByResourceId = 0,
150 kLoadBySceneNumber = 1,
151 kLoadIdTypeMask = 1,
152 kLoadBgMaskIsImage = 1 << 16,
153};
154
156 int32 sceneDescriptor;
157 SceneLoadFlags loadFlag;
158 SceneProc *sceneProc;
159 bool sceneSkipTarget;
160 SceneTransitionType transitionType;
161 int actorsEntrance;
162 int chapter;
163};
164
166
168#define IHNM_PALFADE_TIME 1000
169#define IHNM_INTRO_FRAMETIME 80
170#define IHNM_DGLOGO_TIME 8000
171#define IHNM_TITLE_TIME_GM 28750
172#define IHNM_TITLE_TIME_FM 19500
173
174#define CREDIT_DURATION1 4000
175
176class Scene {
177 public:
178 Scene(SagaEngine *vm);
179 ~Scene();
180
181// Console functions
182 void cmdActionMapInfo();
183 void cmdObjectMapInfo();
184
185 void cmdSceneChange(int argc, const char **argv);
186
187 void startScene();
188 void creditsScene();
189 void nextScene();
190 void skipScene();
191 void endScene();
192 void restoreScene();
193 void queueScene(const LoadSceneParams &sceneQueue) {
194 _sceneQueue.push_back(sceneQueue);
195 }
196
197 void draw();
198 int getFlags() const { return _sceneDescription.flags; }
199 int getScriptModuleNumber() const { return _sceneDescription.scriptModuleNumber; }
200 bool isInIntro() { return !_inGame; }
201 const Rect& getSceneClip() const { return _sceneClip; }
202
203 void getBGMaskInfo(int &width, int &height, byte *&buffer);
204 int isBGMaskPresent() { return _bgMask.loaded; }
205
206 int getBGMaskType(const Point &testPoint) {
207 uint offset;
208 if (!_bgMask.loaded) {
209 return 0;
210 }
211 offset = testPoint.x + testPoint.y * _bgMask.w;
212
213 #ifdef SCENE_DEBUG
214 if (offset >= _bgMask.buf_len) {
215 error("Scene::getBGMaskType offset 0x%X exceed bufferLength 0x%X", offset, (int)_bgMask.buf_len);
216 }
217 #endif
218
219 return (_bgMask.buffer[offset] >> 4) & 0x0f;
220 }
221
222 bool validBGMaskPoint(const Point &testPoint) {
223 #ifdef SCENE_DEBUG
224 if (!_bgMask.loaded) {
225 error("Scene::validBGMaskPoint _bgMask not loaded");
226 }
227 #endif
228
229 return !((testPoint.x < 0) || (testPoint.x >= _bgMask.w) ||
230 (testPoint.y < 0) || (testPoint.y >= _bgMask.h));
231 }
232
233 bool canWalk(const Point &testPoint);
234 bool offscreenPath(Point &testPoint);
235
236 void setDoorState(int doorNumber, int doorState) {
237 #ifdef SCENE_DEBUG
238 if ((doorNumber < 0) || (doorNumber >= SCENE_DOORS_MAX))
239 error("Scene::setDoorState wrong doorNumber");
240 #endif
241
242 _sceneDoors[doorNumber] = doorState;
243 }
244
245 int getDoorState(int doorNumber) {
246 #ifdef SCENE_DEBUG
247 if ((doorNumber < 0) || (doorNumber >= SCENE_DOORS_MAX))
248 error("Scene::getDoorState wrong doorNumber");
249 #endif
250
251 return _sceneDoors[doorNumber];
252 }
253
254 void initDoorsState();
255
256 void getBGInfo(BGInfo &bgInfo);
257 void getBGPal(PalEntry *&pal) {
258 pal = (PalEntry *)_bg.pal;
259 }
260
261 void getSlopes(int &beginSlope, int &endSlope);
262
263 void clearSceneQueue() {
264 _sceneQueue.clear();
265 }
266 void changeScene(int16 sceneNumber, int actorsEntrance, SceneTransitionType transitionType, int chapter = NO_CHAPTER_CHANGE);
267
268 bool isSceneLoaded() const { return _sceneLoaded; }
269
270 uint16 getSceneResourceId(int sceneNumber) {
271 #ifdef SCENE_DEBUG
272 if ((sceneNumber < 0) || (sceneNumber >= _sceneCount)) {
273 error("getSceneResourceId: wrong sceneNumber %i", sceneNumber);
274 }
275 #endif
276 return _sceneLUT[sceneNumber];
277 }
278 int currentSceneNumber() const { return _sceneNumber; }
279 int currentChapterNumber() const { return _chapterNumber; }
280 void setChapterNumber(int ch) { _chapterNumber = ch; }
281 int getOutsetSceneNumber() const { return _outsetSceneNumber; }
282 int currentSceneResourceId() const { return _sceneResourceId; }
283 int getCurrentMusicTrack() const { return _currentMusicTrack; }
284 void setCurrentMusicTrack(int tr) { _currentMusicTrack = tr; }
285 int getCurrentMusicRepeat() const { return _currentMusicRepeat; }
286 void setCurrentMusicRepeat(int rp) { _currentMusicRepeat = rp; }
287 bool haveChapterPointsChanged() const { return _chapterPointsChanged; }
288 void setChapterPointsChanged(bool cp) { _chapterPointsChanged = cp; }
289
290 void cutawaySkip() {
291 _vm->_framesEsc = _vm->_scene->isInIntro() ? 2 : 1;
292 }
293
294 void drawTextList();
295
296 int getHeight(bool speech = false) const {
297 if (_vm->getGameId() == GID_IHNM && _vm->_scene->currentChapterNumber() == 8 && !speech)
298 return _vm->getDisplayInfo().height;
299 else
300 return _vm->getDisplayInfo().sceneHeight;
301 }
302
303 void clearPlacard();
304 void showPsychicProfile(const char *text);
305 void clearPsychicProfile();
306 void showIHNMDemoSpecialScreen();
307
308 bool isNonInteractiveIHNMDemoPart() {
309 return _vm->isIHNMDemo() && (_sceneNumber >= 144 && _sceneNumber <= 149);
310 }
311
312 bool isITEPuzzleScene() {
313 return _vm->getGameId() == GID_ITE && _vm->_puzzle->isActive();
314 }
315
316 private:
317 void loadScene(LoadSceneParams &loadSceneParams);
318 void loadSceneDescriptor(uint32 resourceId);
319 void loadSceneResourceList(uint32 resourceId, SceneResourceDataArray &resourceList);
320 void loadSceneEntryList(const ByteArray &resourceData);
321 void processSceneResources(SceneResourceDataArray &resourceList, SceneLoadFlags flags);
322 void getResourceTypes(SAGAResourceTypes *&types, int &typesCount);
323
324
325 SagaEngine *_vm;
326
327 ResourceContext *_sceneContext;
328 Common::Array<uint16> _sceneLUT;
329 SceneQueueList _sceneQueue;
330 bool _sceneLoaded;
331 int _sceneNumber;
332 int _chapterNumber;
333 int _outsetSceneNumber;
334 int _sceneResourceId;
335 int _currentMusicTrack;
336 int _currentMusicRepeat;
337 bool _chapterPointsChanged;
338 bool _inGame;
339 SceneDescription _sceneDescription;
340 SceneProc *_sceneProc;
341 SceneImage _bg;
342 SceneImage _bgMask;
343 Common::Rect _sceneClip;
344
345 int _sceneDoors[SCENE_DOORS_MAX];
346
347
348 public:
349 ObjectMap *_actionMap;
350 ObjectMap *_objectMap;
351 SceneEntryList _entryList;
352 StringsTable _sceneStrings;
353 TextList _textList;
354
355 private:
356 int ITEStartProc();
357 int IHNMStartProc();
358 int IHNMCreditsProc();
359
360 void IHNMLoadCutaways();
361 bool checkKey();
362 void fadeMusic();
363
364 bool playTitle(int title, int time, int mode = kPanelVideo);
365 bool playLoopingTitle(int title, int seconds);
366
367 public:
368 static int SC_ITEIntroAnimProc(int param, void *refCon);
369 static int SC_ITEIntroCave1Proc(int param, void *refCon);
370 static int SC_ITEIntroCave2Proc(int param, void *refCon);
371 static int SC_ITEIntroCave3Proc(int param, void *refCon);
372 static int SC_ITEIntroCave4Proc(int param, void *refCon);
373 static int SC_ITEIntroValleyProc(int param, void *refCon);
374 static int SC_ITEIntroTreeHouseProc(int param, void *refCon);
375 static int SC_ITEIntroFairePathProc(int param, void *refCon);
376 static int SC_ITEIntroFaireTentProc(int param, void *refCon);
377 static int SC_ITEIntroCaveDemoProc(int param, void *refCon);
378
379 private:
380 EventColumns *queueIntroDialogue(EventColumns *eventColumns, int n_dialogues, const IntroDialogue dialogue[]);
381 EventColumns *queueCredits(int delta_time, int duration, int n_credits, const IntroCredit credits[]);
382 int ITEIntroAnimProc(int param);
383 int ITEIntroCaveCommonProc(int param, int caveScene);
384 int ITEIntroCaveDemoProc(int param);
385 int ITEIntroValleyProc(int param);
386 int ITEIntroTreeHouseProc(int param);
387 int ITEIntroFairePathProc(int param);
388 int ITEIntroFaireTentProc(int param);
389};
390
391} // End of namespace Saga
392
393#endif
Definition: array.h:52
void clear()
Definition: list.h:245
void push_back(const t_T &element)
Definition: list.h:174
Definition: saga.h:464
Definition: objectmap.h:91
Definition: resource.h:105
Definition: saga.h:497
Definition: scene.h:176
Definition: font.h:106
void NORETURN_PRE error(MSVC_PRINTF const char *s,...) GCC_PRINTF(1
Definition: actor.h:34
T y
Definition: rect.h:49
T x
Definition: rect.h:48
Definition: rect.h:144
Definition: rect.h:536
Definition: scene.h:57
Definition: itedata.h:87
Definition: itedata.h:82
Definition: scene.h:155
Definition: actor.h:199
Definition: gfx.h:81
Definition: scene.h:107
Definition: scene.h:122
Definition: scene.h:129
Definition: scene.h:94
Definition: saga.h:356