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 #include "xeen/worldofxeen/worldofxeen.h"
24 #include "xeen/worldofxeen/darkside_cutscenes.h"
25 #include "xeen/worldofxeen/clouds_cutscenes.h"
26 #include "xeen/worldofxeen/worldofxeen_menu.h"
27 #include "xeen/sound.h"
28 #include "common/config-manager.h"
29
30 namespace Xeen {
31 namespace WorldOfXeen {
32
WorldOfXeenEngine(OSystem * syst,const XeenGameDescription * gameDesc)33 WorldOfXeenEngine::WorldOfXeenEngine(OSystem *syst, const XeenGameDescription *gameDesc)
34 : XeenEngine(syst, gameDesc), WorldOfXeenCutscenes(this) {
35 }
36
death()37 void WorldOfXeenEngine::death() {
38 Window &w = (*_windows)[0];
39 _sound->stopAllAudio();
40 SpriteResource fireSprites[4] = {
41 SpriteResource("fire1.vga"),
42 SpriteResource("fire2.vga"),
43 SpriteResource("fire3.vga"),
44 SpriteResource("fire4.vga")
45 };
46 SpriteResource deathSprites("death.vga"), death1Sprites("death1.vga");
47 const int Y_LIST[] = {
48 196, 187, 179, 169, 159, 147, 138, 127, 113, 101, 86,
49 73, 60, 48, 36, 23, 10, 0, 0
50 };
51
52 Graphics::ManagedSurface savedBg;
53 savedBg.copyFrom(*_screen);
54
55 fireSprites[0].draw(0, 0, Common::Point(0, 0));
56 fireSprites[0].draw(0, 1, Common::Point(160, 0));
57 w.update();
58 _sound->playSound("fire.voc");
59
60 // Fire will vertically consume the screen
61 for (int idx = 2; idx < 36; idx += 2) {
62 _events->updateGameCounter();
63 _screen->blitFrom(savedBg);
64
65 fireSprites[idx / 10].draw(0, idx % 10, Common::Point(0, 0));
66 fireSprites[idx / 10].draw(0, (idx % 10) + 1, Common::Point(160, 0));
67
68 for (int yCtr = 0, frame = 0; yCtr < (idx / 2); ++yCtr, frame += 2) {
69 deathSprites.draw(0, frame, Common::Point(0, Y_LIST[yCtr]));
70 deathSprites.draw(0, frame + 1, Common::Point(160, Y_LIST[yCtr]));
71 }
72
73 w.update();
74 _events->wait(1, false);
75 }
76
77 deathSprites.draw(0, 34, Common::Point(0, 0));
78 deathSprites.draw(0, 35, Common::Point(160, 0));
79 w.update();
80 savedBg.blitFrom(*_screen);
81
82 _sound->playSound(_files->_ccNum ? "laff1.voc" : "xeenlaff.voc", _files->_ccNum, 0);
83
84 // Animation of Xeen or Alamar laughing
85 for (int idx = 0, idx2 = 0; idx < (_files->_ccNum ? 10 : 23); ++idx) {
86 _events->updateGameCounter();
87 _screen->blitFrom(savedBg);
88
89 if (idx != 0)
90 death1Sprites.draw(0, idx - 1);
91 w.update();
92
93 if (_files->_ccNum) {
94 _events->wait(2, false);
95 } else {
96 if (idx == 1 || idx == 11)
97 _sound->playFX(33);
98 _events->wait(2, false);
99 if (idx == 15)
100 _sound->playFX(34);
101 }
102
103 if (idx == (_files->_ccNum ? 9 : 10)) {
104 if (idx2 < (_files->_ccNum ? 2 : 1)) {
105 idx = -1;
106 ++idx2;
107 }
108 }
109
110 if (!_sound->isSoundPlaying())
111 idx = 23;
112 }
113
114 while (_sound->isSoundPlaying())
115 _events->wait(1, false);
116
117 _screen->blitFrom(savedBg);
118 w.update();
119 }
120
dream()121 void WorldOfXeenEngine::dream() {
122 if (g_vm->getGameID() == GType_Clouds)
123 // Dreams only available for Dark Side & World
124 return;
125
126 Windows &windows = *_windows;
127 Graphics::ManagedSurface savedBg;
128
129 savedBg.copyFrom(*_screen);
130 _screen->fadeOut();
131 _events->hideCursor();
132
133 _screen->loadBackground("scene1.raw");
134 windows[0].update();
135 _screen->fadeIn();
136
137 _events->updateGameCounter();
138 while (!shouldExit() && _events->timeElapsed() < 7)
139 _events->pollEventsAndWait();
140
141 _sound->playSound("dreams2.voc", 1, 0);
142 while (!shouldExit() && _sound->isSoundPlaying())
143 _events->pollEventsAndWait();
144
145 _sound->playSound("laff1.voc", 1, 0);
146 while (!shouldExit() && _sound->isSoundPlaying())
147 _events->pollEventsAndWait();
148
149 _events->updateGameCounter();
150 while (!shouldExit() && _events->timeElapsed() < 7)
151 _events->pollEventsAndWait();
152
153 _screen->fadeOut();
154 _events->setCursor(0);
155 _screen->blitFrom(savedBg);
156 windows[0].update();
157
158 _screen->fadeIn();
159 }
160
showCutscene(const Common::String & name,int status,uint score)161 void WorldOfXeenEngine::showCutscene(const Common::String &name, int status, uint score) {
162 _sound->stopAllAudio();
163 _events->clearEvents();
164
165 if (name == "ENDGAME")
166 showCloudsEnding(score);
167 else if (name == "ENDGAME2")
168 showDarkSideEnding(score);
169 else if (name == "WORLDEND")
170 showWorldOfXeenEnding((GooberState)status, score);
171
172 _screen->freePages();
173 _sound->stopAllAudio();
174 _events->clearEvents();
175 _gameMode = GMODE_MENU;
176 }
177
showStartup()178 void WorldOfXeenEngine::showStartup() {
179 bool seenIntro = ConfMan.hasKey("seen_intro") && ConfMan.getBool("seen_intro");
180 bool completedIntro;
181
182 if (getGameID() == GType_Clouds)
183 completedIntro = showCloudsIntro();
184 else
185 completedIntro = showDarkSideIntro(seenIntro);
186
187 if (!seenIntro && completedIntro) {
188 ConfMan.setBool("seen_intro", true);
189 ConfMan.flushToDisk();
190 }
191
192 _gameMode = GMODE_MENU;
193 }
194
showMainMenu()195 void WorldOfXeenEngine::showMainMenu() {
196 WorldOfXeenMainMenuContainer::show();
197 }
198
199 } // End of namespace WorldOfXeen
200 } // End of namespace Xeen
201