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
|
/* 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/render.h"
#include "saga/rscfile.h"
#include "saga/sndres.h"
#include "saga/music.h"
#include "saga/scene.h"
#include "common/events.h"
namespace Saga {
// IHNM cutaway intro resource IDs
#define RID_IHNM_INTRO_CUTAWAYS 39
#define RID_IHNMDEMO_INTRO_CUTAWAYS 25
int Scene::IHNMStartProc() {
LoadSceneParams firstScene;
IHNMLoadCutaways();
if (_vm->getGameId() != GID_IHNM_DEMO) {
int logoLength = -168;
if (_vm->getLanguage() == Common::DE_DEU || _vm->getLanguage() == Common::ES_ESP)
logoLength = -128;
// Play Cyberdreams logo for 168 frames
if (!playTitle(0, logoLength, true)) {
if (_vm->shouldQuit())
return !SUCCESS;
// Play Dreamers Guild logo for 10 seconds
if (!playLoopingTitle(1, 10)) {
if (_vm->shouldQuit())
return !SUCCESS;
// Play the title music
_vm->_music->play(1, MUSIC_NORMAL);
// Play title screen
playTitle(2, 17);
}
}
} else {
_vm->_music->play(1, MUSIC_NORMAL);
playTitle(0, 10);
if (_vm->shouldQuit())
return !SUCCESS;
playTitle(2, 12);
}
_vm->_music->setVolume(0, 1000);
_vm->_anim->freeCutawayList();
// Queue first scene
firstScene.loadFlag = kLoadBySceneNumber;
firstScene.sceneDescriptor = -1;
firstScene.sceneDescription = NULL;
firstScene.sceneSkipTarget = false;
firstScene.sceneProc = NULL;
firstScene.transitionType = kTransitionFade;
firstScene.actorsEntrance = 0;
firstScene.chapter = -1;
_vm->_scene->queueScene(&firstScene);
return SUCCESS;
}
int Scene::IHNMCreditsProc() {
IHNMLoadCutaways();
_vm->_music->play(0, MUSIC_NORMAL);
if (_vm->getGameId() != GID_IHNM_DEMO) {
// Display the credits for 400 frames
playTitle(4, -400, true);
} else {
// Display sales info for 60 seconds
playTitle(3, 60, true);
}
_vm->_music->setVolume(0, 1000);
_vm->_anim->freeCutawayList();
return SUCCESS;
}
void Scene::IHNMLoadCutaways() {
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);
free(resourcePointer);
}
bool Scene::checkKey() {
Common::Event event;
bool res = false;
while (_vm->_eventMan->pollEvent(event)) {
switch (event.type) {
case Common::EVENT_RTL:
case Common::EVENT_QUIT:
res = true;
break;
case Common::EVENT_KEYDOWN:
// Don't react to modifier keys alone. The original did
// non, and the user may want to change scaler without
// terminating the intro.
if (event.kbd.ascii)
res = true;
break;
default:
break;
}
}
return res;
}
bool Scene::playTitle(int title, int time, int mode) {
bool interrupted = false;
int startTime = _vm->_system->getMillis();
int frameTime = 0;
int curTime;
int assignedId;
int phase = 0;
bool done = false;
bool playParameter = true;
static PalEntry cur_pal[PAL_ENTRIES];
static PalEntry pal_cut[PAL_ENTRIES];
Surface *backBufferSurface = _vm->_render->getBackGroundSurface();
// Load the cutaway
_vm->_anim->setCutAwayMode(mode);
_vm->_frameCount = 0;
_vm->_gfx->getCurrentPal(cur_pal);
assignedId = _vm->_anim->playCutaway(title, false);
_vm->_gfx->getCurrentPal(pal_cut);
while (!done && !_vm->shouldQuit()) {
curTime = _vm->_system->getMillis();
switch (phase) {
case 0: // fadeout
case 1: // fadeout 100%
case 7: // fadeout
case 8: // fadeout 100%
_vm->_gfx->palToBlack(cur_pal, (double)(curTime - startTime) / kNormalFadeDuration);
// fall through
case 3: // fadein
case 4: // fadein 100%
if (phase == 3 || phase == 4)
_vm->_gfx->blackToPal(pal_cut, (double)(curTime - startTime) / kNormalFadeDuration);
if (curTime - startTime > kNormalFadeDuration) {
phase++;
if (phase == 2 || phase == 5 || phase == 9)
startTime = curTime;
break;
}
break;
case 2: // display background
_vm->_system->copyRectToScreen((byte *)backBufferSurface->pixels, backBufferSurface->w, 0, 0,
backBufferSurface->w, backBufferSurface->h);
phase++;
startTime = curTime;
break;
case 5: // playback
if (time < 0) {
if (_vm->_frameCount >= -time) {
phase++;
break;
}
} else {
if (curTime - startTime >= time * 1000) {
phase++;
break;
}
}
if (checkKey()) {
_vm->_scene->cutawaySkip();
interrupted = true;
phase = 6; // end playback and fade out
break;
}
if (_vm->_anim->getCycles(assignedId)) { // IHNM demo has 0 frames logo
if (curTime - frameTime > _vm->_anim->getFrameTime(assignedId)) {
_vm->_anim->play(assignedId, 0, playParameter);
if (playParameter == true) // Do not loop animations
playParameter = false;
frameTime = curTime;
_vm->_system->copyRectToScreen((byte *)backBufferSurface->pixels, backBufferSurface->w, 0, 0,
backBufferSurface->w, backBufferSurface->h);
}
}
break;
case 6: // playback end
startTime = curTime;
_vm->_gfx->getCurrentPal(cur_pal);
phase++;
break;
case 9: // end
done = true;
break;
}
_vm->_system->updateScreen();
_vm->_system->delayMillis(10);
}
// Clean up
_vm->_anim->endVideo();
memset((byte *)backBufferSurface->pixels, 0, backBufferSurface->w * backBufferSurface->h);
_vm->_system->copyRectToScreen((byte *)backBufferSurface->pixels, backBufferSurface->w, 0, 0,
backBufferSurface->w, backBufferSurface->h);
return interrupted;
}
bool Scene::playLoopingTitle(int title, int seconds) {
return playTitle(title, seconds, kPanelCutaway);
}
} // End of namespace Saga
|