aboutsummaryrefslogtreecommitdiff
path: root/saga/scene.h
blob: 0f7176b7d79275227d4173157b0e3594be51c40a (plain)
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
/* ScummVM - Scumm Interpreter
 * Copyright (C) 2004 The ScummVM project
 *
 * The ReInherit Engine is (C)2000-2003 by Daniel Balsom.
 *
 * 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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 * $Header$
 *
 */

// Scene management module private header file

#ifndef SAGA_SCENE_H
#define SAGA_SCENE_H

#include "saga/text.h"

namespace Saga {

class ActionMap;
class ObjectMap;

enum R_SCENE_MODES {
	R_SCENE_MODE_INVALID,
	R_SCENE_MODE_NORMAL,
	R_SCENE_MODE_ISO
};

struct SCENE_ZINFO {
	int beginSlope;
	int endSlope;
};

struct SCENE_BGINFO {
	int bg_x;
	int bg_y;
	int bg_w;
	int bg_h;
	int bg_p;
	byte *bg_buf;
	size_t bg_buflen;
};

struct R_SCENE_INFO {
	SCENE_ZINFO z_info;
	SCENE_BGINFO bg_info;
	R_TEXTLIST *text_list;
};

typedef int (R_SCENE_PROC) (int, R_SCENE_INFO *, void *);

#define PALETTE_FADE_DURATION 1000

enum SCENE_LOAD_FLAGS {
	BY_RESOURCE = 0,
	BY_SCENE,
	BY_DESC
};

enum SCENE_PROC_PARAMS {
	SCENE_BEGIN = 0,
	SCENE_END
};

// Resource type numbers
enum SAGA_RESOURCE_TYPES {
	SAGA_BG_IMAGE = 2,
	SAGA_BG_MASK = 3,
	SAGA_OBJECT_NAME_LIST = 5,
	SAGA_OBJECT_MAP = 6,
	SAGA_ACTION_MAP = 7,
	SAGA_ISO_TILESET = 8,
	SAGA_ISO_METAMAP = 9,
	SAGA_ISO_METATILESET = 10,
	SAGA_ENTRY = 12,
	SAGA_ANIM_1 = 14,
	SAGA_ANIM_2,
	SAGA_ANIM_3,
	SAGA_ANIM_4,
	SAGA_ANIM_5,
	SAGA_ANIM_6,
	SAGA_ANIM_7,
	SAGA_PAL_ANIM = 23,
	SAGA_FACES = 24
};

#define SAGA_RESLIST_ENTRY_LEN 4

struct R_SCENE_RESLIST {
	uint32 res_number;
	int res_type;
	byte *res_data;
	size_t res_data_len;
};

#define SAGA_SCENE_DESC_LEN 16

struct R_SCENE_DESC {
	int16 flags;
	int16 resListRN;
	int16 endSlope;
	int16 beginSlope;
	uint16 scriptNum;
	uint16 sceneScriptNum;
	uint16 startScriptNum;
	int16 musicRN;
	R_SCENE_RESLIST *resList;
	size_t resListCnt;
};

struct SCENE_IMAGE {
	int loaded;
	int w;
	int h;
	int p;
	byte *buf;
	size_t buf_len;
	byte *res_buf;
	size_t res_len;
	PALENTRY pal[256];
};

struct SCENE_ANIMINFO {
	int anim_res_number;
	int anim_handle;
	SCENE_ANIMINFO *next;
};

enum SCENE_FADE_TYPES {
	SCENE_NOFADE = 0,
	SCENE_FADE = 1,
	SCENE_FADE_NO_INTERFACE = 2
};

struct R_SCENE_QUEUE {
	uint32 scene_n;
	R_SCENE_DESC *scene_desc;
	int load_flag;
	R_SCENE_PROC *scene_proc;
	int scene_skiptarget;
	int fadeType;
};

///// IHNM-specific stuff
#define R_IHNM_PALFADE_TIME    1000
#define R_IHNM_INTRO_FRAMETIME 80
#define R_IHNM_DGLOGO_TIME     8000
#define R_IHNM_TITLE_TIME      16000

///// ITE-specific stuff
#define R_INTRO_STRMAX 256

#define ITE_INTRO_FRAMETIME 90

#define INTRO_CAPTION_Y 170
#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

enum R_INTRO_SCENE_DIALOGUE_INFO {
	INTRO_CAVE1_START = 0,
	INTRO_CAVE1_END = 4,

	INTRO_CAVE2_START = 4,
	INTRO_CAVE2_END = 7,

	INTRO_CAVE3_START = 7,
	INTRO_CAVE3_END = 10,

	INTRO_CAVE4_START = 10,
	INTRO_CAVE4_END = 14
};

struct R_INTRO_DIALOGUE {
	uint32 i_voice_rn;
	const char *i_cvar_name;
	char i_str[R_INTRO_STRMAX];
};

struct INTRO_CAPTION {
	int res_n;
	char *caption;
};

struct INTRO_CREDIT {
	int text_x;
	int text_y;
	int delta_time;
	int duration;
	const char *string;
	int font_id;
};


class Scene {
 public:
	Scene(SagaEngine *vm);
	~Scene();
	int reg();

