aboutsummaryrefslogtreecommitdiff
path: root/saga/ite_introproc.cpp
blob: 8190472af940cd267864f627087127b007ad18ff (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
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
/* 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$
 *
 */
/*
 Description:   
 
    Intro sequence scene procedures

 Notes: 
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "yslib.h"

#include "reinherit.h"

/*
 * Uses the following modules:
\*--------------------------------------------------------------------------*/
#include "animation_mod.h"
#include "cvar_mod.h"
#include "events_mod.h"
#include "font_mod.h"
#include "game_mod.h"
#include "rscfile_mod.h"
#include "scene_mod.h"
#include "sndres_mod.h"
#include "text_mod.h"
#include "palanim_mod.h"

/*
 * Begin module:
\*--------------------------------------------------------------------------*/
#include "scene.h"
#include "ite_introproc.h"

namespace Saga {

static R_INTRO_DIALOGUE IntroDiag[] = {

	{
		    CAVE_VOICE_0, "intro1a",
	    "We see the sky, we see the land, we see the water, "
		    "and we wonder: Are we the only ones?"},
	{
		    CAVE_VOICE_1, "intro2a",
	    "Long before we came to exist, the humans ruled "
		    "the Earth."},
	{
		    CAVE_VOICE_2, "intro3a",
	    "They made marvelous things, and moved whole " "mountains."},
	{
		    CAVE_VOICE_3, "intro4a",
	    "They knew the Secret of Flight, the Secret of "
		    "Happiness, and other secrets beyond our imagining."},
	{
		    CAVE_VOICE_4, "intro1b",
	    "The humans also knew the Secret of Life, "
		    "and used it to give us the Four Great Gifts:"},
	{
		    CAVE_VOICE_5, "intro2b",
	    "Thinking minds, feeling hearts, speaking "
		    "mouths, and reaching hands."},
	{
		    CAVE_VOICE_6, "intro3b",
	    "We are their children."},
	{
		    CAVE_VOICE_7, "intro1c",
	    "They taught us how to use our hands, and how " "to speak."},
	{
		    CAVE_VOICE_8, "intro2c",
	    "They showed us the joy of using our minds."},
	{
		    CAVE_VOICE_9, "intro3c",
	    "They loved us, and when we were ready, they "
		    "surely would have given us the Secret of Happiness."},

	{
		    CAVE_VOICE_10, "intro1d",
	    "And now we see the sky, the land, and the water "
		    "that we are heirs to, and we wonder: why did "
		    "they leave?"},

	{
		    CAVE_VOICE_11, "intro2d",
	    "Do they live still, in the stars? In the oceans "
		    "depths? In the wind?"},
	{
		    CAVE_VOICE_12, "intro3d",
	    "We wonder, was their fate good or evil?"},

	{
		    CAVE_VOICE_13, "intro4d",
	    "And will we also share the same fate one day?"},
};

R_SCENE_QUEUE ITE_IntroList[] = {
	{ITE_INTRO_ANIM_SCENE, NULL, BY_RESOURCE, ITE_IntroAnimProc, 0},
	{ITE_CAVE_SCENE_1, NULL, BY_RESOURCE, ITE_IntroCave1Proc, 1},
	{ITE_CAVE_SCENE_2, NULL, BY_RESOURCE, ITE_IntroCave2Proc, 0},
	{ITE_CAVE_SCENE_3, NULL, BY_RESOURCE, ITE_IntroCave3Proc, 0},
	{ITE_CAVE_SCENE_4, NULL, BY_RESOURCE, ITE_IntroCave4Proc, 0},
	{ITE_VALLEY_SCENE, NULL, BY_RESOURCE, ITE_IntroValleyProc, 0},
	{ITE_TREEHOUSE_SCENE, NULL, BY_RESOURCE, ITE_IntroTreeHouseProc, 0},
	{ITE_FAIREPATH_SCENE, NULL, BY_RESOURCE, ITE_IntroFairePathProc, 0},
	{ITE_FAIRETENT_SCENE, NULL, BY_RESOURCE, ITE_IntroFaireTentProc, 0}
};

int ITE_StartProc(void)
{
	size_t n_introscenes;
	size_t i;

	R_SCENE_QUEUE first_scene;
	R_GAME_SCENEDESC gs_desc;

	n_introscenes = YS_NELEMS(ITE_IntroList);

	for (i = 0; i < n_introscenes; i++) {

		SCENE_Queue(&ITE_IntroList[i]);
	}

	GAME_GetSceneInfo(&gs_desc);

	first_scene.load_flag = BY_SCENE;
	first_scene.scene_n = gs_desc.first_scene;
	first_scene.scene_skiptarget = 1;
	first_scene.scene_proc = InitialSceneProc;

	SCENE_Queue(&first_scene);

	return R_SUCCESS;
}

int ITE_IntroRegisterLang(void)
{

	size_t i;

	for (i = 0; i < YS_NELEMS(IntroDiag); i++) {

		if (CVAR_Register_S(IntroDiag[i].i_str,
			IntroDiag[i].i_cvar_name,
			NULL, R_CVAR_CFG, R_INTRO_STRMAX) != R_SUCCESS) {

			R_printf(R_STDERR,
			    "Error registering intro text cvars.");

			return R_FAILURE;
		}
	}

	return R_SUCCESS;
}

int ITE_IntroAnimProc(int param, R_SCENE_INFO * scene_info)
/*--------------------------------------------------------------------------*\
 * Handles the introductory Dreamer's Guild / NWC logo animation scene.
\*--------------------------------------------------------------------------*/
{
	R_EVENT event;

	YS_IGNORE_PARAM(scene_info);

	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 = R_ONESHOT_EVENT;
		event.code = R_BG_EVENT;
		event.op = EVENT_DISPLAY;
		event.param = SET_PALETTE;
		event.time = 0;

		EVENT_Queue(&event);

		R_printf(R_STDOUT, "Intro animation procedure started.\n");
		R_printf(R_STDOUT, "Linking animation resources...\n");

		ANIM_SetFrameTime(0, ITE_INTRO_FRAMETIME);

		/* Link this scene's animation resources for continuous
		 * playback
		 \*-----------------------------------------------------*/
		ANIM_Link(0, 1);
		ANIM_Link(1, 2);
		ANIM_Link(2, 3);
		ANIM_Link(3, 4);
		ANIM_Link(4, 5);
		ANIM_Link(5, 6);

		/* Scene should end on display of last animation frame
		 * \*----------------------------------------------------- */
		ANIM_SetFlag(6, ANIM_ENDSCENE);

		R_printf(R_STDOUT, "Beginning animation playback.\n");

		ANIM_Play(0, 0);

		/* Queue intro music playback
		 * \*----------------------------------------------------- */
		event.type = R_ONESHOT_EVENT;
		event.code = R_MUSIC_EVENT;
		event.param = MUSIC_1;
		event.param2 = R_MUSIC_LOOP;
		event.op = EVENT_PLAY;
		event.time = 0;

		EVENT_Queue(&event);
		break;

	case SCENE_END:
		break;

	default:
		R_printf(R_STDERR, "Illegal scene procedure parameter.\n");
		break;

	}

	return 0;
}

int ITE_IntroCave1Proc(int param, R_SCENE_INFO * scene_info)
/*--------------------------------------------------------------------------*\
 * Handles first introductory cave painting scene
\*--------------------------------------------------------------------------*/
{
	R_EVENT event = { 0 };
	R_EVENT *q_event;

	int event_time = 0;
	int voice_len;
	int voice_pad = 50;

	R_TEXTLIST_ENTRY text_entry = { 0 };
	R_TEXTLIST_ENTRY *entry_p;

	PALENTRY *pal;

	static PALENTRY current_pal[R_PAL_ENTRIES];

	int i;

	int font_flags = FONT_OUTLINE | FONT_CENTERED;

	switch (param) {

	case SCENE_BEGIN:

		/* Fade to black out of the intro DG/NWC logo animation
		 * \*----------------------------------------------------- */
		SYSGFX_GetCurrentPal(current_pal);

		event.type = R_CONTINUOUS_EVENT;
		event.code = R_PAL_EVENT;
		event.op = EVENT_PALTOBLACK;
		event.time = 0;
		event.duration = PALETTE_FADE_DURATION;
		event.data = current_pal;

		q_event = EVENT_Queue(&event);

		/* Display scene background, but stay with black palette
		 * \*----------------------------------------------------- */
		event.type = R_ONESHOT_EVENT;
		event.code = R_BG_EVENT;
		event.op = EVENT_DISPLAY;
		event.param = NO_SET_PALETTE;
		event.time = 0;

		q_event = EVENT_Chain(q_event, &event);

		/* Fade in from black to the scene background palette
		 * \*----------------------------------------------------- */
		SCENE_GetBGPal(&pal);

		event.type = R_CONTINUOUS_EVENT;
		event.code = R_PAL_EVENT;
		event.op = EVENT_BLACKTOPAL;
		event.time = 0;
		event.duration = PALETTE_FADE_DURATION;
		event.data = pal;

		q_event = EVENT_Chain(q_event, &event);

		/* Begin palette cycling animation for candles
		 * \*----------------------------------------------------- */
		event.type = R_ONESHOT_EVENT;
		event.code = R_PALANIM_EVENT;
		event.op = EVENT_CYCLESTART;
		event.time = 0;

		q_event = EVENT_Chain(q_event, &event);

		/* Queue narrator dialogue list
		 * \*----------------------------------------------------- */
		text_entry.color = 255;
		text_entry.effect_color = 0;
		text_entry.text_x = 320 / 2;
		text_entry.text_y = INTRO_CAPTION_Y;
		text_entry.font_id = MEDIUM_FONT_ID;
		text_entry.flags = font_flags;

		for (i = INTRO_CAVE1_START; i < INTRO_CAVE1_END; i++) {

			text_entry.string = IntroDiag[i].i_str;

			entry_p = TEXT_AddEntry(scene_info->text_list,
			    &text_entry);

			/* Display text */
			event.type = R_ONESHOT_EVENT;
			event.code = R_TEXT_EVENT;
			event.op = EVENT_DISPLAY;
			event.data = entry_p;
			event.time = event_time;

			q_event = EVENT_Chain(q_event, &event);

			/* Play voice */
			event.type = R_ONESHOT_EVENT;
			event.code = R_VOICE_EVENT;
			event.op = EVENT_PLAY;
			event.param = IntroDiag[i].i_voice_rn;
			event.time = event_time;

			q_event = EVENT_Chain(q_event, &event);

			voice_len =
			    SND_GetVoiceLength(IntroDiag[i].i_voice_rn);
			if (voice_len < 0) {
				voice_len = strlen(IntroDiag[i].i_str) *
				    VOICE_LETTERLEN;
			}

			/* Remove text */
			event.type = R_ONESHOT_EVENT;
			event.code = R_TEXT_EVENT;
			event.op = EVENT_REMOVE;
			event.data = entry_p;
			event.time = voice_len;

			q_event = EVENT_Chain(q_event, &event);

			event_time = voice_pad;

		}

		/* End scene after last dialogue over
		 * \*----------------------------------------------------- */
		event.type = R_ONESHOT_EVENT;
		event.code = R_SCENE_EVENT;
		event.op = EVENT_END;
		event.time = 0;

		q_event = EVENT_Chain(q_event, &event);

		break;

	case SCENE_END:
		break;

	default:
		R_printf(R_STDERR, "Illegal scene procedure paramater.\n");
		break;

	}

	return 0;
}

int ITE_IntroCave2Proc(int param, R_SCENE_INFO * scene_info)
/*--------------------------------------------------------------------------*\
 * Handles second introductory cave painting scene
\*--------------------------------------------------------------------------*/
{

	R_EVENT event = { 0 };
	R_EVENT *q_event;

	int event_time = 0;
	int voice_len;
	int voice_pad = 50;

	R_TEXTLIST_ENTRY text_entry = { 0 };
	R_TEXTLIST_ENTRY *entry_p;

	int i;

	int font_flags = FONT_OUTLINE | FONT_CENTERED;

	switch (param) {

	case SCENE_BEGIN:

		/* Start 'dissolve' transition to new scene background
		 * \*----------------------------------------------------- */
		event.type = R_CONTINUOUS_EVENT;
		event.code = R_TRANSITION_EVENT;
		event.op = EVENT_DISSOLVE;
		event.time = 0;
		event.duration = DISSOLVE_DURATION;

		q_event = EVENT_Queue(&event);

		/* Begin palette cycling animation for candles
		 * \*----------------------------------------------------- */
		event.type = R_ONESHOT_EVENT;
		event.code = R_PALANIM_EVENT;
		event.op = EVENT_CYCLESTART;
		event.time = 0;

		q_event = EVENT_Chain(q_event, &event);

		/* Queue narrator dialogue list
		 * \*----------------------------------------------------- */
		text_entry.color = 255;
		text_entry.effect_color = 0;
		text_entry.text_x = 320 / 2;
		text_entry.text_y = INTRO_CAPTION_Y;
		text_entry.font_id = MEDIUM_FONT_ID;
		text_entry.flags = font_flags;

		for (i = INTRO_CAVE2_START; i < INTRO_CAVE2_END; i++) {

			text_entry.string = IntroDiag[i].i_str;

			entry_p = TEXT_AddEntry(scene_info->text_list,
			    &text_entry);

			/* Display text */
			event.type = R_ONESHOT_EVENT;
			event.code = R_TEXT_EVENT;
			event.op = EVENT_DISPLAY;
			event.data = entry_p;
			event.time = event_time;

			q_event = EVENT_Chain(q_event, &event);

			/* Play voice */
			event.type = R_ONESHOT_EVENT;
			event.code = R_VOICE_EVENT;
			event.op = EVENT_PLAY;
			event.param = IntroDiag[i].i_voice_rn;
			event.time = event_time;

			q_event = EVENT_Chain(q_event, &event);

			voice_len =
			    SND_GetVoiceLength(IntroDiag[i].i_voice_rn);
			if (voice_len < 0) {
				voice_len = strlen(IntroDiag[i].i_str) *
				    VOICE_LETTERLEN;
			}

			/* Remove text */
			event.type = R_ONESHOT_EVENT;
			event.code = R_TEXT_EVENT;
			event.op = EVENT_REMOVE;
			event.data = entry_p;
			event.time = voice_len;

			q_event = EVENT_Chain(q_event, &event);

			event_time = voice_pad;
		}

		/* End scene after last dialogue over
		 * \*----------------------------------------------------- */
		event.type = R_ONESHOT_EVENT;
		event.code = R_SCENE_EVENT;
		event.op = EVENT_END;
		event.time = event_time;

		q_event = EVENT_Chain(q_event, &event);

		break;

	case SCENE_END:
		break;

	default:
		R_printf(R_STDERR, "Illegal scene procedure paramater.\n");
		break;

	}

	return 0;
}

int ITE_IntroCave3Proc(int param, R_SCENE_INFO * scene_info)
/*--------------------------------------------------------------------------*\
 * Handles third introductory cave painting scene
\*--------------------------------------------------------------------------*/
{
	R_EVENT event = { 0 };
	R_EVENT *q_event;

	int event_time = 0;
	int voice_len;
	int voice_pad = 50;

	R_TEXTLIST_ENTRY text_entry = { 0 };
	R_TEXTLIST_ENTRY *entry_p;

	int i;

	int font_flags = FONT_OUTLINE | FONT_CENTERED;

	switch (param) {

	case SCENE_BEGIN:

		/* Start 'dissolve' transition to new scene background
		 * \*----------------------------------------------------- */
		event.type = R_CONTINUOUS_EVENT;
		event.code = R_TRANSITION_EVENT;
		event.op = EVENT_DISSOLVE;
		event.time = 0;
		event.duration = DISSOLVE_DURATION;

		q_event = EVENT_Queue(&event);

		/* Begin palette cycling animation for candles
		 * \*----------------------------------------------------- */
		event.type = R_ONESHOT_EVENT;
		event.code = R_PALANIM_EVENT;
		event.op = EVENT_CYCLESTART;
		event.time = 0;

		q_event = EVENT_Chain(q_event, &event);

		/* Queue narrator dialogue list
		 * \*----------------------------------------------------- */
		text_entry.color = 255;
		text_entry.effect_color = 0;
		text_entry.text_x = 320 / 2;
		text_entry.text_y = INTRO_CAPTION_Y;
		text_entry.font_id = MEDIUM_FONT_ID;
		text_entry.flags = font_flags;

		for (i = INTRO_CAVE3_START; i < INTRO_CAVE3_END; i++) {

			text_entry.string = IntroDiag[i].i_str;

			entry_p = TEXT_AddEntry(scene_info->text_list,
			    &text_entry);

			/* Display text */
			event.type = R_ONESHOT_EVENT;
			event.code = R_TEXT_EVENT;
			event.op = EVENT_DISPLAY;
			event.data = entry_p;
			event.time = event_time;

			q_event = EVENT_Chain(q_event, &event);

			/* Play voice */
			event.type = R_ONESHOT_EVENT;
			event.code = R_VOICE_EVENT;
			event.op = EVENT_PLAY;
			event.param = IntroDiag[i].i_voice_rn;
			event.time = event_time;

			q_event = EVENT_Chain(q_event, &event);

			voice_len =
			    SND_GetVoiceLength(IntroDiag[i].i_voice_rn);
			if (voice_len < 0) {
				voice_len = strlen(IntroDiag[i].i_str) *
				    VOICE_LETTERLEN;
			}

			/* Remove text */
			event.type = R_ONESHOT_EVENT;
			event.code = R_TEXT_EVENT;
			event.op = EVENT_REMOVE;
			event.data = entry_p;
			event.time = voice_len;

			q_event = EVENT_Chain(q_event, &event);

			event_time = voice_pad;
		}

		/* End scene after last dialogue over
		 * \*----------------------------------------------------- */
		event.type = R_ONESHOT_EVENT;
		event.code = R_SCENE_EVENT;
		event.op = EVENT_END;
		event.time = event_time;

		q_event = EVENT_Chain(q_event, &event);

		break;

	case SCENE_END:
		break;

	default:
		R_printf(R_STDERR, "Illegal scene procedure paramater.\n");
		break;

	}

	return 0;
}

int ITE_IntroCave4Proc(int param, R_SCENE_INFO * scene_info)
/*--------------------------------------------------------------------------*\
 * Handles fourth introductory cave painting scene
\*--------------------------------------------------------------------------*/
{
	R_EVENT event = { 0 };
	R_EVENT *q_event;

	int event_time = 0;
	int voice_len;
	int voice_pad = 50;

	R_TEXTLIST_ENTRY text_entry = { 0 };
	R_TEXTLIST_ENTRY *entry_p;

	int i;

	int font_flags = FONT_OUTLINE | FONT_CENTERED;

	switch (param) {

	case SCENE_BEGIN:

		/* Start 'dissolve' transition to new scene background
		 * \*----------------------------------------------------- */
		event.type = R_CONTINUOUS_EVENT;
		event.code = R_TRANSITION_EVENT;
		event.op = EVENT_DISSOLVE;
		event.time = 0;
		event.duration = DISSOLVE_DURATION;

		q_event = EVENT_Queue(&event);

		/* Begin palette cycling animation for candles
		 * \*----------------------------------------------------- */
		event.type = R_ONESHOT_EVENT;
		event.code = R_PALANIM_EVENT;
		event.op = EVENT_CYCLESTART;
		event.time = 0;

		q_event = EVENT_Chain(q_event, &event);

		/* Queue narrator dialogue list
		 * \*----------------------------------------------------- */
		text_entry.color = 255;
		text_entry.effect_color = 0;
		text_entry.text_x = 320 / 2;
		text_entry.text_y = INTRO_CAPTION_Y;
		text_entry.font_id = MEDIUM_FONT_ID;
		text_entry.flags = font_flags;

		for (i = INTRO_CAVE4_START; i < INTRO_CAVE4_END; i++) {

			text_entry.string = IntroDiag[i].i_str;
			entry_p = TEXT_AddEntry(scene_info->text_list,
			    &text_entry);

			/* Display text */
			event.type = R_ONESHOT_EVENT;
			event.code = R_TEXT_EVENT;
			event.op = EVENT_DISPLAY;
			event.data = entry_p;
			event.time = event_time;

			q_event = EVENT_Chain(q_event, &event);

			/* Play voice */
			event.type = R_ONESHOT_EVENT;
			event.code = R_VOICE_EVENT;
			event.op = EVENT_PLAY;
			event.param = IntroDiag[i].i_voice_rn;
			event.time = event_time;

			q_event = EVENT_Chain(q_event, &event);

			voice_len =
			    SND_GetVoiceLength(IntroDiag[i].i_voice_rn);
			if (voice_len < 0) {
				voice_len = strlen(IntroDiag[i].i_str) *
				    VOICE_LETTERLEN;
			}

			/* Remove text */
			event.type = R_ONESHOT_EVENT;
			event.code = R_TEXT_EVENT;
			event.op = EVENT_REMOVE;
			event.data = entry_p;
			event.time = voice_len;

			q_event = EVENT_Chain(q_event, &event);

			event_time = voice_pad;

		}

		/* End scene after last dialogue over
		 * \*----------------------------------------------------- */
		event.type = R_ONESHOT_EVENT;
		event.code = R_SCENE_EVENT;
		event.op = EVENT_END;
		event.time = event_time;

		q_event = EVENT_Chain(q_event, &event);

		break;

	case SCENE_END:
		break;

	default:
		R_printf(R_STDERR, "Illegal scene procedure paramater.\n");
		break;

	}

	return 0;

}

int ITE_IntroValleyProc(int param, R_SCENE_INFO * scene_info)
/*--------------------------------------------------------------------------*\
 * Handles intro title scene (valley overlook)
\*--------------------------------------------------------------------------*/
{
	R_TEXTLIST_ENTRY text_entry = { 0 };
	R_TEXTLIST_ENTRY *entry_p;

	R_EVENT event;
	R_EVENT *q_event;

	int i;

	const INTRO_CREDIT credits[] = {
		{160, 44, 9000, CREDIT_DURATION1,
		    "Producer", SMALL_FONT_ID},
		{160, 56, 0, CREDIT_DURATION1,
		    "Walter Hochbrueckner", MEDIUM_FONT_ID},
		{160, 88, 0, CREDIT_DURATION1,
		    "Executive Producer", SMALL_FONT_ID},
		{160, 100, 0, CREDIT_DURATION1,
		    "Robert McNally", MEDIUM_FONT_ID},
		{160, 132, 0, CREDIT_DURATION1,
		    "Publisher", SMALL_FONT_ID},
		{160, 144, 0, CREDIT_DURATION1,
		    "Jon Van Caneghem", MEDIUM_FONT_ID}
	};

	int n_credits = sizeof credits / sizeof credits[0];

	int event_delay = 0;

	switch (param) {

	case SCENE_BEGIN:

		/* Display ITE title screen background
		 * \*----------------------------------------------------- */
		event.type = R_ONESHOT_EVENT;
		event.code = R_BG_EVENT;
		event.op = EVENT_DISPLAY;
		event.param = SET_PALETTE;
		event.time = 0;

		q_event = EVENT_Queue(&event);

		R_printf(R_STDOUT, "Beginning animation playback.\n");

		/* Begin title screen background animation 
		 * \*----------------------------------------------------- */
		ANIM_SetFlag(0, ANIM_LOOP);
		ANIM_Play(0, 0);

		/* Begin ITE title theme music
		 * \*----------------------------------------------------- */
		SYSMUSIC_Stop();

		event.type = R_ONESHOT_EVENT;
		event.code = R_MUSIC_EVENT;
		event.param = MUSIC_2;
		event.op = EVENT_PLAY;
		event.time = 0;

		q_event = EVENT_Chain(q_event, &event);

		/* Queue game credits list
		 * \*----------------------------------------------------- */
		text_entry.color = 255;
		text_entry.effect_color = 0;
		text_entry.flags = FONT_OUTLINE | FONT_CENTERED;

		for (i = 0; i < n_credits; i++) {

			text_entry.string = credits[i].string;
			text_entry.font_id = credits[i].font_id;
			text_entry.text_x = credits[i].text_x;
			text_entry.text_y = credits[i].text_y;

			entry_p = TEXT_AddEntry(scene_info->text_list,
			    &text_entry);

			/* Display text */
			event.type = R_ONESHOT_EVENT;
			event.code = R_TEXT_EVENT;
			event.op = EVENT_DISPLAY;
			event.data = entry_p;
			event.time = event_delay += credits[i].delta_time;

			q_event = EVENT_Queue(&event);

			/* Remove text */
			event.type = R_ONESHOT_EVENT;
			event.code = R_TEXT_EVENT;
			event.op = EVENT_REMOVE;
			event.data = entry_p;
			event.time = credits[i].duration;

			q_event = EVENT_Chain(q_event, &event);
		}

		/* End scene after credit display
		 * \*----------------------------------------------------- */
		event.type = R_ONESHOT_EVENT;
		event.code = R_SCENE_EVENT;
		event.op = EVENT_END;
		event.time = 1000;

		q_event = EVENT_Chain(q_event, &event);
		break;

	case SCENE_END:
		break;

	default:
		R_printf(R_STDERR, "Illegal scene procedure parameter.\n");
		break;

	}

	return 0;
}

int ITE_IntroTreeHouseProc(int param, R_SCENE_INFO * scene_info)
/*--------------------------------------------------------------------------*\
 * Handles second intro credit screen (treehouse view)
\*--------------------------------------------------------------------------*/
{
	R_TEXTLIST_ENTRY text_entry = { 0 };
	R_TEXTLIST_ENTRY *entry_p;

	R_EVENT event = { 0 };
	R_EVENT *q_event;

	int i;

	const INTRO_CREDIT credits[] = {
		{160, 58, 2000, CREDIT_DURATION1,
		    "Game Design", SMALL_FONT_ID},
		{160, 70, 0, CREDIT_DURATION1,
		    "Talin, Joe Pearce, Robert McNally", MEDIUM_FONT_ID},
		{160, 80, 0, CREDIT_DURATION1,
		    "and Carolly Hauksdottir", MEDIUM_FONT_ID},
		{160, 119, 0, CREDIT_DURATION1,
		    "Screenplay and Dialog", SMALL_FONT_ID},
		{160, 131, 0, CREDIT_DURATION1,
		    "Robert Leh, Len Wein, and Bill Rotsler",
			    MEDIUM_FONT_ID},
		{160, 54, 5000, CREDIT_DURATION1,
		    "Art", SMALL_FONT_ID},
		{160, 66, 0, CREDIT_DURATION1,
		    "Edward Lacabanne, Glenn Price, April Lee,",
			    MEDIUM_FONT_ID},
		{160, 76, 0, CREDIT_DURATION1,
		    "Lisa Iennaco, Brian Dowrick, Reed", MEDIUM_FONT_ID},
		{160, 86, 0, CREDIT_DURATION1,
		    "Waller, Allison Hershey and Talin", MEDIUM_FONT_ID},
		{160, 123, 0, CREDIT_DURATION1,
		    "Art Direction", SMALL_FONT_ID},
		{160, 135, 0, CREDIT_DURATION1,
		    "Allison Hershey", MEDIUM_FONT_ID}
	};

	int n_credits = YS_NELEMS(credits);

	int event_delay = 0;

	switch (param) {

	case SCENE_BEGIN:

		/* Start 'dissolve' transition to new scene background
		 * \*----------------------------------------------------- */
		event.type = R_CONTINUOUS_EVENT;
		event.code = R_TRANSITION_EVENT;
		event.op = EVENT_DISSOLVE;
		event.time = 0;
		event.duration = DISSOLVE_DURATION;

		q_event = EVENT_Queue(&event);

		event_delay = DISSOLVE_DURATION;

		/* Begin title screen background animation 
		 * \*----------------------------------------------------- */
		ANIM_SetFrameTime(0, 100);
		ANIM_Play(0, event_delay);

		/* Queue game credits list
		 * \*----------------------------------------------------- */
		text_entry.color = 255;
		text_entry.effect_color = 0;
		text_entry.flags = FONT_OUTLINE | FONT_CENTERED;

		for (i = 0; i < n_credits; i++) {

			text_entry.string = credits[i].string;
			text_entry.font_id = credits[i].font_id;
			text_entry.text_x = credits[i].text_x;
			text_entry.text_y = credits[i].text_y;

			entry_p = TEXT_AddEntry(scene_info->text_list,
			    &text_entry);

			/* Display text */
			event.type = R_ONESHOT_EVENT;
			event.code = R_TEXT_EVENT;
			event.op = EVENT_DISPLAY;
			event.data = entry_p;
			event.time = event_delay += credits[i].delta_time;

			q_event = EVENT_Queue(&event);

			/* Remove text */
			event.type = R_ONESHOT_EVENT;
			event.code = R_TEXT_EVENT;
			event.op = EVENT_REMOVE;
			event.data = entry_p;
			event.time = credits[i].duration;

			q_event = EVENT_Chain(q_event, &event);
		}

		/* End scene after credit display
		 * \*----------------------------------------------------- */
		event.type = R_ONESHOT_EVENT;
		event.code = R_SCENE_EVENT;
		event.op = EVENT_END;
		event.time = 1000;

		q_event = EVENT_Chain(q_event, &event);

		break;

	case SCENE_END:

		break;

	default:
		R_printf(R_STDERR, "Illegal scene procedure parameter.\n");
		break;

	}

	return 0;

}

int ITE_IntroFairePathProc(int param, R_SCENE_INFO * scene_info)
/*--------------------------------------------------------------------------*\
 * Handles third intro credit screen (path to puzzle tent)
\*--------------------------------------------------------------------------*/
{
	R_TEXTLIST_ENTRY text_entry = { 0 };
	R_TEXTLIST_ENTRY *entry_p;

	R_EVENT event = { 0 };
	R_EVENT *q_event;

	long event_delay = 0;

	int i;

	INTRO_CREDIT credits[] = {
		{160, 58, 2000, CREDIT_DURATION1,
		    "Original Game Engine Programming", SMALL_FONT_ID},

		{160, 70, 0, CREDIT_DURATION1,
		    "Talin, Walter Hochbrueckner,", MEDIUM_FONT_ID},

		{160, 80, 0, CREDIT_DURATION1,
		    "Joe Burks and Robert Wiggins", MEDIUM_FONT_ID},

		{160, 119, 0, CREDIT_DURATION1,
		    "Music and Sound", SMALL_FONT_ID},

		{160, 131, 0, CREDIT_DURATION1,
		    "Matt Nathan", MEDIUM_FONT_ID},

		{160, 58, 5000, CREDIT_DURATION1,
		    "Directed by", SMALL_FONT_ID},

		{160, 70, 0, CREDIT_DURATION1,
		    "Talin", MEDIUM_FONT_ID},

		{160, 119, 0, CREDIT_DURATION1,
		    "Game Engine Reconstruction", SMALL_FONT_ID},

		{160, 131, 0, CREDIT_DURATION1,
		    "Alpha software - Use at your own risk.",
			    MEDIUM_FONT_ID}
	};

	int n_credits = sizeof credits / sizeof credits[0];

	switch (param) {

	case SCENE_BEGIN:

		/* Start 'dissolve' transition to new scene background
		 * \*----------------------------------------------------- */
		event.type = R_CONTINUOUS_EVENT;
		event.code = R_TRANSITION_EVENT;
		event.op = EVENT_DISSOLVE;
		event.time = 0;
		event.duration = DISSOLVE_DURATION;

		q_event = EVENT_Queue(&event);

		event_delay = DISSOLVE_DURATION;

		/* Begin title screen background animation 
		 * \*----------------------------------------------------- */
		ANIM_SetFlag(0, ANIM_LOOP);
		ANIM_Play(0, event_delay);

		/* Queue game credits list
		 * \*----------------------------------------------------- */
		text_entry.color = 255;
		text_entry.effect_color = 0;
		text_entry.flags = FONT_OUTLINE | FONT_CENTERED;

		for (i = 0; i < n_credits; i++) {

			text_entry.string = credits[i].string;
			text_entry.font_id = credits[i].font_id;
			text_entry.text_x = credits[i].text_x;
			text_entry.text_y = credits[i].text_y;

			entry_p = TEXT_AddEntry(scene_info->text_list,
			    &text_entry);

			/* Display text */
			event.type = R_ONESHOT_EVENT;
			event.code = R_TEXT_EVENT;
			event.op = EVENT_DISPLAY;
			event.data = entry_p;
			event.time = event_delay += credits[i].delta_time;

			q_event = EVENT_Queue(&event);

			/* Remove text */
			event.type = R_ONESHOT_EVENT;
			event.code = R_TEXT_EVENT;
			event.op = EVENT_REMOVE;
			event.data = entry_p;
			event.time = credits[i].duration;

			q_event = EVENT_Chain(q_event, &event);
		}

		/* End scene after credit display
		 * \*----------------------------------------------------- */
		event.type = R_ONESHOT_EVENT;
		event.code = R_SCENE_EVENT;
		event.op = EVENT_END;
		event.time = 1000;

		q_event = EVENT_Chain(q_event, &event);

		break;

	case SCENE_END:
		break;

	default:
		R_printf(R_STDERR, "Illegal scene procedure parameter.\n");
		break;

	}

	return 0;
}

int ITE_IntroFaireTentProc(int param, R_SCENE_INFO * scene_info)
/*--------------------------------------------------------------------------*\
 * Handles fourth intro credit screen (treehouse view)
\*--------------------------------------------------------------------------*/
{
	R_EVENT event = { 0 };
	R_EVENT *q_event;
	R_EVENT *q_event_start;

	YS_IGNORE_PARAM(scene_info);

	switch (param) {

	case SCENE_BEGIN:

		/* Start 'dissolve' transition to new scene background
		 * \*----------------------------------------------------- */
		event.type = R_CONTINUOUS_EVENT;
		event.code = R_TRANSITION_EVENT;
		event.op = EVENT_DISSOLVE;
		event.time = 0;
		event.duration = DISSOLVE_DURATION;

		q_event_start = EVENT_Queue(&event);

		/* End scene after momentary pause
		 * \*----------------------------------------------------- */
		event.type = R_ONESHOT_EVENT;
		event.code = R_SCENE_EVENT;
		event.op = EVENT_END;
		event.time = 5000;

		q_event = EVENT_Chain(q_event_start, &event);

		break;

	case SCENE_END:

		break;

	default:
		R_printf(R_STDERR, "Illegal scene procedure parameter.\n");
		break;

	}

	return 0;
}

} // End of namespace Saga