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.
|
2005-04-05 18:08:02 +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
|
2005-04-05 18:08:02 +00:00
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2005-04-09 19:19:54 +00:00
|
|
|
* 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.
|
2005-04-05 18:08:02 +00:00
|
|
|
*
|
|
|
|
*/
|
2006-03-29 15:59:37 +00:00
|
|
|
|
|
|
|
#include "common/endian.h"
|
2006-06-12 22:21:07 +00:00
|
|
|
#include "common/stream.h"
|
2006-03-29 15:59:37 +00:00
|
|
|
|
2005-04-05 15:07:40 +00:00
|
|
|
#include "gob/gob.h"
|
|
|
|
#include "gob/scenery.h"
|
2007-03-20 14:51:57 +00:00
|
|
|
#include "gob/global.h"
|
2005-04-05 15:07:40 +00:00
|
|
|
#include "gob/draw.h"
|
|
|
|
#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/inter.h"
|
2008-04-27 03:19:19 +00:00
|
|
|
#include "gob/map.h"
|
|
|
|
#include "gob/videoplayer.h"
|
2005-04-05 15:07:40 +00:00
|
|
|
|
|
|
|
namespace Gob {
|
|
|
|
|
2006-01-03 23:14:39 +00:00
|
|
|
Scenery::Scenery(GobEngine *vm) : _vm(vm) {
|
2007-03-20 14:51:57 +00:00
|
|
|
for (int i = 0; i < 20; i++) {
|
2009-06-24 21:49:37 +00:00
|
|
|
_spriteRefs[i] = 0;
|
2006-01-09 16:10:22 +00:00
|
|
|
_spriteResId[i] = 0;
|
2006-01-03 23:14:39 +00:00
|
|
|
}
|
2007-03-20 14:51:57 +00:00
|
|
|
|
|
|
|
for (int i = 0; i < 10; i++) {
|
2006-01-09 16:10:22 +00:00
|
|
|
_staticPictCount[i] = 0;
|
2009-06-24 21:49:37 +00:00
|
|
|
_staticResId[i] = 0;
|
|
|
|
_animPictCount[i] = 0;
|
|
|
|
_animResId[i] = 0;
|
2006-01-03 23:14:39 +00:00
|
|
|
}
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2009-06-24 21:49:37 +00:00
|
|
|
_curStatic = 0;
|
2006-01-09 16:10:22 +00:00
|
|
|
_curStaticLayer = 0;
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2009-06-24 21:49:37 +00:00
|
|
|
_toRedrawLeft = 0;
|
|
|
|
_toRedrawRight = 0;
|
|
|
|
_toRedrawTop = 0;
|
2006-01-09 16:10:22 +00:00
|
|
|
_toRedrawBottom = 0;
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2009-06-24 21:49:37 +00:00
|
|
|
_animTop = 0;
|
2006-01-09 16:10:22 +00:00
|
|
|
_animLeft = 0;
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2006-01-09 16:10:22 +00:00
|
|
|
_pCaptureCounter = 0;
|
2007-03-20 14:51:57 +00:00
|
|
|
|
2010-10-12 04:19:58 +00:00
|
|
|
for (int i = 0; i < 70; i++) {
|
2007-03-20 14:51:57 +00:00
|
|
|
_staticPictToSprite[i] = 0;
|
2009-06-24 21:49:37 +00:00
|
|
|
_animPictToSprite[i] = 0;
|
2007-03-20 14:51:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Scenery::~Scenery() {
|
|
|
|
for (int i = 0; i < 10; i++) {
|
|
|
|
freeStatic(i);
|
|
|
|
freeAnim(i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Scenery::init() {
|
|
|
|
for (int i = 0; i < 10; i++) {
|
2010-08-16 00:29:05 +00:00
|
|
|
if (_vm->getGameType() == kGameTypeFascination) {
|
|
|
|
freeAnim(i);
|
|
|
|
freeStatic(i);
|
|
|
|
}
|
2009-06-24 21:49:37 +00:00
|
|
|
_animPictCount[i] = 0;
|
2007-03-20 14:51:57 +00:00
|
|
|
_staticPictCount[i] = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int i = 0; i < 20; i++) {
|
2009-06-24 21:49:37 +00:00
|
|
|
_spriteRefs[i] = 0;
|
2007-03-20 14:51:57 +00:00
|
|
|
_spriteResId[i] = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
_curStaticLayer = -1;
|
2009-06-24 21:49:37 +00:00
|
|
|
_curStatic = -1;
|
2006-01-03 23:14:39 +00:00
|
|
|
}
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2006-01-03 23:14:39 +00:00
|
|
|
int16 Scenery::loadStatic(char search) {
|
2007-03-20 14:51:57 +00:00
|
|
|
int16 size;
|
2009-07-28 15:19:55 +00:00
|
|
|
byte *backsPtr;
|
2005-04-05 15:07:40 +00:00
|
|
|
int16 picsCount;
|
|
|
|
int16 resId;
|
|
|
|
int16 sceneryIndex;
|
2006-01-03 23:14:39 +00:00
|
|
|
Static *ptr;
|
2005-04-05 15:07:40 +00:00
|
|
|
int16 width;
|
|
|
|
int16 height;
|
|
|
|
int16 sprResId;
|
|
|
|
int16 sprIndex;
|
|
|
|
|
2009-06-22 10:29:32 +00:00
|
|
|
_vm->_game->_script->evalExpr(&sceneryIndex);
|
2007-03-20 14:51:57 +00:00
|
|
|
|
2009-06-24 21:49:37 +00:00
|
|
|
size = _vm->_game->_script->readInt16();
|
2009-07-28 15:19:55 +00:00
|
|
|
backsPtr = _vm->_game->_script->getData() + _vm->_game->_script->pos();
|
2009-06-22 10:13:37 +00:00
|
|
|
_vm->_game->_script->skip(size * 2);
|
|
|
|
picsCount = _vm->_game->_script->readInt16();
|
2009-06-24 21:49:37 +00:00
|
|
|
resId = _vm->_game->_script->readInt16();
|
2007-03-20 14:51:57 +00:00
|
|
|
|
2005-04-05 15:07:40 +00:00
|
|
|
if (search) {
|
2007-03-20 14:51:57 +00:00
|
|
|
int i;
|
|
|
|
|
2005-04-05 15:07:40 +00:00
|
|
|
for (i = 0; i < 10; i++) {
|
2007-03-20 14:51:57 +00:00
|
|
|
if ((_staticPictCount[i] != -1) && (_staticResId[i] == resId)) {
|
2009-06-22 10:13:37 +00:00
|
|
|
_vm->_game->_script->skip(8 * _staticPictCount[i]);
|
2005-04-05 15:07:40 +00:00
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
2006-01-09 16:10:22 +00:00
|
|
|
if (_staticPictCount[i] == -1 && i < sceneryIndex)
|
2005-04-05 15:07:40 +00:00
|
|
|
sceneryIndex = i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-01-09 16:10:22 +00:00
|
|
|
_staticPictCount[sceneryIndex] = picsCount;
|
2009-06-24 21:49:37 +00:00
|
|
|
_staticResId[sceneryIndex] = resId;
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2009-06-24 21:49:37 +00:00
|
|
|
Resource *resource = _vm->_game->_resources->getResource((uint16) resId);
|
|
|
|
if (!resource)
|
|
|
|
return 0;
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2006-01-09 16:10:22 +00:00
|
|
|
ptr = &_statics[sceneryIndex];
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2009-06-24 21:49:37 +00:00
|
|
|
ptr->layersCount = resource->stream()->readSint16LE();
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2006-06-13 08:10:54 +00:00
|
|
|
ptr->layers = new StaticLayer[ptr->layersCount];
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
for (int i = 0; i < ptr->layersCount; i++) {
|
2009-06-24 21:49:37 +00:00
|
|
|
Common::SeekableReadStream &layerData = *resource->stream();
|
2006-06-13 08:10:54 +00:00
|
|
|
|
2009-06-24 21:49:37 +00:00
|
|
|
layerData.seek(2 + i * 2);
|
|
|
|
layerData.seek(layerData.readUint16LE());
|
2006-06-13 08:10:54 +00:00
|
|
|
|
2009-06-24 21:49:37 +00:00
|
|
|
ptr->layers[i].backResId = layerData.readSint16LE();
|
|
|
|
ptr->layers[i].planeCount = layerData.readSint16LE();
|
|
|
|
if (ptr->layers[i].planeCount > 0) {
|
|
|
|
ptr->layers[i].planes = new StaticPlane[ptr->layers[i].planeCount];
|
|
|
|
for (int j = 0; j < ptr->layers[i].planeCount; j++) {
|
|
|
|
ptr->layers[i].planes[j].pictIndex = layerData.readByte();
|
|
|
|
ptr->layers[i].planes[j].pieceIndex = layerData.readByte();
|
|
|
|
ptr->layers[i].planes[j].drawOrder = layerData.readByte();
|
|
|
|
ptr->layers[i].planes[j].destX = layerData.readSint16LE();
|
|
|
|
ptr->layers[i].planes[j].destY = layerData.readSint16LE();
|
|
|
|
ptr->layers[i].planes[j].transp = layerData.readSByte();
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
ptr->layers[i].planes = 0;
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
ptr->layers[i].backResId = (int16) READ_LE_UINT16(backsPtr);
|
2009-07-28 15:19:55 +00:00
|
|
|
backsPtr += 2;
|
2005-04-05 15:07:40 +00:00
|
|
|
}
|
|
|
|
|
2009-06-24 21:49:37 +00:00
|
|
|
ptr->pieces = new PieceDesc*[picsCount];
|
2008-05-26 15:29:12 +00:00
|
|
|
ptr->piecesCount = new uint32[picsCount];
|
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
for (int i = 0; i < picsCount; i++) {
|
2009-06-22 10:13:37 +00:00
|
|
|
int16 pictDescId = _vm->_game->_script->readInt16();
|
2007-03-20 14:51:57 +00:00
|
|
|
|
2008-05-26 15:29:12 +00:00
|
|
|
loadPieces(pictDescId, ptr->pieces[i], ptr->piecesCount[i]);
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2009-06-24 21:49:37 +00:00
|
|
|
width = _vm->_game->_script->readInt16();
|
|
|
|
height = _vm->_game->_script->readInt16();
|
2009-06-22 10:13:37 +00:00
|
|
|
sprResId = _vm->_game->_script->readInt16();
|
2005-04-05 15:07:40 +00:00
|
|
|
for (sprIndex = 0; sprIndex < 20; sprIndex++) {
|
2006-01-09 16:10:22 +00:00
|
|
|
if (_spriteResId[sprIndex] == sprResId)
|
2005-04-05 15:07:40 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sprIndex < 20) {
|
2007-03-20 14:51:57 +00:00
|
|
|
_staticPictToSprite[7 * sceneryIndex + i] = sprIndex;
|
2006-01-09 16:10:22 +00:00
|
|
|
_spriteRefs[sprIndex]++;
|
2005-04-05 15:07:40 +00:00
|
|
|
} else {
|
2009-07-28 15:05:44 +00:00
|
|
|
for (sprIndex = 19; _vm->_draw->_spritesArray[sprIndex] != 0; sprIndex--) { }
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
_staticPictToSprite[7 * sceneryIndex + i] = sprIndex;
|
2006-01-09 16:10:22 +00:00
|
|
|
_spriteRefs[sprIndex] = 1;
|
|
|
|
_spriteResId[sprIndex] = sprResId;
|
2007-03-20 14:51:57 +00:00
|
|
|
_vm->_draw->initSpriteSurf(sprIndex, width, height, 2);
|
2006-01-03 23:14:39 +00:00
|
|
|
|
2010-09-30 13:02:16 +00:00
|
|
|
_vm->_draw->_spritesArray[sprIndex]->clear();
|
2009-06-24 21:49:37 +00:00
|
|
|
_vm->_draw->_destSurface = sprIndex;
|
|
|
|
_vm->_draw->_spriteLeft = sprResId;
|
2006-01-07 22:28:54 +00:00
|
|
|
_vm->_draw->_transparency = 0;
|
2009-06-24 21:49:37 +00:00
|
|
|
_vm->_draw->_destSpriteX = 0;
|
|
|
|
_vm->_draw->_destSpriteY = 0;
|
2006-01-03 23:14:39 +00:00
|
|
|
_vm->_draw->spriteOperation(DRAW_LOADSPRITE);
|
2005-04-05 15:07:40 +00:00
|
|
|
}
|
|
|
|
}
|
2007-03-20 14:51:57 +00:00
|
|
|
|
2009-06-24 21:49:37 +00:00
|
|
|
delete resource;
|
2005-04-05 15:07:40 +00:00
|
|
|
return sceneryIndex + 100;
|
|
|
|
}
|
|
|
|
|
2006-01-03 23:14:39 +00:00
|
|
|
void Scenery::freeStatic(int16 index) {
|
2005-04-05 15:07:40 +00:00
|
|
|
int16 spr;
|
|
|
|
|
|
|
|
if (index == -1)
|
2009-06-22 10:29:32 +00:00
|
|
|
_vm->_game->_script->evalExpr(&index);
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2006-01-09 16:10:22 +00:00
|
|
|
if (_staticPictCount[index] == -1)
|
2005-04-05 15:07:40 +00:00
|
|
|
return;
|
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
for (int i = 0; i < _staticPictCount[index]; i++) {
|
2008-05-26 15:29:12 +00:00
|
|
|
delete[] _statics[index].pieces[i];
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2006-01-09 16:10:22 +00:00
|
|
|
spr = _staticPictToSprite[index * 7 + i];
|
|
|
|
_spriteRefs[spr]--;
|
|
|
|
if (_spriteRefs[spr] == 0) {
|
2007-03-20 14:51:57 +00:00
|
|
|
_vm->_draw->freeSprite(spr);
|
2006-01-09 16:10:22 +00:00
|
|
|
_spriteResId[spr] = -1;
|
2005-04-05 15:07:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
for (int i = 0; i < _statics[index].layersCount; i++)
|
2006-06-13 08:10:54 +00:00
|
|
|
delete[] _statics[index].layers[i].planes;
|
2009-06-24 21:49:37 +00:00
|
|
|
|
2006-01-29 02:27:10 +00:00
|
|
|
delete[] _statics[index].layers;
|
|
|
|
delete[] _statics[index].pieces;
|
2008-05-26 15:29:12 +00:00
|
|
|
delete[] _statics[index].piecesCount;
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2007-03-02 11:37:42 +00:00
|
|
|
_statics[index].layersCount = 0;
|
2009-06-24 21:49:37 +00:00
|
|
|
_staticPictCount[index] = -1;
|
2005-04-05 15:07:40 +00:00
|
|
|
}
|
|
|
|
|
2006-01-03 23:14:39 +00:00
|
|
|
void Scenery::renderStatic(int16 scenery, int16 layer) {
|
|
|
|
Static *ptr;
|
|
|
|
StaticLayer *layerPtr;
|
|
|
|
StaticPlane *planePtr;
|
2005-04-05 15:07:40 +00:00
|
|
|
int16 planeCount;
|
|
|
|
int16 order;
|
|
|
|
int16 plane;
|
|
|
|
|
2008-05-26 15:29:12 +00:00
|
|
|
uint16 pieceIndex;
|
|
|
|
uint16 pictIndex;
|
2005-04-05 15:07:40 +00:00
|
|
|
|
|
|
|
int16 left;
|
|
|
|
int16 right;
|
|
|
|
int16 top;
|
|
|
|
int16 bottom;
|
|
|
|
|
2006-01-09 16:10:22 +00:00
|
|
|
ptr = &_statics[scenery];
|
2005-04-05 15:07:40 +00:00
|
|
|
if (layer >= ptr->layersCount)
|
|
|
|
return;
|
|
|
|
|
2006-06-13 08:10:54 +00:00
|
|
|
layerPtr = &ptr->layers[layer];
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2006-01-07 22:28:54 +00:00
|
|
|
_vm->_draw->_spriteLeft = layerPtr->backResId;
|
|
|
|
if (_vm->_draw->_spriteLeft != -1) {
|
2010-08-08 00:35:18 +00:00
|
|
|
_vm->_draw->_destSpriteX = 0;
|
|
|
|
_vm->_draw->_destSpriteY = 0;
|
|
|
|
_vm->_draw->_destSurface = Draw::kBackSurface;
|
|
|
|
_vm->_draw->_transparency = 0;
|
2006-01-03 23:14:39 +00:00
|
|
|
_vm->_draw->spriteOperation(DRAW_LOADSPRITE);
|
2005-04-05 15:07:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
planeCount = layerPtr->planeCount;
|
2008-05-07 02:56:18 +00:00
|
|
|
for (order = 0; order < 100; order++) {
|
2009-06-24 21:49:37 +00:00
|
|
|
for (plane = 0, planePtr = layerPtr->planes; plane < planeCount; plane++, planePtr++) {
|
2005-04-05 15:07:40 +00:00
|
|
|
if (planePtr->drawOrder != order)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
pieceIndex = planePtr->pieceIndex;
|
2009-06-24 21:49:37 +00:00
|
|
|
pictIndex = planePtr->pictIndex - 1;
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2008-05-26 15:29:12 +00:00
|
|
|
if (pictIndex >= _staticPictCount[scenery])
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (!ptr->pieces || !ptr->pieces[pictIndex])
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (pieceIndex >= ptr->piecesCount[pictIndex])
|
2008-05-24 14:54:22 +00:00
|
|
|
continue;
|
|
|
|
|
2006-01-07 22:28:54 +00:00
|
|
|
_vm->_draw->_destSpriteX = planePtr->destX;
|
|
|
|
_vm->_draw->_destSpriteY = planePtr->destY;
|
2009-06-24 21:49:37 +00:00
|
|
|
left = ptr->pieces[pictIndex][pieceIndex].left;
|
|
|
|
right = ptr->pieces[pictIndex][pieceIndex].right;
|
|
|
|
top = ptr->pieces[pictIndex][pieceIndex].top;
|
2008-05-26 15:29:12 +00:00
|
|
|
bottom = ptr->pieces[pictIndex][pieceIndex].bottom;
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2006-01-07 22:28:54 +00:00
|
|
|
_vm->_draw->_sourceSurface =
|
2006-01-09 16:10:22 +00:00
|
|
|
_staticPictToSprite[scenery * 7 + pictIndex];
|
2010-08-08 00:35:18 +00:00
|
|
|
_vm->_draw->_destSurface = Draw::kBackSurface;
|
2009-06-24 21:49:37 +00:00
|
|
|
_vm->_draw->_spriteLeft = left;
|
|
|
|
_vm->_draw->_spriteTop = top;
|
|
|
|
_vm->_draw->_spriteRight = right - left + 1;
|
|
|
|
_vm->_draw->_spriteBottom = bottom - top + 1;
|
|
|
|
_vm->_draw->_transparency = planePtr->transp ? 3 : 0;
|
2006-01-03 23:14:39 +00:00
|
|
|
_vm->_draw->spriteOperation(DRAW_BLITSURF);
|
2005-04-05 15:07:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-04-05 13:37:20 +00:00
|
|
|
void Scenery::updateStatic(int16 orderFrom, byte index, byte layer) {
|
2006-01-03 23:14:39 +00:00
|
|
|
StaticLayer *layerPtr;
|
|
|
|
PieceDesc **pictPtr;
|
|
|
|
StaticPlane *planePtr;
|
2005-04-05 15:07:40 +00:00
|
|
|
int16 planeCount;
|
|
|
|
int16 order;
|
|
|
|
int16 plane;
|
2008-05-26 15:29:12 +00:00
|
|
|
uint16 pieceIndex;
|
|
|
|
uint16 pictIndex;
|
2005-04-05 15:07:40 +00:00
|
|
|
|
|
|
|
int16 left;
|
|
|
|
int16 right;
|
|
|
|
int16 top;
|
|
|
|
int16 bottom;
|
|
|
|
|
2007-07-25 21:02:30 +00:00
|
|
|
if ((index >= 10) || layer >= _statics[index].layersCount)
|
2005-04-05 15:07:40 +00:00
|
|
|
return;
|
|
|
|
|
2007-04-05 13:37:20 +00:00
|
|
|
layerPtr = &_statics[index].layers[layer];
|
|
|
|
pictPtr = _statics[index].pieces;
|
2005-04-05 15:07:40 +00:00
|
|
|
|
|
|
|
planeCount = layerPtr->planeCount;
|
|
|
|
|
2008-05-07 02:56:18 +00:00
|
|
|
for (order = orderFrom; order < 100; order++) {
|
2005-04-05 15:07:40 +00:00
|
|
|
for (planePtr = layerPtr->planes, plane = 0;
|
|
|
|
plane < planeCount; plane++, planePtr++) {
|
|
|
|
if (planePtr->drawOrder != order)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
pieceIndex = planePtr->pieceIndex;
|
2009-06-24 21:49:37 +00:00
|
|
|
pictIndex = planePtr->pictIndex - 1;
|
2008-05-07 02:56:18 +00:00
|
|
|
|
2008-05-26 15:29:12 +00:00
|
|
|
if (pictIndex >= _staticPictCount[index])
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (!pictPtr || !pictPtr[pictIndex])
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (pieceIndex >= _statics[index].piecesCount[pictIndex])
|
2008-05-07 02:56:18 +00:00
|
|
|
continue;
|
|
|
|
|
2006-01-07 22:28:54 +00:00
|
|
|
_vm->_draw->_destSpriteX = planePtr->destX;
|
|
|
|
_vm->_draw->_destSpriteY = planePtr->destY;
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2009-06-24 21:49:37 +00:00
|
|
|
left = pictPtr[pictIndex][pieceIndex].left;
|
|
|
|
right = pictPtr[pictIndex][pieceIndex].right;
|
|
|
|
top = pictPtr[pictIndex][pieceIndex].top;
|
2008-05-26 15:29:12 +00:00
|
|
|
bottom = pictPtr[pictIndex][pieceIndex].bottom;
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2006-01-09 16:10:22 +00:00
|
|
|
if (_vm->_draw->_destSpriteX > _toRedrawRight)
|
2005-04-05 15:07:40 +00:00
|
|
|
continue;
|
|
|
|
|
2006-01-09 16:10:22 +00:00
|
|
|
if (_vm->_draw->_destSpriteY > _toRedrawBottom)
|
2005-04-05 15:07:40 +00:00
|
|
|
continue;
|
|
|
|
|
2006-01-09 16:10:22 +00:00
|
|
|
if (_vm->_draw->_destSpriteX < _toRedrawLeft) {
|
|
|
|
left += _toRedrawLeft - _vm->_draw->_destSpriteX;
|
|
|
|
_vm->_draw->_destSpriteX = _toRedrawLeft;
|
2005-04-05 15:07:40 +00:00
|
|
|
}
|
|
|
|
|
2006-01-09 16:10:22 +00:00
|
|
|
if (_vm->_draw->_destSpriteY < _toRedrawTop) {
|
|
|
|
top += _toRedrawTop - _vm->_draw->_destSpriteY;
|
|
|
|
_vm->_draw->_destSpriteY = _toRedrawTop;
|
2005-04-05 15:07:40 +00:00
|
|
|
}
|
|
|
|
|
2009-06-24 21:49:37 +00:00
|
|
|
_vm->_draw->_spriteLeft = left;
|
|
|
|
_vm->_draw->_spriteTop = top;
|
|
|
|
_vm->_draw->_spriteRight = right - left + 1;
|
|
|
|
_vm->_draw->_spriteBottom = bottom - top + 1;
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
if ((_vm->_draw->_spriteRight <= 0) ||
|
|
|
|
(_vm->_draw->_spriteBottom <= 0))
|
2005-04-05 15:07:40 +00:00
|
|
|
continue;
|
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
if ((_vm->_draw->_destSpriteX + _vm->_draw->_spriteRight - 1) >
|
2006-01-09 16:10:22 +00:00
|
|
|
_toRedrawRight)
|
2006-01-07 22:28:54 +00:00
|
|
|
_vm->_draw->_spriteRight =
|
2006-01-09 16:10:22 +00:00
|
|
|
_toRedrawRight - _vm->_draw->_destSpriteX + 1;
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
if ((_vm->_draw->_destSpriteY + _vm->_draw->_spriteBottom - 1) >
|
2006-01-09 16:10:22 +00:00
|
|
|
_toRedrawBottom)
|
2006-01-07 22:28:54 +00:00
|
|
|
_vm->_draw->_spriteBottom =
|
2006-01-09 16:10:22 +00:00
|
|
|
_toRedrawBottom - _vm->_draw->_destSpriteY + 1;
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2006-01-07 22:28:54 +00:00
|
|
|
_vm->_draw->_sourceSurface =
|
2007-04-05 13:37:20 +00:00
|
|
|
_staticPictToSprite[index * 7 + pictIndex];
|
2010-08-08 00:35:18 +00:00
|
|
|
_vm->_draw->_destSurface = Draw::kBackSurface;
|
2009-06-24 21:49:37 +00:00
|
|
|
_vm->_draw->_transparency = planePtr->transp ? 3 : 0;
|
2006-01-03 23:14:39 +00:00
|
|
|
_vm->_draw->spriteOperation(DRAW_BLITSURF);
|
2005-04-05 15:07:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-04-05 13:37:20 +00:00
|
|
|
void Scenery::updateStatic(int16 orderFrom) {
|
|
|
|
if (_curStatic == -1)
|
|
|
|
return;
|
|
|
|
|
2007-10-30 10:47:24 +00:00
|
|
|
if (_curStatic < 10000) {
|
|
|
|
updateStatic(orderFrom, _curStatic & 0xFF, _curStaticLayer & 0xFF);
|
2007-04-05 13:37:20 +00:00
|
|
|
|
2007-10-30 10:47:24 +00:00
|
|
|
if (_curStatic & 0xFF00)
|
|
|
|
updateStatic(orderFrom, ((_curStatic >> 8) & 0xFF) - 1,
|
|
|
|
(_curStaticLayer >> 8) & 0xFF);
|
|
|
|
} else
|
|
|
|
for (int i = 0; i < (_curStatic - 10000); i++)
|
|
|
|
updateStatic(orderFrom, i, 0);
|
2007-04-05 13:37:20 +00:00
|
|
|
}
|
|
|
|
|
2006-01-03 23:14:39 +00:00
|
|
|
int16 Scenery::loadAnim(char search) {
|
2005-04-05 15:07:40 +00:00
|
|
|
int16 picsCount;
|
|
|
|
int16 resId;
|
|
|
|
int16 i;
|
2006-06-12 21:33:30 +00:00
|
|
|
int16 j;
|
2005-04-05 15:07:40 +00:00
|
|
|
int16 sceneryIndex;
|
2006-06-12 21:33:30 +00:00
|
|
|
int16 framesCount;
|
2006-01-03 23:14:39 +00:00
|
|
|
Animation *ptr;
|
2005-04-05 15:07:40 +00:00
|
|
|
int16 width;
|
|
|
|
int16 height;
|
|
|
|
int16 sprResId;
|
|
|
|
int16 sprIndex;
|
2006-06-12 22:21:07 +00:00
|
|
|
uint32 layerPos;
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2009-06-22 10:29:32 +00:00
|
|
|
_vm->_game->_script->evalExpr(&sceneryIndex);
|
2009-06-22 10:13:37 +00:00
|
|
|
picsCount = _vm->_game->_script->readInt16();
|
|
|
|
resId = _vm->_game->_script->readInt16();
|
2005-04-05 15:07:40 +00:00
|
|
|
|
|
|
|
if (search) {
|
|
|
|
for (i = 0; i < 10; i++) {
|
2007-03-20 14:51:57 +00:00
|
|
|
if ((_animPictCount[i] != 0) && (_animResId[i] == resId)) {
|
2009-06-22 10:13:37 +00:00
|
|
|
_vm->_game->_script->skip(8 * _animPictCount[i]);
|
2005-04-05 15:07:40 +00:00
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
if ((_animPictCount[i] == 0) && (i < sceneryIndex))
|
2005-04-05 15:07:40 +00:00
|
|
|
sceneryIndex = i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-01-09 16:10:22 +00:00
|
|
|
_animPictCount[sceneryIndex] = picsCount;
|
|
|
|
_animResId[sceneryIndex] = resId;
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2009-06-24 21:49:37 +00:00
|
|
|
Resource *resource = _vm->_game->_resources->getResource((uint16) resId);
|
|
|
|
if (!resource)
|
|
|
|
return 0;
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2006-01-09 16:10:22 +00:00
|
|
|
ptr = &_animations[sceneryIndex];
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2009-06-24 21:49:37 +00:00
|
|
|
ptr->layersCount = resource->stream()->readSint16LE();
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2006-06-12 21:33:30 +00:00
|
|
|
ptr->layers = new AnimLayer[ptr->layersCount];
|
2005-04-05 15:07:40 +00:00
|
|
|
|
|
|
|
for (i = 0; i < ptr->layersCount; i++) {
|
2009-06-24 21:49:37 +00:00
|
|
|
Common::SeekableReadStream &layerData = *resource->stream();
|
|
|
|
|
|
|
|
layerData.seek(2 + i * 2);
|
|
|
|
layerData.seek(layerData.readUint16LE());
|
|
|
|
|
|
|
|
ptr->layers[i].unknown0 = layerData.readSint16LE();
|
|
|
|
ptr->layers[i].posX = layerData.readSint16LE();
|
|
|
|
ptr->layers[i].posY = layerData.readSint16LE();
|
|
|
|
ptr->layers[i].animDeltaX = layerData.readSint16LE();
|
|
|
|
ptr->layers[i].animDeltaY = layerData.readSint16LE();
|
|
|
|
ptr->layers[i].transp = layerData.readSByte();
|
2006-06-12 22:21:07 +00:00
|
|
|
ptr->layers[i].framesCount = layerData.readSint16LE();
|
2006-06-12 21:33:30 +00:00
|
|
|
|
2009-06-24 21:49:37 +00:00
|
|
|
// Going through the AnimFramePiece, finding the end for each
|
2006-06-12 22:21:07 +00:00
|
|
|
layerPos = layerData.pos();
|
2006-06-12 21:33:30 +00:00
|
|
|
framesCount = 0;
|
2009-06-24 21:49:37 +00:00
|
|
|
for (j = 0; j < ptr->layers[i].framesCount; j++) {
|
|
|
|
layerData.skip(4); // pictIndex, pieceIndex, destX, destY
|
2006-07-08 16:37:23 +00:00
|
|
|
while (layerData.readByte() == 1) {
|
2006-06-12 21:33:30 +00:00
|
|
|
framesCount++;
|
2009-06-24 21:49:37 +00:00
|
|
|
layerData.skip(4); // pictIndex, pieceIndex, destX, destY
|
2006-06-12 21:33:30 +00:00
|
|
|
}
|
2009-06-24 21:49:37 +00:00
|
|
|
framesCount++;
|
2006-06-12 21:33:30 +00:00
|
|
|
}
|
2006-06-12 22:21:07 +00:00
|
|
|
layerData.seek(layerPos);
|
2006-06-12 21:33:30 +00:00
|
|
|
|
|
|
|
ptr->layers[i].frames = new AnimFramePiece[framesCount];
|
|
|
|
for (j = 0; j < framesCount; j++) {
|
2009-06-24 21:49:37 +00:00
|
|
|
ptr->layers[i].frames[j].pictIndex = layerData.readByte();
|
2006-06-12 22:21:07 +00:00
|
|
|
ptr->layers[i].frames[j].pieceIndex = layerData.readByte();
|
2009-06-24 21:49:37 +00:00
|
|
|
ptr->layers[i].frames[j].destX = layerData.readSByte();
|
|
|
|
ptr->layers[i].frames[j].destY = layerData.readSByte();
|
|
|
|
ptr->layers[i].frames[j].notFinal = layerData.readSByte();
|
2006-06-12 21:33:30 +00:00
|
|
|
}
|
2005-04-05 15:07:40 +00:00
|
|
|
}
|
|
|
|
|
2008-05-26 15:29:12 +00:00
|
|
|
ptr->pieces = new PieceDesc*[picsCount];
|
|
|
|
ptr->piecesCount = new uint32[picsCount];
|
|
|
|
|
2005-04-05 15:07:40 +00:00
|
|
|
for (i = 0; i < picsCount; i++) {
|
2009-06-22 10:13:37 +00:00
|
|
|
int16 pictDescId = _vm->_game->_script->readInt16();
|
2008-04-27 03:19:19 +00:00
|
|
|
|
2008-05-26 15:29:12 +00:00
|
|
|
loadPieces(pictDescId, ptr->pieces[i], ptr->piecesCount[i]);
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2009-06-24 21:49:37 +00:00
|
|
|
width = _vm->_game->_script->readInt16();
|
|
|
|
height = _vm->_game->_script->readInt16();
|
2009-06-22 10:13:37 +00:00
|
|
|
sprResId = _vm->_game->_script->readInt16();
|
2007-03-20 14:51:57 +00:00
|
|
|
for (sprIndex = 0; sprIndex < 20; sprIndex++)
|
2006-01-09 16:10:22 +00:00
|
|
|
if (_spriteResId[sprIndex] == sprResId)
|
2005-04-05 15:07:40 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
if (sprIndex < 20) {
|
2006-01-09 16:10:22 +00:00
|
|
|
_animPictToSprite[7 * sceneryIndex + i] = sprIndex;
|
|
|
|
_spriteRefs[sprIndex]++;
|
2005-04-05 15:07:40 +00:00
|
|
|
} else {
|
2009-06-06 20:03:13 +00:00
|
|
|
for (sprIndex = 19; _vm->_draw->_spritesArray[sprIndex];
|
2009-01-29 05:26:12 +00:00
|
|
|
sprIndex--)
|
|
|
|
;
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2006-01-09 16:10:22 +00:00
|
|
|
_animPictToSprite[7 * sceneryIndex + i] = sprIndex;
|
2009-06-24 21:49:37 +00:00
|
|
|
_spriteRefs[sprIndex] = 1;
|
2006-01-09 16:10:22 +00:00
|
|
|
_spriteResId[sprIndex] = sprResId;
|
2007-03-20 14:51:57 +00:00
|
|
|
_vm->_draw->initSpriteSurf(sprIndex, width, height, 2);
|
2006-01-03 23:14:39 +00:00
|
|
|
|
2010-09-30 13:02:16 +00:00
|
|
|
_vm->_draw->_spritesArray[sprIndex]->clear();
|
2009-06-24 21:49:37 +00:00
|
|
|
_vm->_draw->_destSurface = sprIndex;
|
|
|
|
_vm->_draw->_spriteLeft = sprResId;
|
2006-01-07 22:28:54 +00:00
|
|
|
_vm->_draw->_transparency = 0;
|
2009-06-24 21:49:37 +00:00
|
|
|
_vm->_draw->_destSpriteX = 0;
|
|
|
|
_vm->_draw->_destSpriteY = 0;
|
2006-01-03 23:14:39 +00:00
|
|
|
_vm->_draw->spriteOperation(DRAW_LOADSPRITE);
|
2005-04-05 15:07:40 +00:00
|
|
|
}
|
|
|
|
}
|
2007-03-20 14:51:57 +00:00
|
|
|
|
2009-06-24 21:49:37 +00:00
|
|
|
delete resource;
|
2005-04-05 15:07:40 +00:00
|
|
|
return sceneryIndex + 100;
|
|
|
|
}
|
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
void Scenery::freeAnim(int16 index) {
|
2005-04-05 15:07:40 +00:00
|
|
|
int16 spr;
|
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
if (index == -1)
|
2009-06-22 10:29:32 +00:00
|
|
|
_vm->_game->_script->evalExpr(&index);
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
if (_animPictCount[index] == 0)
|
2005-04-05 15:07:40 +00:00
|
|
|
return;
|
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
for (int i = 0; i < _animPictCount[index]; i++) {
|
2008-05-26 15:29:12 +00:00
|
|
|
delete[] _animations[index].pieces[i];
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
spr = _animPictToSprite[index * 7 + i];
|
2006-01-09 16:10:22 +00:00
|
|
|
_spriteRefs[spr]--;
|
|
|
|
if (_spriteRefs[spr] == 0) {
|
2007-03-20 14:51:57 +00:00
|
|
|
_vm->_draw->freeSprite(spr);
|
2006-01-09 16:10:22 +00:00
|
|
|
_spriteResId[spr] = -1;
|
2005-04-05 15:07:40 +00:00
|
|
|
}
|
|
|
|
}
|
2007-09-19 08:40:12 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
for (int i = 0; i < _animations[index].layersCount; i++)
|
|
|
|
delete[] _animations[index].layers[i].frames;
|
2009-06-24 21:49:37 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
delete[] _animations[index].layers;
|
|
|
|
delete[] _animations[index].pieces;
|
2008-05-26 15:29:12 +00:00
|
|
|
delete[] _animations[index].piecesCount;
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
_animPictCount[index] = 0;
|
2005-04-05 15:07:40 +00:00
|
|
|
}
|
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
// flags & 1 - do capture all area animation is occupying
|
|
|
|
// flags & 4 == 0 - calculate animation final size
|
|
|
|
// flags & 2 != 0 - don't check with "toRedraw"'s
|
|
|
|
// flags & 4 != 0 - checkk view toRedraw
|
|
|
|
void Scenery::updateAnim(int16 layer, int16 frame, int16 animation, int16 flags,
|
|
|
|
int16 drawDeltaX, int16 drawDeltaY, char doDraw) {
|
2006-01-03 23:14:39 +00:00
|
|
|
AnimLayer *layerPtr;
|
2007-03-20 14:51:57 +00:00
|
|
|
PieceDesc **pictPtr;
|
|
|
|
AnimFramePiece *framePtr;
|
|
|
|
|
|
|
|
uint16 pieceIndex;
|
|
|
|
uint16 pictIndex;
|
|
|
|
|
|
|
|
int16 left;
|
|
|
|
int16 right;
|
|
|
|
int16 top;
|
|
|
|
int16 bottom;
|
|
|
|
|
|
|
|
byte highX;
|
|
|
|
byte highY;
|
|
|
|
|
|
|
|
int16 i;
|
|
|
|
int16 transp;
|
|
|
|
|
|
|
|
int16 destX;
|
|
|
|
int16 destY;
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2011-01-30 13:14:32 +00:00
|
|
|
if ((animation < 0) &&
|
|
|
|
((_vm->getGameType() == kGameTypeWoodruff) ||
|
|
|
|
(_vm->getGameType() == kGameTypeAdibou2))) {
|
2008-04-27 03:19:19 +00:00
|
|
|
// Object video
|
|
|
|
|
|
|
|
if (flags & 1) { // Do capture
|
|
|
|
updateAnim(layer, frame, animation, 0, drawDeltaX, drawDeltaY, 0);
|
|
|
|
|
|
|
|
if (_toRedrawLeft == -12345)
|
|
|
|
return;
|
|
|
|
|
|
|
|
_vm->_game->capturePush(_toRedrawLeft, _toRedrawTop,
|
2009-06-24 21:49:37 +00:00
|
|
|
_toRedrawRight - _toRedrawLeft + 1,
|
|
|
|
_toRedrawBottom - _toRedrawTop + 1);
|
2008-04-27 03:19:19 +00:00
|
|
|
|
|
|
|
*_pCaptureCounter = *_pCaptureCounter + 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
Mult::Mult_Object &obj = _vm->_mult->_objects[-animation - 1];
|
|
|
|
|
2008-05-17 04:07:16 +00:00
|
|
|
if ((obj.videoSlot == 0) || !_vm->_vidPlayer->slotIsOpen(obj.videoSlot - 1)) {
|
|
|
|
_toRedrawLeft = -12345;
|
2008-04-27 03:19:19 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-08-08 01:03:21 +00:00
|
|
|
if (frame >= (int32)_vm->_vidPlayer->getFrameCount(obj.videoSlot - 1))
|
2010-08-08 00:33:59 +00:00
|
|
|
frame = _vm->_vidPlayer->getFrameCount(obj.videoSlot - 1) - 1;
|
2008-05-01 18:38:36 +00:00
|
|
|
|
2011-07-23 13:37:33 +00:00
|
|
|
if ((int32)_vm->_vidPlayer->getCurrentFrame(obj.videoSlot - 1) >= 255) {
|
2010-10-07 09:18:15 +00:00
|
|
|
// Allow for object videos with more than 255 frames, although the
|
|
|
|
// object frame counter is just a byte.
|
|
|
|
|
|
|
|
uint32 curFrame = _vm->_vidPlayer->getCurrentFrame(obj.videoSlot - 1) + 1;
|
|
|
|
uint16 frameWrap = curFrame / 256;
|
|
|
|
|
|
|
|
frame = ((frame + 1) % 256) + frameWrap * 256;
|
|
|
|
}
|
|
|
|
|
2010-08-08 01:04:19 +00:00
|
|
|
if (frame != (int32)_vm->_vidPlayer->getCurrentFrame(obj.videoSlot - 1)) {
|
|
|
|
// Seek to frame
|
|
|
|
|
2010-08-08 00:55:27 +00:00
|
|
|
VideoPlayer::Properties props;
|
|
|
|
|
2010-08-08 01:04:19 +00:00
|
|
|
props.forceSeek = true;
|
2010-08-08 01:03:21 +00:00
|
|
|
props.waitEndFrame = false;
|
|
|
|
props.lastFrame = frame;
|
2008-05-13 15:52:01 +00:00
|
|
|
|
2010-08-08 01:04:19 +00:00
|
|
|
if ((int32)_vm->_vidPlayer->getCurrentFrame(obj.videoSlot - 1) < frame)
|
|
|
|
props.startFrame = _vm->_vidPlayer->getCurrentFrame(obj.videoSlot - 1) + 1;
|
|
|
|
else
|
2010-08-08 01:04:46 +00:00
|
|
|
props.startFrame = frame;
|
2010-08-08 00:55:27 +00:00
|
|
|
|
|
|
|
_vm->_vidPlayer->play(obj.videoSlot - 1, props);
|
2008-05-13 15:52:01 +00:00
|
|
|
}
|
2008-04-27 03:19:19 +00:00
|
|
|
|
2010-08-08 01:05:46 +00:00
|
|
|
int32 subtitle = _vm->_vidPlayer->getSubtitleIndex(obj.videoSlot - 1);
|
|
|
|
if (subtitle != -1)
|
|
|
|
_vm->_draw->printTotText(subtitle);
|
2009-07-24 21:31:00 +00:00
|
|
|
|
2009-06-24 21:49:37 +00:00
|
|
|
destX = 0;
|
|
|
|
destY = 0;
|
|
|
|
left = *(obj.pPosX);
|
|
|
|
top = *(obj.pPosY);
|
|
|
|
right = left + _vm->_vidPlayer->getWidth(obj.videoSlot - 1) - 1;
|
|
|
|
bottom = top + _vm->_vidPlayer->getHeight(obj.videoSlot - 1) - 1;
|
2008-04-27 03:19:19 +00:00
|
|
|
|
|
|
|
if (flags & 2) {
|
|
|
|
if (left < _vm->_mult->_animLeft) {
|
|
|
|
destX += _vm->_mult->_animLeft - left;
|
2009-06-24 21:49:37 +00:00
|
|
|
left = _vm->_mult->_animLeft;
|
2008-04-27 03:19:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ((_vm->_mult->_animLeft + _vm->_mult->_animWidth) <= right)
|
|
|
|
right = _vm->_mult->_animLeft + _vm->_mult->_animWidth - 1;
|
|
|
|
|
|
|
|
if (top < _vm->_mult->_animTop) {
|
|
|
|
destY += _vm->_mult->_animTop - top;
|
2009-06-24 21:49:37 +00:00
|
|
|
top = _vm->_mult->_animTop;
|
2008-04-27 03:19:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ((_vm->_mult->_animTop + _vm->_mult->_animHeight) <= bottom)
|
|
|
|
bottom = _vm->_mult->_animTop + _vm->_mult->_animHeight - 1;
|
|
|
|
|
|
|
|
} else if (flags & 4) {
|
|
|
|
if (left < _toRedrawLeft) {
|
|
|
|
destX += _toRedrawLeft - left;
|
2009-06-24 21:49:37 +00:00
|
|
|
left = _toRedrawLeft;
|
2008-04-27 03:19:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (right > _toRedrawRight)
|
|
|
|
right = _toRedrawRight;
|
|
|
|
|
|
|
|
if (top < _toRedrawTop) {
|
|
|
|
destY += _toRedrawTop - top;
|
2009-06-24 21:49:37 +00:00
|
|
|
top = _toRedrawTop;
|
2008-04-27 03:19:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (bottom > _toRedrawBottom)
|
|
|
|
bottom = _toRedrawBottom;
|
|
|
|
|
|
|
|
} else {
|
2009-06-24 21:49:37 +00:00
|
|
|
_toRedrawTop = top;
|
|
|
|
_toRedrawLeft = left;
|
|
|
|
_toRedrawRight = right;
|
2008-04-27 03:19:19 +00:00
|
|
|
_toRedrawBottom = bottom;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (doDraw) {
|
|
|
|
if ((left > right) || (top > bottom))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (left < _vm->_mult->_animLeft) {
|
|
|
|
destX += _vm->_mult->_animLeft - left;
|
2009-06-24 21:49:37 +00:00
|
|
|
left = _vm->_mult->_animLeft;
|
2008-04-27 03:19:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ((_vm->_mult->_animLeft + _vm->_mult->_animWidth) <= right)
|
|
|
|
right = _vm->_mult->_animLeft + _vm->_mult->_animWidth - 1;
|
|
|
|
|
|
|
|
if (top < _vm->_mult->_animTop) {
|
|
|
|
destY += _vm->_mult->_animTop - top;
|
2009-06-24 21:49:37 +00:00
|
|
|
top = _vm->_mult->_animTop;
|
2008-04-27 03:19:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ((_vm->_mult->_animTop + _vm->_mult->_animHeight) <= bottom)
|
|
|
|
bottom = _vm->_mult->_animTop + _vm->_mult->_animHeight - 1;
|
|
|
|
|
2009-06-24 21:49:37 +00:00
|
|
|
_vm->_draw->_spriteLeft = destX;
|
|
|
|
_vm->_draw->_spriteTop = destY;
|
|
|
|
_vm->_draw->_spriteRight = right - left + 1;
|
|
|
|
_vm->_draw->_spriteBottom = bottom - top + 1;
|
|
|
|
_vm->_draw->_destSpriteX = left;
|
|
|
|
_vm->_draw->_destSpriteY = top;
|
2008-04-27 03:19:19 +00:00
|
|
|
_vm->_draw->_transparency = layer;
|
|
|
|
if (layer & 0x80)
|
|
|
|
_vm->_draw->_spriteLeft = _vm->_vidPlayer->getWidth(obj.videoSlot - 1) -
|
|
|
|
(destX + _vm->_draw->_spriteRight);
|
|
|
|
|
2011-01-20 05:19:41 +00:00
|
|
|
_vm->_vidPlayer->copyFrame(obj.videoSlot - 1, *_vm->_draw->_backSurface,
|
2009-06-24 21:49:37 +00:00
|
|
|
_vm->_draw->_spriteLeft, _vm->_draw->_spriteTop,
|
2008-04-27 03:19:19 +00:00
|
|
|
_vm->_draw->_spriteRight, _vm->_draw->_spriteBottom,
|
|
|
|
_vm->_draw->_destSpriteX, _vm->_draw->_destSpriteY,
|
|
|
|
(_vm->_draw->_transparency != 0) ? 0 : -1);
|
|
|
|
|
|
|
|
_vm->_draw->invalidateRect(_vm->_draw->_destSpriteX, _vm->_draw->_destSpriteY,
|
2009-06-24 21:49:37 +00:00
|
|
|
_vm->_draw->_destSpriteX + _vm->_draw->_spriteRight - 1,
|
2008-04-27 03:19:19 +00:00
|
|
|
_vm->_draw->_destSpriteY + _vm->_draw->_spriteBottom - 1);
|
|
|
|
}
|
|
|
|
|
2008-05-17 04:07:16 +00:00
|
|
|
if (!(flags & 4)) {
|
2010-08-08 01:04:19 +00:00
|
|
|
_animLeft = _toRedrawLeft = left;
|
|
|
|
_animTop = _toRedrawTop = top;
|
|
|
|
_animRight = _toRedrawRight = right;
|
2008-04-27 03:19:19 +00:00
|
|
|
_animBottom = _toRedrawBottom = bottom;
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-06-19 16:27:49 +00:00
|
|
|
if ((animation < 0) || (animation >= 10))
|
|
|
|
return;
|
2007-03-20 14:51:57 +00:00
|
|
|
if ((_animPictCount[animation] == 0) || (layer < 0))
|
|
|
|
return;
|
|
|
|
if (layer >= _animations[animation].layersCount)
|
|
|
|
return;
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2006-06-12 21:33:30 +00:00
|
|
|
layerPtr = &_animations[animation].layers[layer];
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
if (frame >= layerPtr->framesCount)
|
|
|
|
return;
|
|
|
|
|
2007-03-29 21:03:32 +00:00
|
|
|
if (flags & 1) { // Do capture
|
2007-03-20 14:51:57 +00:00
|
|
|
updateAnim(layer, frame, animation, 0, drawDeltaX, drawDeltaY, 0);
|
|
|
|
|
|
|
|
if (_toRedrawLeft == -12345)
|
|
|
|
return;
|
|
|
|
|
|
|
|
_vm->_game->capturePush(_toRedrawLeft, _toRedrawTop,
|
2009-06-24 21:49:37 +00:00
|
|
|
_toRedrawRight - _toRedrawLeft + 1,
|
|
|
|
_toRedrawBottom - _toRedrawTop + 1);
|
2007-03-20 14:51:57 +00:00
|
|
|
|
|
|
|
*_pCaptureCounter = *_pCaptureCounter + 1;
|
|
|
|
}
|
|
|
|
|
2009-06-24 21:49:37 +00:00
|
|
|
pictPtr = _animations[animation].pieces;
|
2007-03-20 14:51:57 +00:00
|
|
|
framePtr = layerPtr->frames;
|
|
|
|
|
|
|
|
for (i = 0; i < frame; i++, framePtr++)
|
|
|
|
while (framePtr->notFinal == 1)
|
|
|
|
framePtr++;
|
|
|
|
|
|
|
|
if (flags & 4) {
|
2009-06-24 21:49:37 +00:00
|
|
|
_toRedrawLeft = MAX(_toRedrawLeft, _vm->_mult->_animLeft);
|
|
|
|
_toRedrawTop = MAX(_toRedrawTop, _vm->_mult->_animTop);
|
|
|
|
_toRedrawRight = MIN(_toRedrawRight,
|
2007-03-20 14:51:57 +00:00
|
|
|
(int16)(_vm->_mult->_animLeft + _vm->_mult->_animWidth - 1));
|
|
|
|
_toRedrawBottom = MIN(_toRedrawBottom,
|
|
|
|
(int16)(_vm->_mult->_animTop + _vm->_mult->_animHeight - 1));
|
|
|
|
} else
|
|
|
|
_toRedrawLeft = -12345;
|
|
|
|
|
|
|
|
transp = layerPtr->transp ? 3 : 0;
|
|
|
|
|
|
|
|
framePtr--;
|
|
|
|
do {
|
|
|
|
framePtr++;
|
|
|
|
|
|
|
|
pieceIndex = framePtr->pieceIndex;
|
|
|
|
pictIndex = framePtr->pictIndex;
|
|
|
|
|
|
|
|
destX = framePtr->destX;
|
|
|
|
destY = framePtr->destY;
|
|
|
|
|
|
|
|
highX = pictIndex & 0xC0;
|
|
|
|
highY = pictIndex & 0x30;
|
|
|
|
highX >>= 6;
|
|
|
|
highY >>= 4;
|
|
|
|
if (destX >= 0)
|
|
|
|
destX += ((uint16)highX) << 7;
|
|
|
|
else
|
|
|
|
destX -= ((uint16)highX) << 7;
|
|
|
|
|
|
|
|
if (destY >= 0)
|
|
|
|
destY += ((uint16)highY) << 7;
|
|
|
|
else
|
|
|
|
destY -= ((uint16)highY) << 7;
|
|
|
|
|
|
|
|
if (drawDeltaX == 1000)
|
|
|
|
destX += layerPtr->posX;
|
|
|
|
else
|
|
|
|
destX += drawDeltaX;
|
|
|
|
|
|
|
|
if (drawDeltaY == 1000)
|
|
|
|
destY += layerPtr->posY;
|
|
|
|
else
|
|
|
|
destY += drawDeltaY;
|
|
|
|
|
|
|
|
pictIndex = (pictIndex & 15) - 1;
|
|
|
|
|
2008-05-26 15:29:12 +00:00
|
|
|
if (pictIndex >= _animPictCount[animation])
|
|
|
|
continue;
|
2008-04-27 03:19:19 +00:00
|
|
|
|
2008-05-26 15:29:12 +00:00
|
|
|
if (!pictPtr[pictIndex])
|
2008-04-27 03:19:19 +00:00
|
|
|
continue;
|
|
|
|
|
2008-05-26 15:29:12 +00:00
|
|
|
if (pieceIndex >= _animations[animation].piecesCount[pictIndex])
|
|
|
|
continue;
|
|
|
|
|
|
|
|
left = pictPtr[pictIndex][pieceIndex].left;
|
|
|
|
right = pictPtr[pictIndex][pieceIndex].right;
|
|
|
|
top = pictPtr[pictIndex][pieceIndex].top;
|
|
|
|
bottom = pictPtr[pictIndex][pieceIndex].bottom;
|
2007-03-20 14:51:57 +00:00
|
|
|
|
|
|
|
if (flags & 2) {
|
|
|
|
if (destX < _vm->_mult->_animLeft) {
|
|
|
|
left += _vm->_mult->_animLeft - destX;
|
|
|
|
destX = _vm->_mult->_animLeft;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((left <= right) && ((destX + right - left) >=
|
|
|
|
(_vm->_mult->_animLeft + _vm->_mult->_animWidth)))
|
|
|
|
right -= (destX + right - left) -
|
|
|
|
(_vm->_mult->_animLeft + _vm->_mult->_animWidth) + 1;
|
|
|
|
|
|
|
|
if (destY < _vm->_mult->_animTop) {
|
2009-06-24 21:49:37 +00:00
|
|
|
top += _vm->_mult->_animTop - destY;
|
2007-03-20 14:51:57 +00:00
|
|
|
destY = _vm->_mult->_animTop;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((top <= bottom) && ((destY + bottom - top) >=
|
|
|
|
(_vm->_mult->_animTop + _vm->_mult->_animHeight)))
|
|
|
|
bottom -= (destY + bottom - top) -
|
|
|
|
(_vm->_mult->_animTop + _vm->_mult->_animHeight) + 1;
|
|
|
|
|
|
|
|
} else if (flags & 4) {
|
|
|
|
if (destX < _toRedrawLeft) {
|
|
|
|
left += _toRedrawLeft - destX;
|
|
|
|
destX = _toRedrawLeft;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((left <= right) && ((destX + right - left) > _toRedrawRight))
|
|
|
|
right -= destX + right - left - _toRedrawRight;
|
|
|
|
|
|
|
|
if (destY < _toRedrawTop) {
|
2009-06-24 21:49:37 +00:00
|
|
|
top += _toRedrawTop - destY;
|
2007-03-20 14:51:57 +00:00
|
|
|
destY = _toRedrawTop;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((top <= bottom) && ((destY + bottom - top) > _toRedrawBottom))
|
|
|
|
bottom -= destY + bottom - top - _toRedrawBottom;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((left > right) || (top > bottom))
|
|
|
|
continue;
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
if (doDraw) {
|
|
|
|
_vm->_draw->_sourceSurface =
|
|
|
|
_animPictToSprite[animation * 7 + pictIndex];
|
2010-08-08 00:35:18 +00:00
|
|
|
_vm->_draw->_destSurface = Draw::kBackSurface;
|
2007-03-20 14:51:57 +00:00
|
|
|
|
2009-06-24 21:49:37 +00:00
|
|
|
_vm->_draw->_spriteLeft = left;
|
|
|
|
_vm->_draw->_spriteTop = top;
|
|
|
|
_vm->_draw->_spriteRight = right - left + 1;
|
2007-03-20 14:51:57 +00:00
|
|
|
_vm->_draw->_spriteBottom = bottom - top + 1;
|
2009-06-24 21:49:37 +00:00
|
|
|
_vm->_draw->_destSpriteX = destX;
|
|
|
|
_vm->_draw->_destSpriteY = destY;
|
2007-03-20 14:51:57 +00:00
|
|
|
_vm->_draw->_transparency = transp;
|
|
|
|
_vm->_draw->spriteOperation(DRAW_BLITSURF);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(flags & 4)) {
|
|
|
|
if (_toRedrawLeft == -12345) {
|
2009-06-24 21:49:37 +00:00
|
|
|
_toRedrawLeft = destX;
|
|
|
|
_animLeft = destX;
|
|
|
|
_toRedrawTop = destY;
|
|
|
|
_animTop = destY;
|
|
|
|
_toRedrawRight = destX + right - left;
|
|
|
|
_animRight = destX + right - left;
|
2007-03-20 14:51:57 +00:00
|
|
|
_toRedrawBottom = destY + bottom - top;
|
2009-06-24 21:49:37 +00:00
|
|
|
_animBottom = destY + bottom - top;
|
2007-03-20 14:51:57 +00:00
|
|
|
} else {
|
2009-06-24 21:49:37 +00:00
|
|
|
_toRedrawLeft = MIN(_toRedrawLeft, destX);
|
|
|
|
_toRedrawTop = MIN(_toRedrawTop, destY);
|
|
|
|
_toRedrawRight =
|
|
|
|
MAX(_toRedrawRight, (int16)(destX + right - left));
|
2007-03-20 14:51:57 +00:00
|
|
|
_toRedrawBottom =
|
|
|
|
MAX(_toRedrawBottom, (int16)(destY + bottom - top));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} while (framePtr->notFinal == 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Scenery::writeAnimLayerInfo(uint16 index, uint16 layer,
|
|
|
|
int16 varDX, int16 varDY, int16 varUnk0, int16 varFrames) {
|
|
|
|
|
|
|
|
assert(index < 10);
|
|
|
|
|
2010-08-22 23:11:29 +00:00
|
|
|
// WORKAROUND - Fascination Hebrew is using scripts from the CD versions, but of course
|
|
|
|
// no CD track, so the anim syncing failed, and the anims were suppressed. But they
|
|
|
|
// didn't updated the scripts. Skipping the wrong anims is a solution.
|
|
|
|
if ((_vm->getGameType() == kGameTypeFascination) && (layer >= _animations[index].layersCount)) {
|
|
|
|
WRITE_VAR_OFFSET(varDX, 0);
|
|
|
|
WRITE_VAR_OFFSET(varDY, 0);
|
|
|
|
WRITE_VAR_OFFSET(varUnk0, 0);
|
|
|
|
WRITE_VAR_OFFSET(varFrames, 0);
|
|
|
|
} else {
|
|
|
|
assert(layer < _animations[index].layersCount);
|
|
|
|
|
|
|
|
AnimLayer &animLayer = _animations[index].layers[layer];
|
|
|
|
WRITE_VAR_OFFSET(varDX, animLayer.animDeltaX);
|
|
|
|
WRITE_VAR_OFFSET(varDY, animLayer.animDeltaY);
|
|
|
|
WRITE_VAR_OFFSET(varUnk0, animLayer.unknown0);
|
|
|
|
WRITE_VAR_OFFSET(varFrames, animLayer.framesCount);
|
|
|
|
}
|
2007-03-20 14:51:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int16 Scenery::getStaticLayersCount(uint16 index) {
|
|
|
|
assert(index < 10);
|
|
|
|
|
|
|
|
return _statics[index].layersCount;
|
|
|
|
}
|
|
|
|
|
|
|
|
int16 Scenery::getAnimLayersCount(uint16 index) {
|
|
|
|
assert(index < 10);
|
|
|
|
|
|
|
|
return _animations[index].layersCount;
|
|
|
|
}
|
|
|
|
|
|
|
|
Scenery::StaticLayer *Scenery::getStaticLayer(uint16 index, uint16 layer) {
|
|
|
|
assert(index < 10);
|
|
|
|
assert(layer < _statics[index].layersCount);
|
|
|
|
|
|
|
|
return &_statics[index].layers[layer];
|
|
|
|
}
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
Scenery::AnimLayer *Scenery::getAnimLayer(uint16 index, uint16 layer) {
|
|
|
|
assert(index < 10);
|
|
|
|
assert(layer < _animations[index].layersCount);
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
return &_animations[index].layers[layer];
|
2005-04-05 15:07:40 +00:00
|
|
|
}
|
|
|
|
|
2008-05-26 15:29:12 +00:00
|
|
|
void Scenery::loadPieces(int16 pictDescId, PieceDesc *&pieceDesc, uint32 &piecesCount) {
|
2009-06-24 21:49:37 +00:00
|
|
|
Resource *resource = _vm->_game->_resources->getResource(pictDescId);
|
|
|
|
if (!resource) {
|
|
|
|
warning("Scenery::loadPieces(): Can't load %d", pictDescId);
|
|
|
|
return;
|
2008-05-26 15:29:12 +00:00
|
|
|
}
|
|
|
|
|
2009-06-24 21:49:37 +00:00
|
|
|
piecesCount = resource->getSize() / 8;
|
2008-05-26 15:29:12 +00:00
|
|
|
pieceDesc = new PieceDesc[piecesCount];
|
|
|
|
|
|
|
|
for (uint32 i = 0; i < piecesCount; i++) {
|
2009-06-24 21:49:37 +00:00
|
|
|
pieceDesc[i].left = resource->stream()->readSint16LE();
|
|
|
|
pieceDesc[i].right = resource->stream()->readSint16LE();
|
|
|
|
pieceDesc[i].top = resource->stream()->readSint16LE();
|
|
|
|
pieceDesc[i].bottom = resource->stream()->readSint16LE();
|
2008-05-26 15:29:12 +00:00
|
|
|
}
|
2009-06-25 10:54:35 +00:00
|
|
|
|
|
|
|
delete resource;
|
2008-05-26 15:29:12 +00:00
|
|
|
}
|
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
} // End of namespace Gob
|