2007-05-30 21:56:52 +00:00
|
|
|
/* 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.
|
2006-02-21 14:22:25 +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
|
2006-02-21 14:22:25 +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
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
* $URL$
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
*/
|
2006-03-29 15:59:37 +00:00
|
|
|
|
|
|
|
#include "common/endian.h"
|
2006-06-13 17:02:53 +00:00
|
|
|
#include "common/stream.h"
|
2006-02-21 14:22:25 +00:00
|
|
|
|
|
|
|
#include "gob/gob.h"
|
|
|
|
#include "gob/mult.h"
|
|
|
|
#include "gob/global.h"
|
2007-03-20 14:51:57 +00:00
|
|
|
#include "gob/util.h"
|
2006-04-12 09:49:08 +00:00
|
|
|
#include "gob/draw.h"
|
2007-03-20 14:51:57 +00:00
|
|
|
#include "gob/game.h"
|
2009-06-22 10:13:37 +00:00
|
|
|
#include "gob/script.h"
|
2009-06-24 21:49:37 +00:00
|
|
|
#include "gob/resources.h"
|
2007-03-20 14:51:57 +00:00
|
|
|
#include "gob/goblin.h"
|
|
|
|
#include "gob/inter.h"
|
|
|
|
#include "gob/scenery.h"
|
|
|
|
#include "gob/video.h"
|
2007-07-30 15:53:38 +00:00
|
|
|
#include "gob/videoplayer.h"
|
2006-02-21 14:22:25 +00:00
|
|
|
|
|
|
|
namespace Gob {
|
|
|
|
|
|
|
|
Mult_v2::Mult_v2(GobEngine *vm) : Mult_v1(vm) {
|
2007-03-20 14:51:57 +00:00
|
|
|
_renderObjs = 0;
|
2007-02-05 14:08:50 +00:00
|
|
|
_multData = 0;
|
2007-03-20 14:51:57 +00:00
|
|
|
for (int i = 0; i < 8; i++)
|
|
|
|
_multDatas[i] = 0;
|
2006-02-21 14:22:25 +00:00
|
|
|
}
|
|
|
|
|
2006-05-31 08:44:14 +00:00
|
|
|
Mult_v2::~Mult_v2() {
|
|
|
|
freeMultKeys();
|
2007-02-17 09:56:09 +00:00
|
|
|
for (int i = 0; i < 8; i++) {
|
2007-02-05 14:08:50 +00:00
|
|
|
_multData = _multDatas[i];
|
2006-05-31 08:44:14 +00:00
|
|
|
freeMultKeys();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-02-21 14:22:25 +00:00
|
|
|
void Mult_v2::loadMult(int16 resId) {
|
|
|
|
int8 index;
|
2007-03-20 14:51:57 +00:00
|
|
|
uint8 staticCount;
|
|
|
|
uint8 animCount;
|
|
|
|
bool hasImds;
|
2007-09-19 08:40:12 +00:00
|
|
|
|
2009-06-22 10:13:37 +00:00
|
|
|
index = (resId & 0x8000) ? _vm->_game->_script->readByte() : 0;
|
2007-04-02 11:05:09 +00:00
|
|
|
resId &= 0x7FFF;
|
2006-02-21 14:22:25 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
debugC(4, kDebugGameFlow, "Loading mult %d", index);
|
|
|
|
|
2007-02-05 14:08:50 +00:00
|
|
|
_multData = new Mult_Data;
|
|
|
|
memset(_multData, 0, sizeof(Mult_Data));
|
2006-05-11 19:43:30 +00:00
|
|
|
|
2007-02-05 14:08:50 +00:00
|
|
|
_multDatas[index] = _multData;
|
2006-02-21 14:22:25 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
for (int i = 0; i < 4; i++)
|
|
|
|
_multData->animObjs[0][i] = i;
|
2006-02-21 14:22:25 +00:00
|
|
|
|
2007-02-05 14:08:50 +00:00
|
|
|
_multData->sndSlotsCount = 0;
|
|
|
|
_multData->frameStart = 0;
|
2006-02-21 14:22:25 +00:00
|
|
|
|
2009-06-24 21:49:37 +00:00
|
|
|
Resource *resource = _vm->_game->_resources->getResource(resId);
|
|
|
|
if (!resource)
|
|
|
|
return;
|
|
|
|
|
|
|
|
Common::SeekableReadStream &data = *resource->stream();
|
2006-02-21 14:22:25 +00:00
|
|
|
|
2007-02-05 14:08:50 +00:00
|
|
|
_multData->staticCount = staticCount = data.readSByte();
|
|
|
|
_multData->animCount = animCount = data.readSByte();
|
2006-02-21 14:22:25 +00:00
|
|
|
staticCount++;
|
|
|
|
animCount++;
|
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
hasImds = (staticCount & 0x80) != 0;
|
2006-02-21 14:22:25 +00:00
|
|
|
staticCount &= 0x7F;
|
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
debugC(7, kDebugGraphics, "statics: %u, anims: %u, imds: %u",
|
|
|
|
staticCount, animCount, hasImds);
|
|
|
|
|
|
|
|
for (int i = 0; i < 10; i++) {
|
|
|
|
_multData->staticLoaded[i] = false;
|
|
|
|
_multData->animLoaded[i] = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int i = 0; i < staticCount; i++, data.seek(14, SEEK_CUR)) {
|
2007-02-05 14:08:50 +00:00
|
|
|
_multData->staticIndices[i] = _vm->_scenery->loadStatic(1);
|
2006-02-21 14:22:25 +00:00
|
|
|
|
2007-02-05 14:08:50 +00:00
|
|
|
if (_multData->staticIndices[i] >= 100) {
|
|
|
|
_multData->staticIndices[i] -= 100;
|
2007-03-20 14:51:57 +00:00
|
|
|
_multData->staticLoaded[i] = true;
|
|
|
|
}
|
2006-02-21 14:22:25 +00:00
|
|
|
}
|
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
for (int i = 0; i < animCount; i++, data.seek(14, SEEK_CUR)) {
|
2007-02-05 14:08:50 +00:00
|
|
|
_multData->animIndices[i] = _vm->_scenery->loadAnim(1);
|
2006-02-21 14:22:25 +00:00
|
|
|
|
2007-02-05 14:08:50 +00:00
|
|
|
if (_multData->animIndices[i] >= 100) {
|
|
|
|
_multData->animIndices[i] -= 100;
|
2007-03-20 14:51:57 +00:00
|
|
|
_multData->animLoaded[i] = true;
|
|
|
|
}
|
2006-02-21 14:22:25 +00:00
|
|
|
}
|
|
|
|
|
2007-02-05 14:08:50 +00:00
|
|
|
_multData->frameRate = data.readSint16LE();
|
|
|
|
_multData->staticKeysCount = data.readSint16LE();
|
|
|
|
_multData->staticKeys = new Mult_StaticKey[_multData->staticKeysCount];
|
2007-03-20 14:51:57 +00:00
|
|
|
for (int i = 0; i < _multData->staticKeysCount; i++) {
|
2007-02-05 14:08:50 +00:00
|
|
|
_multData->staticKeys[i].frame = data.readSint16LE();
|
|
|
|
_multData->staticKeys[i].layer = data.readSint16LE();
|
2006-02-21 14:22:25 +00:00
|
|
|
}
|
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
for (int i = 0; i < 4; i++) {
|
|
|
|
_multData->imdKeysCount[i] = 0;
|
|
|
|
_multData->imdKeys[i] = 0;
|
|
|
|
_multData->imdIndices[i] = -1;
|
2006-02-21 14:22:25 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
for (int j = 0; j < 4; j++) {
|
2007-02-05 14:08:50 +00:00
|
|
|
_multData->animKeysIndices[i][j] = 0;
|
2007-03-20 14:51:57 +00:00
|
|
|
_multData->imdKeysIndices[i][j] = 0;
|
2006-02-21 14:22:25 +00:00
|
|
|
}
|
|
|
|
|
2007-02-05 14:08:50 +00:00
|
|
|
_multData->animKeysFrames[i] = -1;
|
|
|
|
_multData->animKeysCount[i] = data.readSint16LE();
|
|
|
|
_multData->animKeys[i] = new Mult_AnimKey[_multData->animKeysCount[i]];
|
2007-03-20 14:51:57 +00:00
|
|
|
for (int j = 0; j < _multData->animKeysCount[i]; j++) {
|
2007-02-05 14:08:50 +00:00
|
|
|
_multData->animKeys[i][j].frame = data.readSint16LE();
|
|
|
|
_multData->animKeys[i][j].layer = data.readSint16LE();
|
|
|
|
_multData->animKeys[i][j].posX = data.readSint16LE();
|
|
|
|
_multData->animKeys[i][j].posY = data.readSint16LE();
|
|
|
|
_multData->animKeys[i][j].order = data.readSint16LE();
|
2006-02-21 14:22:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
for (int i = 0; i < 5; i++) {
|
|
|
|
for (int j = 0; j < 16; j++) {
|
|
|
|
_multData->fadePal[i][j].red = data.readByte();
|
|
|
|
_multData->fadePal[i][j].green = data.readByte();
|
|
|
|
_multData->fadePal[i][j].blue = data.readByte();
|
2006-02-21 14:22:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-02-05 14:08:50 +00:00
|
|
|
_multData->palFadeKeysCount = data.readSint16LE();
|
|
|
|
_multData->palFadeKeys = new Mult_PalFadeKey[_multData->palFadeKeysCount];
|
2007-03-20 14:51:57 +00:00
|
|
|
for (int i = 0; i < _multData->palFadeKeysCount; i++) {
|
2007-02-05 14:08:50 +00:00
|
|
|
_multData->palFadeKeys[i].frame = data.readSint16LE();
|
|
|
|
_multData->palFadeKeys[i].fade = data.readSint16LE();
|
|
|
|
_multData->palFadeKeys[i].palIndex = data.readSint16LE();
|
|
|
|
_multData->palFadeKeys[i].flag = data.readSByte();
|
2006-02-21 14:22:25 +00:00
|
|
|
}
|
|
|
|
|
2007-02-05 14:08:50 +00:00
|
|
|
_multData->palKeysCount = data.readSint16LE();
|
|
|
|
_multData->palKeys = new Mult_PalKey[_multData->palKeysCount];
|
2007-03-20 14:51:57 +00:00
|
|
|
for (int i = 0; i < _multData->palKeysCount; i++) {
|
2007-02-05 14:08:50 +00:00
|
|
|
_multData->palKeys[i].frame = data.readSint16LE();
|
|
|
|
_multData->palKeys[i].cmd = data.readSint16LE();
|
|
|
|
_multData->palKeys[i].rates[0] = data.readSint16LE();
|
|
|
|
_multData->palKeys[i].rates[1] = data.readSint16LE();
|
|
|
|
_multData->palKeys[i].rates[2] = data.readSint16LE();
|
|
|
|
_multData->palKeys[i].rates[3] = data.readSint16LE();
|
|
|
|
_multData->palKeys[i].unknown0 = data.readSint16LE();
|
|
|
|
_multData->palKeys[i].unknown1 = data.readSint16LE();
|
|
|
|
data.read(_multData->palKeys[i].subst, 64);
|
2006-02-21 14:22:25 +00:00
|
|
|
}
|
|
|
|
|
2007-02-05 14:08:50 +00:00
|
|
|
_multData->textKeysCount = data.readSint16LE();
|
|
|
|
_multData->textKeys = new Mult_TextKey[_multData->textKeysCount];
|
2007-03-20 14:51:57 +00:00
|
|
|
for (int i = 0; i < _multData->textKeysCount; i++) {
|
2007-02-05 14:08:50 +00:00
|
|
|
_multData->textKeys[i].frame = data.readSint16LE();
|
|
|
|
_multData->textKeys[i].cmd = data.readSint16LE();
|
2007-03-20 14:51:57 +00:00
|
|
|
if (!hasImds)
|
2006-06-13 17:02:53 +00:00
|
|
|
data.seek(24, SEEK_CUR);
|
2006-02-21 14:22:25 +00:00
|
|
|
}
|
|
|
|
|
2007-02-05 14:08:50 +00:00
|
|
|
_multData->sndKeysCount = data.readSint16LE();
|
|
|
|
_multData->sndKeys = new Mult_SndKey[_multData->sndKeysCount];
|
2007-03-20 14:51:57 +00:00
|
|
|
for (int i = 0; i < _multData->sndKeysCount; i++) {
|
|
|
|
int j;
|
|
|
|
|
2007-02-05 14:08:50 +00:00
|
|
|
_multData->sndKeys[i].frame = data.readSint16LE();
|
|
|
|
_multData->sndKeys[i].cmd = data.readSint16LE();
|
|
|
|
_multData->sndKeys[i].freq = data.readSint16LE();
|
|
|
|
_multData->sndKeys[i].fadeLength = data.readSint16LE();
|
|
|
|
_multData->sndKeys[i].repCount = data.readSint16LE();
|
|
|
|
_multData->sndKeys[i].soundIndex = -1;
|
|
|
|
_multData->sndKeys[i].resId = -1;
|
2006-06-13 17:02:53 +00:00
|
|
|
data.seek(2, SEEK_CUR);
|
2007-03-20 14:51:57 +00:00
|
|
|
if (!hasImds)
|
2006-06-13 17:02:53 +00:00
|
|
|
data.seek(24, SEEK_CUR);
|
2006-02-21 14:22:25 +00:00
|
|
|
|
2007-02-05 14:08:50 +00:00
|
|
|
switch (_multData->sndKeys[i].cmd) {
|
2006-02-21 14:22:25 +00:00
|
|
|
case 1:
|
|
|
|
case 4:
|
2009-06-22 10:13:37 +00:00
|
|
|
_multData->sndKeys[i].resId = _vm->_game->_script->peekUint16();
|
2007-03-20 14:51:57 +00:00
|
|
|
for (j = 0; j < i; j++) {
|
|
|
|
if (_multData->sndKeys[j].resId ==
|
|
|
|
_multData->sndKeys[i].resId) {
|
|
|
|
_multData->sndKeys[i].soundIndex =
|
|
|
|
_multData->sndKeys[j].soundIndex;
|
2009-06-22 10:13:37 +00:00
|
|
|
_vm->_game->_script->skip(2);
|
2006-02-21 14:22:25 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (i == j) {
|
2007-03-20 14:51:57 +00:00
|
|
|
_multData->sndSlot[_multData->sndSlotsCount] =
|
|
|
|
_vm->_inter->loadSound(1);
|
|
|
|
_multData->sndKeys[i].soundIndex =
|
|
|
|
_multData->sndSlot[_multData->sndSlotsCount] & 0x7FFF;
|
2007-02-05 14:08:50 +00:00
|
|
|
_multData->sndSlotsCount++;
|
2006-02-21 14:22:25 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 3:
|
2009-06-22 10:13:37 +00:00
|
|
|
_vm->_game->_script->skip(4);
|
2006-02-21 14:22:25 +00:00
|
|
|
break;
|
2007-04-21 20:13:15 +00:00
|
|
|
|
|
|
|
case -1:
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
warning("Mult_v2::loadMult(): Unknown sound key command (%d)",
|
|
|
|
_multData->sndKeys[i].cmd);
|
2006-02-21 14:22:25 +00:00
|
|
|
}
|
|
|
|
}
|
2007-09-19 08:40:12 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
_multData->imdFiles = 0;
|
2007-02-05 14:08:50 +00:00
|
|
|
_multData->somepointer10 = 0;
|
2006-02-21 14:22:25 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
if (hasImds)
|
|
|
|
loadImds(data);
|
|
|
|
|
2009-06-24 21:49:37 +00:00
|
|
|
delete resource;
|
2007-03-20 14:51:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Mult_v2::loadImds(Common::SeekableReadStream &data) {
|
|
|
|
int16 size;
|
|
|
|
|
2009-06-22 10:13:37 +00:00
|
|
|
size = _vm->_game->_script->readInt16();
|
|
|
|
_multData->execPtr = _vm->_game->_script->getData() + _vm->_game->_script->pos();
|
|
|
|
_vm->_game->_script->skip(size * 2);
|
2007-03-20 14:51:57 +00:00
|
|
|
|
2009-06-23 01:19:03 +00:00
|
|
|
if (_vm->_game->_script->getVersionMinor() < 3)
|
2007-03-20 14:51:57 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
size = data.readSint16LE();
|
2007-08-08 03:42:33 +00:00
|
|
|
if (size > 0) {
|
|
|
|
_multData->somepointer10 = new char[size * 20];
|
|
|
|
data.read(_multData->somepointer10, size * 20);
|
|
|
|
}
|
|
|
|
|
2009-06-22 10:13:37 +00:00
|
|
|
size = _vm->_game->_script->readInt16();
|
2007-03-20 14:51:57 +00:00
|
|
|
if (size <= 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
_multData->imdFiles = new char[size * 14];
|
2009-06-22 10:13:37 +00:00
|
|
|
memcpy(_multData->imdFiles,
|
|
|
|
_vm->_game->_script->getData() + _vm->_game->_script->pos(), size * 14);
|
2009-06-09 18:53:35 +00:00
|
|
|
|
|
|
|
// WORKAROUND: The Windows version of Lost in Time has VMD not IMD files,
|
|
|
|
// but they are still referenced as IMD.
|
|
|
|
if ((_vm->getGameType() == kGameTypeLostInTime) &&
|
|
|
|
(_vm->getPlatform() == Common::kPlatformWindows)) {
|
|
|
|
|
|
|
|
for (int i = 0; i < size; i++) {
|
|
|
|
char *dot = strrchr(_multData->imdFiles + (i * 14), '.');
|
|
|
|
if (dot)
|
|
|
|
*dot = '\0';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-06-22 10:13:37 +00:00
|
|
|
_vm->_game->_script->skip(size * 14);
|
2007-03-20 14:51:57 +00:00
|
|
|
data.seek(2, SEEK_CUR);
|
|
|
|
for (int i = 0; i < 4; i++) {
|
|
|
|
_multData->imdKeysCount[i] = data.readSint16LE();
|
|
|
|
_multData->imdKeys[i] = new Mult_ImdKey[_multData->imdKeysCount[i]];
|
|
|
|
for (int j = 0; j < _multData->imdKeysCount[i]; j++) {
|
|
|
|
_multData->imdKeys[i][j].frame = data.readSint16LE();
|
|
|
|
_multData->imdKeys[i][j].imdFile = data.readSint16LE();
|
|
|
|
_multData->imdKeys[i][j].field_4 = data.readSint16LE();
|
|
|
|
_multData->imdKeys[i][j].field_6 = data.readSint16LE();
|
|
|
|
_multData->imdKeys[i][j].flags = data.readUint16LE();
|
2007-03-30 17:52:31 +00:00
|
|
|
_multData->imdKeys[i][j].palFrame = data.readSint16LE();
|
2007-03-20 14:51:57 +00:00
|
|
|
_multData->imdKeys[i][j].lastFrame = data.readSint16LE();
|
|
|
|
_multData->imdKeys[i][j].palStart = data.readSByte();
|
|
|
|
_multData->imdKeys[i][j].palEnd = data.readSByte();
|
2006-02-21 14:22:25 +00:00
|
|
|
}
|
|
|
|
}
|
2007-03-20 14:51:57 +00:00
|
|
|
}
|
2006-02-21 14:22:25 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
void Mult_v2::freeMultKeys() {
|
|
|
|
uint8 animCount;
|
|
|
|
uint8 staticCount;
|
|
|
|
|
|
|
|
if (!_multData)
|
|
|
|
return;
|
|
|
|
|
|
|
|
staticCount = (_multData->staticCount + 1) & 0x7F;
|
|
|
|
animCount = _multData->animCount + 1;
|
|
|
|
|
|
|
|
for (int i = 0; i < staticCount; i++)
|
|
|
|
if (_multData->staticLoaded[i])
|
|
|
|
_vm->_scenery->freeStatic(_multData->staticIndices[i]);
|
|
|
|
|
|
|
|
for (int i = 0; i < animCount; i++)
|
|
|
|
if (_multData->animLoaded[i])
|
|
|
|
_vm->_scenery->freeAnim(_multData->animIndices[i]);
|
|
|
|
|
|
|
|
delete[] _multData->staticKeys;
|
|
|
|
|
|
|
|
for (int i = 0; i < 4; i++) {
|
|
|
|
delete[] _multData->animKeys[i];
|
|
|
|
delete[] _multData->imdKeys[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
delete[] _multData->palFadeKeys;
|
|
|
|
delete[] _multData->palKeys;
|
|
|
|
delete[] _multData->textKeys;
|
|
|
|
|
|
|
|
for (int i = 0; i < _multData->sndSlotsCount; i++)
|
|
|
|
if (!(_multData->sndSlot[i] & 0x8000))
|
|
|
|
_vm->_game->freeSoundSlot(_multData->sndSlot[i]);
|
2007-09-19 08:40:12 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
delete[] _multData->sndKeys;
|
|
|
|
|
|
|
|
delete[] _multData->imdFiles;
|
|
|
|
delete[] _multData->somepointer10;
|
|
|
|
|
|
|
|
if (_animDataAllocated) {
|
|
|
|
freeMult();
|
2007-09-19 08:40:12 +00:00
|
|
|
|
2008-07-12 15:21:38 +00:00
|
|
|
delete _animArrayX;
|
|
|
|
delete _animArrayY;
|
2007-03-20 14:51:57 +00:00
|
|
|
delete[] _animArrayData;
|
|
|
|
|
|
|
|
_animArrayX = 0;
|
|
|
|
_animArrayY = 0;
|
|
|
|
_animArrayData = 0;
|
|
|
|
|
|
|
|
_animDataAllocated = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int i = 0; i < 8; i++)
|
|
|
|
if (_multDatas[i] == _multData)
|
|
|
|
_multDatas[i] = 0;
|
|
|
|
|
|
|
|
delete _multData;
|
|
|
|
_multData = 0;
|
2006-02-21 14:22:25 +00:00
|
|
|
}
|
|
|
|
|
2007-07-24 06:11:38 +00:00
|
|
|
bool Mult_v2::hasMultData(uint16 multIndex) {
|
|
|
|
if (multIndex > 7)
|
2006-02-24 21:58:03 +00:00
|
|
|
error("Multindex out of range");
|
|
|
|
|
2007-07-24 06:11:38 +00:00
|
|
|
return _multDatas[multIndex] != 0;
|
2006-02-24 21:58:03 +00:00
|
|
|
}
|
|
|
|
|
2007-07-24 06:11:38 +00:00
|
|
|
void Mult_v2::setMultData(uint16 multIndex) {
|
|
|
|
if (multIndex > 7)
|
|
|
|
error("Multindex out of range");
|
|
|
|
|
|
|
|
debugC(4, kDebugGameFlow, "Switching to mult %d", multIndex);
|
|
|
|
_multData = _multDatas[multIndex];
|
|
|
|
}
|
|
|
|
|
|
|
|
void Mult_v2::zeroMultData(uint16 multIndex) {
|
|
|
|
if (multIndex > 7)
|
|
|
|
error("Multindex out of range");
|
|
|
|
|
|
|
|
_multDatas[multIndex] = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Mult_v2::multSub(uint16 multIndex) {
|
2006-05-01 16:04:53 +00:00
|
|
|
uint16 flags;
|
|
|
|
int16 expr;
|
2007-03-20 14:51:57 +00:00
|
|
|
int16 index;
|
|
|
|
int16 startFrame, stopFrame, firstFrame;
|
2006-05-01 16:04:53 +00:00
|
|
|
|
2007-07-24 06:11:38 +00:00
|
|
|
flags = multIndex;
|
|
|
|
multIndex = (multIndex >> 12) & 0xF;
|
2006-05-01 16:04:53 +00:00
|
|
|
|
2007-07-24 06:11:38 +00:00
|
|
|
if (multIndex > 7)
|
2006-05-01 16:04:53 +00:00
|
|
|
error("Multindex out of range");
|
|
|
|
|
2009-06-14 12:19:42 +00:00
|
|
|
_vm->_util->notifyNewAnim();
|
|
|
|
|
2007-07-24 06:11:38 +00:00
|
|
|
debugC(4, kDebugGameFlow, "Sub mult %d", multIndex);
|
|
|
|
_multData = _multDatas[multIndex];
|
2006-05-01 16:04:53 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
if (!_multData) {
|
2009-06-22 10:13:37 +00:00
|
|
|
_vm->_game->_script->readValExpr();
|
|
|
|
_vm->_game->_script->readValExpr();
|
|
|
|
_vm->_game->_script->readValExpr();
|
|
|
|
_vm->_game->_script->readValExpr();
|
2006-05-01 16:04:53 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (flags & 0x200)
|
2006-06-10 14:37:48 +00:00
|
|
|
index = 3;
|
2006-05-01 16:04:53 +00:00
|
|
|
else if (flags & 0x100)
|
2006-06-10 14:37:48 +00:00
|
|
|
index = 2;
|
2006-05-01 16:04:53 +00:00
|
|
|
else if (flags & 0x80)
|
2006-06-10 14:37:48 +00:00
|
|
|
index = 1;
|
2006-05-01 16:04:53 +00:00
|
|
|
else
|
2006-06-10 14:37:48 +00:00
|
|
|
index = 0;
|
2006-05-01 16:04:53 +00:00
|
|
|
|
|
|
|
if (flags & 0x400) {
|
|
|
|
flags = 0x400;
|
2007-02-05 14:08:50 +00:00
|
|
|
_multData->animDirection = -1;
|
2006-05-01 16:04:53 +00:00
|
|
|
} else {
|
2007-02-05 14:08:50 +00:00
|
|
|
_multData->animDirection = 1;
|
2006-05-01 16:04:53 +00:00
|
|
|
flags &= 0x7F;
|
|
|
|
}
|
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
_multData->animObjs[index][0] = flags;
|
|
|
|
for (int i = 1; i < 4; i++)
|
2009-06-22 10:13:37 +00:00
|
|
|
_multData->animObjs[index][i] = _vm->_game->_script->readValExpr();
|
2006-08-12 09:16:08 +00:00
|
|
|
|
2009-06-22 10:13:37 +00:00
|
|
|
expr = _vm->_game->_script->readValExpr();
|
2007-02-05 14:08:50 +00:00
|
|
|
_multData->animKeysFrames[index] = expr;
|
|
|
|
_multData->animKeysStartFrames[index] = expr;
|
2007-09-19 08:40:12 +00:00
|
|
|
|
2006-06-10 14:37:48 +00:00
|
|
|
WRITE_VAR(18 + index, expr);
|
|
|
|
if (expr == -1) {
|
2007-03-20 14:51:57 +00:00
|
|
|
if (!_objects)
|
|
|
|
return;
|
2006-06-10 14:37:48 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
for (int i = 0; i < 4; i++) {
|
|
|
|
int obj = _multData->animObjs[index][i];
|
2006-06-10 14:37:48 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
if ((obj == -1) || (obj == 1024))
|
|
|
|
continue;
|
2006-06-07 18:49:20 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
Mult_AnimData &animData = *(_objects[obj].pAnimData);
|
|
|
|
animData.animType = animData.animTypeBak;
|
2006-06-10 14:37:48 +00:00
|
|
|
}
|
2006-05-01 16:04:53 +00:00
|
|
|
|
2006-04-12 09:49:08 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
startFrame = _multData->animKeysStartFrames[index];
|
|
|
|
stopFrame = _multData->animKeysStopFrames[index];
|
2006-04-12 09:49:08 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
if (_multData->animDirection == 1) {
|
|
|
|
stopFrame = 32000;
|
|
|
|
for (int i = 0; i < _multData->textKeysCount; i++) {
|
|
|
|
int16 textFrame = _multData->textKeys[i].frame;
|
2006-04-12 09:49:08 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
if ((textFrame > startFrame) && (textFrame < stopFrame))
|
|
|
|
stopFrame = textFrame;
|
2006-04-12 09:49:08 +00:00
|
|
|
}
|
2007-03-20 14:51:57 +00:00
|
|
|
} else {
|
|
|
|
stopFrame = 0;
|
|
|
|
for (int i = 0; i < _multData->textKeysCount; i++) {
|
|
|
|
int16 textFrame = _multData->textKeys[i].frame;
|
2006-04-12 09:49:08 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
if ((textFrame < startFrame) && (textFrame > stopFrame))
|
|
|
|
stopFrame = textFrame;
|
2006-04-12 09:49:08 +00:00
|
|
|
}
|
2007-03-20 14:51:57 +00:00
|
|
|
}
|
2006-04-12 09:49:08 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
if (_objects) {
|
|
|
|
for (int i = 0; i < 4; i++) {
|
|
|
|
int obj = _multData->animObjs[index][i];
|
2006-04-12 09:49:08 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
if ((obj != -1) && (obj != 1024))
|
2008-04-27 03:19:19 +00:00
|
|
|
_objects[obj].pAnimData->animTypeBak = _objects[obj].pAnimData->animType;
|
2007-03-20 14:51:57 +00:00
|
|
|
}
|
|
|
|
}
|
2006-04-12 09:49:08 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
for (int i = 0; i < 4; i++) {
|
|
|
|
_multData->animKeysIndices[index][i] = 0;
|
2006-04-12 09:49:08 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
for (int j = 0; j < _multData->animKeysCount[i]; j++)
|
2008-04-27 03:19:19 +00:00
|
|
|
if (_multData->animKeys[i][j].frame >= startFrame) {
|
2007-03-20 14:51:57 +00:00
|
|
|
_multData->animKeysIndices[index][i] = j;
|
2008-04-27 03:19:19 +00:00
|
|
|
break;
|
|
|
|
}
|
2007-03-20 14:51:57 +00:00
|
|
|
}
|
2006-04-12 09:49:08 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
if (_multData->animDirection == -1) {
|
2007-08-08 03:42:33 +00:00
|
|
|
int i = 0;
|
|
|
|
while (_multData->imdKeys[index][i].frame <= startFrame)
|
|
|
|
i++;
|
2006-04-12 09:49:08 +00:00
|
|
|
|
2007-08-08 03:42:33 +00:00
|
|
|
_multData->imdIndices[index] = i - 1;
|
2007-03-20 14:51:57 +00:00
|
|
|
}
|
2006-04-12 09:49:08 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
firstFrame = (_multData->animDirection == 1) ? startFrame : stopFrame;
|
|
|
|
for (int i = 0; i < 4; i++) {
|
|
|
|
_multData->imdKeysIndices[index][i] = 0;
|
2008-04-27 03:19:19 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
for (int j = 0; j < _multData->imdKeysCount[i]; j++)
|
2007-03-30 17:52:31 +00:00
|
|
|
if (_multData->imdKeys[i][j].frame >= firstFrame) {
|
2007-03-20 14:51:57 +00:00
|
|
|
_multData->imdKeysIndices[index][i] = j;
|
2007-03-30 17:52:31 +00:00
|
|
|
break;
|
|
|
|
}
|
2007-03-20 14:51:57 +00:00
|
|
|
}
|
2006-04-12 09:49:08 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
_multData->animKeysStartFrames[index] = startFrame;
|
|
|
|
_multData->animKeysStopFrames[index] = stopFrame;
|
|
|
|
}
|
2006-04-12 09:49:08 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
void Mult_v2::playMultInit() {
|
|
|
|
_doPalSubst = false;
|
|
|
|
_palFadingRed = 0;
|
|
|
|
_palFadingGreen = 0;
|
|
|
|
_palFadingBlue = 0;
|
2006-04-12 09:49:08 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
_oldPalette = _vm->_global->_pPaletteDesc->vgaPal;
|
2006-04-12 09:49:08 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
if (!_animSurf) {
|
|
|
|
int16 width, height;
|
2006-04-12 09:49:08 +00:00
|
|
|
|
2008-08-15 10:47:42 +00:00
|
|
|
if (_objects)
|
|
|
|
for (int i = 0; i < _objCount; i++) {
|
|
|
|
delete _objects[i].pPosX;
|
|
|
|
delete _objects[i].pPosY;
|
|
|
|
}
|
2008-07-12 15:21:38 +00:00
|
|
|
|
|
|
|
delete[] _objects;
|
2009-01-01 15:06:43 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
_vm->_util->setFrameRate(_multData->frameRate);
|
|
|
|
_animTop = 0;
|
|
|
|
_animLeft = 0;
|
|
|
|
_animWidth = _vm->_video->_surfWidth;
|
|
|
|
_animHeight = _vm->_video->_surfHeight;
|
|
|
|
_objCount = 4;
|
2006-05-31 08:44:14 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
delete[] _orderArray;
|
|
|
|
delete[] _renderObjs;
|
2008-07-12 15:21:38 +00:00
|
|
|
delete _animArrayX;
|
|
|
|
delete _animArrayY;
|
2007-03-20 14:51:57 +00:00
|
|
|
delete[] _animArrayData;
|
2006-04-12 09:49:08 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
_objects = new Mult_Object[_objCount];
|
2008-05-07 02:56:18 +00:00
|
|
|
_orderArray = new int8[_objCount];
|
2007-03-20 14:51:57 +00:00
|
|
|
_renderObjs = new Mult_Object*[_objCount];
|
2008-07-12 15:21:38 +00:00
|
|
|
_animArrayX = new VariablesLE(_objCount * 4);
|
|
|
|
_animArrayY = new VariablesLE(_objCount * 4);
|
2007-03-20 14:51:57 +00:00
|
|
|
_animArrayData = new Mult_AnimData[_objCount];
|
|
|
|
|
|
|
|
memset(_objects, 0, _objCount * sizeof(Mult_Object));
|
2008-05-07 02:56:18 +00:00
|
|
|
memset(_orderArray, 0, _objCount * sizeof(int8));
|
2007-03-20 14:51:57 +00:00
|
|
|
memset(_renderObjs, 0, _objCount * sizeof(Mult_Object *));
|
|
|
|
memset(_animArrayData, 0, _objCount * sizeof(Mult_AnimData));
|
|
|
|
|
|
|
|
for (_counter = 0; _counter < _objCount; _counter++) {
|
|
|
|
Mult_Object &multObj = _objects[_counter];
|
|
|
|
Mult_AnimData &animData = _animArrayData[_counter];
|
|
|
|
|
2008-07-12 15:21:38 +00:00
|
|
|
multObj.pPosX = new VariableReference(*_animArrayX, _counter * 4);
|
|
|
|
multObj.pPosY = new VariableReference(*_animArrayY, _counter * 4);
|
2007-03-20 14:51:57 +00:00
|
|
|
multObj.pAnimData = &animData;
|
|
|
|
|
|
|
|
animData.isStatic = 1;
|
|
|
|
|
|
|
|
multObj.lastLeft = -1;
|
|
|
|
multObj.lastTop = -1;
|
|
|
|
multObj.lastRight = -1;
|
|
|
|
multObj.lastBottom = -1;
|
2006-04-12 09:49:08 +00:00
|
|
|
}
|
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
width = _animWidth;
|
|
|
|
height = _animHeight;
|
|
|
|
_vm->_draw->adjustCoords(0, &width, &height);
|
2010-08-08 00:35:18 +00:00
|
|
|
_vm->_draw->initSpriteSurf(Draw::kAnimSurface, width, height, 0);
|
|
|
|
_animSurf = _vm->_draw->_spritesArray[Draw::kAnimSurface];
|
2007-03-20 14:51:57 +00:00
|
|
|
|
2010-08-08 00:35:18 +00:00
|
|
|
_vm->_video->drawSprite(*_vm->_draw->_spritesArray[Draw::kBackSurface],
|
|
|
|
*_vm->_draw->_spritesArray[Draw::kAnimSurface], 0, 0,
|
2007-03-20 14:51:57 +00:00
|
|
|
_vm->_video->_surfWidth, _vm->_video->_surfHeight, 0, 0, 0);
|
|
|
|
|
|
|
|
for (_counter = 0; _counter < _objCount; _counter++)
|
|
|
|
_multData->palAnimIndices[_counter] = _counter;
|
2006-04-12 09:49:08 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
_animDataAllocated = true;
|
2006-11-27 14:19:30 +00:00
|
|
|
} else
|
2007-03-20 14:51:57 +00:00
|
|
|
_animDataAllocated = false;
|
|
|
|
|
|
|
|
_frame = 0;
|
2006-04-12 09:49:08 +00:00
|
|
|
}
|
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
void Mult_v2::drawStatics(bool &stop) {
|
|
|
|
int staticIndex;
|
2006-04-12 09:49:08 +00:00
|
|
|
|
2007-02-05 14:08:50 +00:00
|
|
|
if (_multData->staticKeys[_multData->staticKeysCount - 1].frame > _frame)
|
2007-03-20 14:51:57 +00:00
|
|
|
stop = false;
|
2006-04-12 09:49:08 +00:00
|
|
|
|
2007-02-05 14:08:50 +00:00
|
|
|
for (_counter = 0; _counter < _multData->staticKeysCount; _counter++) {
|
2007-03-20 14:51:57 +00:00
|
|
|
if ((_multData->staticKeys[_counter].frame != _frame)
|
|
|
|
|| (_multData->staticKeys[_counter].layer == -1))
|
2006-04-12 09:49:08 +00:00
|
|
|
continue;
|
|
|
|
|
2007-02-05 14:08:50 +00:00
|
|
|
if (_multData->staticKeys[_counter].layer >= 0) {
|
2007-03-20 14:51:57 +00:00
|
|
|
int i = 0;
|
2006-04-12 09:49:08 +00:00
|
|
|
_vm->_scenery->_curStatic = 0;
|
2007-03-20 14:51:57 +00:00
|
|
|
_vm->_scenery->_curStaticLayer =
|
|
|
|
_multData->staticKeys[_counter].layer;
|
2007-09-19 08:40:12 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
staticIndex = _multData->staticIndices[i];
|
2007-03-29 20:49:37 +00:00
|
|
|
while (_vm->_scenery->getStaticLayersCount(staticIndex) <=
|
2007-03-20 14:51:57 +00:00
|
|
|
_vm->_scenery->_curStaticLayer) {
|
2006-04-12 09:49:08 +00:00
|
|
|
_vm->_scenery->_curStaticLayer -=
|
2007-03-20 14:51:57 +00:00
|
|
|
_vm->_scenery->getStaticLayersCount(staticIndex);
|
|
|
|
|
|
|
|
staticIndex = _multData->staticIndices[++i];
|
2006-04-12 09:49:08 +00:00
|
|
|
_vm->_scenery->_curStatic++;
|
|
|
|
}
|
2007-03-20 14:51:57 +00:00
|
|
|
_vm->_scenery->_curStatic =
|
|
|
|
_multData->staticIndices[_vm->_scenery->_curStatic];
|
|
|
|
_vm->_scenery->renderStatic(_vm->_scenery->_curStatic,
|
|
|
|
_vm->_scenery->_curStaticLayer);
|
2006-04-12 09:49:08 +00:00
|
|
|
} else {
|
2007-03-20 14:51:57 +00:00
|
|
|
int layer = -_multData->staticKeys[_counter].layer - 2;
|
|
|
|
|
2006-04-12 09:49:08 +00:00
|
|
|
_vm->_draw->_spriteLeft =
|
2007-03-20 14:51:57 +00:00
|
|
|
READ_LE_UINT16(_multData->execPtr + layer * 2);
|
2006-04-12 09:49:08 +00:00
|
|
|
_vm->_draw->_destSpriteX = 0;
|
|
|
|
_vm->_draw->_destSpriteY = 0;
|
2010-08-08 00:35:18 +00:00
|
|
|
_vm->_draw->_destSurface = Draw::kBackSurface;
|
2006-04-12 09:49:08 +00:00
|
|
|
_vm->_draw->_transparency = 0;
|
2007-03-20 14:51:57 +00:00
|
|
|
_vm->_draw->spriteOperation(DRAW_LOADSPRITE);
|
2006-04-12 09:49:08 +00:00
|
|
|
_vm->_scenery->_curStatic = -1;
|
|
|
|
}
|
2007-03-20 14:51:57 +00:00
|
|
|
|
2010-08-08 00:35:18 +00:00
|
|
|
_vm->_video->drawSprite(*_vm->_draw->_spritesArray[Draw::kBackSurface],
|
|
|
|
*_vm->_draw->_spritesArray[Draw::kAnimSurface], 0, 0,
|
2007-03-20 14:51:57 +00:00
|
|
|
_vm->_video->_surfWidth, _vm->_video->_surfHeight, 0, 0, 0);
|
2006-04-12 09:49:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-04-27 18:56:28 +00:00
|
|
|
void Mult_v2::drawAnims(bool &stop) {
|
2006-04-12 09:49:08 +00:00
|
|
|
int16 count;
|
2007-03-20 14:51:57 +00:00
|
|
|
int animIndex;
|
2007-09-19 08:40:12 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
for (int i = 0; i < 4; i++) {
|
|
|
|
int16 animKeysCount = _multData->animKeysCount[i];
|
2009-10-06 19:57:17 +00:00
|
|
|
if ((animKeysCount > 0) && ((uint16) _multData->animKeys[i][animKeysCount - 1].frame > _frame))
|
2007-03-20 14:51:57 +00:00
|
|
|
stop = false;
|
2006-04-12 09:49:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for (_index = 0; _index < 4; _index++) {
|
2007-03-20 14:51:57 +00:00
|
|
|
int16 animKeysCount = _multData->animKeysCount[_index];
|
|
|
|
for (_counter = 0; _counter < animKeysCount; _counter++) {
|
|
|
|
Mult_AnimKey &key = _multData->animKeys[_index][_counter];
|
|
|
|
Mult_Object &animObj = _objects[_multData->animObjs[0][_index]];
|
|
|
|
Mult_AnimData &animData = *(animObj.pAnimData);
|
|
|
|
|
|
|
|
if (key.frame != _frame)
|
2006-04-12 09:49:08 +00:00
|
|
|
continue;
|
2007-09-19 08:40:12 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
if (key.layer != -1) {
|
|
|
|
*(animObj.pPosX) = key.posX;
|
|
|
|
*(animObj.pPosY) = key.posY;
|
|
|
|
|
|
|
|
animData.frame = 0;
|
|
|
|
animData.order = key.order;
|
|
|
|
animData.animType = 1;
|
|
|
|
|
|
|
|
animData.isPaused = 0;
|
|
|
|
animData.isStatic = 0;
|
|
|
|
animData.maxTick = 0;
|
|
|
|
animObj.tick = 0;
|
|
|
|
animData.layer = key.layer;
|
|
|
|
|
|
|
|
int i = 0;
|
|
|
|
animIndex = _multData->animIndices[i];
|
|
|
|
count = _vm->_scenery->getAnimLayersCount(animIndex);
|
|
|
|
while (animData.layer >= count) {
|
|
|
|
animData.layer -= count;
|
|
|
|
animIndex = _multData->animIndices[++i];
|
|
|
|
|
|
|
|
count = _vm->_scenery->getAnimLayersCount(animIndex);
|
2006-04-12 09:49:08 +00:00
|
|
|
}
|
2007-03-20 14:51:57 +00:00
|
|
|
animData.animation = animIndex;
|
|
|
|
|
|
|
|
} else
|
|
|
|
animData.isStatic = 1;
|
2006-04-12 09:49:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
void Mult_v2::newCycleAnim(Mult_Object &animObj) {
|
|
|
|
Mult_AnimData &animData = *(animObj.pAnimData);
|
2008-04-27 03:19:19 +00:00
|
|
|
Scenery::AnimLayer *animLayer = 0;
|
2007-04-05 13:36:26 +00:00
|
|
|
|
2008-04-27 03:19:19 +00:00
|
|
|
if (animData.animation >= 0) {
|
|
|
|
int nAnim = animData.animation, nLayer = animData.layer;
|
|
|
|
|
|
|
|
if (_vm->_scenery->getAnimLayersCount(nAnim) <= nLayer)
|
|
|
|
return;
|
2007-04-05 13:36:26 +00:00
|
|
|
|
2008-04-27 03:19:19 +00:00
|
|
|
animLayer = _vm->_scenery->getAnimLayer(nAnim, nLayer);
|
2008-05-07 03:49:53 +00:00
|
|
|
} else {
|
|
|
|
if (animObj.videoSlot > 0) {
|
|
|
|
_vm->_video->retrace();
|
|
|
|
_vm->_vidPlayer->slotWaitEndFrame(animObj.videoSlot - 1, true);
|
|
|
|
}
|
2008-04-27 03:19:19 +00:00
|
|
|
}
|
2006-04-12 09:49:08 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
if (animData.animType == 4) {
|
|
|
|
animData.frame = 0;
|
|
|
|
animData.isPaused = 1;
|
2008-04-27 03:19:19 +00:00
|
|
|
if (animData.animation < 0)
|
2008-05-13 15:52:01 +00:00
|
|
|
warning("Woodruff Stub: AnimType 4, animation: %d", animData.animation);
|
2008-04-27 03:19:19 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (animData.animType == 12)
|
|
|
|
animData.animType = 11;
|
|
|
|
|
|
|
|
if (animData.animType == 11) {
|
2008-05-13 15:52:01 +00:00
|
|
|
if (animData.isBusy != 0)
|
|
|
|
warning("Woodruff Stub: AnimType 11");
|
2007-03-20 14:51:57 +00:00
|
|
|
return;
|
2006-04-12 09:49:08 +00:00
|
|
|
}
|
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
if (animData.animType != 8)
|
|
|
|
animData.frame++;
|
2006-04-12 09:49:08 +00:00
|
|
|
|
2008-04-27 03:19:19 +00:00
|
|
|
if (animData.animation < 0) {
|
|
|
|
if ((animObj.videoSlot > 0) &&
|
|
|
|
(_vm->_vidPlayer->getCurrentFrame(animObj.videoSlot - 1) <
|
2010-08-08 00:33:59 +00:00
|
|
|
_vm->_vidPlayer->getFrameCount(animObj.videoSlot - 1))) {
|
2008-04-27 03:19:19 +00:00
|
|
|
animData.newCycle = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (animData.frame < animLayer->framesCount) {
|
|
|
|
animData.newCycle = 0;
|
|
|
|
return;
|
|
|
|
}
|
2007-03-20 14:51:57 +00:00
|
|
|
}
|
2006-04-12 09:49:08 +00:00
|
|
|
|
2008-04-27 03:19:19 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
switch (animData.animType) {
|
|
|
|
case 0:
|
|
|
|
animData.frame = 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
animData.frame = 0;
|
|
|
|
*(animObj.pPosX) += animLayer->animDeltaX;
|
|
|
|
*(animObj.pPosY) += animLayer->animDeltaY;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
animData.frame = 0;
|
|
|
|
animData.animation = animData.newAnimation;
|
|
|
|
animData.layer = animData.newLayer;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
animData.animType = 4;
|
|
|
|
animData.frame = 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 5:
|
|
|
|
animData.isStatic = 1;
|
|
|
|
animData.frame = 0;
|
2008-05-13 15:52:01 +00:00
|
|
|
if ((animData.animation < 0) && (animObj.videoSlot > 0)) {
|
|
|
|
_vm->_vidPlayer->slotClose(animObj.videoSlot - 1);
|
2008-05-17 04:07:16 +00:00
|
|
|
animObj.videoSlot = 0;
|
2008-05-13 15:52:01 +00:00
|
|
|
}
|
2009-01-01 15:06:43 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 6:
|
|
|
|
case 7:
|
|
|
|
animData.frame--;
|
|
|
|
animData.isPaused = 1;
|
2008-05-18 15:02:01 +00:00
|
|
|
/*
|
2008-04-27 03:19:19 +00:00
|
|
|
if ((animData.animation < 0) && (animObj.videoSlot > 0)) {
|
|
|
|
if (_vm->_vidPlayer->getFlags(animObj.videoSlot - 1) & 0x1000) {
|
|
|
|
_vm->_vidPlayer->slotClose(animObj.videoSlot - 1);
|
|
|
|
animObj.videoSlot = 0;
|
|
|
|
}
|
|
|
|
}
|
2008-05-18 15:02:01 +00:00
|
|
|
*/
|
2007-03-20 14:51:57 +00:00
|
|
|
break;
|
2008-05-13 15:52:01 +00:00
|
|
|
|
|
|
|
case 10:
|
|
|
|
warning("Woodruff Stub: AnimType 10");
|
|
|
|
break;
|
2006-04-12 09:49:08 +00:00
|
|
|
}
|
2008-05-13 15:52:01 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
animData.newCycle = 1;
|
2006-04-12 09:49:08 +00:00
|
|
|
}
|
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
void Mult_v2::animate() {
|
2008-05-07 02:56:18 +00:00
|
|
|
int8 minOrder = 100;
|
|
|
|
int8 maxOrder = 0;
|
|
|
|
int8 *orderArray;
|
2007-03-20 14:51:57 +00:00
|
|
|
int orderArrayPos = 0;
|
|
|
|
int8 animIndices[150];
|
|
|
|
int numAnims = 0;
|
2007-09-19 08:40:12 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
if (!_objects)
|
2006-04-12 09:49:08 +00:00
|
|
|
return;
|
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
if (_objCount > 0) {
|
|
|
|
if (!_orderArray)
|
|
|
|
return;
|
|
|
|
orderArray = _orderArray;
|
|
|
|
} else
|
|
|
|
orderArray = 0;
|
2006-04-12 09:49:08 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
advanceAllObjects();
|
2007-09-19 08:40:12 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
// Find relevant objects
|
|
|
|
for (int i = 0; i < _objCount; i++) {
|
|
|
|
Mult_Object &animObj = _objects[i];
|
|
|
|
Mult_AnimData &animData = *(animObj.pAnimData);
|
|
|
|
|
|
|
|
animData.intersected = 200;
|
|
|
|
if (animData.isStatic != 2) {
|
|
|
|
if ((animData.isStatic == 0) || (animObj.lastLeft != -1)) {
|
|
|
|
animIndices[numAnims] = i;
|
|
|
|
_renderObjs[numAnims] = &animObj;
|
|
|
|
numAnims++;
|
2006-04-12 09:49:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
// Find dirty areas
|
|
|
|
for (int i = 0; i < numAnims; i++) {
|
|
|
|
Mult_Object &animObj = *_renderObjs[i];
|
|
|
|
Mult_AnimData &animData = *(animObj.pAnimData);
|
2006-04-12 09:49:08 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
animObj.needRedraw = 0;
|
|
|
|
animObj.newTop = 1000;
|
|
|
|
animObj.newLeft = 1000;
|
|
|
|
animObj.newBottom = 0;
|
|
|
|
animObj.newRight = 0;
|
2007-09-19 08:40:12 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
if (animData.isStatic == 2)
|
2006-04-12 09:49:08 +00:00
|
|
|
continue;
|
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
if (!animData.isStatic && !animData.isPaused &&
|
|
|
|
(animData.maxTick == animObj.tick)) {
|
|
|
|
|
|
|
|
animObj.needRedraw = 1;
|
|
|
|
_vm->_scenery->updateAnim(animData.layer, animData.frame,
|
|
|
|
animData.animation, 8, *animObj.pPosX, *animObj.pPosY, 0);
|
|
|
|
if (animObj.lastLeft == -1) {
|
|
|
|
animObj.newLeft = _vm->_scenery->_toRedrawLeft;
|
|
|
|
animObj.newTop = _vm->_scenery->_toRedrawTop;
|
|
|
|
animObj.newRight = _vm->_scenery->_toRedrawRight;
|
|
|
|
animObj.newBottom = _vm->_scenery->_toRedrawBottom;
|
2006-04-12 09:49:08 +00:00
|
|
|
} else {
|
2007-03-20 14:51:57 +00:00
|
|
|
animObj.newLeft =
|
|
|
|
MIN(animObj.lastLeft, _vm->_scenery->_toRedrawLeft);
|
|
|
|
animObj.newTop =
|
|
|
|
MIN(animObj.lastTop, _vm->_scenery->_toRedrawTop);
|
|
|
|
animObj.newRight =
|
|
|
|
MAX(animObj.lastRight, _vm->_scenery->_toRedrawRight);
|
|
|
|
animObj.newBottom =
|
|
|
|
MAX(animObj.lastBottom, _vm->_scenery->_toRedrawBottom);
|
|
|
|
|
2009-06-23 01:19:03 +00:00
|
|
|
if ((_vm->_game->_script->getVersionMinor() > 2) &&
|
2007-03-20 14:51:57 +00:00
|
|
|
(animObj.newLeft == animObj.lastLeft) &&
|
|
|
|
(animObj.newTop == animObj.lastTop) &&
|
|
|
|
(animObj.newRight == animObj.lastRight) &&
|
|
|
|
(animObj.newBottom == animObj.lastBottom) &&
|
|
|
|
(animData.redrawLayer == animData.layer) &&
|
|
|
|
(animData.redrawFrame == animData.frame) &&
|
|
|
|
(animData.redrawAnimation == animData.animation)) {
|
|
|
|
animObj.needRedraw = 0;
|
|
|
|
}
|
2006-04-12 09:49:08 +00:00
|
|
|
}
|
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
} else if (!animData.isStatic) {
|
2006-04-12 09:49:08 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
if (animObj.lastLeft == -1) {
|
|
|
|
animObj.needRedraw = 1;
|
|
|
|
_vm->_scenery->updateAnim(animData.layer, animData.frame,
|
|
|
|
animData.animation, 8, *animObj.pPosX, *animObj.pPosY, 0);
|
2006-04-12 09:49:08 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
animObj.newLeft = _vm->_scenery->_toRedrawLeft;
|
|
|
|
animObj.newTop = _vm->_scenery->_toRedrawTop;
|
|
|
|
animObj.newRight = _vm->_scenery->_toRedrawRight;
|
|
|
|
animObj.newBottom = _vm->_scenery->_toRedrawBottom;
|
|
|
|
} else {
|
|
|
|
animObj.newLeft = animObj.lastLeft;
|
|
|
|
animObj.newTop = animObj.lastTop;
|
|
|
|
animObj.newRight = animObj.lastRight;
|
|
|
|
animObj.newBottom = animObj.lastBottom;
|
2006-04-12 09:49:08 +00:00
|
|
|
}
|
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
} else if (animObj.lastLeft != -1) {
|
|
|
|
animObj.needRedraw = 1;
|
|
|
|
animObj.newLeft = animObj.lastLeft;
|
|
|
|
animObj.newTop = animObj.lastTop;
|
|
|
|
animObj.newRight = animObj.lastRight;
|
|
|
|
animObj.newBottom = animObj.lastBottom;
|
2006-04-12 09:49:08 +00:00
|
|
|
}
|
2006-06-12 10:55:53 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
animData.redrawLayer = animData.layer;
|
|
|
|
animData.redrawFrame = animData.frame;
|
|
|
|
animData.redrawAnimation = animData.animation;
|
|
|
|
if (animObj.needRedraw || !animData.isStatic) {
|
|
|
|
minOrder = MIN(minOrder, animData.order);
|
|
|
|
maxOrder = MAX(maxOrder, animData.order);
|
2006-04-12 09:49:08 +00:00
|
|
|
}
|
|
|
|
}
|
2006-06-12 21:33:30 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
// Restore dirty areas
|
|
|
|
for (int i = 0; i < numAnims; i++) {
|
|
|
|
Mult_Object &animObj = *_renderObjs[i];
|
2006-04-12 09:49:08 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
if (!animObj.needRedraw || (animObj.lastLeft == -1))
|
|
|
|
continue;
|
2006-04-12 09:49:08 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
animObj.lastLeft = -1;
|
2006-04-12 09:49:08 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
int maxleft = MAX(animObj.newLeft, _animLeft);
|
|
|
|
int maxtop = MAX(animObj.newTop, _animTop);
|
|
|
|
int right = animObj.newRight - maxleft + 1;
|
|
|
|
int bottom = animObj.newBottom - maxtop + 1;
|
2006-04-12 09:49:08 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
if ((right <= 0) || (bottom <= 0))
|
|
|
|
continue;
|
2006-04-12 09:49:08 +00:00
|
|
|
|
2010-08-08 00:35:18 +00:00
|
|
|
_vm->_draw->_sourceSurface = Draw::kAnimSurface;
|
|
|
|
_vm->_draw->_destSurface = Draw::kBackSurface;
|
2007-03-20 14:51:57 +00:00
|
|
|
_vm->_draw->_spriteLeft = maxleft - _animLeft;
|
|
|
|
_vm->_draw->_spriteTop = maxtop - _animTop;
|
|
|
|
_vm->_draw->_spriteRight = right;
|
|
|
|
_vm->_draw->_spriteBottom = bottom;
|
|
|
|
_vm->_draw->_destSpriteX = maxleft;
|
|
|
|
_vm->_draw->_destSpriteY = maxtop;
|
|
|
|
_vm->_draw->_transparency = 0;
|
|
|
|
_vm->_draw->spriteOperation(DRAW_DRAWLETTER);
|
2006-04-12 09:49:08 +00:00
|
|
|
}
|
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
// Figure out the correct drawing order
|
|
|
|
for (int i = minOrder; i <= maxOrder; i++) {
|
|
|
|
for (int j = 0; j < numAnims; j++) {
|
|
|
|
Mult_Object &animObj = *_renderObjs[j];
|
|
|
|
Mult_AnimData &animData = *(animObj.pAnimData);
|
2006-04-12 09:49:08 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
if (animData.order == i)
|
|
|
|
if (animObj.needRedraw || !animData.isStatic)
|
|
|
|
orderArray[orderArrayPos++] = j;
|
2006-04-12 09:49:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
// Put the goblins in correct drawing order as well
|
2006-05-11 19:43:30 +00:00
|
|
|
if (_vm->_goblin->_gobsCount >= 0) {
|
2007-03-20 14:51:57 +00:00
|
|
|
for (int i = 0; i < orderArrayPos; i++) {
|
|
|
|
Mult_Object &animObj1 = *_renderObjs[orderArray[i]];
|
|
|
|
Mult_AnimData &animData1 = *(animObj1.pAnimData);
|
|
|
|
|
2008-04-27 03:19:19 +00:00
|
|
|
if (!animObj1.goblinStates)
|
|
|
|
continue;
|
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
for (int j = i+1; j < orderArrayPos; j++) {
|
|
|
|
Mult_Object &animObj2 = *_renderObjs[orderArray[j]];
|
|
|
|
Mult_AnimData &animData2 = *(animObj2.pAnimData);
|
|
|
|
|
|
|
|
if ((animData1.order == animData2.order) &&
|
|
|
|
((animObj1.newBottom > animObj2.newBottom) ||
|
|
|
|
((animObj1.newBottom == animObj2.newBottom) &&
|
|
|
|
(animData1.isBusy == 1))))
|
2006-04-12 09:49:08 +00:00
|
|
|
SWAP(orderArray[i], orderArray[j]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
// Update view
|
|
|
|
for (int i = 0; i < orderArrayPos; i++) {
|
|
|
|
Mult_Object &animObj1 = *_renderObjs[orderArray[i]];
|
|
|
|
Mult_AnimData &animData1 = *(animObj1.pAnimData);
|
|
|
|
|
2008-05-07 02:56:18 +00:00
|
|
|
if (!animObj1.needRedraw) {
|
|
|
|
|
|
|
|
if (!animData1.isStatic) {
|
|
|
|
for (int j = 0; j < orderArrayPos; j++) {
|
|
|
|
Mult_Object &animObj2 = *_renderObjs[orderArray[j]];
|
2007-03-20 14:51:57 +00:00
|
|
|
|
2008-05-07 02:56:18 +00:00
|
|
|
if (!animObj2.needRedraw)
|
|
|
|
continue;
|
2007-03-20 14:51:57 +00:00
|
|
|
|
2008-05-07 02:56:18 +00:00
|
|
|
if ((animObj1.newRight >= animObj2.newLeft) &&
|
|
|
|
(animObj2.newRight >= animObj1.newLeft) &&
|
|
|
|
(animObj1.newBottom >= animObj2.newTop) &&
|
|
|
|
(animObj2.newBottom >= animObj1.newTop)) {
|
2007-03-29 21:03:32 +00:00
|
|
|
|
2008-05-07 02:56:18 +00:00
|
|
|
_vm->_scenery->_toRedrawLeft = animObj2.newLeft;
|
|
|
|
_vm->_scenery->_toRedrawRight = animObj2.newRight;
|
|
|
|
_vm->_scenery->_toRedrawTop = animObj2.newTop;
|
|
|
|
_vm->_scenery->_toRedrawBottom = animObj2.newBottom;
|
2007-03-20 14:51:57 +00:00
|
|
|
|
2008-05-07 02:56:18 +00:00
|
|
|
_vm->_scenery->updateAnim(animData1.layer, animData1.frame,
|
|
|
|
animData1.animation, 12, *animObj1.pPosX, *animObj1.pPosY, 1);
|
|
|
|
_vm->_scenery->updateStatic(animData1.order + 1);
|
|
|
|
}
|
2006-04-14 18:18:46 +00:00
|
|
|
}
|
|
|
|
}
|
2008-05-07 02:56:18 +00:00
|
|
|
|
2006-06-12 21:33:30 +00:00
|
|
|
} else {
|
2008-05-07 02:56:18 +00:00
|
|
|
|
|
|
|
if (animData1.isStatic != 0) {
|
|
|
|
_vm->_scenery->_toRedrawLeft = animObj1.newLeft;
|
|
|
|
_vm->_scenery->_toRedrawRight = animObj1.newRight;
|
|
|
|
_vm->_scenery->_toRedrawTop = animObj1.newTop;
|
|
|
|
_vm->_scenery->_toRedrawBottom = animObj1.newBottom;
|
|
|
|
} else {
|
|
|
|
_vm->_scenery->updateAnim(animData1.layer, animData1.frame,
|
|
|
|
animData1.animation, 10, *animObj1.pPosX, *animObj1.pPosY, 1);
|
|
|
|
|
|
|
|
if (_vm->_scenery->_toRedrawLeft != -12345) {
|
|
|
|
animObj1.lastLeft = _vm->_scenery->_toRedrawLeft;
|
|
|
|
animObj1.lastRight = _vm->_scenery->_toRedrawRight;
|
|
|
|
animObj1.lastTop = _vm->_scenery->_toRedrawTop;
|
|
|
|
animObj1.lastBottom = _vm->_scenery->_toRedrawBottom;
|
|
|
|
} else {
|
|
|
|
animObj1.lastLeft = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
_vm->_scenery->updateStatic(animData1.order + 1);
|
|
|
|
|
2006-04-12 09:49:08 +00:00
|
|
|
}
|
2008-05-07 02:56:18 +00:00
|
|
|
|
2006-04-12 09:49:08 +00:00
|
|
|
}
|
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
// Advance animations
|
|
|
|
for (int i = 0; i < numAnims; i++) {
|
|
|
|
Mult_Object &animObj = *_renderObjs[i];
|
|
|
|
Mult_AnimData &animData = *(animObj.pAnimData);
|
|
|
|
|
|
|
|
if (animData.isStatic)
|
2006-04-12 09:49:08 +00:00
|
|
|
continue;
|
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
if ((animData.animType == 7) && (animData.newState != -1)) {
|
|
|
|
animData.layer = animData.newState;
|
|
|
|
animData.frame = 0;
|
|
|
|
animData.newState = -1;
|
|
|
|
animData.isPaused = 0;
|
2006-04-12 09:49:08 +00:00
|
|
|
}
|
2007-03-20 14:51:57 +00:00
|
|
|
if (animData.isPaused)
|
2006-04-12 09:49:08 +00:00
|
|
|
continue;
|
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
if (animData.maxTick == animObj.tick) {
|
|
|
|
animObj.tick = 0;
|
|
|
|
if ((animData.animType < 100) || (_vm->_goblin->_gobsCount < 0))
|
|
|
|
newCycleAnim(animObj);
|
|
|
|
else if (animData.animType == 100)
|
|
|
|
_vm->_goblin->moveAdvance(&animObj, 0, 0, 0);
|
|
|
|
else if (animData.animType == 101)
|
|
|
|
_vm->_goblin->animate(&animObj);
|
2006-04-12 09:49:08 +00:00
|
|
|
} else
|
2007-03-20 14:51:57 +00:00
|
|
|
animObj.tick++;
|
2006-04-12 09:49:08 +00:00
|
|
|
}
|
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
// Find intersections
|
|
|
|
for (int i = 0; i < numAnims; i++) {
|
|
|
|
Mult_Object &animObj1 = *_renderObjs[i];
|
|
|
|
Mult_AnimData &animData1 = *(animObj1.pAnimData);
|
2006-06-12 21:33:30 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
if (animData1.isStatic || (animObj1.lastLeft == -1))
|
|
|
|
continue;
|
2006-04-12 09:49:08 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
for (int j = 0; j < numAnims; j++) {
|
|
|
|
Mult_Object &animObj2 = *_renderObjs[i];
|
|
|
|
Mult_AnimData &animData2 = *(animObj2.pAnimData);
|
2006-04-13 16:25:07 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
if (i == j)
|
|
|
|
continue;
|
|
|
|
if ((animData2.isStatic) || (animObj2.lastLeft == -1))
|
|
|
|
continue;
|
2006-06-10 14:37:48 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
if ((animObj2.lastRight >= animObj1.lastLeft) &&
|
|
|
|
(animObj2.lastLeft <= animObj1.lastRight) &&
|
|
|
|
(animObj2.lastBottom >= animObj1.lastTop) &&
|
|
|
|
(animObj2.lastTop <= animObj1.lastBottom))
|
|
|
|
animData2.intersected = animIndices[i];
|
|
|
|
}
|
|
|
|
}
|
2006-06-10 14:37:48 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2007-04-02 11:05:09 +00:00
|
|
|
void Mult_v2::playImd(const char *imdFile, Mult::Mult_ImdKey &key, int16 dir,
|
2007-03-20 14:51:57 +00:00
|
|
|
int16 startFrame) {
|
2010-08-08 00:43:22 +00:00
|
|
|
|
|
|
|
VideoPlayer::Properties props;
|
2006-04-13 16:25:07 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
if (_vm->_draw->_renderFlags & 0x100) {
|
2010-08-08 00:43:22 +00:00
|
|
|
props.x = VAR(55);
|
|
|
|
props.y = VAR(56);
|
|
|
|
}
|
2007-03-20 14:51:57 +00:00
|
|
|
|
|
|
|
if (key.imdFile == -1) {
|
2010-08-08 00:43:22 +00:00
|
|
|
_vm->_vidPlayer->closeVideo();
|
2006-04-13 16:25:07 +00:00
|
|
|
return;
|
2007-03-20 14:51:57 +00:00
|
|
|
}
|
2006-04-13 16:25:07 +00:00
|
|
|
|
2010-08-08 00:43:22 +00:00
|
|
|
props.flags = (key.flags >> 8) & 0xFF;
|
|
|
|
if (props.flags & 0x20)
|
|
|
|
props.flags = (props.flags & 0x9F) | 0x80;
|
2006-04-13 16:25:07 +00:00
|
|
|
|
2010-08-08 00:43:22 +00:00
|
|
|
props.palStart = key.palStart;
|
|
|
|
props.palEnd = key.palEnd;
|
|
|
|
props.palFrame = key.palFrame;
|
|
|
|
props.lastFrame = key.lastFrame;
|
2006-04-13 16:25:07 +00:00
|
|
|
|
2010-08-08 00:43:22 +00:00
|
|
|
if ((props.palFrame != -1) && (props.lastFrame != -1))
|
|
|
|
if ((props.lastFrame - props.palFrame) < props.startFrame)
|
2007-03-20 14:51:57 +00:00
|
|
|
if (!(key.flags & 0x4000)) {
|
2010-08-08 00:43:22 +00:00
|
|
|
_vm->_vidPlayer->closeVideo();
|
2007-03-20 14:51:57 +00:00
|
|
|
return;
|
|
|
|
}
|
2006-04-13 16:25:07 +00:00
|
|
|
|
2010-08-08 00:44:33 +00:00
|
|
|
_vm->_vidPlayer->evaluateFlags(props);
|
|
|
|
|
2010-08-08 00:43:22 +00:00
|
|
|
int slot;
|
|
|
|
if ((slot = _vm->_vidPlayer->openVideo(true, imdFile, props)) < 0)
|
2007-03-20 14:51:57 +00:00
|
|
|
return;
|
2006-04-13 16:25:07 +00:00
|
|
|
|
2010-08-08 00:43:22 +00:00
|
|
|
if (props.palFrame == -1)
|
|
|
|
props.palFrame = 0;
|
|
|
|
|
|
|
|
if (props.lastFrame == -1)
|
|
|
|
props.lastFrame = _vm->_vidPlayer->getFrameCount() - 1;
|
|
|
|
|
|
|
|
uint32 baseFrame = startFrame % (props.lastFrame - props.palFrame + 1);
|
|
|
|
|
2010-08-08 00:44:33 +00:00
|
|
|
props.endFrame = props.lastFrame;
|
2010-08-08 00:43:22 +00:00
|
|
|
props.startFrame = baseFrame + props.palFrame;
|
|
|
|
props.lastFrame = baseFrame + props.palFrame;
|
2007-07-30 15:53:38 +00:00
|
|
|
|
2010-08-08 00:44:33 +00:00
|
|
|
props.flags &= 0x7F;
|
|
|
|
|
2010-08-08 00:43:22 +00:00
|
|
|
debugC(2, kDebugVideo, "Playing mult video \"%s\" @ %d+%d, frame %d, "
|
2010-08-08 00:44:33 +00:00
|
|
|
"paletteCmd %d (%d - %d; %d), flags %X", imdFile,
|
2010-08-08 00:43:22 +00:00
|
|
|
props.x, props.y, props.startFrame,
|
2010-08-08 00:44:33 +00:00
|
|
|
props.palCmd, props.palStart, props.palEnd, props.endFrame, props.flags);
|
2006-04-13 16:25:07 +00:00
|
|
|
|
2010-08-08 00:43:22 +00:00
|
|
|
_vm->_vidPlayer->play(slot, props);
|
2007-03-20 14:51:57 +00:00
|
|
|
}
|
2006-04-13 16:25:07 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
void Mult_v2::advanceObjects(int16 index) {
|
|
|
|
int16 frame;
|
|
|
|
bool stop = false;
|
2007-09-19 08:40:12 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
frame = _multData->animKeysFrames[index];
|
|
|
|
if (frame == -1)
|
|
|
|
return;
|
2006-04-13 16:25:07 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
for (int i = 0; i < 4; i++) {
|
2007-07-24 06:11:38 +00:00
|
|
|
int obj = _multData->animObjs[index][i];
|
|
|
|
|
2007-08-08 03:42:33 +00:00
|
|
|
if ((obj != -1) && (obj != 1024)) {
|
2007-03-20 14:51:57 +00:00
|
|
|
int keyIndex = _multData->animKeysIndices[index][i];
|
|
|
|
int count = _multData->animKeysCount[i];
|
2006-04-13 16:25:07 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
for (int j = keyIndex; j < count; j++) {
|
|
|
|
Mult_AnimKey &key = _multData->animKeys[i][j];
|
2007-07-24 06:11:38 +00:00
|
|
|
Mult_Object &animObj = _objects[obj];
|
2007-03-20 14:51:57 +00:00
|
|
|
Mult_AnimData &animData = *(animObj.pAnimData);
|
2006-04-13 16:25:07 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
if (key.frame > frame)
|
|
|
|
break;
|
|
|
|
else if (key.frame < frame)
|
|
|
|
continue;
|
2006-04-13 16:25:07 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
if (key.layer > -1) {
|
|
|
|
int16 layer;
|
|
|
|
int16 layers;
|
|
|
|
int16 curAnim;
|
|
|
|
|
|
|
|
_multData->animKeysIndices[index][i] = j;
|
|
|
|
*(animObj.pPosX) = key.posX;
|
|
|
|
*(animObj.pPosY) = key.posY;
|
|
|
|
animData.frame = 0;
|
|
|
|
animData.animType = 1;
|
|
|
|
animData.isStatic = 0;
|
|
|
|
animData.isPaused = 0;
|
|
|
|
animData.maxTick = 0;
|
|
|
|
animData.animation = 0;
|
|
|
|
animObj.tick = 0;
|
|
|
|
|
|
|
|
curAnim = _multData->animIndices[0];
|
|
|
|
layer = key.layer;
|
|
|
|
layers = _vm->_scenery->getAnimLayersCount(curAnim);
|
|
|
|
while (layer >= layers) {
|
|
|
|
layer -= layers;
|
|
|
|
animData.animation++;
|
|
|
|
curAnim = _multData->animIndices[animData.animation];
|
|
|
|
layers = _vm->_scenery->getAnimLayersCount(curAnim);
|
|
|
|
}
|
|
|
|
animData.layer = layer;
|
|
|
|
animData.animation =
|
|
|
|
_multData->animIndices[animData.animation];
|
|
|
|
break;
|
|
|
|
} else
|
|
|
|
animData.isStatic = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-07-24 06:11:38 +00:00
|
|
|
if (obj != -1) {
|
2007-03-20 14:51:57 +00:00
|
|
|
int keyIndex = _multData->imdKeysIndices[index][i];
|
|
|
|
int count = _multData->imdKeysCount[i];
|
2006-04-13 16:25:07 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
for (int j = keyIndex; j < count; j++) {
|
|
|
|
Mult_ImdKey &key1 = _multData->imdKeys[i][j];
|
|
|
|
Mult_ImdKey &key2 = _multData->imdKeys[i][j - 1];
|
|
|
|
|
|
|
|
if (key1.frame > frame)
|
|
|
|
break;
|
|
|
|
else if (key1.frame < frame)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (key1.imdFile != -1) {
|
|
|
|
_multData->imdIndices[0] = -1;
|
|
|
|
_multData->imdIndices[1] = -1;
|
|
|
|
_multData->imdIndices[2] = -1;
|
|
|
|
_multData->imdIndices[3] = -1;
|
2007-08-08 03:42:33 +00:00
|
|
|
if ((_multData->animDirection == 1) || (key2.imdFile == -1))
|
2007-03-20 14:51:57 +00:00
|
|
|
_multData->imdIndices[i] = j;
|
|
|
|
else if (_multData->animKeysStopFrames[index] == frame)
|
|
|
|
_multData->imdIndices[i] = -1;
|
|
|
|
else
|
|
|
|
_multData->imdIndices[i] = j - 1;
|
|
|
|
} else
|
|
|
|
_multData->imdIndices[i] = -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_multData->imdIndices[i] != -1) {
|
|
|
|
int fileN;
|
|
|
|
char *imdFile;
|
|
|
|
int dir;
|
|
|
|
int startFrame;
|
|
|
|
|
2007-03-30 17:52:31 +00:00
|
|
|
Mult_ImdKey &key = _multData->imdKeys[i][_multData->imdIndices[i]];
|
|
|
|
|
|
|
|
fileN = -key.imdFile - 2;
|
2007-03-20 14:51:57 +00:00
|
|
|
if (fileN < 0)
|
|
|
|
return;
|
|
|
|
|
2007-03-30 17:52:31 +00:00
|
|
|
imdFile = _multData->imdFiles + fileN * 14;
|
2007-03-20 14:51:57 +00:00
|
|
|
dir = _multData->animDirection;
|
|
|
|
startFrame = frame - key.frame;
|
2007-08-08 03:42:33 +00:00
|
|
|
|
|
|
|
if ((dir != 1) && (--startFrame < 0))
|
2007-03-20 14:51:57 +00:00
|
|
|
startFrame = 0;
|
|
|
|
|
|
|
|
playImd(imdFile, key, dir, startFrame);
|
|
|
|
}
|
2006-04-13 16:25:07 +00:00
|
|
|
}
|
2007-09-19 08:40:12 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
doSoundAnim(stop, frame);
|
|
|
|
WRITE_VAR(22, frame);
|
2006-04-13 16:25:07 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
if (_multData->animKeysStopFrames[index] == frame) {
|
|
|
|
_multData->imdIndices[0] = -1;
|
|
|
|
_multData->imdIndices[1] = -1;
|
|
|
|
_multData->imdIndices[2] = -1;
|
|
|
|
_multData->imdIndices[3] = -1;
|
|
|
|
frame = -1;
|
|
|
|
for (int i = 0; i < 4; i++) {
|
|
|
|
int obj = _multData->animObjs[index][i];
|
2006-05-31 08:44:14 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
if ((obj == -1) || (obj == 1024))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
Mult_Object &animObj = _objects[_multData->animObjs[index][i]];
|
|
|
|
animObj.pAnimData->animType = animObj.pAnimData->animTypeBak;
|
|
|
|
}
|
|
|
|
} else if (_multData->animDirection == 1)
|
|
|
|
frame++;
|
|
|
|
else
|
|
|
|
frame--;
|
|
|
|
|
|
|
|
_multData->animKeysFrames[index] = frame;
|
|
|
|
WRITE_VAR(18 + index, frame);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Mult_v2::advanceAllObjects() {
|
2007-04-21 20:13:15 +00:00
|
|
|
Mult_Data *multData = _multData;
|
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
for (int i = 0; i < 8; i++) {
|
|
|
|
if (_multDatas[i]) {
|
|
|
|
_multData = _multDatas[i];
|
|
|
|
for (int j = 0; j < 4; j++)
|
|
|
|
advanceObjects(j);
|
|
|
|
}
|
|
|
|
}
|
2007-04-21 20:13:15 +00:00
|
|
|
|
|
|
|
_multData = multData;
|
2006-04-13 16:25:07 +00:00
|
|
|
}
|
|
|
|
|
2006-02-21 14:22:25 +00:00
|
|
|
} // End of namespace Gob
|