	int startScene();
	int nextScene();
	int skipScene();
	int endScene();
	int queueScene(R_SCENE_QUEUE *scene_queue);
	int draw(R_SURFACE *);
	int getMode();
	int getBGMaskInfo(int *w, int *h, byte **buf, size_t *buf_len);
	int isBGMaskPresent(void);
	int getBGInfo(SCENE_BGINFO *bginfo);
	int getZInfo(SCENE_ZINFO *zinfo);
	int getBGPal(PALENTRY **pal);
	int getInfo(R_SCENE_INFO *si);

	int clearSceneQueue(void);
	int changeScene(int scene_num);

	bool initialized() { return _initialized; }

	void sceneInfoCmd(int argc, char *argv[]);
	void sceneChangeCmd(int argc, char *argv[]);

 private:
	int loadScene(int scene, int load_flag, R_SCENE_PROC scene_proc, R_SCENE_DESC *, 
				  int fadeIn);
	int loadSceneDescriptor(uint32 res_number);
	int loadSceneResourceList(uint32 res_number);
	int processSceneResources();

 private:
	SagaEngine *_vm;
	bool _initialized;

	R_RSCFILE_CONTEXT *_sceneContext;
	int *_sceneLUT;
	int _sceneCount;
	int _sceneMax;
	YS_DL_LIST *_sceneQueue;
	int _firstScene;
	bool _sceneLoaded;
	int _sceneMode;
	int _sceneNumber;
	int _sceneResNum;
	bool _inGame;
	bool _loadDesc;
	R_SCENE_DESC _desc;
	int _resListEntries;
	R_SCENE_RESLIST *_resList;
	int _animEntries;
	YS_DL_LIST *_animList;
	R_SCENE_PROC *_sceneProc;
	R_TEXTLIST *_textList;
	SCENE_IMAGE _bg;
	SCENE_IMAGE _bgMask;

	static int SC_defaultScene(int param, R_SCENE_INFO *scene_info, void *refCon);
	int defaultScene(int param, R_SCENE_INFO *scene_info);

 public:
	ActionMap *_actionMap;
	ObjectMap *_objectMap;

 private:
	int IHNMStartProc();
	int ITEStartProc();

 public:
	static int SC_IHNMIntroMovieProc1(int param, R_SCENE_INFO *scene_info, void *refCon);
	static int SC_IHNMIntroMovieProc2(int param, R_SCENE_INFO *scene_info, void *refCon);
	static int SC_IHNMIntroMovieProc3(int param, R_SCENE_INFO *scene_info, void *refCon);
	static int SC_IHNMHateProc(int param, R_SCENE_INFO *scene_info, void *refCon);

 private:
	int IHNMIntroMovieProc1(int param, R_SCENE_INFO *scene_info);
	int IHNMIntroMovieProc2(int param, R_SCENE_INFO *scene_info);
	int IHNMIntroMovieProc3(int param, R_SCENE_INFO *scene_info);
	int IHNMHateProc(int param, R_SCENE_INFO *scene_info);

 public:
	int ITEIntroRegisterLang(void);
	static int SC_ITEIntroAnimProc(int param, R_SCENE_INFO *scene_info, void *refCon);
	static int SC_ITEIntroCave1Proc(int param, R_SCENE_INFO *scene_info, void *refCon);
	static int SC_ITEIntroCave2Proc(int param, R_SCENE_INFO *scene_info, void *refCon);
	static int SC_ITEIntroCave3Proc(int param, R_SCENE_INFO *scene_info, void *refCon);
	static int SC_ITEIntroCave4Proc(int param, R_SCENE_INFO *scene_info, void *refCon);
	static int SC_ITEIntroValleyProc(int param, R_SCENE_INFO *scene_info, void *refCon);
	static int SC_ITEIntroTreeHouseProc(int param, R_SCENE_INFO *scene_info, void *refCon);
	static int SC_ITEIntroFairePathProc(int param, R_SCENE_INFO *scene_info, void *refCon);
	static int SC_ITEIntroFaireTentProc(int param, R_SCENE_INFO *scene_info, void *refCon);

 private:
	int ITEIntroAnimProc(int param, R_SCENE_INFO *scene_info);
	int ITEIntroCave1Proc(int param, R_SCENE_INFO *scene_info);
	int ITEIntroCave2Proc(int param, R_SCENE_INFO *scene_info);
	int ITEIntroCave3Proc(int param, R_SCENE_INFO *scene_info);
	int ITEIntroCave4Proc(int param, R_SCENE_INFO *scene_info);
	int ITEIntroValleyProc(int param, R_SCENE_INFO *scene_info);
	int ITEIntroTreeHouseProc(int param, R_SCENE_INFO *scene_info);
	int ITEIntroFairePathProc(int param, R_SCENE_INFO *scene_info);
	int ITEIntroFaireTentProc(int param, R_SCENE_INFO *scene_info);

};

} // End of namespace Saga

#endif