aboutsummaryrefslogtreecommitdiff
path: root/engines/gnap/scenes/scenecore.cpp
blob: fb6f91c95413e259d8eef53d86e251cd409beb16 (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
/* 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.
 *
 */

#include "gnap/gnap.h"
#include "gnap/gamesys.h"
#include "gnap/resource.h"

#include "gnap/scenes/scenecore.h"

#include "gnap/scenes/arcade.h"
#include "gnap/scenes/groupcs.h"
#include "gnap/scenes/group0.h"
#include "gnap/scenes/group1.h"
#include "gnap/scenes/group2.h"
#include "gnap/scenes/group3.h"
#include "gnap/scenes/group4.h"
#include "gnap/scenes/group5.h"
#include "gnap/scenes/intro.h"

namespace Gnap {

int GnapEngine::initSceneLogic() {
	int backgroundId = -1;

	switch (_currentSceneNum) {
	case 0:
		_scene = new SceneIntro(this);
		backgroundId = _scene->init();
		_gameSys->setScaleValues(0, 500, 1, 1000);
		break;
	case 1:
		_scene = new Scene01(this);
		backgroundId = _scene->init();
		_scene->updateHotspots();
		_gameSys->setScaleValues(0, 500, 1, 1000);
		initSceneGrid(21, 146, 11, 10);
		break;
	case 2:
		_scene = new Scene02(this);
		backgroundId = _scene->init();
		_scene->updateHotspots();
		_gameSys->setScaleValues(0, 500, 1, 1000);
		initSceneGrid(21, 146, 11, 10);
		break;
	case 3:
		_scene = new Scene03(this);
		backgroundId = _scene->init();
		_scene->updateHotspots();
		_gameSys->setScaleValues(0, 500, 1, 1000);
		initSceneGrid(21, 146, 11, 10);
		break;
	case 4:
		_scene = new Scene04(this);
		backgroundId = _scene->init();
		_scene->updateHotspots();
		_gameSys->setScaleValues(0, 500, 1, 1000);
		initSceneGrid(21, 146, 11, 10);
		break;
	case 5:
		_scene = new Scene05(this);
		backgroundId = _scene->init();
		_scene->updateHotspots();
		_gameSys->setScaleValues(0, 500, 1, 1000);
		initSceneGrid(21, 146, 11, 10);
		break;
	case 6:
		_scene = new Scene06(this);
		backgroundId = _scene->init();
		_scene->updateHotspots();
		_gameSys->setScaleValues(0, 500, 1, 1000);
		initSceneGrid(21, 146, 11, 10);
		break;
	case 7:
		_scene = new Scene07(this);
		backgroundId = _scene->init();
		_scene->updateHotspots();
		_gameSys->setScaleValues(0, 500, 1, 1000);
		initSceneGrid(21, 146, 11, 10);
		break;
	case 8:
		_scene = new Scene08(this);
		backgroundId = _scene->init();
		_scene->updateHotspots();
		_gameSys->setScaleValues(0, 500, 1, 1000);
		initSceneGrid(21, 146, 11, 10);
		break;
	case 9:
		_scene = new Scene09(this);
		backgroundId = _scene->init();
		_scene->updateHotspots();
		_gameSys->setScaleValues(0, 500, 1, 1000);
		initSceneGrid(21, 146, 11, 10);
		break;
	case 10:
		_scene = new Scene10(this);
		backgroundId = _scene->init();
		_scene->updateHotspots();
		_gameSys->setScaleValues(0, 500, 1, 1000);
		initSceneGrid(21, 146, 11, 10);
		break;
	case 11:
		_scene = new Scene11(this);
		backgroundId = _scene->init();
		_scene->updateHotspots();
		_gameSys->setScaleValues(0, 500, 1, 1000);
		initSceneGrid(21, 146, 11, 10);
		break;
	case 12:
		_scene = new Scene12(this);
		backgroundId = _scene->init();
		_scene->updateHotspots();
		_gameSys->setScaleValues(0, 500, 1, 1000);
		initSceneGrid(21, 146, 11, 10);
		break;
	case 13:
		_scene = new Scene13(this);
		backgroundId = _scene->init();
		_scene->updateHotspots();
		_gameSys->setScaleValues(0, 500, 1, 1000);
		initSceneGrid(21, 146, 11, 10);
		break;
	case 14:
		_scene = new Scene14(this);
		backgroundId = _scene->init();
		_scene->updateHotspots();
		_gameSys->setScaleValues(0, 500, 1, 1000);
		break;
	case 15:
		_scene = new Scene15(this);
		backgroundId = _scene->init();
		_scene->updateHotspots();
		_gameSys->setScaleValues(0, 500, 1, 1000);
		break;
	case 16:
	case 47:
	case 48:
	case 54:
		backgroundId = -1;
		_gameSys->setScaleValues(0, 500, 1, 1000);
		break;
	case 17:
		_scene = new Scene17(this);
		backgroundId = _scene->init();
		_scene->updateHotspots();
		_gameSys->setScaleValues(0, 500, 1, 1000);
		initSceneGrid(21, 146, 11, 10);
		break;
	case 18:
		_scene = new Scene18(this);
		backgroundId = _scene->init();
		_gameSys->setScaleValues(0, 500, 1, 1000);
		initSceneGrid(21, 146, 11, 10);
		_scene->updateHotspots();
		break;
	case 19:
		_scene = new Scene19(this);
		backgroundId = _scene->init();
		_scene->updateHotspots();
		_gameSys->setScaleValues(0, 500, 1, 1000);
		initSceneGrid(21, 146, 11, 10);
		break;
	case 20:
		_scene = new Scene20(this);
		backgroundId = _scene->init();
		_scene->updateHotspots();
		_gameSys->setScaleValues(0, 500, 1, 1000);
		initSceneGrid(21, 146, 11, 10);
		break;
	case 21:
		_scene = new Scene21(this);
		backgroundId = _scene->init();
		_scene->updateHotspots();
		_gameSys->setScaleValues(0, 500, 1, 1000);
		initSceneGrid(21, 146, 11, 10);
		break;
	case 22:
		_scene = new Scene22(this);
		backgroundId = _scene->init();
		_scene->updateHotspots();
		_gameSys->setScaleValues(0, 500, 1, 1000);
		initSceneGrid(21, 146, 11, 10);
		break;
	case 23:
		_scene = new Scene23(this);
		backgroundId = _scene->init();
		_scene->updateHotspots();
		_gameSys->setScaleValues(0, 500, 1, 1000);
		initSceneGrid(21, 146, 11, 10);
		break;
	case 24:
		_scene = new Scene24(this);
		backgroundId = _scene->init();
		_scene->updateHotspots();
		_gameSys->setScaleValues(0, 500, 1, 1000);
		initSceneGrid(21, 136, 11, 10);
		break;
	case 25:
		_scene = new Scene25(this);
		backgroundId = _scene->init();
		_scene->updateHotspots();
		_gameSys->setScaleValues(0, 500, 1, 1000);
		initSceneGrid(21, 146, 11, 10);
		break;
	case 26:
		_scene = new Scene26(this);
		backgroundId = _scene->init();
		_scene->updateHotspots();
		_gameSys->setScaleValues(0, 500, 1, 1000);
		initSceneGrid(21, 146, 11, 10);
		break;
	case 27:
		_scene = new Scene27(this);
		backgroundId = _scene->init();
		_scene->updateHotspots();
		_gameSys->setScaleValues(0, 500, 1, 1000);
		initSceneGrid(21, 146, 11, 10);
		break;
	case 28:
		_scene = new Scene28(this);
		backgroundId = _scene->init();
		_scene->updateHotspots();
		_gameSys->setScaleValues(0, 500, 1, 1000);
		initSceneGrid(21, 146, 11, 10);
		break;
	case 29:
		_scene = new Scene29(this);
		backgroundId = _scene->init();
		_scene->updateHotspots();
		_gameSys->setScaleValues(0, 500, 1, 1000);
		initSceneGrid(21, 146, 11, 10);
		break;
	case 30:
		_scene = new Scene30(this);
		backgroundId = _scene->init();
		_scene->updateHotspots();
		_gameSys->setScaleValues(0, 500, 1, 1000);
		initSceneGrid(21, 146, 11, 10);
		break;
	case 31:
		_scene = new Scene31(this);
		backgroundId = _scene->init();
		_scene->updateHotspots();
		_gameSys->setScaleValues(0, 500, 1, 1000);
		initSceneGrid(21, 146, 11, 10);
		break;
	case 32:
		_scene = new Scene32(this);
		backgroundId = _scene->init();
		_scene->updateHotspots();
		_gameSys->setScaleValues(0, 500, 1, 1000);
		initSceneGrid(21, 146, 11, 10);
		break;
	case 33:
		_scene = new Scene33(this);
		backgroundId = _scene->init();
		_scene->updateHotspots();
		_gameSys->setScaleValues(0, 500, 1, 1000);
		initSceneGrid(21, 146, 11, 10);
		break;
	case 34:
		_scene = new Scene03(this);
		backgroundId = _scene->init();
		_scene->updateHotspots();
		_gameSys->setScaleValues(0, 500, 1, 1000);
		initSceneGrid(21, 146, 11, 10);
		break;
	case 35:
		_scene = new Scene05(this);
		backgroundId = _scene->init();
		_scene->updateHotspots();
		_gameSys->setScaleValues(0, 500, 1, 1000);
		initSceneGrid(21, 146, 11, 10);
		break;
	case 36:
		_scene = new Scene06(this);
		backgroundId = _scene->init();
		_scene->updateHotspots();
		_gameSys->setScaleValues(0, 500, 1, 1000);
		initSceneGrid(21, 146, 11, 10);
		break;
	case 37:
		_scene = new Scene04(this);
		backgroundId = _scene->init();
		_scene->updateHotspots();
		_gameSys->setScaleValues(0, 500, 1, 1000);
		initSceneGrid(21, 146, 11, 10);
		break;
	case 38:
		_scene = new Scene38(this);
		backgroundId = _scene->init();
		_scene->updateHotspots();
		_gameSys->setScaleValues(0, 500, 1, 1000);
		initSceneGrid(21, 146, 11, 10);
		break;
	case 39:
		_scene = new Scene39(this);
		backgroundId = _scene->init();
		_scene->updateHotspots();
		_gameSys->setScaleValues(0, 500, 1, 1000);
		initSceneGrid(21, 146, 11, 10);
		break;
	case 40:
		_scene = new Scene40(this);
		backgroundId = _scene->init();
		_scene->updateHotspots();
		_gameSys->setScaleValues(0, 500, 1, 1000);
		initSceneGrid(21, 146, 11, 10);
		break;
	case 41:
		_scene = new Scene41(this);
		backgroundId = _scene->init();
		_scene->updateHotspots();
		_gameSys->setScaleValues(0, 500, 1, 1000);
		initSceneGrid(21, 146, 11, 10);
		break;
	case 42:
		_scene = new Scene42(this);
		backgroundId = _scene->init();
		_scene->updateHotspots();
		_gameSys->setScaleValues(0, 500, 1, 1000);
		initSceneGrid(21, 146, 11, 10);
		break;
	case 43:
		_scene = new Scene43(this);
		backgroundId = _scene->init();
		_scene->updateHotspots();
		_gameSys->setScaleValues(0, 500, 1, 1000);
		initSceneGrid(21, 146, 11, 10);
		break;
	case 44:
		_scene = new Scene44(this);
		backgroundId = _scene->init();
		_scene->updateHotspots();
		_gameSys->setScaleValues(0, 500, 1, 1000);
		initSceneGrid(21, 146, 11, 10);
		break;
	case 45:
		_scene = new Scene45(this);
		backgroundId = _scene->init();
		_scene->updateHotspots();
		_gameSys->setScaleValues(0, 500, 1, 1000);
		initSceneGrid(21, 146, 11, 10);
		break;
	case 46:
		_scene = new Scene46(this);
		backgroundId = _scene->init();
		_scene->updateHotspots();
		_gameSys->setScaleValues(0, 500, 1, 1000);
		initSceneGrid(21, 146, 11, 10);
		break;
	case 49:
		_scene = new Scene49(this);
		backgroundId = _scene->init();
		_scene->updateHotspots();
		_gameSys->setScaleValues(0, 500, 1, 1000);
		initSceneGrid(21, 146, 11, 10);
		break;
	case 50:
		_scene = new Scene50(this);
		backgroundId = _scene->init();
		_gameSys->setScaleValues(0, 500, 1, 1000);
		initSceneGrid(21, 146, 11, 10);
		break;
	case 51:
		_scene = new Scene51(this);
		backgroundId = _scene->init();
		_gameSys->setScaleValues(0, 500, 1, 1000);
		initSceneGrid(21, 146, 11, 10);
		break;
	case 52:
		_scene = new Scene52(this);
		backgroundId = _scene->init();
		_gameSys->setScaleValues(0, 500, 1, 1000);
		initSceneGrid(21, 146, 11, 10);
		break;
	case 53:
		_scene = new Scene53(this);
		backgroundId = _scene->init();
		_scene->updateHotspots();
		_gameSys->setScaleValues(0, 500, 1, 1000);
		initSceneGrid(21, 146, 11, 10);
		break;
	}

	return backgroundId;
}

void GnapEngine::runSceneLogic() {
	switch (_currentSceneNum) {
	case 0:
		_scene->run();
		delete _scene;
		if (_newSceneNum == 55)
			_newSceneNum = 8;
		break;
	case 1:
	case 2:
	case 3:
	case 4:
	case 5:
	case 6:
		_scene->run();
		delete _scene;
		if (_newSceneNum == 55)
			_newSceneNum = 4;
		break;
	case 7:
		_scene->run();
		delete _scene;
		if (_newSceneNum == 55)
			_newSceneNum = 8;
		break;
	case 8:
		_scene->run();
		delete _scene;
		if (_newSceneNum == 55)
			_newSceneNum = 9;
		break;
	case 9:
		_scene->run();
		delete _scene;
		if (_newSceneNum == 55)
			_newSceneNum = 10;
		break;
	case 10:
	case 12:
	case 13:
		_scene->run();
		delete _scene;
		if (_newSceneNum == 55)
			_newSceneNum = 11;
		break;
	case 11:
	case 15:
		_scene->run();
		delete _scene;
		if (_newSceneNum == 55)
			_newSceneNum = 12;
		break;
	case 14:
		_scene->run();
		delete _scene;
		if (_newSceneNum == 55)
			_newSceneNum = 13;
		break;
	case 16:
		_scene = new Scene16(this);
		_scene->init();
		_newSceneNum = 17;
		_newCursorValue = 3;
		_scene->run();
		delete _scene;
		break;
	case 17:
	case 18:
	case 21:
	case 22:
	case 23:
	case 24:
	case 25:
	case 26:
	case 27:
	case 28:
	case 29:
	case 30:
	case 31:
		_scene->run();
		delete _scene;
		if (_newSceneNum == 55)
			_newSceneNum = 20;
		break;
	case 19:
		_scene->run();
		delete _scene;
		if (_newSceneNum == 55)
			_newSceneNum = 19;
		break;
	case 20:
		_scene->run();
		delete _scene;
		if (_newSceneNum == 55)
			_newSceneNum = 22;
		break;
	case 32:
	case 33:
	case 34:
	case 35:
	case 36:
	case 37:
	case 38:
	case 39:
	case 40:
	case 41:
	case 42:
	case 43:
	case 44:
	case 45:
	case 46:
		_scene->run();
		delete _scene;
		if (_newSceneNum == 55)
			_newSceneNum = 37;
		break;
	case 47:
		if (_prevSceneNum == 49) {
			_scene = new Scene471(this);
			_scene->init();
			_newSceneNum = 7;
			_newCursorValue = 2;
		} else if (_prevSceneNum == 13) {
			_scene = new Scene472(this);
			_scene->init();
			_newSceneNum = 11;
		} else if (!isFlag(kGFPlatypusDisguised) && _prevSceneNum == 2) {//CHECKME
			if (isFlag(kGFUnk25)) {
				_scene = new Scene473(this);
				_scene->init();
				_newSceneNum = 2;
			} else {
				_scene = new Scene474(this);
				_scene->init();
				_newSceneNum = 49;
			}
		} else if (_prevSceneNum == 21) {
			_scene = new Scene475(this);
			_scene->init();
			_newSceneNum = 21;
			setFlag(kGFTwigTaken);
			setFlag(kGFKeysTaken);
		} else if (_prevSceneNum == 30) {
			_scene = new Scene476(this);
			_scene->init();
			_newSceneNum = 26;
		} else if (isFlag(kGFPlatypusDisguised) && _cursorValue == 1) {
			_scene = new Scene477(this);
			_scene->init();
			_newSceneNum = 4;
		}
		_scene->run();
		delete _scene;
		break;
	case 48:
		_scene = new Scene48(this);
		_scene->init();
		_newSceneNum = 33;
		_newCursorValue = 4;
		_scene->run();
		delete _scene;
		break;
	case 49:
		_scene->run();
		delete _scene;
		if (_newSceneNum == 55)
			_newSceneNum = 47;
		break;
	case 50:
		_scene->run();
		delete _scene;
		_newSceneNum = _prevSceneNum;
		break;
	case 51:
		_scene->run();
		delete _scene;
		break;
	case 52:
		_scene->run();
		delete _scene;
		_newSceneNum = _prevSceneNum;
		break;
	case 53:
		_scene->run();
		delete _scene;
		if (_newSceneNum == 55)
			_newSceneNum = 53;
		break;
	case 54:
		if (_prevSceneNum == 45) {
			_scene = new Scene541(this);
			_scene->init();
			_newSceneNum = 43;
			_scene->run();
			delete _scene;
		} else {
			_scene = new Scene542(this);
			_scene->init();
			_scene->run();
			delete _scene;
			_gameDone = true;
		}
		break;
	}
}

void Scene::playRandomSound(int timerIndex) {
	if (!_vm->_timers[timerIndex]) {
		_vm->_timers[timerIndex] = _vm->getRandom(40) + 50;
		switch (_vm->getRandom(4)) {
		case 0:
			_vm->playSound(0x1091B, false);
			break;
		case 1:
			_vm->playSound(0x10921, false);
			break;
		case 2:
			_vm->playSound(0x10927, false);
			break;
		case 3:
			_vm->playSound(0x1091D, false);
			break;
		}
	}
}

bool Scene::clearKeyStatus() {
	if (_vm->isKeyStatus1(Common::KEYCODE_ESCAPE)) {
		_vm->clearKeyStatus1(Common::KEYCODE_ESCAPE);
		_vm->clearKeyStatus1(Common::KEYCODE_UP);
		_vm->clearKeyStatus1(Common::KEYCODE_RIGHT);
		_vm->clearKeyStatus1(Common::KEYCODE_LEFT);
		_vm->clearKeyStatus1(Common::KEYCODE_p);
		return true;
	}

	if (_vm->isKeyStatus1(Common::KEYCODE_p)) {
		_vm->clearKeyStatus1(Common::KEYCODE_p);
		_vm->pauseGame();
		_vm->updatePause();
	}

	return false;
}

/****************************************************************************/

CutScene::CutScene(GnapEngine *vm) : Scene(vm) {
	_itemsCount = -1;
	
	for (int i = 0; i < 16; i++) {
		_resourceIdArr[i] = -1;
		_sequenceCountArr[i] = -1;
		_canSkip[i] = false;
	}

	for (int i = 0; i < 50; i++)
		_sequenceIdArr[i] = -1;
}

void CutScene::run() {
	GameSys& gameSys = *_vm->_gameSys;

	int itemIndex = 0;
	int soundId = -1;
	int volume = 100;
	int duration = 0;
	bool skip = false;

	if (_vm->_prevSceneNum == 2) {
		soundId = 0x36B;
		duration = MAX(1, 300 / _vm->getSequenceTotalDuration(_sequenceIdArr[_itemsCount - 1]));
		_vm->_timers[0] = 0;
	}

	if (soundId != -1)
		_vm->playSound(soundId, false);

	_vm->hideCursor();

	gameSys.drawSpriteToBackground(0, 0, _resourceIdArr[0]);

	for (int j = 0; j < _sequenceCountArr[0]; ++j)
		gameSys.insertSequence(_sequenceIdArr[j], j + 2, 0, 0, kSeqNone, 0, 0, 0);
	gameSys.setAnimation(_sequenceIdArr[0], 2, 0);

	_vm->clearKeyStatus1(Common::KEYCODE_ESCAPE);
	_vm->clearKeyStatus1(Common::KEYCODE_SPACE);
	_vm->clearKeyStatus1(Common::KEYCODE_RETURN);

	_vm->_mouseClickState._left = false;

	int firstSequenceIndex = 0;
	while (!_vm->_sceneDone) {
		_vm->gameUpdateTick();

		if (gameSys.getAnimationStatus(0) == 2 || skip) {
			skip = false;
			gameSys.requestClear2(false);
			gameSys.requestClear1();
			gameSys.setAnimation(0, 0, 0);
			firstSequenceIndex += _sequenceCountArr[itemIndex++];
			if (itemIndex >= _itemsCount) {
				_vm->_sceneDone = true;
			} else {
				for (int m = 0; m < _sequenceCountArr[itemIndex]; ++m)
					gameSys.insertSequence(_sequenceIdArr[firstSequenceIndex + m], m + 2, 0, 0, kSeqNone, 0, 0, 0);
				gameSys.drawSpriteToBackground(0, 0, _resourceIdArr[itemIndex]);
				gameSys.setAnimation(_sequenceIdArr[firstSequenceIndex], 2, 0);
			}
		}

		if (_vm->isKeyStatus1(Common::KEYCODE_ESCAPE) || _vm->isKeyStatus1(Common::KEYCODE_SPACE) || _vm->isKeyStatus1(Common::KEYCODE_RETURN)) {
			_vm->clearKeyStatus1(Common::KEYCODE_ESCAPE);
			_vm->clearKeyStatus1(Common::KEYCODE_SPACE);
			_vm->clearKeyStatus1(Common::KEYCODE_RETURN);
			if (_canSkip[itemIndex])
				skip = true;
			else
				_vm->_sceneDone = true;
		}

		if (!_vm->_timers[0] && itemIndex == _itemsCount - 1) {
			_vm->_timers[0] = 2;
			volume = MAX(1, volume - duration);
			_vm->setSoundVolume(soundId, volume);
		}
	}

	if (soundId != -1)
		_vm->stopSound(soundId);
}

} // End of namespace Gnap