aboutsummaryrefslogtreecommitdiff
path: root/engines/saga/ihnm_introproc.cpp
blob: 631da37e82170a0bda3d47999042b5f2c30a92b8 (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
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
/* 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$
 *
 */

// "I Have No Mouth" Intro sequence scene procedures

#include "saga/saga.h"
#include "saga/gfx.h"

#include "saga/animation.h"
#include "saga/events.h"
#include "saga/interface.h"
#include "saga/rscfile.h"
#include "saga/sndres.h"
#include "saga/music.h"

#include "saga/scene.h"

namespace Saga {

SceneResourceData IHNM_IntroMovie1RL[] = {
	{30, 2, 0, 0, false},
	{31, 14, 0, 0, false}
};

SceneDescription IHNM_IntroMovie1Desc = {
	0, 0, 0, 0, 0, 0, 0, 0,
	IHNM_IntroMovie1RL,
	ARRAYSIZE(IHNM_IntroMovie1RL)
};

SceneResourceData IHNM_IntroMovie2RL[] = {
	{32, 2, 0, 0, false},
	{33, 14, 0, 0, false}
};

SceneDescription IHNM_IntroMovie2Desc = {
	0, 0, 0, 0, 0, 0, 0, 0,
	IHNM_IntroMovie2RL,
	ARRAYSIZE(IHNM_IntroMovie2RL)
};

SceneResourceData IHNM_IntroMovie3RL[] = {
	{34, 2, 0, 0, false},
	{35, 14, 0, 0, false}
};

SceneDescription IHNM_IntroMovie3Desc = {
	0, 0, 0, 0, 0, 0, 0, 0,
	IHNM_IntroMovie3RL,
	ARRAYSIZE(IHNM_IntroMovie3RL)
};

SceneResourceData IHNM_IntroMovie4RL[] = {
	{1227, 2, 0, 0, false},
	{1226, 14, 0, 0, false}
};

SceneDescription IHNM_IntroMovie4Desc = {
	0, 0, 0, 0, 0, 0, 0, 0,
	IHNM_IntroMovie4RL,
	ARRAYSIZE(IHNM_IntroMovie4RL)
};

// Demo
SceneResourceData IHNMDEMO_IntroMovie1RL[] = {
	{19, 2, 0, 0, false}	// this scene doesn't have an animation
};

SceneDescription IHNMDEMO_IntroMovie1Desc = {
	0, 0, 0, 0, 0, 0, 0, 0,
	IHNMDEMO_IntroMovie1RL,
	ARRAYSIZE(IHNMDEMO_IntroMovie1RL)
};

SceneResourceData IHNMDEMO_IntroMovie2RL[] = {
	{22, 2, 0, 0, false},
	{23, 14, 0, 0, false}
};

SceneDescription IHNMDEMO_IntroMovie2Desc = {
	0, 0, 0, 0, 0, 0, 0, 0,
	IHNMDEMO_IntroMovie2RL,
	ARRAYSIZE(IHNMDEMO_IntroMovie2RL)
};

LoadSceneParams IHNM_IntroList[] = {
	{0, kLoadByDescription, &IHNM_IntroMovie1Desc, Scene::SC_IHNMIntroMovieProc1, false, kTransitionNoFade, 0, NO_CHAPTER_CHANGE},
	{0, kLoadByDescription, &IHNM_IntroMovie2Desc, Scene::SC_IHNMIntroMovieProc2, false, kTransitionNoFade, 0, NO_CHAPTER_CHANGE},
	{0, kLoadByDescription, &IHNM_IntroMovie3Desc, Scene::SC_IHNMIntroMovieProc3, false, kTransitionNoFade, 0, NO_CHAPTER_CHANGE},
};

LoadSceneParams IHNMDEMO_IntroList[] = {
	{0, kLoadByDescription, &IHNMDEMO_IntroMovie1Desc, Scene::SC_IHNMIntroMovieProc1, false, kTransitionNoFade, 0, NO_CHAPTER_CHANGE},
	{0, kLoadByDescription, &IHNMDEMO_IntroMovie2Desc, Scene::SC_IHNMIntroMovieProc3, false, kTransitionNoFade, 0, NO_CHAPTER_CHANGE},
};

// IHNM cutaway intro resource IDs
#define RID_IHNM_INTRO_CUTAWAYS 39
#define RID_IHNMDEMO_INTRO_CUTAWAYS 25

int Scene::IHNMStartProc() {
	size_t n_introscenes;
	size_t i;

	LoadSceneParams firstScene;

	/*
	// Test code - uses loadCutawayList to load the intro cutaways, like the original

	ResourceContext *resourceContext;
	//ResourceContext *soundContext;
	byte *resourcePointer;
	size_t resourceLength;

	resourceContext = _vm->_resource->getContext(GAME_RESOURCEFILE);
	if (resourceContext == NULL) {
		error("Scene::IHNMStartProc() resource context not found");
	}

	if (_vm->getGameId() != GID_IHNM_DEMO)
		_vm->_resource->loadResource(resourceContext, RID_IHNM_INTRO_CUTAWAYS, resourcePointer, resourceLength);
	else
		_vm->_resource->loadResource(resourceContext, RID_IHNMDEMO_INTRO_CUTAWAYS, resourcePointer, resourceLength);

	if (resourceLength == 0) {
		error("Scene::IHNMStartProc() Can't load cutaway list");
	}

	// Load the cutaways for the title screens
	_vm->_anim->loadCutawayList(resourcePointer, resourceLength);
	
	// Note that the resource ID needed is the returned ID minus one
	printf("%i\n", _vm->_anim->cutawayResourceID(0));
	printf("%i\n", _vm->_anim->cutawayResourceID(1));
	printf("%i\n", _vm->_anim->cutawayResourceID(2));
	*/

	// The original used the "play video" mechanism for the first part of
	// the intro. We just use that panel mode.

	_vm->_anim->setCutAwayMode(kPanelVideo);
	_vm->_interface->setMode(kPanelVideo);

	if (_vm->getGameId() != GID_IHNM_DEMO)
		n_introscenes = ARRAYSIZE(IHNM_IntroList);
	else
		n_introscenes = ARRAYSIZE(IHNMDEMO_IntroList);

	// Queue the company and title videos
	if (_vm->getGameId() != GID_IHNM_DEMO) {
		for (i = 0; i < n_introscenes; i++) {
			_vm->_scene->queueScene(&IHNM_IntroList[i]);
		}
	} else {
		for (i = 0; i < n_introscenes; i++) {
			_vm->_scene->queueScene(&IHNMDEMO_IntroList[i]);
		}
	}

	firstScene.loadFlag = kLoadBySceneNumber;
	firstScene.sceneDescriptor = -1;
	firstScene.sceneDescription = NULL;
	firstScene.sceneSkipTarget = true;
	firstScene.sceneProc = NULL;
	firstScene.transitionType = kTransitionFade;
	firstScene.actorsEntrance = 0;
	firstScene.chapter = -1;

	_vm->_scene->queueScene(&firstScene);

	return SUCCESS;
}

int Scene::SC_IHNMIntroMovieProc1(int param, void *refCon) {
	return ((Scene *)refCon)->IHNMIntroMovieProc1(param);
}

int Scene::IHNMIntroMovieProc1(int param) {
	Event event;
	Event *q_event;

	switch (param) {
	case SCENE_BEGIN:
		// Background for intro scene is the first frame of the
		// intro animation; display it and set the palette
		event.type = kEvTOneshot;
		event.code = kBgEvent;
		event.op = kEventDisplay;
		event.param = kEvPSetPalette;
		event.time = 0;

		q_event = _vm->_events->queue(&event);

		if (_vm->getGameId() != GID_IHNM_DEMO) {
			_vm->_anim->setFrameTime(0, IHNM_INTRO_FRAMETIME);
			_vm->_anim->setFlag(0, ANIM_FLAG_ENDSCENE);

			event.type = kEvTOneshot;
			event.code = kAnimEvent;
			event.op = kEventPlay;
			event.param = 0;
			event.time = 0;

			q_event = _vm->_events->chain(q_event, &event);
		} else {
			// Start playing the intro music for the demo version
			event.type = kEvTOneshot;
			event.code = kMusicEvent;
			event.param = 1;
			event.param2 = MUSIC_NORMAL;
			event.op = kEventPlay;
			event.time = 0;

			q_event = _vm->_events->chain(q_event, &event);

			// The IHNM demo doesn't have an animation at the
			// Cyberdreans logo screen

			// Queue end of scene after a while
			event.type = kEvTOneshot;
			event.code = kSceneEvent;
			event.op = kEventEnd;
			event.time = 8000;

			q_event = _vm->_events->chain(q_event, &event);
		}

		break;
	default:
		break;
	}

	return 0;
}

int Scene::SC_IHNMIntroMovieProc2(int param, void *refCon) {
	return ((Scene *)refCon)->IHNMIntroMovieProc2(param);
}

int Scene::IHNMIntroMovieProc2(int param) {
	Event event;
	Event *q_event;
	PalEntry *pal;

	static PalEntry current_pal[PAL_ENTRIES];

	switch (param) {
	case SCENE_BEGIN:
		// Fade to black out of the intro CyberDreams logo anim
		_vm->_gfx->getCurrentPal(current_pal);

		event.type = kEvTContinuous;
		event.code = kPalEvent;
		event.op = kEventPalToBlack;
		event.time = 0;
		event.duration = IHNM_PALFADE_TIME;
		event.data = current_pal;

		q_event = _vm->_events->queue(&event);

		// Background for intro scene is the first frame of the
		// intro animation; display it but don't set palette
		event.type = kEvTOneshot;
		event.code = kBgEvent;
		event.op = kEventDisplay;
		event.param = kEvPNoSetPalette;
		event.time = 0;

		q_event = _vm->_events->chain(q_event, &event);

		_vm->_anim->setCycles(0, -1);

		// Unlike the original, we keep the logo spinning during the
		// palette fades. We don't have to, but I think it looks better
		// that way.

		event.type = kEvTOneshot;
		event.code = kAnimEvent;
		event.op = kEventPlay;
		event.param = 0;
		event.time = 0;

		q_event = _vm->_events->chain(q_event, &event);

		// Fade in from black to the scene background palette
		_vm->_scene->getBGPal(pal);

		event.type = kEvTContinuous;
		event.code = kPalEvent;
		event.op = kEventBlackToPal;
		event.time = 0;
		event.duration = IHNM_PALFADE_TIME;
		event.data = pal;

		q_event = _vm->_events->chain(q_event, &event);

		// Fade to black after looping animation for a while
		event.type = kEvTContinuous;
		event.code = kPalEvent;
		event.op = kEventPalToBlack;
		event.time = IHNM_DGLOGO_TIME;
		event.duration = IHNM_PALFADE_TIME;
		event.data = pal;

		q_event = _vm->_events->chain(q_event, &event);

		// Queue end of scene
		event.type = kEvTOneshot;
		event.code = kSceneEvent;
		event.op = kEventEnd;
		event.time = 0;

		q_event = _vm->_events->chain(q_event, &event);
		break;
	default:
		break;
	}

	return 0;
}

int Scene::SC_IHNMIntroMovieProc3(int param, void *refCon) {
	return ((Scene *)refCon)->IHNMIntroMovieProc3(param);
}

int Scene::IHNMIntroMovieProc3(int param) {
	Event event;
	Event *q_event;
	PalEntry *pal;
	static PalEntry current_pal[PAL_ENTRIES];

	switch (param) {
	case SCENE_BEGIN:
		// Fade to black out of the intro DG logo anim
		_vm->_gfx->getCurrentPal(current_pal);

		event.type = kEvTContinuous;
		event.code = kPalEvent;
		event.op = kEventPalToBlack;
		event.time = 0;
		event.duration = IHNM_PALFADE_TIME;
		event.data = current_pal;

		q_event = _vm->_events->queue(&event);

		// Music, maestro

		// In the GM file, this music also appears as tracks 7, 13, 19,
		// 25 and 31, but only track 1 sounds right with the FM music.

		if (_vm->getGameId() != GID_IHNM_DEMO) {
			event.type = kEvTOneshot;
			event.code = kMusicEvent;
			event.param = 1;
			event.param2 = MUSIC_NORMAL;
			event.op = kEventPlay;
			event.time = 0;

			q_event = _vm->_events->chain(q_event, &event);
		}

		// Background for intro scene is the first frame of the intro
		// animation; display it but don't set palette
		event.type = kEvTOneshot;
		event.code = kBgEvent;
		event.op = kEventDisplay;
		event.param = kEvPNoSetPalette;
		event.time = 0;

		q_event = _vm->_events->chain(q_event, &event);

		// Fade in from black to the scene background palette
		_vm->_scene->getBGPal(pal);

		event.type = kEvTContinuous;
		event.code = kPalEvent;
		event.op = kEventBlackToPal;
		event.time = 0;
		event.duration = IHNM_PALFADE_TIME;
		event.data = pal;

		q_event = _vm->_events->chain(q_event, &event);

		event.type = kEvTOneshot;
		event.code = kAnimEvent;
		event.op = kEventPlay;
		event.param = 0;
		event.time = 0;

		q_event = _vm->_events->chain(q_event, &event);

		// Queue end of scene after a while
		// The delay has been increased so the speech won't start until the music has ended
		event.type = kEvTOneshot;
		event.code = kSceneEvent;
		event.op = kEventEnd;
		if (_vm->getGameId() != GID_IHNM_DEMO)
			event.time = _vm->_music->hasAdlib() ? IHNM_TITLE_TIME_FM : IHNM_TITLE_TIME_GM;
		else
			event.time = 12000;

		q_event = _vm->_events->chain(q_event, &event);
		break;
	default:
		break;
	}

	return 0;
}

} // End of namespace Saga