2007-05-30 21:56:52 +00:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
2004-04-12 21:40:49 +00:00
|
|
|
*
|
2007-05-30 21:56:52 +00:00
|
|
|
* 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.
|
2004-04-12 21:40:49 +00:00
|
|
|
*
|
|
|
|
* 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
|
2008-01-05 12:45:14 +00:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2004-04-12 21:40:49 +00:00
|
|
|
* 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
|
2005-10-18 01:30:26 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2004-04-12 21:40:49 +00:00
|
|
|
*
|
2006-02-11 12:44:16 +00:00
|
|
|
* $URL$
|
|
|
|
* $Id$
|
2004-04-12 21:40:49 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2004-05-01 09:19:35 +00:00
|
|
|
// "I Have No Mouth" Intro sequence scene procedures
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2004-08-02 16:20:35 +00:00
|
|
|
#include "saga/saga.h"
|
|
|
|
#include "saga/gfx.h"
|
|
|
|
|
|
|
|
#include "saga/animation.h"
|
2004-08-10 19:00:30 +00:00
|
|
|
#include "saga/events.h"
|
2005-10-07 15:36:28 +00:00
|
|
|
#include "saga/interface.h"
|
2007-08-30 17:55:19 +00:00
|
|
|
#include "saga/render.h"
|
2007-07-30 09:14:15 +00:00
|
|
|
#include "saga/rscfile.h"
|
2004-11-24 15:02:00 +00:00
|
|
|
#include "saga/sndres.h"
|
2004-11-20 17:19:15 +00:00
|
|
|
#include "saga/music.h"
|
2004-08-02 16:20:35 +00:00
|
|
|
|
|
|
|
#include "saga/scene.h"
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2007-08-30 17:55:19 +00:00
|
|
|
#include "common/events.h"
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2007-08-30 17:55:19 +00:00
|
|
|
namespace Saga {
|
2007-07-30 09:14:15 +00:00
|
|
|
|
|
|
|
// IHNM cutaway intro resource IDs
|
|
|
|
#define RID_IHNM_INTRO_CUTAWAYS 39
|
|
|
|
#define RID_IHNMDEMO_INTRO_CUTAWAYS 25
|
|
|
|
|
2007-08-30 17:55:19 +00:00
|
|
|
int Scene::IHNMStartProc() {
|
|
|
|
LoadSceneParams firstScene;
|
|
|
|
|
|
|
|
IHNMLoadCutaways();
|
|
|
|
|
2007-08-27 13:04:35 +00:00
|
|
|
if (_vm->getGameId() != GID_IHNM_DEMO) {
|
2007-09-01 10:49:28 +00:00
|
|
|
int logoLength = -168;
|
|
|
|
|
|
|
|
if (_vm->getLanguage() == Common::DE_DEU || _vm->getLanguage() == Common::ES_ESP)
|
|
|
|
logoLength = -128;
|
|
|
|
|
2007-08-30 17:55:19 +00:00
|
|
|
// Play Cyberdreams logo for 168 frames
|
2007-09-01 10:49:28 +00:00
|
|
|
if (!playTitle(0, logoLength, true)) {
|
2007-08-30 17:55:19 +00:00
|
|
|
// Play Dreamers Guild logo for 10 seconds
|
|
|
|
if (!playLoopingTitle(1, 10)) {
|
|
|
|
// Play the title music
|
|
|
|
_vm->_music->play(1, MUSIC_NORMAL);
|
|
|
|
// Play title screen
|
|
|
|
playTitle(2, 17);
|
|
|
|
}
|
|
|
|
}
|
2007-08-27 13:04:35 +00:00
|
|
|
} else {
|
2007-08-30 17:55:19 +00:00
|
|
|
_vm->_music->play(1, MUSIC_NORMAL);
|
|
|
|
playTitle(0, 10);
|
|
|
|
playTitle(2, 12);
|
2007-08-27 13:04:35 +00:00
|
|
|
}
|
|
|
|
|
2007-08-30 17:55:19 +00:00
|
|
|
_vm->_music->setVolume(0, 1000);
|
|
|
|
_vm->_anim->freeCutawayList();
|
|
|
|
|
|
|
|
// Queue first scene
|
|
|
|
firstScene.loadFlag = kLoadBySceneNumber;
|
|
|
|
firstScene.sceneDescriptor = -1;
|
|
|
|
firstScene.sceneDescription = NULL;
|
2007-09-29 06:19:02 +00:00
|
|
|
firstScene.sceneSkipTarget = false;
|
2007-08-30 17:55:19 +00:00
|
|
|
firstScene.sceneProc = NULL;
|
|
|
|
firstScene.transitionType = kTransitionFade;
|
|
|
|
firstScene.actorsEntrance = 0;
|
|
|
|
firstScene.chapter = -1;
|
|
|
|
|
|
|
|
_vm->_scene->queueScene(&firstScene);
|
|
|
|
|
2007-08-27 13:04:35 +00:00
|
|
|
return SUCCESS;
|
|
|
|
}
|
|
|
|
|
2007-08-30 17:55:19 +00:00
|
|
|
int Scene::IHNMCreditsProc() {
|
|
|
|
IHNMLoadCutaways();
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2007-08-30 17:55:19 +00:00
|
|
|
_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);
|
|
|
|
}
|
2004-11-25 07:13:40 +00:00
|
|
|
|
2007-08-30 17:55:19 +00:00
|
|
|
_vm->_music->setVolume(0, 1000);
|
|
|
|
_vm->_anim->freeCutawayList();
|
2007-08-27 10:14:13 +00:00
|
|
|
|
2007-08-30 17:55:19 +00:00
|
|
|
return SUCCESS;
|
|
|
|
}
|
2007-07-30 09:14:15 +00:00
|
|
|
|
2007-08-30 17:55:19 +00:00
|
|
|
void Scene::IHNMLoadCutaways() {
|
2007-07-30 09:14:15 +00:00
|
|
|
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);
|
2004-08-11 23:42:02 +00:00
|
|
|
}
|
|
|
|
|
2007-08-30 17:55:19 +00:00
|
|
|
bool Scene::checkKey() {
|
|
|
|
Common::Event event;
|
|
|
|
bool res = false;
|
|
|
|
|
|
|
|
while (_vm->_eventMan->pollEvent(event)) {
|
|
|
|
switch (event.type) {
|
2007-08-30 18:59:05 +00:00
|
|
|
case Common::EVENT_QUIT:
|
2007-09-29 05:46:57 +00:00
|
|
|
res = true;
|
2007-08-30 18:59:05 +00:00
|
|
|
_vm->shutDown();
|
2007-09-29 05:46:57 +00:00
|
|
|
break;
|
2007-08-30 17:55:19 +00:00
|
|
|
case Common::EVENT_KEYDOWN:
|
2007-09-29 05:46:57 +00:00
|
|
|
// 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;
|
2007-08-30 17:55:19 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2007-07-30 09:14:15 +00:00
|
|
|
}
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
|
2007-08-30 17:55:19 +00:00
|
|
|
return res;
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
|
2007-08-30 17:55:19 +00:00
|
|
|
bool Scene::playTitle(int title, int time, int mode) {
|
|
|
|
bool interrupted = false;
|
|
|
|
Surface *backBufferSurface;
|
|
|
|
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];
|
|
|
|
|
|
|
|
backBufferSurface = _vm->_render->getBackGroundSurface();
|
|
|
|
|
|
|
|
// Load the cutaway
|
|
|
|
|
|
|
|
_vm->_anim->setCutAwayMode(mode);
|
|
|
|
_vm->_frameCount = 0;
|
|
|
|
|
|
|
|
_vm->_gfx->getCurrentPal(cur_pal);
|
|
|
|
|
2007-08-31 08:20:41 +00:00
|
|
|
assignedId = _vm->_anim->playCutaway(title, false);
|
2007-08-30 17:55:19 +00:00
|
|
|
|
|
|
|
_vm->_gfx->getCurrentPal(pal_cut);
|
|
|
|
|
|
|
|
while (!done) {
|
|
|
|
curTime = _vm->_system->getMillis();
|
|
|
|
|
|
|
|
switch (phase) {
|
|
|
|
case 0: // fadeout
|
|
|
|
case 1: // fadeout 100%
|
|
|
|
case 7: // fadeout
|
|
|
|
case 8: // fadeout 100%
|
2007-08-31 11:14:32 +00:00
|
|
|
_vm->_gfx->palToBlack(cur_pal, (double)(curTime - startTime) / kNormalFadeDuration);
|
|
|
|
// fall through
|
|
|
|
|
|
|
|
case 3: // fadein
|
|
|
|
case 4: // fadein 100%
|
|
|
|
if (phase == 3 || phase == 4)
|
2007-08-30 17:55:19 +00:00
|
|
|
_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;
|
|
|
|
}
|
|
|
|
}
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2007-08-30 17:55:19 +00:00
|
|
|
if (checkKey()) {
|
2007-09-29 06:26:22 +00:00
|
|
|
_vm->_scene->cutawaySkip();
|
2007-08-30 17:55:19 +00:00
|
|
|
interrupted = true;
|
2007-10-22 16:03:42 +00:00
|
|
|
phase = 6; // end playback and fade out
|
2007-08-30 17:55:19 +00:00
|
|
|
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;
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2007-08-30 17:55:19 +00:00
|
|
|
_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;
|
|
|
|
}
|
2004-08-11 23:42:02 +00:00
|
|
|
|
2007-08-30 17:55:19 +00:00
|
|
|
_vm->_system->updateScreen();
|
|
|
|
_vm->_system->delayMillis(10);
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
|
2007-08-30 17:55:19 +00:00
|
|
|
// Clean up
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2007-08-30 17:55:19 +00:00
|
|
|
_vm->_anim->endVideo();
|
2004-11-24 10:37:33 +00:00
|
|
|
|
2007-08-30 17:55:19 +00:00
|
|
|
memset((byte *)backBufferSurface->pixels, 0, backBufferSurface->w * backBufferSurface->h);
|
|
|
|
_vm->_system->copyRectToScreen((byte *)backBufferSurface->pixels, backBufferSurface->w, 0, 0,
|
|
|
|
backBufferSurface->w, backBufferSurface->h);
|
2004-11-24 10:37:33 +00:00
|
|
|
|
2007-08-30 17:55:19 +00:00
|
|
|
return interrupted;
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
|
2007-08-30 17:55:19 +00:00
|
|
|
bool Scene::playLoopingTitle(int title, int seconds) {
|
|
|
|
return playTitle(title, seconds, kPanelCutaway);
|
2007-08-27 13:04:35 +00:00
|
|
|
}
|
|
|
|
|
2004-04-12 21:40:49 +00:00
|
|
|
} // End of namespace Saga
|