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
|
|
|
|
* 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
|
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 13:48:01 +00:00
|
|
|
// Scene management module
|
2004-08-02 16:20:35 +00:00
|
|
|
#include "saga/saga.h"
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2004-08-02 16:20:35 +00:00
|
|
|
#include "saga/gfx.h"
|
|
|
|
#include "saga/animation.h"
|
2004-08-10 18:31:33 +00:00
|
|
|
#include "saga/console.h"
|
2004-10-21 06:49:11 +00:00
|
|
|
#include "saga/interface.h"
|
2004-08-10 19:00:30 +00:00
|
|
|
#include "saga/events.h"
|
2004-08-02 16:20:35 +00:00
|
|
|
#include "saga/isomap.h"
|
|
|
|
#include "saga/objectmap.h"
|
2004-08-10 19:20:33 +00:00
|
|
|
#include "saga/palanim.h"
|
2005-05-23 02:23:34 +00:00
|
|
|
#include "saga/puzzle.h"
|
2004-08-02 16:20:35 +00:00
|
|
|
#include "saga/render.h"
|
|
|
|
#include "saga/script.h"
|
|
|
|
#include "saga/sound.h"
|
|
|
|
#include "saga/music.h"
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2004-08-02 16:20:35 +00:00
|
|
|
#include "saga/scene.h"
|
2004-12-15 00:24:12 +00:00
|
|
|
#include "saga/stream.h"
|
2004-12-18 20:33:02 +00:00
|
|
|
#include "saga/actor.h"
|
2005-07-19 19:05:52 +00:00
|
|
|
#include "saga/rscfile.h"
|
2006-05-13 10:30:38 +00:00
|
|
|
#include "saga/sagaresnames.h"
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2007-05-01 15:39:40 +00:00
|
|
|
#include "graphics/iff.h"
|
2005-07-31 12:03:03 +00:00
|
|
|
#include "common/util.h"
|
2005-07-29 16:37:06 +00:00
|
|
|
|
2004-04-12 21:40:49 +00:00
|
|
|
namespace Saga {
|
|
|
|
|
2005-01-04 16:10:43 +00:00
|
|
|
static int initSceneDoors[SCENE_DOORS_MAX] = {
|
2005-07-29 17:58:00 +00:00
|
|
|
0, 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
|
2005-07-25 17:35:35 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static SAGAResourceTypes ITESceneResourceTypes[26] = {
|
|
|
|
SAGA_ACTOR,
|
|
|
|
SAGA_OBJECT,
|
|
|
|
SAGA_BG_IMAGE,
|
|
|
|
SAGA_BG_MASK,
|
|
|
|
SAGA_UNKNOWN,
|
|
|
|
SAGA_STRINGS,
|
|
|
|
SAGA_OBJECT_MAP,
|
|
|
|
SAGA_ACTION_MAP,
|
|
|
|
SAGA_ISO_IMAGES,
|
|
|
|
SAGA_ISO_MAP,
|
|
|
|
SAGA_ISO_PLATFORMS,
|
|
|
|
SAGA_ISO_METATILES,
|
|
|
|
SAGA_ENTRY,
|
|
|
|
SAGA_UNKNOWN,
|
|
|
|
SAGA_ANIM,
|
|
|
|
SAGA_ANIM,
|
|
|
|
SAGA_ANIM,
|
|
|
|
SAGA_ANIM,
|
|
|
|
SAGA_ANIM,
|
|
|
|
SAGA_ANIM,
|
|
|
|
SAGA_ANIM,
|
|
|
|
SAGA_ANIM,
|
|
|
|
SAGA_ISO_MULTI,
|
|
|
|
SAGA_PAL_ANIM,
|
|
|
|
SAGA_FACES,
|
|
|
|
SAGA_PALETTE
|
|
|
|
};
|
|
|
|
|
|
|
|
static SAGAResourceTypes IHNMSceneResourceTypes[28] = {
|
|
|
|
SAGA_ACTOR,
|
|
|
|
SAGA_UNKNOWN,
|
|
|
|
SAGA_BG_IMAGE,
|
|
|
|
SAGA_BG_MASK,
|
|
|
|
SAGA_UNKNOWN,
|
|
|
|
SAGA_STRINGS,
|
|
|
|
SAGA_OBJECT_MAP,
|
|
|
|
SAGA_ACTION_MAP,
|
|
|
|
SAGA_ISO_IMAGES,
|
|
|
|
SAGA_ISO_MAP,
|
|
|
|
SAGA_ISO_PLATFORMS,
|
|
|
|
SAGA_ISO_METATILES,
|
|
|
|
SAGA_ENTRY,
|
|
|
|
SAGA_UNKNOWN,
|
|
|
|
SAGA_ANIM,
|
|
|
|
SAGA_ANIM,
|
|
|
|
SAGA_ANIM,
|
|
|
|
SAGA_ANIM,
|
|
|
|
SAGA_ANIM,
|
|
|
|
SAGA_ANIM,
|
|
|
|
SAGA_ANIM,
|
|
|
|
SAGA_ANIM,
|
|
|
|
SAGA_ANIM,
|
|
|
|
SAGA_ANIM,
|
|
|
|
SAGA_ISO_MULTI,
|
|
|
|
SAGA_PAL_ANIM,
|
|
|
|
SAGA_FACES,
|
|
|
|
SAGA_PALETTE
|
2005-01-04 16:10:43 +00:00
|
|
|
};
|
|
|
|
|
2005-07-31 16:51:14 +00:00
|
|
|
const char *SAGAResourceTypesString[] = {
|
2005-07-31 12:03:03 +00:00
|
|
|
"SAGA_UNKNOWN",
|
|
|
|
"SAGA_ACTOR",
|
|
|
|
"SAGA_OBJECT",
|
|
|
|
"SAGA_BG_IMAGE",
|
|
|
|
"SAGA_BG_MASK",
|
|
|
|
"SAGA_STRINGS",
|
|
|
|
"SAGA_OBJECT_MAP",
|
|
|
|
"SAGA_ACTION_MAP",
|
|
|
|
"SAGA_ISO_IMAGES",
|
|
|
|
"SAGA_ISO_MAP",
|
|
|
|
"SAGA_ISO_PLATFORMS",
|
|
|
|
"SAGA_ISO_METATILES",
|
|
|
|
"SAGA_ENTRY",
|
|
|
|
"SAGA_ANIM",
|
|
|
|
"SAGA_ISO_MULTI",
|
|
|
|
"SAGA_PAL_ANIM",
|
|
|
|
"SAGA_FACES",
|
|
|
|
"SAGA_PALETTE"
|
|
|
|
};
|
|
|
|
|
2005-07-19 19:05:52 +00:00
|
|
|
Scene::Scene(SagaEngine *vm) : _vm(vm) {
|
|
|
|
byte *sceneLUTPointer;
|
|
|
|
size_t sceneLUTLength;
|
|
|
|
uint32 resourceId;
|
2004-04-12 21:40:49 +00:00
|
|
|
int i;
|
|
|
|
|
2004-05-01 13:48:01 +00:00
|
|
|
// Load scene module resource context
|
2005-07-19 19:05:52 +00:00
|
|
|
_sceneContext = _vm->_resource->getContext(GAME_RESOURCEFILE);
|
2004-11-15 03:03:48 +00:00
|
|
|
if (_sceneContext == NULL) {
|
2005-07-19 19:05:52 +00:00
|
|
|
error("Scene::Scene() scene context not found");
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
|
2004-05-01 13:48:01 +00:00
|
|
|
// Load scene lookup table
|
2005-07-19 19:05:52 +00:00
|
|
|
resourceId = _vm->_resource->convertResourceId(_vm->getResourceDescription()->sceneLUTResourceId);
|
|
|
|
debug(3, "Loading scene LUT from resource %i", resourceId);
|
|
|
|
_vm->_resource->loadResource(_sceneContext, resourceId, sceneLUTPointer, sceneLUTLength);
|
|
|
|
if (sceneLUTLength == 0) {
|
|
|
|
error("Scene::Scene() sceneLUTLength == 0");
|
2004-12-15 00:24:12 +00:00
|
|
|
}
|
2005-07-19 19:05:52 +00:00
|
|
|
_sceneCount = sceneLUTLength / 2;
|
2005-07-08 18:39:53 +00:00
|
|
|
_sceneLUT = (int *)malloc(_sceneCount * sizeof(*_sceneLUT));
|
2004-08-04 20:28:57 +00:00
|
|
|
if (_sceneLUT == NULL) {
|
2005-01-21 21:55:54 +00:00
|
|
|
memoryError("Scene::Scene()");
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
|
2005-07-19 19:05:52 +00:00
|
|
|
MemoryReadStreamEndian readS(sceneLUTPointer, sceneLUTLength, _sceneContext->isBigEndian);
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-07-08 18:39:53 +00:00
|
|
|
for (i = 0; i < _sceneCount; i++) {
|
2004-12-15 00:24:12 +00:00
|
|
|
_sceneLUT[i] = readS.readUint16();
|
2005-05-08 14:04:06 +00:00
|
|
|
debug(8, "sceneNumber %i has resourceId %i", i, _sceneLUT[i]);
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
|
2005-07-19 19:05:52 +00:00
|
|
|
free(sceneLUTPointer);
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-07-31 12:03:03 +00:00
|
|
|
#define DUMP_SCENES_LEVEL 10
|
|
|
|
|
|
|
|
if (DUMP_SCENES_LEVEL <= gDebugLevel) {
|
|
|
|
uint j;
|
|
|
|
int backUpDebugLevel = gDebugLevel;
|
|
|
|
SAGAResourceTypes *types;
|
|
|
|
int typesCount;
|
|
|
|
SAGAResourceTypes resType;
|
|
|
|
|
|
|
|
getResourceTypes(types, typesCount);
|
|
|
|
|
|
|
|
for (i = 0; i < _sceneCount; i++) {
|
|
|
|
gDebugLevel = -1;
|
|
|
|
loadSceneDescriptor(_sceneLUT[i]);
|
|
|
|
loadSceneResourceList(_sceneDescription.resourceListResourceId);
|
|
|
|
gDebugLevel = backUpDebugLevel;
|
|
|
|
debug(DUMP_SCENES_LEVEL, "Dump Scene: number %i, descriptor resourceId %i, resourceList resourceId %i", i, _sceneLUT[i], _sceneDescription.resourceListResourceId);
|
2006-03-08 11:37:25 +00:00
|
|
|
debug(DUMP_SCENES_LEVEL, "\tresourceListCount %i", (int)_resourceListCount);
|
2005-07-31 12:03:03 +00:00
|
|
|
for (j = 0; j < _resourceListCount; j++) {
|
|
|
|
if (_resourceList[j].resourceType >= typesCount) {
|
|
|
|
error("wrong resource type %i", _resourceList[j].resourceType);
|
|
|
|
}
|
|
|
|
resType = types[_resourceList[j].resourceType];
|
|
|
|
|
|
|
|
debug(DUMP_SCENES_LEVEL, "\t%s resourceId %i", SAGAResourceTypesString[resType], _resourceList[j].resourceId);
|
|
|
|
}
|
|
|
|
free(_resourceList);
|
|
|
|
}
|
|
|
|
}
|
2004-04-12 21:40:49 +00:00
|
|
|
|
|
|
|
|
2005-07-29 17:58:00 +00:00
|
|
|
debug(3, "LUT has %d entries.", _sceneCount);
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2004-08-04 20:28:57 +00:00
|
|
|
_sceneLoaded = false;
|
|
|
|
_sceneNumber = 0;
|
2005-04-02 20:04:39 +00:00
|
|
|
_sceneResourceId = 0;
|
2004-08-04 20:28:57 +00:00
|
|
|
_inGame = false;
|
2005-05-08 14:04:06 +00:00
|
|
|
_loadDescription = false;
|
|
|
|
memset(&_sceneDescription, 0, sizeof(_sceneDescription));
|
2005-07-19 19:05:52 +00:00
|
|
|
_resourceListCount = 0;
|
|
|
|
_resourceList = NULL;
|
2004-08-04 20:28:57 +00:00
|
|
|
_sceneProc = NULL;
|
2005-01-18 11:55:31 +00:00
|
|
|
_objectMap = new ObjectMap(_vm);
|
|
|
|
_actionMap = new ObjectMap(_vm);
|
2004-08-04 20:28:57 +00:00
|
|
|
memset(&_bg, 0, sizeof(_bg));
|
|
|
|
memset(&_bgMask, 0, sizeof(_bgMask));
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
|
2004-08-04 20:28:57 +00:00
|
|
|
Scene::~Scene() {
|
2005-07-19 19:05:52 +00:00
|
|
|
delete _actionMap;
|
|
|
|
delete _objectMap;
|
|
|
|
free(_sceneLUT);
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
|
2005-07-31 12:03:03 +00:00
|
|
|
void Scene::getResourceTypes(SAGAResourceTypes *&types, int &typesCount) {
|
|
|
|
if (_vm->getGameType() == GType_IHNM) {
|
|
|
|
typesCount = ARRAYSIZE(IHNMSceneResourceTypes);
|
|
|
|
types = IHNMSceneResourceTypes;
|
|
|
|
} else {
|
|
|
|
typesCount = ARRAYSIZE(ITESceneResourceTypes);
|
|
|
|
types = ITESceneResourceTypes;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-07-14 17:46:21 +00:00
|
|
|
void Scene::drawTextList(Surface *ds) {
|
|
|
|
TextListEntry *entry;
|
|
|
|
|
|
|
|
for (TextList::iterator textIterator = _textList.begin(); textIterator != _textList.end(); ++textIterator) {
|
|
|
|
entry = (TextListEntry *)textIterator.operator->();
|
2005-07-19 19:05:52 +00:00
|
|
|
if (entry->display) {
|
|
|
|
|
|
|
|
if (entry->useRect) {
|
2005-11-26 12:08:05 +00:00
|
|
|
_vm->_font->textDrawRect(entry->font, ds, entry->text, entry->rect, _vm->KnownColor2ColorId(entry->knownColor), _vm->KnownColor2ColorId(entry->effectKnownColor), entry->flags);
|
2005-07-19 19:05:52 +00:00
|
|
|
} else {
|
2005-11-26 12:08:05 +00:00
|
|
|
_vm->_font->textDraw(entry->font, ds, entry->text, entry->point, _vm->KnownColor2ColorId(entry->knownColor), _vm->KnownColor2ColorId(entry->effectKnownColor), entry->flags);
|
2005-07-29 17:58:00 +00:00
|
|
|
}
|
2005-07-14 17:46:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-05-08 14:04:06 +00:00
|
|
|
void Scene::startScene() {
|
2004-12-15 00:24:12 +00:00
|
|
|
SceneQueueList::iterator queueIterator;
|
2005-05-08 14:04:06 +00:00
|
|
|
LoadSceneParams *sceneQueue;
|
2005-08-10 14:11:22 +00:00
|
|
|
Event event;
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2004-08-04 20:28:57 +00:00
|
|
|
if (_sceneLoaded) {
|
2005-05-08 14:04:06 +00:00
|
|
|
error("Scene::start(): Error: Can't start game...scene already loaded");
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
|
2004-08-04 20:28:57 +00:00
|
|
|
if (_inGame) {
|
2005-05-08 14:04:06 +00:00
|
|
|
error("Scene::start(): Error: Can't start game...game already started");
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
|
2004-11-20 00:05:50 +00:00
|
|
|
// Hide cursor during intro
|
2005-08-10 15:31:15 +00:00
|
|
|
event.type = kEvTOneshot;
|
|
|
|
event.code = kCursorEvent;
|
|
|
|
event.op = kEventHide;
|
2004-11-20 00:05:50 +00:00
|
|
|
_vm->_events->queue(&event);
|
|
|
|
|
2005-01-11 21:10:36 +00:00
|
|
|
switch (_vm->getGameType()) {
|
2004-12-22 13:09:47 +00:00
|
|
|
case GType_ITE:
|
2004-08-11 23:42:02 +00:00
|
|
|
ITEStartProc();
|
2004-04-12 21:40:49 +00:00
|
|
|
break;
|
2004-12-22 13:09:47 +00:00
|
|
|
case GType_IHNM:
|
2004-08-11 23:42:02 +00:00
|
|
|
IHNMStartProc();
|
2004-04-12 21:40:49 +00:00
|
|
|
break;
|
|
|
|
default:
|
2005-05-08 14:04:06 +00:00
|
|
|
error("Scene::start(): Error: Can't start game... gametype not supported");
|
2004-04-12 21:40:49 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2004-12-15 00:24:12 +00:00
|
|
|
// Load the head in scene queue
|
|
|
|
queueIterator = _sceneQueue.begin();
|
|
|
|
if (queueIterator == _sceneQueue.end()) {
|
2005-07-29 17:58:00 +00:00
|
|
|
return;
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
|
2005-05-08 14:04:06 +00:00
|
|
|
sceneQueue = queueIterator.operator->();
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-05-08 14:04:06 +00:00
|
|
|
loadScene(sceneQueue);
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
|
2005-05-08 14:04:06 +00:00
|
|
|
void Scene::nextScene() {
|
2004-12-15 00:24:12 +00:00
|
|
|
SceneQueueList::iterator queueIterator;
|
2005-05-08 14:04:06 +00:00
|
|
|
LoadSceneParams *sceneQueue;
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2004-08-04 20:28:57 +00:00
|
|
|
if (!_sceneLoaded) {
|
2005-05-08 14:04:06 +00:00
|
|
|
error("Scene::next(): Error: Can't advance scene...no scene loaded");
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
|
2004-08-04 20:28:57 +00:00
|
|
|
if (_inGame) {
|
2005-05-08 14:04:06 +00:00
|
|
|
error("Scene::next(): Error: Can't advance scene...game already started");
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
|
2004-08-04 20:28:57 +00:00
|
|
|
endScene();
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-10-11 17:39:31 +00:00
|
|
|
// Delete the current head in scene queue
|
2004-12-15 00:24:12 +00:00
|
|
|
queueIterator = _sceneQueue.begin();
|
|
|
|
if (queueIterator == _sceneQueue.end()) {
|
2005-05-08 14:04:06 +00:00
|
|
|
return;
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
2005-07-29 17:58:00 +00:00
|
|
|
|
2004-12-15 00:24:12 +00:00
|
|
|
queueIterator = _sceneQueue.erase(queueIterator);
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2004-12-15 00:24:12 +00:00
|
|
|
if (queueIterator == _sceneQueue.end()) {
|
2005-05-08 14:04:06 +00:00
|
|
|
return;
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
|
2005-10-11 17:39:31 +00:00
|
|
|
// Load the head in scene queue
|
2005-05-08 14:04:06 +00:00
|
|
|
sceneQueue = queueIterator.operator->();
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-05-08 14:04:06 +00:00
|
|
|
loadScene(sceneQueue);
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
|
2005-05-08 14:04:06 +00:00
|
|
|
void Scene::skipScene() {
|
2004-12-15 00:24:12 +00:00
|
|
|
SceneQueueList::iterator queueIterator;
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-05-08 14:04:06 +00:00
|
|
|
LoadSceneParams *sceneQueue = NULL;
|
|
|
|
LoadSceneParams *skipQueue = NULL;
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2004-08-04 20:28:57 +00:00
|
|
|
if (!_sceneLoaded) {
|
2005-05-08 14:04:06 +00:00
|
|
|
error("Scene::skip(): Error: Can't skip scene...no scene loaded");
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
|
2004-08-04 20:28:57 +00:00
|
|
|
if (_inGame) {
|
2005-05-08 14:04:06 +00:00
|
|
|
error("Scene::skip(): Error: Can't skip scene...game already started");
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
|
2004-05-01 13:48:01 +00:00
|
|
|
// Walk down scene queue and try to find a skip target
|
2004-12-15 00:24:12 +00:00
|
|
|
queueIterator = _sceneQueue.begin();
|
|
|
|
if (queueIterator == _sceneQueue.end()) {
|
2005-05-08 14:04:06 +00:00
|
|
|
error("Scene::skip(): Error: Can't skip scene...no scenes in queue");
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
|
2004-12-15 00:24:12 +00:00
|
|
|
++queueIterator;
|
|
|
|
while (queueIterator != _sceneQueue.end()) {
|
2005-05-08 14:04:06 +00:00
|
|
|
sceneQueue = queueIterator.operator->();
|
|
|
|
assert(sceneQueue != NULL);
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-05-08 14:04:06 +00:00
|
|
|
if (sceneQueue->sceneSkipTarget) {
|
|
|
|
skipQueue = sceneQueue;
|
2004-04-12 21:40:49 +00:00
|
|
|
break;
|
|
|
|
}
|
2004-12-15 00:24:12 +00:00
|
|
|
++queueIterator;
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
|
2004-05-01 13:48:01 +00:00
|
|
|
// If skip target found, remove preceding scenes and load
|
2005-05-08 14:04:06 +00:00
|
|
|
if (skipQueue != NULL) {
|
2004-12-15 00:24:12 +00:00
|
|
|
_sceneQueue.erase(_sceneQueue.begin(), queueIterator);
|
|
|
|
|
2004-08-04 20:28:57 +00:00
|
|
|
endScene();
|
2005-05-08 14:04:06 +00:00
|
|
|
loadScene(skipQueue);
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-07-29 16:37:06 +00:00
|
|
|
static struct SceneSubstitutes {
|
2005-10-11 17:39:31 +00:00
|
|
|
int sceneId;
|
|
|
|
const char *message;
|
|
|
|
const char *title;
|
|
|
|
const char *image;
|
2005-07-29 16:37:06 +00:00
|
|
|
} sceneSubstitutes[] = {
|
2005-10-11 17:39:31 +00:00
|
|
|
{
|
2005-07-29 16:37:06 +00:00
|
|
|
7,
|
|
|
|
"Tycho says he knows much about the northern lands. Can Rif convince "
|
|
|
|
"the Dog to share this knowledge?",
|
|
|
|
"The Home of Tycho Northpaw",
|
|
|
|
"tycho.bbm"
|
|
|
|
},
|
|
|
|
|
2005-10-11 17:39:31 +00:00
|
|
|
{
|
2005-07-29 16:37:06 +00:00
|
|
|
27,
|
|
|
|
"The scene of the crime may hold many clues, but will the servants of "
|
|
|
|
"the Sanctuary trust Rif?",
|
|
|
|
"The Sanctuary of the Orb",
|
|
|
|
"sanctuar.bbm"
|
|
|
|
},
|
|
|
|
|
2005-10-11 17:39:31 +00:00
|
|
|
{
|
2005-07-29 16:37:06 +00:00
|
|
|
5,
|
|
|
|
"The Rats hold many secrets that could guide Rif on his quest -- assuming "
|
|
|
|
"he can get past the doorkeeper.",
|
|
|
|
"The Rat Complex",
|
|
|
|
"ratdoor.bbm"
|
|
|
|
},
|
|
|
|
|
2005-10-11 17:39:31 +00:00
|
|
|
{
|
2005-07-29 16:37:06 +00:00
|
|
|
2,
|
|
|
|
"The Ferrets enjoy making things and have the materials to do so. How can "
|
|
|
|
"that help Rif?",
|
|
|
|
"The Ferret Village",
|
|
|
|
"ferrets.bbm"
|
|
|
|
},
|
|
|
|
|
2005-10-11 17:39:31 +00:00
|
|
|
{
|
2005-07-29 16:37:06 +00:00
|
|
|
67,
|
|
|
|
"What aid can the noble King of the Elks provide to Rif and his companions?",
|
|
|
|
"The Realm of the Forest King",
|
|
|
|
"elkenter.bbm"
|
|
|
|
},
|
|
|
|
|
2005-10-11 17:39:31 +00:00
|
|
|
{
|
2005-07-29 16:37:06 +00:00
|
|
|
3,
|
|
|
|
"The King holds Rif's sweetheart hostage. Will the Boar provide any "
|
|
|
|
"assistance to Rif?",
|
|
|
|
"The Great Hall of the Boar King",
|
|
|
|
"boarhall.bbm"
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2005-08-06 14:26:59 +00:00
|
|
|
void Scene::changeScene(int16 sceneNumber, int actorsEntrance, SceneTransitionType transitionType, int chapter) {
|
2005-08-07 00:00:43 +00:00
|
|
|
|
|
|
|
debug(5, "Scene::changeScene(%d, %d, %d, %d)", sceneNumber, actorsEntrance, transitionType, chapter);
|
|
|
|
|
|
|
|
// This is used for latter ITE demos where all places on world map except
|
2005-07-29 16:37:06 +00:00
|
|
|
// Tent Faire are substituted with LBM picture and short description
|
2005-07-29 18:29:23 +00:00
|
|
|
if (_vm->getFeatures() & GF_SCENE_SUBSTITUTES) {
|
|
|
|
for (int i = 0; i < ARRAYSIZE(sceneSubstitutes); i++) {
|
|
|
|
if (sceneSubstitutes[i].sceneId == sceneNumber) {
|
|
|
|
Surface *backBuffer = _vm->_gfx->getBackBuffer();
|
|
|
|
Surface bbmBuffer;
|
|
|
|
byte *pal, *colors;
|
|
|
|
Common::File file;
|
|
|
|
Rect rect;
|
|
|
|
PalEntry cPal[PAL_ENTRIES];
|
2005-07-29 17:58:00 +00:00
|
|
|
|
2005-07-29 16:37:06 +00:00
|
|
|
_vm->_interface->setMode(kPanelSceneSubstitute);
|
2005-07-29 18:29:23 +00:00
|
|
|
|
|
|
|
if (file.open(sceneSubstitutes[i].image)) {
|
2007-05-01 21:40:56 +00:00
|
|
|
Graphics::decodePBM(file, bbmBuffer, pal);
|
2005-07-29 18:29:23 +00:00
|
|
|
colors = pal;
|
|
|
|
rect.setWidth(bbmBuffer.w);
|
|
|
|
rect.setHeight(bbmBuffer.h);
|
|
|
|
backBuffer->blit(rect, (const byte*)bbmBuffer.pixels);
|
|
|
|
for (int j = 0; j < PAL_ENTRIES; j++) {
|
|
|
|
cPal[j].red = *pal++;
|
|
|
|
cPal[j].green = *pal++;
|
|
|
|
cPal[j].blue = *pal++;
|
|
|
|
}
|
|
|
|
free(colors);
|
2005-10-05 01:40:55 +00:00
|
|
|
_vm->_gfx->setPalette(cPal);
|
2005-07-29 18:29:23 +00:00
|
|
|
|
2005-07-29 16:37:06 +00:00
|
|
|
}
|
2005-07-29 17:58:00 +00:00
|
|
|
|
2005-07-29 18:00:40 +00:00
|
|
|
_vm->_interface->setStatusText("Click or Press Return to continue. Press Q to quit.", 96);
|
2005-11-03 18:20:12 +00:00
|
|
|
_vm->_font->textDrawRect(kKnownFontMedium, backBuffer, sceneSubstitutes[i].title,
|
2005-11-26 12:08:05 +00:00
|
|
|
Common::Rect(0, 7, _vm->getDisplayWidth(), 27), _vm->KnownColor2ColorId(kKnownColorBrightWhite), _vm->KnownColor2ColorId(kKnownColorBlack), kFontOutline);
|
2005-11-03 18:20:12 +00:00
|
|
|
_vm->_font->textDrawRect(kKnownFontMedium, backBuffer, sceneSubstitutes[i].message,
|
2005-10-08 15:20:11 +00:00
|
|
|
Common::Rect(24, getHeight() - 33, _vm->getDisplayWidth() - 11,
|
2005-11-26 12:08:05 +00:00
|
|
|
getHeight()), _vm->KnownColor2ColorId(kKnownColorBrightWhite), _vm->KnownColor2ColorId(kKnownColorBlack), kFontOutline);
|
2005-07-29 17:58:00 +00:00
|
|
|
return;
|
2005-07-29 16:37:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-05-08 14:04:06 +00:00
|
|
|
LoadSceneParams sceneParams;
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-05-08 14:04:06 +00:00
|
|
|
sceneParams.actorsEntrance = actorsEntrance;
|
|
|
|
sceneParams.loadFlag = kLoadBySceneNumber;
|
|
|
|
sceneParams.sceneDescriptor = sceneNumber;
|
|
|
|
sceneParams.transitionType = transitionType;
|
|
|
|
sceneParams.sceneProc = NULL;
|
|
|
|
sceneParams.sceneSkipTarget = false;
|
2005-08-06 12:20:10 +00:00
|
|
|
sceneParams.chapter = chapter;
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-08-06 12:20:10 +00:00
|
|
|
if (sceneNumber != -2) {
|
|
|
|
endScene();
|
|
|
|
}
|
2007-06-13 13:00:25 +00:00
|
|
|
|
2005-05-08 14:04:06 +00:00
|
|
|
loadScene(&sceneParams);
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
|
2004-12-19 13:38:11 +00:00
|
|
|
void Scene::getSlopes(int &beginSlope, int &endSlope) {
|
2005-10-08 15:20:11 +00:00
|
|
|
beginSlope = getHeight() - _sceneDescription.beginSlope;
|
|
|
|
endSlope = getHeight() - _sceneDescription.endSlope;
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
|
2005-07-08 16:56:03 +00:00
|
|
|
void Scene::getBGInfo(BGInfo &bgInfo) {
|
|
|
|
bgInfo.buffer = _bg.buf;
|
|
|
|
bgInfo.bufferLength = _bg.buf_len;
|
|
|
|
bgInfo.bounds.left = 0;
|
|
|
|
bgInfo.bounds.top = 0;
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-01-09 23:41:22 +00:00
|
|
|
if (_bg.w < _vm->getDisplayWidth()) {
|
2005-07-08 16:56:03 +00:00
|
|
|
bgInfo.bounds.left = (_vm->getDisplayWidth() - _bg.w) / 2;
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
|
2005-10-08 15:20:11 +00:00
|
|
|
if (_bg.h < getHeight()) {
|
|
|
|
bgInfo.bounds.top = (getHeight() - _bg.h) / 2;
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
|
2005-07-08 16:56:03 +00:00
|
|
|
bgInfo.bounds.setWidth(_bg.w);
|
|
|
|
bgInfo.bounds.setHeight(_bg.h);
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
|
2004-12-28 21:27:18 +00:00
|
|
|
bool Scene::canWalk(const Point &testPoint) {
|
|
|
|
int maskType;
|
2005-01-04 16:10:43 +00:00
|
|
|
|
2004-08-04 20:28:57 +00:00
|
|
|
if (!_bgMask.loaded) {
|
2004-12-28 21:27:18 +00:00
|
|
|
return true;
|
|
|
|
}
|
2005-01-04 16:10:43 +00:00
|
|
|
if (!validBGMaskPoint(testPoint)) {
|
2005-04-23 14:15:00 +00:00
|
|
|
return true;
|
2005-01-04 16:10:43 +00:00
|
|
|
}
|
|
|
|
|
2004-12-28 21:27:18 +00:00
|
|
|
maskType = getBGMaskType(testPoint);
|
|
|
|
return getDoorState(maskType) == 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Scene::offscreenPath(Point &testPoint) {
|
2005-04-24 15:35:03 +00:00
|
|
|
Point point;
|
2004-12-28 21:27:18 +00:00
|
|
|
|
|
|
|
if (!_bgMask.loaded) {
|
|
|
|
return false;
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
|
2005-04-24 15:35:03 +00:00
|
|
|
point.x = clamp( 0, testPoint.x, _bgMask.w - 1 );
|
|
|
|
point.y = clamp( 0, testPoint.y, _bgMask.h - 1 );
|
|
|
|
if (point == testPoint) {
|
2004-12-28 21:27:18 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2005-04-24 15:35:03 +00:00
|
|
|
if (point.y >= _bgMask.h - 1) {
|
|
|
|
point.y = _bgMask.h - 2;
|
2004-12-28 21:27:18 +00:00
|
|
|
}
|
2005-04-24 15:35:03 +00:00
|
|
|
testPoint = point;
|
2004-12-28 21:27:18 +00:00
|
|
|
|
|
|
|
return true;
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-12-28 21:27:18 +00:00
|
|
|
void Scene::getBGMaskInfo(int &width, int &height, byte *&buffer, size_t &bufferLength) {
|
|
|
|
if (!_bgMask.loaded) {
|
|
|
|
error("Scene::getBGMaskInfo _bgMask not loaded");
|
|
|
|
}
|
|
|
|
|
|
|
|
width = _bgMask.w;
|
|
|
|
height = _bgMask.h;
|
|
|
|
buffer = _bgMask.buf;
|
|
|
|
bufferLength = _bgMask.buf_len;
|
|
|
|
}
|
|
|
|
|
2005-01-04 16:10:43 +00:00
|
|
|
void Scene::initDoorsState() {
|
2005-01-04 18:54:29 +00:00
|
|
|
memcpy(_sceneDoors, initSceneDoors, sizeof (_sceneDoors) );
|
2005-01-04 16:10:43 +00:00
|
|
|
}
|
|
|
|
|
2005-05-08 14:04:06 +00:00
|
|
|
void Scene::loadScene(LoadSceneParams *loadSceneParams) {
|
2005-07-19 19:05:52 +00:00
|
|
|
size_t i;
|
2005-08-10 14:11:22 +00:00
|
|
|
Event event;
|
|
|
|
Event *q_event;
|
2005-07-09 16:23:45 +00:00
|
|
|
static PalEntry current_pal[PAL_ENTRIES];
|
2007-05-01 15:39:40 +00:00
|
|
|
|
2007-05-06 22:18:31 +00:00
|
|
|
// Change the cursor to an hourglass in IHNM
|
2007-05-07 06:18:08 +00:00
|
|
|
event.type = kEvTOneshot;
|
|
|
|
event.code = kCursorEvent;
|
|
|
|
event.op = kEventSetBusyCursor;
|
|
|
|
event.time = 0;
|
|
|
|
_vm->_events->queue(&event);
|
2007-05-06 22:18:31 +00:00
|
|
|
|
2005-08-06 18:28:43 +00:00
|
|
|
if ((_vm->getGameType() == GType_IHNM) && (loadSceneParams->chapter != NO_CHAPTER_CHANGE)) {
|
2005-08-06 12:20:10 +00:00
|
|
|
if (loadSceneParams->loadFlag != kLoadBySceneNumber) {
|
|
|
|
error("loadScene wrong usage");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (loadSceneParams->chapter == 6)
|
|
|
|
_vm->_interface->setLeftPortrait(0);
|
|
|
|
|
2005-09-23 14:29:26 +00:00
|
|
|
_vm->_anim->freeCutawayList();
|
2005-08-06 12:20:10 +00:00
|
|
|
_vm->_script->freeModules();
|
|
|
|
// deleteAllScenes();
|
|
|
|
|
|
|
|
// installSomeAlarm()
|
|
|
|
|
|
|
|
_vm->_interface->clearInventory();
|
|
|
|
_vm->_resource->loadGlobalResources(loadSceneParams->chapter, loadSceneParams->actorsEntrance);
|
2005-10-11 02:44:25 +00:00
|
|
|
_vm->_interface->addToInventory(IHNM_OBJ_PROFILE);
|
2005-08-06 12:20:10 +00:00
|
|
|
_vm->_interface->activate();
|
|
|
|
|
|
|
|
if (loadSceneParams->chapter == 8 || loadSceneParams->chapter == -1)
|
2005-08-10 13:56:51 +00:00
|
|
|
_vm->_interface->setMode(kPanelChapterSelection);
|
2005-08-06 12:20:10 +00:00
|
|
|
else
|
|
|
|
_vm->_interface->setMode(kPanelMain);
|
|
|
|
|
2005-10-08 16:25:18 +00:00
|
|
|
_inGame = true;
|
|
|
|
|
2006-01-13 20:20:01 +00:00
|
|
|
_vm->_script->setVerb(_vm->_script->getVerbType(kVerbWalkTo));
|
2005-08-06 12:20:10 +00:00
|
|
|
|
|
|
|
if (loadSceneParams->sceneDescriptor == -2) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2005-08-07 00:00:43 +00:00
|
|
|
|
2004-08-04 20:28:57 +00:00
|
|
|
if (_sceneLoaded) {
|
2005-05-08 14:04:06 +00:00
|
|
|
error("Scene::loadScene(): Error, a scene is already loaded");
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
|
2005-05-08 14:04:06 +00:00
|
|
|
_loadDescription = true;
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-08-07 00:00:43 +00:00
|
|
|
if (_vm->getGameType() == GType_IHNM) {
|
|
|
|
if (loadSceneParams->loadFlag == kLoadBySceneNumber) // When will we get rid of it?
|
|
|
|
if (loadSceneParams->sceneDescriptor <= 0)
|
|
|
|
loadSceneParams->sceneDescriptor = _vm->_resource->_metaResource.sceneIndex;
|
|
|
|
}
|
|
|
|
|
2005-05-08 14:04:06 +00:00
|
|
|
switch (loadSceneParams->loadFlag) {
|
|
|
|
case kLoadByResourceId:
|
|
|
|
_sceneNumber = 0; // original assign zero for loaded by resource id
|
|
|
|
_sceneResourceId = loadSceneParams->sceneDescriptor;
|
2004-04-12 21:40:49 +00:00
|
|
|
break;
|
2005-05-08 14:04:06 +00:00
|
|
|
case kLoadBySceneNumber:
|
|
|
|
_sceneNumber = loadSceneParams->sceneDescriptor;
|
|
|
|
_sceneResourceId = getSceneResourceId(_sceneNumber);
|
2004-04-12 21:40:49 +00:00
|
|
|
break;
|
2005-05-08 14:04:06 +00:00
|
|
|
case kLoadByDescription:
|
|
|
|
_sceneNumber = -1;
|
|
|
|
_sceneResourceId = -1;
|
|
|
|
assert(loadSceneParams->sceneDescription != NULL);
|
2005-07-19 19:05:52 +00:00
|
|
|
assert(loadSceneParams->sceneDescription->resourceList != NULL);
|
2005-05-08 14:04:06 +00:00
|
|
|
_loadDescription = false;
|
|
|
|
_sceneDescription = *loadSceneParams->sceneDescription;
|
2005-07-19 19:05:52 +00:00
|
|
|
_resourceList = loadSceneParams->sceneDescription->resourceList;
|
|
|
|
_resourceListCount = loadSceneParams->sceneDescription->resourceListCount;
|
2004-04-12 21:40:49 +00:00
|
|
|
break;
|
|
|
|
}
|
2005-07-29 17:58:00 +00:00
|
|
|
|
2005-08-07 00:00:43 +00:00
|
|
|
debug(3, "Loading scene number %d:", _sceneNumber);
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2004-05-01 13:48:01 +00:00
|
|
|
// Load scene descriptor and resource list resources
|
2005-05-08 14:04:06 +00:00
|
|
|
if (_loadDescription) {
|
2005-07-19 19:05:52 +00:00
|
|
|
debug(3, "Loading scene resource %i", _sceneResourceId);
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-07-19 19:05:52 +00:00
|
|
|
loadSceneDescriptor(_sceneResourceId);
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-07-19 19:05:52 +00:00
|
|
|
loadSceneResourceList(_sceneDescription.resourceListResourceId);
|
2004-04-12 21:40:49 +00:00
|
|
|
} else {
|
2005-07-19 19:05:52 +00:00
|
|
|
debug(3, "Loading memory scene resource");
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
|
2004-05-01 13:48:01 +00:00
|
|
|
// Load resources from scene resource list
|
2005-07-19 19:05:52 +00:00
|
|
|
for (i = 0; i < _resourceListCount; i++) {
|
|
|
|
if (!_resourceList[i].invalid) {
|
|
|
|
_vm->_resource->loadResource(_sceneContext, _resourceList[i].resourceId,
|
|
|
|
_resourceList[i].buffer, _resourceList[i].size);
|
2005-08-04 14:49:04 +00:00
|
|
|
|
2007-05-01 15:39:40 +00:00
|
|
|
|
2005-08-04 14:49:04 +00:00
|
|
|
if (_resourceList[i].size >= 6) {
|
|
|
|
if (!memcmp(_resourceList[i].buffer, "DUMMY!", 6)) {
|
|
|
|
_resourceList[i].invalid = true;
|
|
|
|
warning("DUMMY resource %i", _resourceList[i].resourceId);
|
|
|
|
}
|
|
|
|
}
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-05-01 13:48:01 +00:00
|
|
|
// Process resources from scene resource list
|
2005-07-19 19:05:52 +00:00
|
|
|
processSceneResources();
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-05-08 14:04:06 +00:00
|
|
|
if (_sceneDescription.flags & kSceneFlagISO) {
|
2005-04-21 01:30:07 +00:00
|
|
|
_outsetSceneNumber = _sceneNumber;
|
2005-07-08 16:56:03 +00:00
|
|
|
|
|
|
|
_sceneClip.left = 0;
|
|
|
|
_sceneClip.top = 0;
|
|
|
|
_sceneClip.right = _vm->getDisplayWidth();
|
2005-10-08 15:20:11 +00:00
|
|
|
_sceneClip.bottom = getHeight();
|
2005-04-21 01:30:07 +00:00
|
|
|
} else {
|
2005-07-08 16:56:03 +00:00
|
|
|
BGInfo backGroundInfo;
|
|
|
|
getBGInfo(backGroundInfo);
|
|
|
|
_sceneClip = backGroundInfo.bounds;
|
2005-10-08 15:20:11 +00:00
|
|
|
if (!(_bg.w < _vm->getDisplayWidth() || _bg.h < getHeight()))
|
2005-04-21 01:30:07 +00:00
|
|
|
_outsetSceneNumber = _sceneNumber;
|
|
|
|
}
|
|
|
|
|
2004-08-04 20:28:57 +00:00
|
|
|
_sceneLoaded = true;
|
2005-07-29 17:58:00 +00:00
|
|
|
|
2005-01-21 21:55:54 +00:00
|
|
|
q_event = NULL;
|
2005-06-16 16:46:50 +00:00
|
|
|
|
2005-07-29 17:58:00 +00:00
|
|
|
//fix placard bug
|
2005-06-16 16:46:50 +00:00
|
|
|
//i guess we should remove RF_PLACARD flag - and use _interface->getMode()
|
2005-08-10 15:31:15 +00:00
|
|
|
event.type = kEvTOneshot;
|
|
|
|
event.code = kGraphicsEvent;
|
|
|
|
event.op = kEventClearFlag;
|
2005-07-29 17:58:00 +00:00
|
|
|
event.param = RF_PLACARD;
|
2005-06-16 16:46:50 +00:00
|
|
|
|
|
|
|
q_event = _vm->_events->chain(q_event, &event);
|
|
|
|
|
2005-08-05 23:14:11 +00:00
|
|
|
if (loadSceneParams->transitionType == kTransitionFade) {
|
2004-08-11 22:27:39 +00:00
|
|
|
|
2005-06-04 15:02:17 +00:00
|
|
|
_vm->_interface->setFadeMode(kFadeOut);
|
2005-01-07 00:57:43 +00:00
|
|
|
|
2004-08-11 22:27:39 +00:00
|
|
|
// Fade to black out
|
|
|
|
_vm->_gfx->getCurrentPal(current_pal);
|
2005-08-10 15:31:15 +00:00
|
|
|
event.type = kEvTImmediate;
|
|
|
|
event.code = kPalEvent;
|
|
|
|
event.op = kEventPalToBlack;
|
2004-08-11 22:27:39 +00:00
|
|
|
event.time = 0;
|
2004-12-29 19:40:59 +00:00
|
|
|
event.duration = kNormalFadeDuration;
|
2004-08-11 22:27:39 +00:00
|
|
|
event.data = current_pal;
|
|
|
|
q_event = _vm->_events->queue(&event);
|
|
|
|
|
2005-06-04 15:02:17 +00:00
|
|
|
// set fade mode
|
2005-08-10 15:31:15 +00:00
|
|
|
event.type = kEvTImmediate;
|
|
|
|
event.code = kInterfaceEvent;
|
|
|
|
event.op = kEventSetFadeMode;
|
2005-06-04 15:02:17 +00:00
|
|
|
event.param = kNoFade;
|
2004-08-11 22:27:39 +00:00
|
|
|
event.time = 0;
|
|
|
|
event.duration = 0;
|
|
|
|
q_event = _vm->_events->chain(q_event, &event);
|
|
|
|
|
2005-06-04 15:02:17 +00:00
|
|
|
// Display scene background, but stay with black palette
|
2005-08-10 15:31:15 +00:00
|
|
|
event.type = kEvTImmediate;
|
|
|
|
event.code = kBgEvent;
|
|
|
|
event.op = kEventDisplay;
|
|
|
|
event.param = kEvPNoSetPalette;
|
2005-01-07 00:57:43 +00:00
|
|
|
event.time = 0;
|
|
|
|
event.duration = 0;
|
|
|
|
q_event = _vm->_events->chain(q_event, &event);
|
2005-06-04 15:02:17 +00:00
|
|
|
|
2005-01-21 21:55:54 +00:00
|
|
|
}
|
2005-01-07 00:57:43 +00:00
|
|
|
|
2005-01-21 21:55:54 +00:00
|
|
|
// Start the scene pre script, but stay with black palette
|
2005-05-08 14:04:06 +00:00
|
|
|
if (_sceneDescription.startScriptEntrypointNumber > 0) {
|
2005-08-10 15:31:15 +00:00
|
|
|
event.type = kEvTOneshot;
|
|
|
|
event.code = kScriptEvent;
|
|
|
|
event.op = kEventExecBlocking;
|
2005-01-21 21:55:54 +00:00
|
|
|
event.time = 0;
|
2005-05-08 14:04:06 +00:00
|
|
|
event.param = _sceneDescription.scriptModuleNumber;
|
|
|
|
event.param2 = _sceneDescription.startScriptEntrypointNumber;
|
2005-01-21 21:55:54 +00:00
|
|
|
event.param3 = 0; // Action
|
|
|
|
event.param4 = _sceneNumber; // Object
|
2005-05-08 14:04:06 +00:00
|
|
|
event.param5 = loadSceneParams->actorsEntrance; // With Object
|
2005-01-21 21:55:54 +00:00
|
|
|
event.param6 = 0; // Actor
|
2004-10-16 07:46:52 +00:00
|
|
|
|
2005-01-21 21:55:54 +00:00
|
|
|
q_event = _vm->_events->chain(q_event, &event);
|
|
|
|
}
|
2004-10-16 07:46:52 +00:00
|
|
|
|
2005-07-08 18:39:53 +00:00
|
|
|
if (loadSceneParams->transitionType == kTransitionFade) {
|
2005-06-04 15:02:17 +00:00
|
|
|
|
|
|
|
// set fade mode
|
2005-08-10 15:31:15 +00:00
|
|
|
event.type = kEvTImmediate;
|
|
|
|
event.code = kInterfaceEvent;
|
|
|
|
event.op = kEventSetFadeMode;
|
2005-06-04 15:02:17 +00:00
|
|
|
event.param = kFadeIn;
|
|
|
|
event.time = 0;
|
|
|
|
event.duration = 0;
|
|
|
|
q_event = _vm->_events->chain(q_event, &event);
|
|
|
|
|
2004-08-11 22:27:39 +00:00
|
|
|
// Fade in from black to the scene background palette
|
2005-08-10 15:31:15 +00:00
|
|
|
event.type = kEvTImmediate;
|
|
|
|
event.code = kPalEvent;
|
|
|
|
event.op = kEventBlackToPal;
|
2004-08-11 22:27:39 +00:00
|
|
|
event.time = 0;
|
2004-12-29 19:40:59 +00:00
|
|
|
event.duration = kNormalFadeDuration;
|
2004-08-11 22:27:39 +00:00
|
|
|
event.data = _bg.pal;
|
|
|
|
|
|
|
|
q_event = _vm->_events->chain(q_event, &event);
|
2005-06-04 15:02:17 +00:00
|
|
|
|
|
|
|
// set fade mode
|
2005-08-10 15:31:15 +00:00
|
|
|
event.type = kEvTImmediate;
|
|
|
|
event.code = kInterfaceEvent;
|
|
|
|
event.op = kEventSetFadeMode;
|
2005-06-04 15:02:17 +00:00
|
|
|
event.param = kNoFade;
|
|
|
|
event.time = 0;
|
|
|
|
event.duration = 0;
|
|
|
|
q_event = _vm->_events->chain(q_event, &event);
|
2004-08-11 22:27:39 +00:00
|
|
|
}
|
|
|
|
|
2005-05-08 14:04:06 +00:00
|
|
|
if (loadSceneParams->sceneProc == NULL) {
|
2005-10-08 16:25:18 +00:00
|
|
|
if (!_inGame && _vm->getGameType() == GType_ITE) {
|
2005-03-29 22:14:20 +00:00
|
|
|
_inGame = true;
|
2005-05-22 11:59:22 +00:00
|
|
|
_vm->_interface->setMode(kPanelMain);
|
2005-03-29 22:14:20 +00:00
|
|
|
}
|
|
|
|
|
2005-08-13 01:35:52 +00:00
|
|
|
_vm->_sound->stopAll();
|
2005-03-29 22:14:20 +00:00
|
|
|
|
2005-10-06 15:54:43 +00:00
|
|
|
// FIXME: Does IHNM use scene background music, or is all the
|
|
|
|
// music scripted? At the very least, it shouldn't try
|
|
|
|
// to start song 0 at the beginning of the game, since
|
|
|
|
// it's the end credits music.
|
|
|
|
|
|
|
|
if (_vm->getGameType() == GType_ITE) {
|
|
|
|
if (_sceneDescription.musicResourceId >= 0) {
|
|
|
|
event.type = kEvTOneshot;
|
|
|
|
event.code = kMusicEvent;
|
|
|
|
event.param = _sceneDescription.musicResourceId;
|
|
|
|
event.param2 = MUSIC_DEFAULT;
|
|
|
|
event.op = kEventPlay;
|
|
|
|
event.time = 0;
|
|
|
|
|
|
|
|
_vm->_events->queue(&event);
|
|
|
|
} else {
|
|
|
|
event.type = kEvTOneshot;
|
|
|
|
event.code = kMusicEvent;
|
|
|
|
event.op = kEventStop;
|
|
|
|
event.time = 0;
|
2005-03-29 22:14:20 +00:00
|
|
|
|
2005-10-06 15:54:43 +00:00
|
|
|
_vm->_events->queue(&event);
|
|
|
|
}
|
2005-03-29 22:14:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Set scene background
|
2005-08-10 15:31:15 +00:00
|
|
|
event.type = kEvTOneshot;
|
|
|
|
event.code = kBgEvent;
|
|
|
|
event.op = kEventDisplay;
|
|
|
|
event.param = kEvPSetPalette;
|
2005-03-29 22:14:20 +00:00
|
|
|
event.time = 0;
|
|
|
|
|
|
|
|
_vm->_events->queue(&event);
|
|
|
|
|
|
|
|
// Begin palette cycle animation if present
|
2005-08-10 15:31:15 +00:00
|
|
|
event.type = kEvTOneshot;
|
|
|
|
event.code = kPalAnimEvent;
|
|
|
|
event.op = kEventCycleStart;
|
2005-03-29 22:14:20 +00:00
|
|
|
event.time = 0;
|
|
|
|
|
|
|
|
q_event = _vm->_events->queue(&event);
|
|
|
|
|
|
|
|
// Start the scene main script
|
2005-05-08 14:04:06 +00:00
|
|
|
if (_sceneDescription.sceneScriptEntrypointNumber > 0) {
|
2005-08-10 15:31:15 +00:00
|
|
|
event.type = kEvTOneshot;
|
|
|
|
event.code = kScriptEvent;
|
|
|
|
event.op = kEventExecNonBlocking;
|
2005-03-29 22:14:20 +00:00
|
|
|
event.time = 0;
|
2005-05-08 14:04:06 +00:00
|
|
|
event.param = _sceneDescription.scriptModuleNumber;
|
|
|
|
event.param2 = _sceneDescription.sceneScriptEntrypointNumber;
|
2006-01-13 20:20:01 +00:00
|
|
|
event.param3 = _vm->_script->getVerbType(kVerbEnter); // Action
|
2005-03-29 22:14:20 +00:00
|
|
|
event.param4 = _sceneNumber; // Object
|
2005-05-08 14:04:06 +00:00
|
|
|
event.param5 = loadSceneParams->actorsEntrance; // With Object
|
2005-03-29 22:14:20 +00:00
|
|
|
event.param6 = 0; // Actor
|
|
|
|
|
|
|
|
_vm->_events->queue(&event);
|
|
|
|
}
|
|
|
|
|
2005-07-05 16:58:36 +00:00
|
|
|
debug(3, "Scene started");
|
2005-03-29 22:14:20 +00:00
|
|
|
|
2004-04-12 21:40:49 +00:00
|
|
|
} else {
|
2005-05-08 14:04:06 +00:00
|
|
|
loadSceneParams->sceneProc(SCENE_BEGIN, this);
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
|
2005-05-08 14:04:06 +00:00
|
|
|
// We probably don't want "followers" to go into scene -1 , 0. At the very
|
2005-02-24 08:03:47 +00:00
|
|
|
// least we don't want garbage to be drawn that early in the ITE intro.
|
2005-05-23 02:23:34 +00:00
|
|
|
if (_sceneNumber > 0 && _sceneNumber != ITE_SCENE_PUZZLE)
|
2005-05-08 14:04:06 +00:00
|
|
|
_vm->_actor->updateActorsScene(loadSceneParams->actorsEntrance);
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-05-23 02:23:34 +00:00
|
|
|
if (_sceneNumber == ITE_SCENE_PUZZLE)
|
|
|
|
_vm->_puzzle->execute();
|
|
|
|
|
2005-10-22 12:47:09 +00:00
|
|
|
if (getFlags() & kSceneFlagShowCursor) {
|
|
|
|
// Activate user interface
|
|
|
|
event.type = kEvTOneshot;
|
|
|
|
event.code = kInterfaceEvent;
|
|
|
|
event.op = kEventActivate;
|
|
|
|
event.time = 0;
|
|
|
|
_vm->_events->queue(&event);
|
|
|
|
}
|
2007-05-06 22:18:31 +00:00
|
|
|
|
|
|
|
// Change the cursor back to a crosshair in IHNM
|
2007-05-07 06:18:08 +00:00
|
|
|
event.type = kEvTOneshot;
|
|
|
|
event.code = kCursorEvent;
|
|
|
|
event.op = kEventSetNormalCursor;
|
|
|
|
event.time = 0;
|
|
|
|
_vm->_events->queue(&event);
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
|
2005-07-19 19:05:52 +00:00
|
|
|
void Scene::loadSceneDescriptor(uint32 resourceId) {
|
|
|
|
byte *sceneDescriptorData;
|
|
|
|
size_t sceneDescriptorDataLength;
|
2007-05-01 15:39:40 +00:00
|
|
|
|
2005-07-31 12:03:03 +00:00
|
|
|
memset(&_sceneDescription, 0, sizeof(_sceneDescription));
|
|
|
|
|
|
|
|
if (resourceId == 0) {
|
|
|
|
return;
|
|
|
|
}
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-07-19 19:05:52 +00:00
|
|
|
_vm->_resource->loadResource(_sceneContext, resourceId, sceneDescriptorData, sceneDescriptorDataLength);
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-07-31 12:03:03 +00:00
|
|
|
if (sceneDescriptorDataLength == 16) {
|
|
|
|
MemoryReadStreamEndian readS(sceneDescriptorData, sceneDescriptorDataLength, _sceneContext->isBigEndian);
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-07-31 12:03:03 +00:00
|
|
|
_sceneDescription.flags = readS.readSint16();
|
|
|
|
_sceneDescription.resourceListResourceId = readS.readSint16();
|
|
|
|
_sceneDescription.endSlope = readS.readSint16();
|
|
|
|
_sceneDescription.beginSlope = readS.readSint16();
|
|
|
|
_sceneDescription.scriptModuleNumber = readS.readUint16();
|
|
|
|
_sceneDescription.sceneScriptEntrypointNumber = readS.readUint16();
|
|
|
|
_sceneDescription.startScriptEntrypointNumber = readS.readUint16();
|
|
|
|
_sceneDescription.musicResourceId = readS.readSint16();
|
|
|
|
}
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-07-19 19:05:52 +00:00
|
|
|
free(sceneDescriptorData);
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
|
2005-07-19 19:05:52 +00:00
|
|
|
void Scene::loadSceneResourceList(uint32 resourceId) {
|
|
|
|
byte *resourceListData;
|
|
|
|
size_t resourceListDataLength;
|
|
|
|
size_t i;
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-07-31 12:03:03 +00:00
|
|
|
_resourceListCount = 0;
|
|
|
|
_resourceList = NULL;
|
|
|
|
|
|
|
|
if (resourceId == 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2004-05-01 13:48:01 +00:00
|
|
|
// Load the scene resource table
|
2005-07-19 19:05:52 +00:00
|
|
|
_vm->_resource->loadResource(_sceneContext, resourceId, resourceListData, resourceListDataLength);
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-07-31 12:03:03 +00:00
|
|
|
if ((resourceListDataLength % SAGA_RESLIST_ENTRY_LEN) == 0) {
|
|
|
|
MemoryReadStreamEndian readS(resourceListData, resourceListDataLength, _sceneContext->isBigEndian);
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-07-31 12:03:03 +00:00
|
|
|
// Allocate memory for scene resource list
|
|
|
|
_resourceListCount = resourceListDataLength / SAGA_RESLIST_ENTRY_LEN;
|
2006-03-08 11:37:25 +00:00
|
|
|
debug(3, "Scene resource list contains %i entries", (int)_resourceListCount);
|
2005-07-31 12:03:03 +00:00
|
|
|
_resourceList = (SceneResourceData *)calloc(_resourceListCount, sizeof(*_resourceList));
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-07-31 12:03:03 +00:00
|
|
|
// Load scene resource list from raw scene
|
|
|
|
// resource table
|
|
|
|
debug(3, "Loading scene resource list");
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-07-31 12:03:03 +00:00
|
|
|
for (i = 0; i < _resourceListCount; i++) {
|
|
|
|
_resourceList[i].resourceId = readS.readUint16();
|
|
|
|
_resourceList[i].resourceType = readS.readUint16();
|
|
|
|
// demo version may contain invalid resourceId
|
|
|
|
_resourceList[i].invalid = !_vm->_resource->validResourceId(_sceneContext, _resourceList[i].resourceId);
|
|
|
|
}
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-07-31 12:03:03 +00:00
|
|
|
}
|
2005-07-19 19:05:52 +00:00
|
|
|
free(resourceListData);
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
|
2005-07-19 19:05:52 +00:00
|
|
|
void Scene::processSceneResources() {
|
2005-06-11 17:24:06 +00:00
|
|
|
byte *resourceData;
|
2005-07-24 17:04:15 +00:00
|
|
|
size_t resourceDataLength;
|
2005-07-19 19:05:52 +00:00
|
|
|
const byte *palPointer;
|
|
|
|
size_t i;
|
2005-07-25 17:35:35 +00:00
|
|
|
SAGAResourceTypes *types;
|
|
|
|
int typesCount;
|
|
|
|
SAGAResourceTypes resType;
|
|
|
|
|
2005-07-31 12:03:03 +00:00
|
|
|
getResourceTypes(types, typesCount);
|
2007-05-01 15:39:40 +00:00
|
|
|
|
2004-05-01 13:48:01 +00:00
|
|
|
// Process the scene resource list
|
2005-07-19 19:05:52 +00:00
|
|
|
for (i = 0; i < _resourceListCount; i++) {
|
|
|
|
if (_resourceList[i].invalid) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
resourceData = _resourceList[i].buffer;
|
|
|
|
resourceDataLength = _resourceList[i].size;
|
2005-07-29 17:58:00 +00:00
|
|
|
|
2005-07-25 17:35:35 +00:00
|
|
|
if (_resourceList[i].resourceType >= typesCount) {
|
|
|
|
error("Scene::processSceneResources() wrong resource type %i", _resourceList[i].resourceType);
|
2005-07-25 02:38:43 +00:00
|
|
|
}
|
|
|
|
|
2005-07-25 17:35:35 +00:00
|
|
|
resType = types[_resourceList[i].resourceType];
|
|
|
|
|
2005-07-25 02:38:43 +00:00
|
|
|
switch (resType) {
|
2005-07-25 17:35:35 +00:00
|
|
|
case SAGA_UNKNOWN:
|
|
|
|
warning("UNKNOWN resourceType %i", _resourceList[i].resourceType);
|
|
|
|
break;
|
2005-07-19 19:05:52 +00:00
|
|
|
case SAGA_ACTOR:
|
2005-07-25 02:38:43 +00:00
|
|
|
//for (a = actorsInScene; a; a = a->nextInScene)
|
|
|
|
// if (a->obj.figID == glist->file_id)
|
|
|
|
// if (_vm->getGameType() == GType_ITE ||
|
|
|
|
// ((a->obj.flags & ACTORF_FINAL_FACE) & 0xff))
|
|
|
|
// a->sprites = (xSpriteSet *)glist->offset;
|
|
|
|
warning("STUB: unimplemeted handler of SAGA_ACTOR resource");
|
2005-07-19 19:05:52 +00:00
|
|
|
break;
|
|
|
|
case SAGA_OBJECT:
|
|
|
|
break;
|
2004-05-01 13:48:01 +00:00
|
|
|
case SAGA_BG_IMAGE: // Scene background resource
|
2004-08-04 20:28:57 +00:00
|
|
|
if (_bg.loaded) {
|
2005-07-19 19:05:52 +00:00
|
|
|
error("Scene::processSceneResources() Multiple background resources encountered");
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
|
2005-07-05 16:58:36 +00:00
|
|
|
debug(3, "Loading background resource.");
|
2005-06-11 17:24:06 +00:00
|
|
|
_bg.res_buf = resourceData;
|
|
|
|
_bg.res_len = resourceDataLength;
|
2004-08-04 20:28:57 +00:00
|
|
|
_bg.loaded = 1;
|
|
|
|
|
|
|
|
if (_vm->decodeBGImage(_bg.res_buf,
|
|
|
|
_bg.res_len,
|
|
|
|
&_bg.buf,
|
|
|
|
&_bg.buf_len,
|
|
|
|
&_bg.w,
|
2004-10-27 21:32:28 +00:00
|
|
|
&_bg.h) != SUCCESS) {
|
2005-07-19 19:05:52 +00:00
|
|
|
error("Scene::processSceneResources() Error loading background resource %i", _resourceList[i].resourceId);
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
|
2005-07-19 19:05:52 +00:00
|
|
|
palPointer = _vm->getImagePal(_bg.res_buf, _bg.res_len);
|
|
|
|
memcpy(_bg.pal, palPointer, sizeof(_bg.pal));
|
2004-04-12 21:40:49 +00:00
|
|
|
break;
|
2004-05-01 13:48:01 +00:00
|
|
|
case SAGA_BG_MASK: // Scene background mask resource
|
2004-08-04 20:28:57 +00:00
|
|
|
if (_bgMask.loaded) {
|
2005-06-11 17:24:06 +00:00
|
|
|
error("Scene::ProcessSceneResources(): Duplicate background mask resource encountered");
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
2005-07-05 16:58:36 +00:00
|
|
|
debug(3, "Loading BACKGROUND MASK resource.");
|
2005-06-11 17:24:06 +00:00
|
|
|
_bgMask.res_buf = resourceData;
|
|
|
|
_bgMask.res_len = resourceDataLength;
|
2004-08-04 20:28:57 +00:00
|
|
|
_bgMask.loaded = 1;
|
|
|
|
_vm->decodeBGImage(_bgMask.res_buf, _bgMask.res_len, &_bgMask.buf,
|
2005-10-17 14:20:18 +00:00
|
|
|
&_bgMask.buf_len, &_bgMask.w, &_bgMask.h, true);
|
2005-07-04 07:46:48 +00:00
|
|
|
|
|
|
|
// At least in ITE the mask needs to be clipped.
|
|
|
|
|
|
|
|
_bgMask.w = MIN(_bgMask.w, _vm->getDisplayWidth());
|
2005-10-08 15:20:11 +00:00
|
|
|
_bgMask.h = MIN(_bgMask.h, getHeight());
|
2005-07-04 07:46:48 +00:00
|
|
|
|
2006-03-08 11:37:25 +00:00
|
|
|
debug(4, "BACKGROUND MASK width=%d height=%d length=%d", _bgMask.w, _bgMask.h, (int)_bgMask.buf_len);
|
2004-04-12 21:40:49 +00:00
|
|
|
break;
|
2005-01-28 19:25:41 +00:00
|
|
|
case SAGA_STRINGS:
|
2005-07-05 16:58:36 +00:00
|
|
|
debug(3, "Loading scene strings resource...");
|
2005-06-11 17:24:06 +00:00
|
|
|
_vm->loadStrings(_sceneStrings, resourceData, resourceDataLength);
|
2004-04-12 21:40:49 +00:00
|
|
|
break;
|
|
|
|
case SAGA_OBJECT_MAP:
|
2005-07-05 16:58:36 +00:00
|
|
|
debug(3, "Loading object map resource...");
|
2005-07-29 17:58:00 +00:00
|
|
|
_objectMap->load(resourceData, resourceDataLength);
|
2004-04-12 21:40:49 +00:00
|
|
|
break;
|
|
|
|
case SAGA_ACTION_MAP:
|
2005-07-05 16:58:36 +00:00
|
|
|
debug(3, "Loading action map resource...");
|
2005-06-11 17:24:06 +00:00
|
|
|
_actionMap->load(resourceData, resourceDataLength);
|
2004-04-12 21:40:49 +00:00
|
|
|
break;
|
2005-01-28 19:25:41 +00:00
|
|
|
case SAGA_ISO_IMAGES:
|
2005-05-08 14:04:06 +00:00
|
|
|
if (!(_sceneDescription.flags & kSceneFlagISO)) {
|
2005-01-28 19:25:41 +00:00
|
|
|
error("Scene::ProcessSceneResources(): not Iso mode");
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
|
2005-07-05 16:58:36 +00:00
|
|
|
debug(3, "Loading isometric images resource.");
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-06-11 17:24:06 +00:00
|
|
|
_vm->_isoMap->loadImages(resourceData, resourceDataLength);
|
2004-04-12 21:40:49 +00:00
|
|
|
break;
|
2005-01-28 19:25:41 +00:00
|
|
|
case SAGA_ISO_MAP:
|
2005-05-08 14:04:06 +00:00
|
|
|
if (!(_sceneDescription.flags & kSceneFlagISO)) {
|
2005-01-28 19:25:41 +00:00
|
|
|
error("Scene::ProcessSceneResources(): not Iso mode");
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
|
2005-07-05 16:58:36 +00:00
|
|
|
debug(3, "Loading isometric map resource.");
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-06-11 17:24:06 +00:00
|
|
|
_vm->_isoMap->loadMap(resourceData, resourceDataLength);
|
2004-04-12 21:40:49 +00:00
|
|
|
break;
|
2005-01-28 19:25:41 +00:00
|
|
|
case SAGA_ISO_PLATFORMS:
|
2005-05-08 14:04:06 +00:00
|
|
|
if (!(_sceneDescription.flags & kSceneFlagISO)) {
|
2005-01-28 19:25:41 +00:00
|
|
|
error("Scene::ProcessSceneResources(): not Iso mode");
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
|
2005-07-05 16:58:36 +00:00
|
|
|
debug(3, "Loading isometric platforms resource.");
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-06-11 17:24:06 +00:00
|
|
|
_vm->_isoMap->loadPlatforms(resourceData, resourceDataLength);
|
2004-04-12 21:40:49 +00:00
|
|
|
break;
|
2005-01-28 19:25:41 +00:00
|
|
|
case SAGA_ISO_METATILES:
|
2005-05-08 14:04:06 +00:00
|
|
|
if (!(_sceneDescription.flags & kSceneFlagISO)) {
|
2005-01-28 19:25:41 +00:00
|
|
|
error("Scene::ProcessSceneResources(): not Iso mode");
|
|
|
|
}
|
|
|
|
|
2005-07-05 16:58:36 +00:00
|
|
|
debug(3, "Loading isometric metatiles resource.");
|
2005-01-28 19:25:41 +00:00
|
|
|
|
2005-06-11 17:24:06 +00:00
|
|
|
_vm->_isoMap->loadMetaTiles(resourceData, resourceDataLength);
|
2005-07-29 17:58:00 +00:00
|
|
|
break;
|
2005-07-25 17:35:35 +00:00
|
|
|
case SAGA_ANIM:
|
2004-04-12 21:40:49 +00:00
|
|
|
{
|
2005-07-25 17:35:35 +00:00
|
|
|
uint16 animId = _resourceList[i].resourceType - 14;
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-07-05 16:58:36 +00:00
|
|
|
debug(3, "Loading animation resource animId=%i", animId);
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-06-20 11:46:34 +00:00
|
|
|
_vm->_anim->load(animId, resourceData, resourceDataLength);
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
break;
|
2005-07-25 02:38:43 +00:00
|
|
|
case SAGA_ENTRY:
|
|
|
|
debug(3, "Loading entry list resource...");
|
|
|
|
loadSceneEntryList(resourceData, resourceDataLength);
|
|
|
|
break;
|
2005-01-28 19:25:41 +00:00
|
|
|
case SAGA_ISO_MULTI:
|
2005-05-08 14:04:06 +00:00
|
|
|
if (!(_sceneDescription.flags & kSceneFlagISO)) {
|
2005-01-28 19:25:41 +00:00
|
|
|
error("Scene::ProcessSceneResources(): not Iso mode");
|
|
|
|
}
|
|
|
|
|
2005-07-05 16:58:36 +00:00
|
|
|
debug(3, "Loading isometric multi resource.");
|
2005-01-28 19:25:41 +00:00
|
|
|
|
2005-06-11 17:24:06 +00:00
|
|
|
_vm->_isoMap->loadMulti(resourceData, resourceDataLength);
|
2005-07-29 17:58:00 +00:00
|
|
|
break;
|
2004-04-12 21:40:49 +00:00
|
|
|
case SAGA_PAL_ANIM:
|
2005-07-05 16:58:36 +00:00
|
|
|
debug(3, "Loading palette animation resource.");
|
2005-06-11 17:24:06 +00:00
|
|
|
_vm->_palanim->loadPalAnim(resourceData, resourceDataLength);
|
2004-04-12 21:40:49 +00:00
|
|
|
break;
|
2004-10-05 02:16:26 +00:00
|
|
|
case SAGA_FACES:
|
2005-07-25 02:38:43 +00:00
|
|
|
if (_vm->getGameType() == GType_ITE)
|
|
|
|
_vm->_interface->loadScenePortraits(_resourceList[i].resourceId);
|
2004-10-05 02:16:26 +00:00
|
|
|
break;
|
2005-07-05 15:15:35 +00:00
|
|
|
case SAGA_PALETTE:
|
|
|
|
{
|
2005-07-09 16:23:45 +00:00
|
|
|
PalEntry pal[PAL_ENTRIES];
|
2005-07-05 15:15:35 +00:00
|
|
|
byte *palPtr = resourceData;
|
|
|
|
|
|
|
|
if (resourceDataLength < 3 * PAL_ENTRIES)
|
2006-03-08 11:37:25 +00:00
|
|
|
error("Too small scene palette %i", (int)resourceDataLength);
|
2005-07-05 15:15:35 +00:00
|
|
|
|
|
|
|
for (uint16 c = 0; c < PAL_ENTRIES; c++) {
|
|
|
|
pal[c].red = *palPtr++;
|
|
|
|
pal[c].green = *palPtr++;
|
|
|
|
pal[c].blue = *palPtr++;
|
|
|
|
}
|
2005-10-05 01:40:55 +00:00
|
|
|
_vm->_gfx->setPalette(pal);
|
2005-07-05 15:15:35 +00:00
|
|
|
}
|
|
|
|
break;
|
2004-04-12 21:40:49 +00:00
|
|
|
default:
|
2005-07-25 02:38:43 +00:00
|
|
|
error("Scene::ProcessSceneResources() Encountered unknown resource type %i", _resourceList[i].resourceType);
|
2004-04-12 21:40:49 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-05-22 11:59:22 +00:00
|
|
|
void Scene::draw() {
|
2005-07-09 16:23:45 +00:00
|
|
|
Surface *backBuffer;
|
|
|
|
Surface *backGroundSurface;
|
|
|
|
Rect rect;
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-05-22 11:59:22 +00:00
|
|
|
backBuffer = _vm->_gfx->getBackBuffer();
|
|
|
|
|
2005-07-09 16:23:45 +00:00
|
|
|
backGroundSurface = _vm->_render->getBackGroundSurface();
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-05-08 14:04:06 +00:00
|
|
|
if (_sceneDescription.flags & kSceneFlagISO) {
|
2005-02-18 00:00:00 +00:00
|
|
|
_vm->_isoMap->adjustScroll(false);
|
2005-05-22 11:59:22 +00:00
|
|
|
_vm->_isoMap->draw(backBuffer);
|
2005-01-09 23:41:22 +00:00
|
|
|
} else {
|
2005-07-09 16:23:45 +00:00
|
|
|
backGroundSurface->getRect(rect);
|
|
|
|
if (_sceneClip.bottom < rect.bottom) {
|
2005-10-08 15:20:11 +00:00
|
|
|
rect.bottom = getHeight();
|
2005-07-09 16:23:45 +00:00
|
|
|
}
|
|
|
|
backBuffer->blit(rect, (const byte *)backGroundSurface->pixels);
|
2005-01-09 23:41:22 +00:00
|
|
|
}
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
|
2005-05-08 14:04:06 +00:00
|
|
|
void Scene::endScene() {
|
2005-07-09 16:23:45 +00:00
|
|
|
Surface *backBuffer;
|
|
|
|
Surface *backGroundSurface;
|
|
|
|
Rect rect;
|
2005-07-19 19:05:52 +00:00
|
|
|
size_t i;
|
2005-06-11 17:24:06 +00:00
|
|
|
|
2005-06-02 22:14:57 +00:00
|
|
|
if (!_sceneLoaded)
|
|
|
|
return;
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-07-05 16:58:36 +00:00
|
|
|
debug(3, "Ending scene...");
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-03-29 22:14:20 +00:00
|
|
|
if (_sceneProc != NULL) {
|
2005-05-08 14:04:06 +00:00
|
|
|
_sceneProc(SCENE_END, this);
|
2005-03-29 22:14:20 +00:00
|
|
|
}
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-03-29 17:54:53 +00:00
|
|
|
//
|
|
|
|
_vm->_script->abortAllThreads();
|
|
|
|
_vm->_script->_skipSpeeches = false;
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-04-22 01:38:27 +00:00
|
|
|
// Copy current screen to render buffer so inset rooms will get proper background
|
2005-07-09 16:23:45 +00:00
|
|
|
backGroundSurface = _vm->_render->getBackGroundSurface();
|
2005-09-03 10:35:34 +00:00
|
|
|
if (!(_sceneDescription.flags & kSceneFlagISO) && !_vm->_scene->isInIntro()) {
|
2005-09-02 20:52:14 +00:00
|
|
|
BGInfo bgInfo;
|
|
|
|
|
|
|
|
_vm->_scene->getBGInfo(bgInfo);
|
|
|
|
backGroundSurface->blit(bgInfo.bounds, bgInfo.buffer);
|
|
|
|
} else {
|
|
|
|
backBuffer = _vm->_gfx->getBackBuffer();
|
|
|
|
backBuffer->getRect(rect);
|
|
|
|
backGroundSurface->blit(rect, (const byte *)backBuffer->pixels);
|
|
|
|
}
|
2005-04-22 01:38:27 +00:00
|
|
|
|
2004-05-01 13:48:01 +00:00
|
|
|
// Free scene background
|
2004-08-04 20:28:57 +00:00
|
|
|
if (_bg.loaded) {
|
|
|
|
free(_bg.buf);
|
|
|
|
_bg.loaded = 0;
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
|
2004-05-01 13:48:01 +00:00
|
|
|
// Free scene background mask
|
2004-08-04 20:28:57 +00:00
|
|
|
if (_bgMask.loaded) {
|
|
|
|
free(_bgMask.buf);
|
|
|
|
_bgMask.loaded = 0;
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
|
2004-05-01 13:48:01 +00:00
|
|
|
// Free scene resource list
|
2005-07-19 19:05:52 +00:00
|
|
|
for (i = 0; i < _resourceListCount; i++) {
|
|
|
|
free(_resourceList[i].buffer);
|
2005-06-11 17:24:06 +00:00
|
|
|
}
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-06-11 17:24:06 +00:00
|
|
|
if (_loadDescription) {
|
2005-07-19 19:05:52 +00:00
|
|
|
free(_resourceList);
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
|
2004-05-01 13:48:01 +00:00
|
|
|
// Free animation info list
|
2004-07-31 13:34:43 +00:00
|
|
|
_vm->_anim->reset();
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2004-08-10 19:20:33 +00:00
|
|
|
_vm->_palanim->freePalAnim();
|
2005-07-29 17:58:00 +00:00
|
|
|
|
2005-01-18 11:55:31 +00:00
|
|
|
_objectMap->freeMem();
|
2004-12-24 20:44:39 +00:00
|
|
|
_actionMap->freeMem();
|
2005-01-18 11:55:31 +00:00
|
|
|
_entryList.freeMem();
|
|
|
|
_sceneStrings.freeMem();
|
2005-03-18 17:11:37 +00:00
|
|
|
_vm->_isoMap->freeMem();
|
2004-10-09 07:39:46 +00:00
|
|
|
|
2004-08-10 19:00:30 +00:00
|
|
|
_vm->_events->clearList();
|
2005-07-14 17:46:21 +00:00
|
|
|
_textList.clear();
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2004-08-04 20:28:57 +00:00
|
|
|
_sceneLoaded = false;
|
2004-04-12 21:40:49 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2007-06-06 19:46:10 +00:00
|
|
|
void Scene::restoreScene() {
|
2007-06-11 02:30:04 +00:00
|
|
|
// There is no implementation for tiled scenes, since this function is only used
|
|
|
|
// in IHNM, which has no tiled scenes
|
|
|
|
|
|
|
|
Event event;
|
|
|
|
|
|
|
|
_vm->_gfx->showCursor(false);
|
|
|
|
_vm->_gfx->restorePalette();
|
|
|
|
|
|
|
|
event.type = kEvTImmediate;
|
|
|
|
event.code = kBgEvent;
|
|
|
|
event.op = kEventDisplay;
|
|
|
|
event.param = kEvPNoSetPalette;
|
|
|
|
event.time = 0;
|
|
|
|
event.duration = 0;
|
|
|
|
_vm->_events->queue(&event);
|
|
|
|
|
|
|
|
_vm->_gfx->showCursor(true);
|
2007-06-06 19:46:10 +00:00
|
|
|
}
|
|
|
|
|
2004-12-24 20:44:39 +00:00
|
|
|
void Scene::cmdSceneChange(int argc, const char **argv) {
|
2004-04-12 21:40:49 +00:00
|
|
|
int scene_num = 0;
|
|
|
|
|
2004-12-03 19:15:44 +00:00
|
|
|
scene_num = atoi(argv[1]);
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-07-08 18:39:53 +00:00
|
|
|
if ((scene_num < 1) || (scene_num >= _sceneCount)) {
|
2004-12-03 19:15:44 +00:00
|
|
|
_vm->_console->DebugPrintf("Invalid scene number.\n");
|
2004-04-12 21:40:49 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2004-08-04 20:28:57 +00:00
|
|
|
clearSceneQueue();
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-05-08 14:04:06 +00:00
|
|
|
changeScene(scene_num, 0, kTransitionNoFade);
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
|
2004-12-24 20:44:39 +00:00
|
|
|
void Scene::cmdActionMapInfo() {
|
|
|
|
_actionMap->cmdInfo();
|
2004-10-07 22:31:39 +00:00
|
|
|
}
|
|
|
|
|
2004-12-24 20:44:39 +00:00
|
|
|
void Scene::cmdObjectMapInfo() {
|
|
|
|
_objectMap->cmdInfo();
|
2004-10-07 23:02:19 +00:00
|
|
|
}
|
|
|
|
|
2004-08-01 09:15:12 +00:00
|
|
|
|
2005-07-29 17:58:00 +00:00
|
|
|
void Scene::loadSceneEntryList(const byte* resourcePointer, size_t resourceLength) {
|
2005-01-16 19:06:04 +00:00
|
|
|
int i;
|
2005-07-29 17:58:00 +00:00
|
|
|
|
2005-01-18 11:55:31 +00:00
|
|
|
_entryList.entryListCount = resourceLength / 8;
|
2005-01-16 19:06:04 +00:00
|
|
|
|
2005-07-19 19:05:52 +00:00
|
|
|
MemoryReadStreamEndian readS(resourcePointer, resourceLength, _sceneContext->isBigEndian);
|
2005-01-16 19:06:04 +00:00
|
|
|
|
|
|
|
|
2005-01-18 11:55:31 +00:00
|
|
|
if (_entryList.entryList)
|
|
|
|
error("Scene::loadSceneEntryList entryList != NULL");
|
2005-01-16 19:06:04 +00:00
|
|
|
|
2005-01-18 11:55:31 +00:00
|
|
|
_entryList.entryList = (SceneEntry *) malloc(_entryList.entryListCount * sizeof(*_entryList.entryList));
|
|
|
|
if (_entryList.entryList == NULL) {
|
2005-01-21 21:55:54 +00:00
|
|
|
memoryError("Scene::loadSceneEntryList");
|
2005-01-16 19:06:04 +00:00
|
|
|
}
|
|
|
|
|
2005-01-18 11:55:31 +00:00
|
|
|
for (i = 0; i < _entryList.entryListCount; i++) {
|
|
|
|
_entryList.entryList[i].location.x = readS.readSint16();
|
|
|
|
_entryList.entryList[i].location.y = readS.readSint16();
|
|
|
|
_entryList.entryList[i].location.z = readS.readSint16();
|
|
|
|
_entryList.entryList[i].facing = readS.readUint16();
|
2005-01-16 19:06:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-04-12 21:40:49 +00:00
|
|
|
} // End of namespace Saga
|