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
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (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, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 *
21 */
22
23 #ifdef ENABLE_SAGA2
24
25 // "Dinotopia" and "Faery Tale Adventure II: Halls of the Dead" Intro sequence scene procedures
26
27 #include "saga/saga.h"
28 #include "saga/scene.h"
29 #include "saga/gfx.h"
30
31 #include "common/events.h"
32 #include "common/keyboard.h"
33 #include "common/system.h"
34 #include "common/textconsole.h"
35 #include "graphics/palette.h"
36 #include "graphics/surface.h"
37 #include "video/smk_decoder.h"
38
39 namespace Saga {
40
DinoStartProc()41 int Scene::DinoStartProc() {
42 _vm->_gfx->showCursor(false);
43
44 playMovie("testvid.smk");
45
46 return SUCCESS;
47 }
48
FTA2StartProc()49 int Scene::FTA2StartProc() {
50 _vm->_gfx->showCursor(false);
51
52 playMovie("trimark.smk");
53 playMovie("intro.smk");
54
55 return SUCCESS;
56 }
57
FTA2EndProc(FTA2Endings whichEnding)58 int Scene::FTA2EndProc(FTA2Endings whichEnding) {
59 char videoName[20];
60
61 switch (whichEnding) {
62 case kFta2BadEndingLaw:
63 strcpy(videoName, "end_1.smk");
64 break;
65 case kFta2BadEndingChaos:
66 strcpy(videoName, "end_2.smk");
67 break;
68 case kFta2GoodEnding1:
69 strcpy(videoName, "end_3a.smk");
70 break;
71 case kFta2GoodEnding2:
72 strcpy(videoName, "end_3b.smk");
73 break;
74 case kFta2BadEndingDeath:
75 strcpy(videoName, "end_4.smk");
76 break;
77 default:
78 error("Unknown FTA2 ending");
79 }
80
81 _vm->_gfx->showCursor(false);
82
83 // Play ending
84 playMovie(videoName);
85
86 return SUCCESS;
87 }
88
playMovie(const char * filename)89 void Scene::playMovie(const char *filename) {
90 Video::SmackerDecoder *smkDecoder = new Video::SmackerDecoder();
91
92 if (!smkDecoder->loadFile(filename))
93 return;
94
95 uint16 x = (g_system->getWidth() - smkDecoder->getWidth()) / 2;
96 uint16 y = (g_system->getHeight() - smkDecoder->getHeight()) / 2;
97 bool skipVideo = false;
98
99 smkDecoder->start();
100
101 while (!_vm->shouldQuit() && !smkDecoder->endOfVideo() && !skipVideo) {
102 if (smkDecoder->needsUpdate()) {
103 const Graphics::Surface *frame = smkDecoder->decodeNextFrame();
104 if (frame) {
105 _vm->_system->copyRectToScreen(frame->getPixels(), frame->pitch, x, y, frame->w, frame->h);
106
107 if (smkDecoder->hasDirtyPalette())
108 _vm->_system->getPaletteManager()->setPalette(smkDecoder->getPalette(), 0, 256);
109
110 _vm->_system->updateScreen();
111 }
112 }
113
114 Common::Event event;
115 while (_vm->_system->getEventManager()->pollEvent(event)) {
116 if ((event.type == Common::EVENT_KEYDOWN && event.kbd.keycode == Common::KEYCODE_ESCAPE) || event.type == Common::EVENT_LBUTTONUP)
117 skipVideo = true;
118 }
119
120 _vm->_system->delayMillis(10);
121 }
122 }
123
124 } // End of namespace Saga
125
126 #endif
127