2005-02-20 10:56:59 +00:00
|
|
|
/* ScummVM - Scumm Interpreter
|
|
|
|
* Copyright (C) 2001 Ludvig Strigeus
|
|
|
|
* Copyright (C) 2001-2005 The ScummVM project
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*
|
|
|
|
* $Header$
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "stdafx.h"
|
|
|
|
|
|
|
|
#include "scumm/intern.h"
|
|
|
|
#include "scumm/resource.h"
|
2005-04-08 23:27:36 +00:00
|
|
|
#include "scumm/saveload.h"
|
2005-02-20 10:56:59 +00:00
|
|
|
#include "scumm/scumm.h"
|
|
|
|
#include "scumm/sprite_he.h"
|
2005-04-02 14:24:43 +00:00
|
|
|
#include "scumm/usage_bits.h"
|
2005-04-10 12:59:17 +00:00
|
|
|
#include "scumm/util.h"
|
2005-02-20 10:56:59 +00:00
|
|
|
#include "scumm/wiz_he.h"
|
|
|
|
|
|
|
|
namespace Scumm {
|
|
|
|
|
2005-02-20 13:07:57 +00:00
|
|
|
void ScummEngine_v90he::allocateArrays() {
|
|
|
|
ScummEngine::allocateArrays();
|
2005-02-26 10:59:50 +00:00
|
|
|
spritesAllocTables(_numSprites, MAX(64, _numSprites / 4), 64);
|
2005-02-20 13:07:57 +00:00
|
|
|
}
|
|
|
|
|
2005-03-31 02:28:14 +00:00
|
|
|
void ScummEngine_v90he::getSpriteBounds(int spriteId, bool checkGroup, Common::Rect &bound) {
|
|
|
|
checkRange(_varNumSprites, 1, spriteId, "Invalid sprite %d");
|
|
|
|
int16 spr_wiz_x, spr_wiz_y;
|
2005-04-01 12:43:13 +00:00
|
|
|
int angle, zoom, x1, y1;
|
2005-03-31 02:28:14 +00:00
|
|
|
int32 w, h;
|
|
|
|
|
|
|
|
SpriteInfo *spi = &_spriteTable[spriteId];
|
|
|
|
|
2005-04-01 12:43:13 +00:00
|
|
|
loadImgSpot(spi->resId, spi->resState, spr_wiz_x, spr_wiz_y);
|
|
|
|
if (checkGroup && spi->groupNum) {
|
|
|
|
SpriteGroup *spg = &_spriteGroups[spi->groupNum];
|
2005-03-31 02:28:14 +00:00
|
|
|
|
|
|
|
if (spg->scaling) {
|
2005-04-15 08:34:18 +00:00
|
|
|
x1 = spi->tx * spg->scale_x_ratio_mul / spg->scale_x_ratio_div - spr_wiz_x + spg->tx;
|
|
|
|
y1 = spi->ty * spg->scale_y_ratio_mul / spg->scale_y_ratio_div - spr_wiz_y + spg->ty;
|
2005-03-31 02:28:14 +00:00
|
|
|
} else {
|
|
|
|
x1 = spi->tx - spr_wiz_x + spg->tx;
|
|
|
|
y1 = spi->ty - spr_wiz_y + spg->ty;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
x1 = spi->tx - spr_wiz_x;
|
|
|
|
y1 = spi->ty - spr_wiz_y;
|
|
|
|
}
|
|
|
|
|
2005-04-01 12:43:13 +00:00
|
|
|
if (spi->resId) {
|
|
|
|
angle = spi->angle;
|
2005-03-31 02:28:14 +00:00
|
|
|
zoom = spi->zoom;
|
2005-04-01 12:43:13 +00:00
|
|
|
getWizImageDim(spi->resId, spi->resState, w, h);
|
2005-03-31 02:28:14 +00:00
|
|
|
if (!(spi->flags & (kSFZoomed | kSFRotated))) {
|
|
|
|
bound.left = x1;
|
|
|
|
bound.top = y1;
|
|
|
|
bound.right = x1 + w;
|
|
|
|
bound.bottom = y1 + h;
|
|
|
|
} else {
|
|
|
|
Common::Point pts[4];
|
|
|
|
|
|
|
|
pts[1].x = pts[2].x = w / 2 - 1;
|
|
|
|
pts[0].x = pts[0].y = pts[1].y = pts[3].x = -w / 2;
|
|
|
|
pts[2].y = pts[3].y = h / 2 - 1;
|
|
|
|
|
|
|
|
if ((spi->flags & kSFZoomed) && zoom) {
|
|
|
|
for (int j = 0; j < 4; ++j) {
|
|
|
|
pts[j].x = pts[j].x * zoom / 256;
|
|
|
|
pts[j].y = pts[j].y * zoom / 256;
|
|
|
|
}
|
|
|
|
}
|
2005-04-01 12:43:13 +00:00
|
|
|
if ((spi->flags & kSFRotated) && angle)
|
|
|
|
_wiz.polygonRotatePoints(pts, 4, angle);
|
2005-03-31 02:28:14 +00:00
|
|
|
|
|
|
|
for (int j = 0; j < 4; ++j) {
|
|
|
|
pts[j].x += x1;
|
|
|
|
pts[j].y += y1;
|
|
|
|
}
|
|
|
|
|
|
|
|
_wiz.polygonCalcBoundBox(pts, 4, bound);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
bound.left = 1234;
|
|
|
|
bound.top = 1234;
|
|
|
|
bound.right = -1234;
|
|
|
|
bound.bottom = -1234;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-02-21 01:08:48 +00:00
|
|
|
//
|
|
|
|
// spriteInfoGet functions
|
|
|
|
//
|
2005-03-29 09:24:41 +00:00
|
|
|
int ScummEngine_v90he::findSpriteWithClassOf(int x_pos, int y_pos, int spriteGroupId, int type, int num, int *args) {
|
|
|
|
bool cond;
|
2005-03-07 14:08:08 +00:00
|
|
|
int code, classId, x, y;
|
2005-03-29 09:24:41 +00:00
|
|
|
debug(1, "findSprite: x %d, y %d, spriteGroup %d, type %d, num %d", x_pos, y_pos, spriteGroupId, type, num);
|
2005-02-25 15:19:03 +00:00
|
|
|
|
2005-03-07 21:58:47 +00:00
|
|
|
for (int i = (_numSpritesToProcess - 1); i >= 0; i--) {
|
2005-02-25 15:19:03 +00:00
|
|
|
SpriteInfo *spi = _activeSpritesTable[i];
|
2005-04-01 12:43:13 +00:00
|
|
|
if (!spi->curResId)
|
2005-02-25 15:19:03 +00:00
|
|
|
continue;
|
|
|
|
|
2005-04-01 12:43:13 +00:00
|
|
|
if (spriteGroupId && spi->groupNum != spriteGroupId)
|
2005-02-25 15:19:03 +00:00
|
|
|
continue;
|
|
|
|
|
2005-03-29 09:24:41 +00:00
|
|
|
cond = true;
|
2005-02-25 15:19:03 +00:00
|
|
|
for (int j = 0; j < num; j++) {
|
2005-03-06 02:03:18 +00:00
|
|
|
code = classId = args[j];
|
|
|
|
classId &= 0x7F;
|
2005-02-25 15:19:03 +00:00
|
|
|
checkRange(32, 1, classId, "class %d out of range in statement");
|
2005-03-06 02:03:18 +00:00
|
|
|
if (code & 0x80) {
|
2005-04-01 12:43:13 +00:00
|
|
|
if (!(spi->classFlags & (1 << (classId - 1))))
|
2005-03-29 09:24:41 +00:00
|
|
|
cond = 0;
|
2005-03-06 02:03:18 +00:00
|
|
|
} else {
|
2005-04-01 12:43:13 +00:00
|
|
|
if ((spi->classFlags & (1 << (classId - 1))))
|
2005-03-29 09:24:41 +00:00
|
|
|
cond = 0;
|
2005-03-06 02:03:18 +00:00
|
|
|
}
|
2005-02-25 15:19:03 +00:00
|
|
|
}
|
2005-03-29 09:24:41 +00:00
|
|
|
if (!cond)
|
|
|
|
continue;
|
2005-02-25 15:19:03 +00:00
|
|
|
|
2005-03-29 09:24:41 +00:00
|
|
|
if (type) {
|
2005-02-25 15:19:03 +00:00
|
|
|
if (spi->bbox.left > spi->bbox.right)
|
|
|
|
continue;
|
|
|
|
if (spi->bbox.top > spi->bbox.bottom)
|
|
|
|
continue;
|
2005-03-07 14:08:08 +00:00
|
|
|
if (spi->bbox.left > x_pos)
|
2005-02-25 15:19:03 +00:00
|
|
|
continue;
|
2005-03-07 14:08:08 +00:00
|
|
|
if (spi->bbox.top > y_pos)
|
2005-02-25 15:19:03 +00:00
|
|
|
continue;
|
2005-03-07 14:08:08 +00:00
|
|
|
if (spi->bbox.right < x_pos)
|
2005-02-25 15:19:03 +00:00
|
|
|
continue;
|
2005-03-07 14:08:08 +00:00
|
|
|
if (spi->bbox.bottom < y_pos)
|
2005-02-25 15:19:03 +00:00
|
|
|
continue;
|
2005-03-07 11:34:23 +00:00
|
|
|
return spi->id;
|
2005-02-25 15:19:03 +00:00
|
|
|
} else {
|
2005-04-01 12:43:13 +00:00
|
|
|
int resId, resState, angle, zoom;
|
2005-02-25 23:37:25 +00:00
|
|
|
int32 w, h;
|
2005-02-25 15:19:03 +00:00
|
|
|
|
2005-04-01 12:43:13 +00:00
|
|
|
resId = spi->curResId;
|
2005-02-25 15:19:03 +00:00
|
|
|
if (spi->field_80) {
|
|
|
|
int16 x1, x2, y1, y2;
|
|
|
|
|
2005-04-01 12:43:13 +00:00
|
|
|
resState = spi->curImageState / getWizImageStates(spi->field_80);
|
2005-02-25 15:19:03 +00:00
|
|
|
|
2005-03-07 14:08:08 +00:00
|
|
|
x = x_pos - spi->pos.x;
|
|
|
|
y = y_pos - spi->pos.y;
|
2005-02-25 15:19:03 +00:00
|
|
|
|
2005-04-01 12:43:13 +00:00
|
|
|
loadImgSpot(spi->curResId, resState, x1, y1);
|
|
|
|
loadImgSpot(spi->field_80, resState, x2, y2);
|
2005-02-25 15:19:03 +00:00
|
|
|
|
|
|
|
x += (x2 - x1);
|
|
|
|
y += (y2 - y1);
|
|
|
|
} else {
|
|
|
|
if (spi->bbox.left > spi->bbox.right)
|
|
|
|
continue;
|
|
|
|
if (spi->bbox.top > spi->bbox.bottom)
|
|
|
|
continue;
|
2005-03-07 14:08:08 +00:00
|
|
|
if (spi->bbox.left > x_pos)
|
2005-02-25 15:19:03 +00:00
|
|
|
continue;
|
2005-03-07 14:08:08 +00:00
|
|
|
if (spi->bbox.top > y_pos)
|
2005-02-25 15:19:03 +00:00
|
|
|
continue;
|
2005-03-07 14:08:08 +00:00
|
|
|
if (spi->bbox.right < x_pos)
|
2005-02-25 15:19:03 +00:00
|
|
|
continue;
|
2005-03-07 14:08:08 +00:00
|
|
|
if (spi->bbox.bottom < y_pos)
|
2005-02-25 15:19:03 +00:00
|
|
|
continue;
|
|
|
|
|
2005-03-07 14:08:08 +00:00
|
|
|
x = x_pos - spi->pos.x;
|
|
|
|
y = y_pos - spi->pos.y;
|
2005-04-01 12:43:13 +00:00
|
|
|
resState = spi->curImageState;
|
2005-02-25 15:19:03 +00:00
|
|
|
}
|
|
|
|
|
2005-04-01 12:43:13 +00:00
|
|
|
angle = spi->curAngle;
|
2005-04-03 02:24:28 +00:00
|
|
|
zoom = spi->curZoom;
|
2005-02-25 15:19:03 +00:00
|
|
|
if ((spi->flags & kSFZoomed) || (spi->flags & kSFRotated)) {
|
2005-02-25 23:37:25 +00:00
|
|
|
if (spi->flags & kSFZoomed && zoom) {
|
|
|
|
x = x * 256 / zoom;
|
|
|
|
y = y * 256 / zoom;
|
|
|
|
}
|
2005-04-01 12:43:13 +00:00
|
|
|
if (spi->flags & kSFRotated && angle) {
|
|
|
|
angle = (360 - angle) % 360;
|
2005-02-25 23:37:25 +00:00
|
|
|
Common::Point pts[1];
|
2005-04-01 12:43:13 +00:00
|
|
|
_wiz.polygonRotatePoints(pts, 1, angle);
|
2005-02-25 23:37:25 +00:00
|
|
|
}
|
2005-02-25 15:19:03 +00:00
|
|
|
|
2005-04-01 12:43:13 +00:00
|
|
|
getWizImageDim(resId, resState, w, h);
|
2005-02-25 23:37:25 +00:00
|
|
|
x += w / 2;
|
|
|
|
y += h / 2;
|
2005-02-25 15:19:03 +00:00
|
|
|
}
|
|
|
|
|
2005-05-08 21:49:52 +00:00
|
|
|
if (isWizPixelNonTransparent(resId, resState, x, y, spi->curImgFlags))
|
2005-03-07 11:34:23 +00:00
|
|
|
return spi->id;
|
2005-02-25 15:19:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-02-22 01:25:53 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-03-28 11:38:04 +00:00
|
|
|
int ScummEngine_v90he::spriteInfoGet_classFlags(int spriteId, int num, int *args) {
|
2005-02-22 01:25:53 +00:00
|
|
|
checkRange(_varNumSprites, 1, spriteId, "Invalid sprite %d");
|
2005-03-06 02:03:18 +00:00
|
|
|
int code, classId;
|
2005-02-24 08:26:58 +00:00
|
|
|
|
2005-03-28 11:38:04 +00:00
|
|
|
if (num == 0)
|
2005-04-01 12:43:13 +00:00
|
|
|
return _spriteTable[spriteId].classFlags;
|
2005-02-23 12:26:17 +00:00
|
|
|
|
|
|
|
for (int i = 0; i < num; i++) {
|
2005-03-06 02:03:18 +00:00
|
|
|
code = classId = args[i];
|
|
|
|
classId &= 0x7F;
|
2005-02-24 08:26:58 +00:00
|
|
|
checkRange(32, 1, classId, "class %d out of range in statement");
|
2005-03-06 02:03:18 +00:00
|
|
|
if (code & 0x80) {
|
2005-04-01 12:43:13 +00:00
|
|
|
if (!(_spriteTable[spriteId].classFlags & (1 << (classId - 1))))
|
2005-03-06 02:03:18 +00:00
|
|
|
return 0;
|
|
|
|
} else {
|
2005-04-01 12:43:13 +00:00
|
|
|
if ((_spriteTable[spriteId].classFlags & (1 << (classId - 1))))
|
2005-03-06 02:03:18 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2005-02-23 12:04:42 +00:00
|
|
|
}
|
|
|
|
|
2005-02-23 12:26:17 +00:00
|
|
|
return 1;
|
2005-02-22 01:25:53 +00:00
|
|
|
}
|
|
|
|
|
2005-03-29 14:11:08 +00:00
|
|
|
int ScummEngine_v90he::spriteInfoGet_flagDoubleBuffered(int spriteId) {
|
2005-02-22 01:25:53 +00:00
|
|
|
checkRange(_varNumSprites, 1, spriteId, "Invalid sprite %d");
|
2005-02-20 13:07:57 +00:00
|
|
|
|
2005-03-24 03:47:54 +00:00
|
|
|
return ((_spriteTable[spriteId].flags & kSFDoubleBuffered) != 0) ? 1 : 0;
|
2005-02-20 13:07:57 +00:00
|
|
|
}
|
|
|
|
|
2005-03-13 13:10:39 +00:00
|
|
|
int ScummEngine_v90he::spriteInfoGet_flagYFlipped(int spriteId) {
|
2005-02-22 01:25:53 +00:00
|
|
|
checkRange(_varNumSprites, 1, spriteId, "Invalid sprite %d");
|
2005-02-20 13:07:57 +00:00
|
|
|
|
2005-03-13 13:10:39 +00:00
|
|
|
return ((_spriteTable[spriteId].flags & kSFYFlipped) != 0) ? 1 : 0;
|
2005-02-20 13:07:57 +00:00
|
|
|
}
|
|
|
|
|
2005-03-13 13:10:39 +00:00
|
|
|
int ScummEngine_v90he::spriteInfoGet_flagXFlipped(int spriteId) {
|
2005-02-22 01:25:53 +00:00
|
|
|
checkRange(_varNumSprites, 1, spriteId, "Invalid sprite %d");
|
2005-02-20 13:07:57 +00:00
|
|
|
|
2005-03-13 13:10:39 +00:00
|
|
|
return ((_spriteTable[spriteId].flags & kSFXFlipped) != 0) ? 1 : 0;
|
2005-02-20 13:07:57 +00:00
|
|
|
}
|
|
|
|
|
2005-02-24 21:05:29 +00:00
|
|
|
int ScummEngine_v90he::spriteInfoGet_flagActive(int spriteId) {
|
2005-02-22 01:25:53 +00:00
|
|
|
checkRange(_varNumSprites, 1, spriteId, "Invalid sprite %d");
|
2005-02-20 13:07:57 +00:00
|
|
|
|
2005-02-24 21:05:29 +00:00
|
|
|
return ((_spriteTable[spriteId].flags & kSFActive) != 0) ? 1 : 0;
|
2005-02-20 13:07:57 +00:00
|
|
|
}
|
|
|
|
|
2005-03-29 14:11:08 +00:00
|
|
|
int ScummEngine_v90he::spriteInfoGet_flagNeedPaletteRemap(int spriteId) {
|
2005-02-22 01:25:53 +00:00
|
|
|
checkRange(_varNumSprites, 1, spriteId, "Invalid sprite %d");
|
2005-02-20 13:07:57 +00:00
|
|
|
|
2005-03-24 03:47:54 +00:00
|
|
|
return ((_spriteTable[spriteId].flags & kSFNeedPaletteRemap) != 0) ? 1 : 0;
|
2005-02-20 13:07:57 +00:00
|
|
|
}
|
|
|
|
|
2005-04-03 02:24:28 +00:00
|
|
|
int ScummEngine_v90he::spriteInfoGet_flagDelayed(int spriteId) {
|
2005-02-22 01:25:53 +00:00
|
|
|
checkRange(_varNumSprites, 1, spriteId, "Invalid sprite %d");
|
2005-02-20 13:07:57 +00:00
|
|
|
|
2005-03-24 03:47:54 +00:00
|
|
|
return ((_spriteTable[spriteId].flags & kSFDelayed) != 0) ? 1 : 0;
|
2005-02-20 13:07:57 +00:00
|
|
|
}
|
|
|
|
|
2005-04-01 06:30:46 +00:00
|
|
|
int ScummEngine_v90he::spriteInfoGet_flagMarkDirty(int spriteId) {
|
2005-02-22 01:25:53 +00:00
|
|
|
checkRange(_varNumSprites, 1, spriteId, "Invalid sprite %d");
|
2005-02-20 13:07:57 +00:00
|
|
|
|
2005-04-01 06:30:46 +00:00
|
|
|
return ((_spriteTable[spriteId].flags & kSFMarkDirty) != 0) ? 1 : 0;
|
2005-02-20 13:07:57 +00:00
|
|
|
}
|
|
|
|
|
2005-02-26 11:05:13 +00:00
|
|
|
int ScummEngine_v90he::spriteInfoGet_flagHasImage(int spriteId) {
|
2005-02-22 01:25:53 +00:00
|
|
|
checkRange(_varNumSprites, 1, spriteId, "Invalid sprite %d");
|
2005-02-20 13:07:57 +00:00
|
|
|
|
2005-02-26 11:05:13 +00:00
|
|
|
return ((_spriteTable[spriteId].flags & kSFImageless) != 0) ? 1 : 0;
|
2005-02-20 13:07:57 +00:00
|
|
|
}
|
|
|
|
|
2005-02-21 00:34:00 +00:00
|
|
|
int ScummEngine_v90he::spriteInfoGet_resId(int spriteId) {
|
2005-02-22 01:25:53 +00:00
|
|
|
checkRange(_varNumSprites, 1, spriteId, "Invalid sprite %d");
|
2005-02-20 23:30:37 +00:00
|
|
|
|
2005-04-01 12:43:13 +00:00
|
|
|
return _spriteTable[spriteId].resId;
|
2005-02-20 23:30:37 +00:00
|
|
|
}
|
|
|
|
|
2005-02-21 00:34:00 +00:00
|
|
|
int ScummEngine_v90he::spriteInfoGet_resState(int spriteId) {
|
2005-02-22 01:25:53 +00:00
|
|
|
checkRange(_varNumSprites, 1, spriteId, "Invalid sprite %d");
|
2005-02-20 23:30:37 +00:00
|
|
|
|
2005-04-01 12:43:13 +00:00
|
|
|
return _spriteTable[spriteId].resState;
|
2005-02-20 23:30:37 +00:00
|
|
|
}
|
|
|
|
|
2005-02-21 00:34:00 +00:00
|
|
|
int ScummEngine_v90he::spriteInfoGet_groupNum(int spriteId) {
|
2005-02-22 01:25:53 +00:00
|
|
|
checkRange(_varNumSprites, 1, spriteId, "Invalid sprite %d");
|
2005-02-20 23:30:37 +00:00
|
|
|
|
2005-04-01 12:43:13 +00:00
|
|
|
return _spriteTable[spriteId].groupNum;
|
2005-02-20 23:30:37 +00:00
|
|
|
}
|
|
|
|
|
2005-03-31 22:51:54 +00:00
|
|
|
int ScummEngine_v90he::spriteInfoGet_paletteNum(int spriteId) {
|
2005-02-22 01:25:53 +00:00
|
|
|
checkRange(_varNumSprites, 1, spriteId, "Invalid sprite %d");
|
2005-02-21 04:53:34 +00:00
|
|
|
|
2005-03-31 22:51:54 +00:00
|
|
|
return _spriteTable[spriteId].paletteNum;
|
2005-02-21 04:53:34 +00:00
|
|
|
}
|
|
|
|
|
2005-03-14 12:54:24 +00:00
|
|
|
int ScummEngine_v90he::spriteInfoGet_zorderPriority(int spriteId) {
|
2005-02-22 01:25:53 +00:00
|
|
|
checkRange(_varNumSprites, 1, spriteId, "Invalid sprite %d");
|
2005-02-20 23:30:37 +00:00
|
|
|
|
2005-03-14 12:54:24 +00:00
|
|
|
return _spriteTable[spriteId].zorderPriority;
|
2005-02-20 23:30:37 +00:00
|
|
|
}
|
|
|
|
|
2005-02-21 00:34:00 +00:00
|
|
|
int ScummEngine_v90he::spriteInfoGet_grp_tx(int spriteId) {
|
2005-02-22 01:25:53 +00:00
|
|
|
checkRange(_varNumSprites, 1, spriteId, "Invalid sprite %d");
|
2005-02-20 23:30:37 +00:00
|
|
|
|
2005-04-01 12:43:13 +00:00
|
|
|
if (_spriteTable[spriteId].groupNum)
|
|
|
|
return _spriteTable[spriteId].tx + _spriteGroups[_spriteTable[spriteId].groupNum].tx;
|
2005-02-21 00:25:30 +00:00
|
|
|
else
|
2005-02-21 00:34:00 +00:00
|
|
|
return _spriteTable[spriteId].tx;
|
2005-02-20 23:30:37 +00:00
|
|
|
}
|
|
|
|
|
2005-02-21 00:34:00 +00:00
|
|
|
int ScummEngine_v90he::spriteInfoGet_grp_ty(int spriteId) {
|
2005-02-22 01:25:53 +00:00
|
|
|
checkRange(_varNumSprites, 1, spriteId, "Invalid sprite %d");
|
2005-02-20 23:30:37 +00:00
|
|
|
|
2005-04-01 12:43:13 +00:00
|
|
|
if (_spriteTable[spriteId].groupNum)
|
|
|
|
return _spriteTable[spriteId].ty + _spriteGroups[_spriteTable[spriteId].groupNum].ty;
|
2005-02-21 00:25:30 +00:00
|
|
|
else
|
2005-02-21 00:34:00 +00:00
|
|
|
return _spriteTable[spriteId].ty;
|
2005-02-20 23:30:37 +00:00
|
|
|
}
|
|
|
|
|
2005-02-21 00:34:00 +00:00
|
|
|
int ScummEngine_v90he::spriteInfoGet_field_44(int spriteId) {
|
2005-02-22 01:25:53 +00:00
|
|
|
checkRange(_varNumSprites, 1, spriteId, "Invalid sprite %d");
|
2005-02-20 23:30:37 +00:00
|
|
|
|
2005-02-21 00:34:00 +00:00
|
|
|
return _spriteTable[spriteId].field_44;
|
2005-02-20 23:30:37 +00:00
|
|
|
}
|
|
|
|
|
2005-04-03 02:24:28 +00:00
|
|
|
int ScummEngine_v90he::spriteInfoGet_xmapNum(int spriteId) {
|
2005-02-22 01:25:53 +00:00
|
|
|
checkRange(_varNumSprites, 1, spriteId, "Invalid sprite %d");
|
2005-02-20 23:30:37 +00:00
|
|
|
|
2005-04-01 12:43:13 +00:00
|
|
|
return _spriteTable[spriteId].xmapNum;
|
2005-02-20 23:30:37 +00:00
|
|
|
}
|
|
|
|
|
2005-02-21 00:34:00 +00:00
|
|
|
int ScummEngine_v90he::spriteInfoGet_wizSize(int spriteId) {
|
2005-02-22 01:25:53 +00:00
|
|
|
checkRange(_varNumSprites, 1, spriteId, "Invalid sprite %d");
|
2005-02-20 23:30:37 +00:00
|
|
|
|
2005-02-21 00:34:00 +00:00
|
|
|
return _spriteTable[spriteId].res_wiz_states;
|
2005-02-20 23:30:37 +00:00
|
|
|
}
|
|
|
|
|
2005-02-21 00:34:00 +00:00
|
|
|
int ScummEngine_v90he::spriteInfoGet_zoom(int spriteId) {
|
2005-02-22 01:25:53 +00:00
|
|
|
checkRange(_varNumSprites, 1, spriteId, "Invalid sprite %d");
|
2005-02-20 23:30:37 +00:00
|
|
|
|
2005-02-21 00:34:00 +00:00
|
|
|
return _spriteTable[spriteId].zoom;
|
2005-02-20 23:30:37 +00:00
|
|
|
}
|
|
|
|
|
2005-03-14 12:54:24 +00:00
|
|
|
int ScummEngine_v90he::spriteInfoGet_delayAmount(int spriteId) {
|
2005-02-22 01:25:53 +00:00
|
|
|
checkRange(_varNumSprites, 1, spriteId, "Invalid sprite %d");
|
2005-02-20 23:30:37 +00:00
|
|
|
|
2005-03-14 12:54:24 +00:00
|
|
|
return _spriteTable[spriteId].delayAmount;
|
2005-02-20 23:30:37 +00:00
|
|
|
}
|
|
|
|
|
2005-04-20 05:24:02 +00:00
|
|
|
int ScummEngine_v90he::spriteInfoGet_maskImgResNum(int spriteId) {
|
2005-02-22 01:25:53 +00:00
|
|
|
checkRange(_varNumSprites, 1, spriteId, "Invalid sprite %d");
|
2005-02-21 04:53:34 +00:00
|
|
|
|
2005-04-20 05:24:02 +00:00
|
|
|
return _spriteTable[spriteId].maskImgResNum;
|
2005-02-21 04:53:34 +00:00
|
|
|
}
|
|
|
|
|
2005-02-21 00:34:00 +00:00
|
|
|
int ScummEngine_v90he::spriteInfoGet_field_80(int spriteId) {
|
2005-02-22 01:25:53 +00:00
|
|
|
checkRange(_varNumSprites, 1, spriteId, "Invalid sprite %d");
|
2005-02-20 23:30:37 +00:00
|
|
|
|
2005-02-21 00:34:00 +00:00
|
|
|
return _spriteTable[spriteId].field_80;
|
2005-02-20 23:30:37 +00:00
|
|
|
}
|
|
|
|
|
2005-04-11 07:40:14 +00:00
|
|
|
int ScummEngine_v90he::spriteInfoGet_field_8C_90(int spriteId, int type) {
|
2005-04-20 10:38:13 +00:00
|
|
|
debug(0, "spriteInfoGet_field_8C_90: spriteId %d type 0x%x", spriteId, type);
|
2005-02-23 09:55:34 +00:00
|
|
|
checkRange(_varNumSprites, 1, spriteId, "Invalid sprite %d");
|
|
|
|
|
2005-04-11 07:40:14 +00:00
|
|
|
// XXX U32 related check
|
|
|
|
|
|
|
|
switch(type) {
|
|
|
|
case 0x7B:
|
2005-04-20 10:33:20 +00:00
|
|
|
return _spriteTable[spriteId].imgFlags;
|
2005-04-11 07:40:14 +00:00
|
|
|
case 0x7D:
|
|
|
|
return _spriteTable[spriteId].field_90;
|
|
|
|
case 0x7E:
|
|
|
|
return _spriteTable[spriteId].delayCount;
|
|
|
|
default:
|
|
|
|
error("spriteInfoGet_field_8C_90: Invalid type %d", type);
|
|
|
|
}
|
2005-02-23 09:55:34 +00:00
|
|
|
}
|
|
|
|
|
2005-02-21 00:34:00 +00:00
|
|
|
void ScummEngine_v90he::getSpriteImageDim(int spriteId, int32 &w, int32 &h) {
|
2005-02-22 01:25:53 +00:00
|
|
|
checkRange(_varNumSprites, 1, spriteId, "Invalid sprite %d");
|
2005-02-20 23:55:11 +00:00
|
|
|
|
2005-04-01 12:43:13 +00:00
|
|
|
if (_spriteTable[spriteId].resId) {
|
|
|
|
getWizImageDim(_spriteTable[spriteId].resId, _spriteTable[spriteId].resState, w, h);
|
2005-02-26 04:53:43 +00:00
|
|
|
} else {
|
|
|
|
w = 0;
|
|
|
|
h = 0;
|
|
|
|
}
|
2005-02-20 23:55:11 +00:00
|
|
|
}
|
|
|
|
|
2005-02-21 00:34:00 +00:00
|
|
|
void ScummEngine_v90he::spriteInfoGet_tx_ty(int spriteId, int32 &tx, int32 &ty) {
|
2005-02-22 01:25:53 +00:00
|
|
|
checkRange(_varNumSprites, 1, spriteId, "Invalid sprite %d");
|
2005-02-21 00:25:30 +00:00
|
|
|
|
2005-02-21 00:34:00 +00:00
|
|
|
tx = _spriteTable[spriteId].tx;
|
|
|
|
ty = _spriteTable[spriteId].ty;
|
2005-02-21 00:25:30 +00:00
|
|
|
}
|
|
|
|
|
2005-02-23 04:05:22 +00:00
|
|
|
void ScummEngine_v90he::spriteInfoGet_dx_dy(int spriteId, int32 &dx, int32 &dy) {
|
2005-02-22 01:25:53 +00:00
|
|
|
checkRange(_varNumSprites, 1, spriteId, "Invalid sprite %d");
|
2005-02-21 00:25:30 +00:00
|
|
|
|
2005-02-23 04:05:22 +00:00
|
|
|
dx = _spriteTable[spriteId].dx;
|
|
|
|
dy = _spriteTable[spriteId].dy;
|
2005-02-21 00:25:30 +00:00
|
|
|
}
|
|
|
|
|
2005-02-21 01:08:48 +00:00
|
|
|
//
|
|
|
|
// spriteGroupGet functions
|
|
|
|
//
|
2005-02-21 02:37:05 +00:00
|
|
|
int ScummEngine_v90he::spriteGroupGet_allocateGroupSpritesList(int spriteGroupId) {
|
2005-04-08 07:49:06 +00:00
|
|
|
int i, numSprites = 0;
|
2005-02-23 05:09:14 +00:00
|
|
|
|
2005-02-27 06:07:09 +00:00
|
|
|
checkRange(_varNumSpriteGroups, 1, spriteGroupId, "Invalid sprite group %d");
|
2005-02-21 02:37:05 +00:00
|
|
|
|
2005-04-08 07:49:06 +00:00
|
|
|
for (i = (_varNumSprites - 1); i > 0; i--) {
|
2005-04-01 12:43:13 +00:00
|
|
|
if (_spriteTable[i].groupNum == spriteGroupId)
|
2005-04-08 07:49:06 +00:00
|
|
|
numSprites++;
|
2005-02-23 05:09:14 +00:00
|
|
|
}
|
|
|
|
|
2005-04-08 07:49:06 +00:00
|
|
|
if (!numSprites)
|
2005-02-23 05:09:14 +00:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
writeVar(0, 0);
|
2005-04-08 07:49:06 +00:00
|
|
|
defineArray(0, kDwordArray, 0, 0, 0, numSprites);
|
|
|
|
writeArray(0, 0, 0, numSprites);
|
2005-02-23 05:09:14 +00:00
|
|
|
|
2005-04-08 07:49:06 +00:00
|
|
|
numSprites = 1;
|
2005-02-24 12:22:14 +00:00
|
|
|
for (i = (_varNumSprites - 1); i > 0; i--) {
|
2005-04-08 12:05:15 +00:00
|
|
|
if (_spriteTable[i].groupNum == spriteGroupId) {
|
2005-04-08 07:49:06 +00:00
|
|
|
writeArray(0, 0, numSprites, i);
|
2005-04-08 12:05:15 +00:00
|
|
|
numSprites++;
|
|
|
|
}
|
2005-02-23 05:09:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return readVar(0);
|
2005-02-21 02:37:05 +00:00
|
|
|
}
|
2005-02-21 01:08:48 +00:00
|
|
|
|
2005-02-26 11:22:00 +00:00
|
|
|
int ScummEngine_v90he::spriteGroupGet_zorderPriority(int spriteGroupId) {
|
2005-02-27 06:07:09 +00:00
|
|
|
checkRange(_varNumSpriteGroups, 1, spriteGroupId, "Invalid sprite group %d");
|
2005-02-21 01:08:48 +00:00
|
|
|
|
2005-02-26 11:22:00 +00:00
|
|
|
return _spriteGroups[spriteGroupId].zorderPriority;
|
2005-02-21 01:08:48 +00:00
|
|
|
}
|
|
|
|
|
2005-04-03 02:24:28 +00:00
|
|
|
int ScummEngine_v90he::spriteGroupGet_dstResNum(int spriteGroupId) {
|
2005-02-27 06:07:09 +00:00
|
|
|
checkRange(_varNumSpriteGroups, 1, spriteGroupId, "Invalid sprite group %d");
|
2005-02-21 01:08:48 +00:00
|
|
|
|
2005-04-01 08:51:13 +00:00
|
|
|
return _spriteGroups[spriteGroupId].dstResNum;
|
2005-02-21 01:08:48 +00:00
|
|
|
}
|
|
|
|
|
2005-02-26 11:22:00 +00:00
|
|
|
int ScummEngine_v90he::spriteGroupGet_scale_x_ratio_mul(int spriteGroupId) {
|
2005-02-27 06:07:09 +00:00
|
|
|
checkRange(_varNumSpriteGroups, 1, spriteGroupId, "Invalid sprite group %d");
|
2005-02-21 01:08:48 +00:00
|
|
|
|
2005-02-26 11:22:00 +00:00
|
|
|
return _spriteGroups[spriteGroupId].scale_x_ratio_mul;
|
2005-02-21 01:08:48 +00:00
|
|
|
}
|
|
|
|
|
2005-02-26 11:22:00 +00:00
|
|
|
int ScummEngine_v90he::spriteGroupGet_scale_x_ratio_div(int spriteGroupId) {
|
2005-02-27 06:07:09 +00:00
|
|
|
checkRange(_varNumSpriteGroups, 1, spriteGroupId, "Invalid sprite group %d");
|
2005-02-21 01:08:48 +00:00
|
|
|
|
2005-02-26 11:22:00 +00:00
|
|
|
return _spriteGroups[spriteGroupId].scale_x_ratio_div;
|
2005-02-21 01:08:48 +00:00
|
|
|
}
|
|
|
|
|
2005-02-26 11:22:00 +00:00
|
|
|
int ScummEngine_v90he::spriteGroupGet_scale_y_ratio_mul(int spriteGroupId) {
|
2005-02-27 06:07:09 +00:00
|
|
|
checkRange(_varNumSpriteGroups, 1, spriteGroupId, "Invalid sprite group %d");
|
2005-02-21 01:08:48 +00:00
|
|
|
|
2005-02-26 11:22:00 +00:00
|
|
|
return _spriteGroups[spriteGroupId].scale_y_ratio_mul;
|
2005-02-21 01:08:48 +00:00
|
|
|
}
|
|
|
|
|
2005-02-26 11:22:00 +00:00
|
|
|
int ScummEngine_v90he::spriteGroupGet_scale_y_ratio_div(int spriteGroupId) {
|
2005-02-27 06:07:09 +00:00
|
|
|
checkRange(_varNumSpriteGroups, 1, spriteGroupId, "Invalid sprite group %d");
|
2005-02-21 01:08:48 +00:00
|
|
|
|
2005-02-26 11:22:00 +00:00
|
|
|
return _spriteGroups[spriteGroupId].scale_y_ratio_div;
|
2005-02-21 01:08:48 +00:00
|
|
|
}
|
|
|
|
|
2005-02-21 02:37:05 +00:00
|
|
|
void ScummEngine_v90he::spriteGroupGet_tx_ty(int spriteGroupId, int32 &tx, int32 &ty) {
|
2005-02-27 06:07:09 +00:00
|
|
|
checkRange(_varNumSpriteGroups, 1, spriteGroupId, "Invalid sprite group %d");
|
2005-02-21 01:08:48 +00:00
|
|
|
|
2005-02-21 02:37:05 +00:00
|
|
|
tx = _spriteGroups[spriteGroupId].tx;
|
|
|
|
ty = _spriteGroups[spriteGroupId].ty;
|
2005-02-21 01:08:48 +00:00
|
|
|
}
|
|
|
|
|
2005-02-21 00:02:44 +00:00
|
|
|
//
|
|
|
|
// spriteInfoSet functions
|
|
|
|
//
|
2005-03-31 22:51:54 +00:00
|
|
|
void ScummEngine_v90he::spriteInfoSet_paletteNum(int spriteId, int value) {
|
2005-02-21 00:34:00 +00:00
|
|
|
checkRange(_varNumSprites, 1, spriteId, "Invalid sprite %d");
|
2005-02-21 00:02:44 +00:00
|
|
|
|
2005-03-31 22:51:54 +00:00
|
|
|
if (_spriteTable[spriteId].paletteNum != value) {
|
|
|
|
_spriteTable[spriteId].paletteNum = value;
|
2005-02-24 21:05:29 +00:00
|
|
|
_spriteTable[spriteId].flags |= kSFChanged | kSFNeedRedraw;
|
2005-02-21 00:02:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-04-20 05:24:02 +00:00
|
|
|
void ScummEngine_v90he::spriteInfoSet_maskImgResNum(int spriteId, int value) {
|
2005-02-21 00:34:00 +00:00
|
|
|
checkRange(_varNumSprites, 1, spriteId, "Invalid sprite %d");
|
2005-02-21 00:02:44 +00:00
|
|
|
|
2005-04-20 05:24:02 +00:00
|
|
|
if (_spriteTable[spriteId].maskImgResNum != value) {
|
|
|
|
_spriteTable[spriteId].maskImgResNum = value;
|
2005-02-24 21:05:29 +00:00
|
|
|
_spriteTable[spriteId].flags |= kSFChanged | kSFNeedRedraw;
|
2005-02-21 00:02:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-02-21 00:34:00 +00:00
|
|
|
void ScummEngine_v90he::spriteInfoSet_field_80(int spriteId, int value) {
|
|
|
|
checkRange(_varNumSprites, 1, spriteId, "Invalid sprite %d");
|
2005-02-21 00:02:44 +00:00
|
|
|
|
2005-02-21 00:34:00 +00:00
|
|
|
_spriteTable[spriteId].field_80 = value;
|
2005-02-21 00:02:44 +00:00
|
|
|
}
|
|
|
|
|
2005-02-26 01:39:52 +00:00
|
|
|
void ScummEngine_v90he::spriteInfoSet_resState(int spriteId, int state) {
|
2005-02-21 02:37:05 +00:00
|
|
|
checkRange(_varNumSprites, 1, spriteId, "Invalid sprite %d");
|
2005-02-21 00:59:50 +00:00
|
|
|
|
2005-04-01 12:43:13 +00:00
|
|
|
if (_spriteTable[spriteId].resId) {
|
2005-02-26 01:39:52 +00:00
|
|
|
int res_wiz_states = _spriteTable[spriteId].res_wiz_states - 1;
|
2005-03-11 03:21:43 +00:00
|
|
|
state = MAX(0, state);
|
|
|
|
state = MIN(state, res_wiz_states);
|
2005-02-21 00:59:50 +00:00
|
|
|
|
2005-04-01 12:43:13 +00:00
|
|
|
if (_spriteTable[spriteId].resState != state) {
|
|
|
|
_spriteTable[spriteId].resState = state;
|
2005-02-24 21:05:29 +00:00
|
|
|
_spriteTable[spriteId].flags |= kSFChanged | kSFNeedRedraw;
|
2005-02-21 00:59:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-02-21 02:37:05 +00:00
|
|
|
void ScummEngine_v90he::spriteInfoSet_tx_ty(int spriteId, int value1, int value2) {
|
|
|
|
checkRange(_varNumSprites, 1, spriteId, "Invalid sprite %d");
|
2005-02-21 00:59:50 +00:00
|
|
|
|
2005-02-21 02:37:05 +00:00
|
|
|
if (_spriteTable[spriteId].tx != value1 || _spriteTable[spriteId].ty != value2) {
|
|
|
|
_spriteTable[spriteId].tx = value1;
|
|
|
|
_spriteTable[spriteId].ty = value2;
|
2005-02-24 21:05:29 +00:00
|
|
|
_spriteTable[spriteId].flags |= kSFChanged | kSFNeedRedraw;
|
2005-02-21 00:59:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-02-21 02:37:05 +00:00
|
|
|
void ScummEngine_v90he::spriteInfoSet_groupNum(int spriteId, int value) {
|
|
|
|
checkRange(_varNumSprites, 1, spriteId, "Invalid sprite %d");
|
2005-02-21 12:43:18 +00:00
|
|
|
checkRange(_varNumSpriteGroups, 0, value, "Invalid sprite group %d");
|
2005-02-21 00:59:50 +00:00
|
|
|
|
2005-04-01 12:43:13 +00:00
|
|
|
_spriteTable[spriteId].groupNum = value;
|
2005-02-24 21:05:29 +00:00
|
|
|
_spriteTable[spriteId].flags |= kSFChanged | kSFNeedRedraw;
|
2005-02-21 00:59:50 +00:00
|
|
|
}
|
|
|
|
|
2005-02-23 04:05:22 +00:00
|
|
|
void ScummEngine_v90he::spriteInfoSet_dx_dy(int spriteId, int value1, int value2) {
|
2005-02-21 02:37:05 +00:00
|
|
|
checkRange(_varNumSprites, 1, spriteId, "Invalid sprite %d");
|
2005-02-21 00:59:50 +00:00
|
|
|
|
2005-02-22 21:38:44 +00:00
|
|
|
_spriteTable[spriteId].dx = value1;
|
|
|
|
_spriteTable[spriteId].dy = value2;
|
2005-02-21 00:59:50 +00:00
|
|
|
}
|
|
|
|
|
2005-04-03 02:24:28 +00:00
|
|
|
void ScummEngine_v90he::spriteInfoSet_xmapNum(int spriteId, int value) {
|
2005-02-21 02:37:05 +00:00
|
|
|
checkRange(_varNumSprites, 1, spriteId, "Invalid sprite %d");
|
2005-02-21 00:59:50 +00:00
|
|
|
|
2005-04-01 12:43:13 +00:00
|
|
|
_spriteTable[spriteId].xmapNum = value;
|
|
|
|
if (_spriteTable[spriteId].resId)
|
2005-02-24 21:05:29 +00:00
|
|
|
_spriteTable[spriteId].flags |= kSFChanged | kSFNeedRedraw;
|
2005-02-21 00:59:50 +00:00
|
|
|
}
|
|
|
|
|
2005-02-21 02:37:05 +00:00
|
|
|
void ScummEngine_v90he::spriteInfoSet_field_44(int spriteId, int value1, int value2) {
|
|
|
|
checkRange(_varNumSprites, 1, spriteId, "Invalid sprite %d");
|
2005-02-21 00:59:50 +00:00
|
|
|
|
2005-02-21 02:37:05 +00:00
|
|
|
_spriteTable[spriteId].field_44 = value2;
|
2005-02-21 00:59:50 +00:00
|
|
|
}
|
|
|
|
|
2005-03-14 12:54:24 +00:00
|
|
|
void ScummEngine_v90he::spriteInfoSet_zorderPriority(int spriteId, int value) {
|
2005-02-21 02:37:05 +00:00
|
|
|
checkRange(_varNumSprites, 1, spriteId, "Invalid sprite %d");
|
2005-02-21 00:59:50 +00:00
|
|
|
|
2005-03-14 12:54:24 +00:00
|
|
|
_spriteTable[spriteId].zorderPriority = value;
|
2005-02-21 00:59:50 +00:00
|
|
|
}
|
|
|
|
|
2005-02-21 02:37:05 +00:00
|
|
|
void ScummEngine_v90he::spriteInfoSet_Inc_tx_ty(int spriteId, int value1, int value2) {
|
|
|
|
checkRange(_varNumSprites, 1, spriteId, "Invalid sprite %d");
|
2005-02-21 00:59:50 +00:00
|
|
|
|
2005-02-21 02:37:05 +00:00
|
|
|
_spriteTable[spriteId].tx += value1;
|
|
|
|
_spriteTable[spriteId].ty += value2;
|
2005-02-21 00:59:50 +00:00
|
|
|
|
2005-02-23 09:23:54 +00:00
|
|
|
if (value1 || value2)
|
2005-02-24 21:05:29 +00:00
|
|
|
_spriteTable[spriteId].flags |= kSFChanged | kSFNeedRedraw;
|
2005-02-21 00:59:50 +00:00
|
|
|
}
|
|
|
|
|
2005-02-21 02:37:05 +00:00
|
|
|
void ScummEngine_v90he::spriteInfoSet_zoom(int spriteId, int value) {
|
|
|
|
checkRange(_varNumSprites, 1, spriteId, "Invalid sprite %d");
|
2005-02-21 00:59:50 +00:00
|
|
|
|
2005-02-21 02:37:05 +00:00
|
|
|
_spriteTable[spriteId].flags |= kSFZoomed;
|
2005-02-21 00:59:50 +00:00
|
|
|
|
2005-02-21 02:37:05 +00:00
|
|
|
if (_spriteTable[spriteId].zoom != value) {
|
|
|
|
_spriteTable[spriteId].zoom = value;
|
2005-02-21 00:59:50 +00:00
|
|
|
|
2005-04-01 12:43:13 +00:00
|
|
|
if (_spriteTable[spriteId].resId)
|
2005-02-24 21:05:29 +00:00
|
|
|
_spriteTable[spriteId].flags |= kSFChanged | kSFNeedRedraw;
|
2005-02-21 00:59:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-04-03 02:24:28 +00:00
|
|
|
void ScummEngine_v90he::spriteInfoSet_angle(int spriteId, int value) {
|
2005-02-21 02:37:05 +00:00
|
|
|
checkRange(_varNumSprites, 1, spriteId, "Invalid sprite %d");
|
2005-02-21 02:02:32 +00:00
|
|
|
|
2005-02-21 02:37:05 +00:00
|
|
|
_spriteTable[spriteId].flags |= kSFRotated;
|
2005-02-21 02:02:32 +00:00
|
|
|
|
2005-04-01 12:43:13 +00:00
|
|
|
if (_spriteTable[spriteId].angle != value) {
|
|
|
|
_spriteTable[spriteId].angle = value;
|
2005-02-21 02:02:32 +00:00
|
|
|
|
2005-04-01 12:43:13 +00:00
|
|
|
if (_spriteTable[spriteId].resId)
|
2005-02-24 21:05:29 +00:00
|
|
|
_spriteTable[spriteId].flags |= kSFChanged | kSFNeedRedraw;
|
2005-02-21 02:02:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-03-29 14:11:08 +00:00
|
|
|
void ScummEngine_v90he::spriteInfoSet_flagDoubleBuffered(int spriteId, int value) {
|
2005-02-21 02:37:05 +00:00
|
|
|
checkRange(_varNumSprites, 1, spriteId, "Invalid sprite %d");
|
2005-02-21 02:02:32 +00:00
|
|
|
|
2005-02-27 05:14:24 +00:00
|
|
|
int oldFlags = _spriteTable[spriteId].flags;
|
2005-02-21 02:02:32 +00:00
|
|
|
if (value)
|
2005-03-24 03:47:54 +00:00
|
|
|
_spriteTable[spriteId].flags |= kSFDoubleBuffered;
|
2005-02-21 02:02:32 +00:00
|
|
|
else
|
2005-03-24 03:47:54 +00:00
|
|
|
_spriteTable[spriteId].flags &= ~kSFDoubleBuffered;
|
2005-02-24 06:47:12 +00:00
|
|
|
|
2005-04-01 12:43:13 +00:00
|
|
|
if (_spriteTable[spriteId].resId && _spriteTable[spriteId].flags != oldFlags)
|
2005-02-24 21:05:29 +00:00
|
|
|
_spriteTable[spriteId].flags |= kSFChanged | kSFNeedRedraw;
|
2005-02-21 02:02:32 +00:00
|
|
|
}
|
|
|
|
|
2005-03-17 09:42:31 +00:00
|
|
|
void ScummEngine_v90he::spriteInfoSet_flagYFlipped(int spriteId, int value) {
|
2005-02-21 02:37:05 +00:00
|
|
|
checkRange(_varNumSprites, 1, spriteId, "Invalid sprite %d");
|
2005-02-21 02:02:32 +00:00
|
|
|
|
2005-02-27 05:14:24 +00:00
|
|
|
int oldFlags = _spriteTable[spriteId].flags;
|
2005-02-21 02:02:32 +00:00
|
|
|
if (value)
|
2005-03-13 13:10:39 +00:00
|
|
|
_spriteTable[spriteId].flags |= kSFYFlipped;
|
2005-02-21 02:02:32 +00:00
|
|
|
else
|
2005-03-17 09:28:36 +00:00
|
|
|
_spriteTable[spriteId].flags &= ~kSFYFlipped;
|
2005-02-21 02:02:32 +00:00
|
|
|
|
2005-04-01 12:43:13 +00:00
|
|
|
if (_spriteTable[spriteId].resId && _spriteTable[spriteId].flags != oldFlags)
|
2005-02-24 21:05:29 +00:00
|
|
|
_spriteTable[spriteId].flags |= kSFChanged | kSFNeedRedraw;
|
2005-02-21 02:02:32 +00:00
|
|
|
}
|
|
|
|
|
2005-03-17 09:42:31 +00:00
|
|
|
void ScummEngine_v90he::spriteInfoSet_flagXFlipped(int spriteId, int value) {
|
2005-02-21 02:37:05 +00:00
|
|
|
checkRange(_varNumSprites, 1, spriteId, "Invalid sprite %d");
|
2005-02-21 02:02:32 +00:00
|
|
|
|
2005-02-27 05:14:24 +00:00
|
|
|
int oldFlags = _spriteTable[spriteId].flags;
|
2005-02-21 02:02:32 +00:00
|
|
|
if (value)
|
2005-03-13 13:10:39 +00:00
|
|
|
_spriteTable[spriteId].flags |= kSFXFlipped;
|
2005-02-21 02:02:32 +00:00
|
|
|
else
|
2005-03-17 09:28:36 +00:00
|
|
|
_spriteTable[spriteId].flags &= ~kSFXFlipped;
|
2005-02-21 02:02:32 +00:00
|
|
|
|
2005-04-01 12:43:13 +00:00
|
|
|
if (_spriteTable[spriteId].resId && _spriteTable[spriteId].flags != oldFlags)
|
2005-02-24 21:05:29 +00:00
|
|
|
_spriteTable[spriteId].flags |= kSFChanged | kSFNeedRedraw;
|
2005-02-21 02:02:32 +00:00
|
|
|
}
|
|
|
|
|
2005-02-24 21:05:29 +00:00
|
|
|
void ScummEngine_v90he::spriteInfoSet_flagActive(int spriteId, int value) {
|
2005-02-21 02:37:05 +00:00
|
|
|
checkRange(_varNumSprites, 1, spriteId, "Invalid sprite %d");
|
2005-02-21 02:02:32 +00:00
|
|
|
|
|
|
|
if (value)
|
2005-02-24 21:05:29 +00:00
|
|
|
_spriteTable[spriteId].flags |= kSFActive;
|
2005-02-21 02:02:32 +00:00
|
|
|
else
|
2005-03-17 09:28:36 +00:00
|
|
|
_spriteTable[spriteId].flags &= ~kSFActive;
|
2005-02-21 02:02:32 +00:00
|
|
|
}
|
|
|
|
|
2005-03-29 14:11:08 +00:00
|
|
|
void ScummEngine_v90he::spriteInfoSet_flagNeedPaletteRemap(int spriteId, int value) {
|
2005-02-21 02:37:05 +00:00
|
|
|
checkRange(_varNumSprites, 1, spriteId, "Invalid sprite %d");
|
2005-02-21 02:02:32 +00:00
|
|
|
|
2005-02-27 05:14:24 +00:00
|
|
|
int oldFlags = _spriteTable[spriteId].flags;
|
2005-02-21 02:02:32 +00:00
|
|
|
if (value)
|
2005-03-24 03:47:54 +00:00
|
|
|
_spriteTable[spriteId].flags |= kSFNeedPaletteRemap;
|
2005-02-21 02:02:32 +00:00
|
|
|
else
|
2005-03-24 03:47:54 +00:00
|
|
|
_spriteTable[spriteId].flags &= ~kSFNeedPaletteRemap;
|
2005-02-21 02:02:32 +00:00
|
|
|
|
2005-04-01 12:43:13 +00:00
|
|
|
if (_spriteTable[spriteId].resId && _spriteTable[spriteId].flags != oldFlags)
|
2005-02-24 21:05:29 +00:00
|
|
|
_spriteTable[spriteId].flags |= kSFChanged | kSFNeedRedraw;
|
2005-02-21 02:02:32 +00:00
|
|
|
}
|
|
|
|
|
2005-04-03 02:24:28 +00:00
|
|
|
void ScummEngine_v90he::spriteInfoSet_flagDelayed(int spriteId, int value) {
|
2005-02-21 02:37:05 +00:00
|
|
|
checkRange(_varNumSprites, 1, spriteId, "Invalid sprite %d");
|
2005-02-21 02:02:32 +00:00
|
|
|
|
|
|
|
if (value)
|
2005-03-24 03:47:54 +00:00
|
|
|
_spriteTable[spriteId].flags |= kSFDelayed;
|
2005-02-21 02:02:32 +00:00
|
|
|
else
|
2005-03-24 03:47:54 +00:00
|
|
|
_spriteTable[spriteId].flags &= ~kSFDelayed;
|
2005-02-21 02:02:32 +00:00
|
|
|
}
|
|
|
|
|
2005-04-01 06:30:46 +00:00
|
|
|
void ScummEngine_v90he::spriteInfoSet_flagMarkDirty(int spriteId, int value) {
|
2005-02-21 02:37:05 +00:00
|
|
|
checkRange(_varNumSprites, 1, spriteId, "Invalid sprite %d");
|
2005-02-21 02:02:32 +00:00
|
|
|
|
2005-04-03 01:42:06 +00:00
|
|
|
switch(value) {
|
|
|
|
case 2:
|
|
|
|
_spriteTable[spriteId].flags &= ~(kSFMarkDirty);
|
|
|
|
_spriteTable[spriteId].flags |= kSFBlitDirectly;
|
|
|
|
break;
|
|
|
|
case 1:
|
2005-04-01 06:30:46 +00:00
|
|
|
_spriteTable[spriteId].flags |= kSFMarkDirty | kSFBlitDirectly;
|
2005-04-03 01:42:06 +00:00
|
|
|
break;
|
|
|
|
case 0:
|
2005-04-01 06:30:46 +00:00
|
|
|
_spriteTable[spriteId].flags &= ~(kSFMarkDirty | kSFBlitDirectly);
|
2005-04-03 01:42:06 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
error("spriteInfoSet_flagMarkDirty: Invalid value %d", value);
|
|
|
|
}
|
2005-02-21 02:02:32 +00:00
|
|
|
}
|
|
|
|
|
2005-02-26 11:05:13 +00:00
|
|
|
void ScummEngine_v90he::spriteInfoSet_flagHasImage(int spriteId, int value) {
|
2005-02-21 02:37:05 +00:00
|
|
|
checkRange(_varNumSprites, 1, spriteId, "Invalid sprite %d");
|
2005-02-21 02:02:32 +00:00
|
|
|
|
|
|
|
// Note that condition is inverted
|
|
|
|
if (!value)
|
2005-02-26 11:05:13 +00:00
|
|
|
_spriteTable[spriteId].flags |= kSFImageless;
|
2005-02-21 02:02:32 +00:00
|
|
|
else
|
2005-03-17 09:28:36 +00:00
|
|
|
_spriteTable[spriteId].flags &= ~kSFImageless;
|
2005-02-21 02:02:32 +00:00
|
|
|
}
|
|
|
|
|
2005-03-14 12:54:24 +00:00
|
|
|
void ScummEngine_v90he::spriteInfoSet_delay(int spriteId, int value) {
|
2005-02-21 02:37:05 +00:00
|
|
|
checkRange(_varNumSprites, 1, spriteId, "Invalid sprite %d");
|
2005-02-21 02:02:32 +00:00
|
|
|
|
2005-03-14 12:54:24 +00:00
|
|
|
_spriteTable[spriteId].delayAmount = value;
|
|
|
|
_spriteTable[spriteId].delayCount = value;
|
2005-02-21 02:02:32 +00:00
|
|
|
}
|
|
|
|
|
2005-02-23 11:15:41 +00:00
|
|
|
void ScummEngine_v90he::spriteInfoSet_setClassFlag(int spriteId, int classId, int toggle) {
|
2005-02-22 22:23:10 +00:00
|
|
|
checkRange(_varNumSprites, 1, spriteId, "Invalid sprite %d");
|
|
|
|
checkRange(32, 1, classId, "class %d out of range in statement");
|
|
|
|
|
|
|
|
if (toggle) {
|
2005-04-01 12:43:13 +00:00
|
|
|
_spriteTable[spriteId].classFlags |= (1 << (classId - 1));
|
2005-02-22 22:23:10 +00:00
|
|
|
} else {
|
2005-04-01 12:43:13 +00:00
|
|
|
_spriteTable[spriteId].classFlags &= ~(1 << (classId - 1));
|
2005-02-22 22:23:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-02-22 22:52:35 +00:00
|
|
|
void ScummEngine_v90he::spriteInfoSet_resetClassFlags(int spriteId) {
|
2005-02-22 22:23:10 +00:00
|
|
|
checkRange(_varNumSprites, 1, spriteId, "Invalid sprite %d");
|
|
|
|
|
2005-04-01 12:43:13 +00:00
|
|
|
_spriteTable[spriteId].classFlags = 0;
|
2005-02-22 22:23:10 +00:00
|
|
|
}
|
|
|
|
|
2005-04-11 07:40:14 +00:00
|
|
|
void ScummEngine_v90he::spriteInfoSet_field_84(int spriteId, int value) {
|
|
|
|
checkRange(_varNumSprites, 1, spriteId, "Invalid sprite %d");
|
|
|
|
|
|
|
|
_spriteTable[spriteId].field_84 = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScummEngine_v90he::spriteInfoSet_field_8C_90(int spriteId, int type, int value) {
|
2005-04-20 10:38:13 +00:00
|
|
|
debug(0, "spriteInfoSet_field_8C_90: spriteId %d type 0x%x", spriteId, type);
|
2005-02-23 09:23:54 +00:00
|
|
|
checkRange(_varNumSprites, 1, spriteId, "Invalid sprite %d");
|
2005-04-11 07:40:14 +00:00
|
|
|
int delay;
|
2005-02-23 09:23:54 +00:00
|
|
|
|
2005-04-11 07:40:14 +00:00
|
|
|
// XXX U32 related check
|
|
|
|
|
|
|
|
switch(type) {
|
|
|
|
case 0x7B:
|
2005-04-20 10:33:20 +00:00
|
|
|
_spriteTable[spriteId].imgFlags = value;
|
2005-04-11 07:40:14 +00:00
|
|
|
_spriteTable[spriteId].flags |= kSFChanged | kSFNeedRedraw;
|
|
|
|
break;
|
|
|
|
case 0x7D:
|
|
|
|
_spriteTable[spriteId].field_90 = value;
|
2005-02-24 21:05:29 +00:00
|
|
|
_spriteTable[spriteId].flags |= kSFChanged | kSFNeedRedraw;
|
2005-04-11 07:40:14 +00:00
|
|
|
break;
|
|
|
|
case 0x7E:
|
|
|
|
delay = MAX(0, value);
|
2005-04-11 20:34:21 +00:00
|
|
|
delay = MIN((int32)value, _spriteTable[spriteId].delayAmount);
|
2005-04-11 07:40:14 +00:00
|
|
|
|
|
|
|
_spriteTable[spriteId].delayCount = value;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
error("spriteInfoSet_field_8C_90: Invalid value %d", type);
|
2005-02-23 09:23:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-02-23 02:35:59 +00:00
|
|
|
void ScummEngine_v90he::spriteInfoSet_resetSprite(int spriteId) {
|
2005-02-21 02:37:05 +00:00
|
|
|
checkRange(_varNumSprites, 1, spriteId, "Invalid sprite %d");
|
2005-02-21 00:59:50 +00:00
|
|
|
|
2005-04-01 12:43:13 +00:00
|
|
|
_spriteTable[spriteId].angle = 0;
|
2005-02-23 02:35:59 +00:00
|
|
|
_spriteTable[spriteId].zoom = 0;
|
|
|
|
|
2005-02-24 00:48:24 +00:00
|
|
|
int tmp = 0;
|
2005-02-24 21:05:29 +00:00
|
|
|
spriteAddImageToList(spriteId, 1, &tmp);
|
2005-02-23 02:35:59 +00:00
|
|
|
|
2005-04-01 12:43:13 +00:00
|
|
|
_spriteTable[spriteId].xmapNum = 0;
|
2005-02-23 02:35:59 +00:00
|
|
|
_spriteTable[spriteId].tx = 0;
|
|
|
|
_spriteTable[spriteId].ty = 0;
|
|
|
|
|
2005-03-17 09:28:36 +00:00
|
|
|
_spriteTable[spriteId].flags &= ~(kSFYFlipped | kSFXFlipped);
|
2005-02-24 21:05:29 +00:00
|
|
|
_spriteTable[spriteId].flags |= kSFChanged | kSFNeedRedraw;
|
2005-02-23 02:35:59 +00:00
|
|
|
_spriteTable[spriteId].dx = 0;
|
|
|
|
_spriteTable[spriteId].dy = 0;
|
|
|
|
_spriteTable[spriteId].field_44 = 0;
|
2005-04-01 12:43:13 +00:00
|
|
|
_spriteTable[spriteId].groupNum = 0;
|
2005-03-14 12:54:24 +00:00
|
|
|
_spriteTable[spriteId].delayAmount = 0;
|
|
|
|
_spriteTable[spriteId].delayCount = 0;
|
2005-04-01 12:43:13 +00:00
|
|
|
_spriteTable[spriteId].classFlags = 0;
|
2005-03-31 22:51:54 +00:00
|
|
|
_spriteTable[spriteId].paletteNum = 0;
|
2005-04-20 05:24:02 +00:00
|
|
|
_spriteTable[spriteId].maskImgResNum = 0;
|
2005-02-23 02:35:59 +00:00
|
|
|
_spriteTable[spriteId].field_80 = 0;
|
2005-03-14 12:54:24 +00:00
|
|
|
_spriteTable[spriteId].zorderPriority = 0;
|
2005-04-11 07:40:14 +00:00
|
|
|
_spriteTable[spriteId].field_84 = 0;
|
2005-04-20 10:33:20 +00:00
|
|
|
_spriteTable[spriteId].imgFlags = 0;
|
2005-04-11 07:40:14 +00:00
|
|
|
_spriteTable[spriteId].field_90 = 0;
|
2005-02-21 00:59:50 +00:00
|
|
|
}
|
2005-02-21 00:02:44 +00:00
|
|
|
|
2005-02-24 21:05:29 +00:00
|
|
|
void ScummEngine_v90he::spriteAddImageToList(int spriteId, int imageNum, int *spriteIdptr) {
|
2005-02-25 02:07:22 +00:00
|
|
|
int origResId, origResWizStates;
|
2005-02-23 03:18:49 +00:00
|
|
|
|
|
|
|
checkRange(_varNumSprites, 1, spriteId, "Invalid sprite %d");
|
|
|
|
|
2005-04-01 12:43:13 +00:00
|
|
|
origResId = _spriteTable[spriteId].resId;
|
2005-02-25 02:07:22 +00:00
|
|
|
origResWizStates = _spriteTable[spriteId].res_wiz_states;
|
2005-02-23 03:18:49 +00:00
|
|
|
|
2005-04-01 12:43:13 +00:00
|
|
|
_spriteTable[spriteId].resId = *spriteIdptr;
|
2005-02-23 03:18:49 +00:00
|
|
|
_spriteTable[spriteId].field_74 = 0;
|
2005-04-01 12:43:13 +00:00
|
|
|
_spriteTable[spriteId].resState = 0;
|
2005-02-23 03:18:49 +00:00
|
|
|
|
2005-04-01 12:43:13 +00:00
|
|
|
if (_spriteTable[spriteId].resId) {
|
|
|
|
_spriteTable[spriteId].res_wiz_states = getWizImageStates(_spriteTable[spriteId].resId);
|
2005-04-01 06:30:46 +00:00
|
|
|
_spriteTable[spriteId].flags |= kSFActive | kSFDelayed | kSFMarkDirty | kSFBlitDirectly;
|
2005-02-23 03:18:49 +00:00
|
|
|
|
2005-04-01 12:43:13 +00:00
|
|
|
if (_spriteTable[spriteId].resId != origResId || _spriteTable[spriteId].res_wiz_states != origResWizStates)
|
2005-02-28 04:34:22 +00:00
|
|
|
_spriteTable[spriteId].flags |= kSFChanged | kSFNeedRedraw;
|
2005-02-23 03:18:49 +00:00
|
|
|
} else {
|
2005-03-05 23:50:50 +00:00
|
|
|
if (_spriteTable[spriteId].flags & kSFImageless)
|
|
|
|
_spriteTable[spriteId].flags = 0;
|
|
|
|
else
|
|
|
|
_spriteTable[spriteId].flags = kSFChanged | kSFBlitDirectly;
|
2005-04-01 12:43:13 +00:00
|
|
|
_spriteTable[spriteId].curResId = 0;
|
|
|
|
_spriteTable[spriteId].curImageState = 0;
|
2005-02-23 03:18:49 +00:00
|
|
|
_spriteTable[spriteId].res_wiz_states = 0;
|
|
|
|
}
|
2005-02-21 00:02:44 +00:00
|
|
|
}
|
|
|
|
|
2005-02-23 01:08:29 +00:00
|
|
|
//
|
|
|
|
// spriteGroupSet functions
|
|
|
|
//
|
2005-02-23 04:35:20 +00:00
|
|
|
void ScummEngine_v90he::redrawSpriteGroup(int spriteGroupId) {
|
|
|
|
for (int i = 0; i < _numSpritesToProcess; ++i) {
|
|
|
|
SpriteInfo *spi = _activeSpritesTable[i];
|
2005-04-01 12:43:13 +00:00
|
|
|
if (spi->groupNum == spriteGroupId) {
|
2005-02-24 21:05:29 +00:00
|
|
|
spi->flags |= kSFChanged | kSFNeedRedraw;
|
2005-02-23 04:35:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-02-23 01:08:29 +00:00
|
|
|
void ScummEngine_v90he::spriteGroupSet_case0_0(int spriteGroupId, int value1, int value2) {
|
2005-02-27 06:07:09 +00:00
|
|
|
checkRange(_varNumSpriteGroups, 1, spriteGroupId, "Invalid sprite group %d");
|
2005-02-23 03:22:05 +00:00
|
|
|
|
|
|
|
for (int i = 1; i < _varNumSprites; i++) {
|
2005-04-01 12:43:13 +00:00
|
|
|
if (_spriteTable[i].groupNum == spriteGroupId) {
|
2005-02-23 03:22:05 +00:00
|
|
|
_spriteTable[i].tx += value1;
|
|
|
|
_spriteTable[i].ty += value2;
|
|
|
|
|
|
|
|
if (value1 || value2)
|
2005-02-24 21:05:29 +00:00
|
|
|
_spriteTable[i].flags |= kSFChanged | kSFNeedRedraw;
|
2005-02-23 03:22:05 +00:00
|
|
|
}
|
|
|
|
}
|
2005-02-23 01:08:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ScummEngine_v90he::spriteGroupSet_case0_1(int spriteGroupId, int value) {
|
2005-02-27 06:07:09 +00:00
|
|
|
checkRange(_varNumSpriteGroups, 1, spriteGroupId, "Invalid sprite group %d");
|
2005-02-23 03:22:05 +00:00
|
|
|
|
|
|
|
for (int i = 1; i < _varNumSprites; i++) {
|
2005-04-01 12:43:13 +00:00
|
|
|
if (_spriteTable[i].groupNum == spriteGroupId)
|
2005-03-14 12:54:24 +00:00
|
|
|
_spriteTable[i].zorderPriority = value;
|
2005-02-23 03:22:05 +00:00
|
|
|
}
|
2005-02-23 01:08:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ScummEngine_v90he::spriteGroupSet_case0_2(int spriteGroupId, int value) {
|
2005-02-27 06:07:09 +00:00
|
|
|
checkRange(_varNumSpriteGroups, 1, spriteGroupId, "Invalid sprite group %d");
|
2005-02-23 03:22:05 +00:00
|
|
|
|
|
|
|
for (int i = 1; i < _varNumSprites; i++) {
|
2005-04-01 12:43:13 +00:00
|
|
|
if (_spriteTable[i].groupNum == spriteGroupId) {
|
|
|
|
_spriteTable[i].groupNum = value;
|
2005-02-24 21:05:29 +00:00
|
|
|
_spriteTable[i].flags |= kSFChanged | kSFNeedRedraw;
|
2005-02-23 03:22:05 +00:00
|
|
|
}
|
|
|
|
}
|
2005-02-23 01:08:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ScummEngine_v90he::spriteGroupSet_case0_3(int spriteGroupId, int value) {
|
2005-02-27 06:07:09 +00:00
|
|
|
checkRange(_varNumSpriteGroups, 1, spriteGroupId, "Invalid sprite group %d");
|
2005-02-23 03:22:05 +00:00
|
|
|
|
|
|
|
for (int i = 1; i < _varNumSprites; i++) {
|
2005-04-03 01:42:06 +00:00
|
|
|
if (_spriteTable[i].groupNum == spriteGroupId)
|
|
|
|
spriteInfoSet_flagMarkDirty(i, value);
|
2005-02-23 03:22:05 +00:00
|
|
|
}
|
2005-02-23 01:08:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ScummEngine_v90he::spriteGroupSet_case0_4(int spriteGroupId) {
|
2005-02-27 06:07:09 +00:00
|
|
|
checkRange(_varNumSpriteGroups, 1, spriteGroupId, "Invalid sprite group %d");
|
2005-02-23 04:05:22 +00:00
|
|
|
|
|
|
|
for (int i = 1; i < _varNumSprites; i++) {
|
2005-04-01 12:43:13 +00:00
|
|
|
if (_spriteTable[i].groupNum == spriteGroupId)
|
2005-02-23 04:05:22 +00:00
|
|
|
spriteInfoSet_resetSprite(i);
|
|
|
|
}
|
2005-02-23 01:08:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ScummEngine_v90he::spriteGroupSet_case0_5(int spriteGroupId, int value) {
|
2005-02-27 06:07:09 +00:00
|
|
|
checkRange(_varNumSpriteGroups, 1, spriteGroupId, "Invalid sprite group %d");
|
2005-02-23 03:22:05 +00:00
|
|
|
|
|
|
|
for (int i = 1; i < _varNumSprites; i++) {
|
2005-04-01 12:43:13 +00:00
|
|
|
if (_spriteTable[i].groupNum == spriteGroupId) {
|
2005-03-14 12:54:24 +00:00
|
|
|
_spriteTable[i].delayAmount = value;
|
|
|
|
_spriteTable[i].delayCount = value;
|
2005-02-23 03:22:05 +00:00
|
|
|
}
|
|
|
|
}
|
2005-02-23 01:08:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ScummEngine_v90he::spriteGroupSet_case0_6(int spriteGroupId, int value) {
|
2005-02-27 06:07:09 +00:00
|
|
|
checkRange(_varNumSpriteGroups, 1, spriteGroupId, "Invalid sprite group %d");
|
2005-02-23 03:22:05 +00:00
|
|
|
|
|
|
|
for (int i = 1; i < _varNumSprites; i++) {
|
2005-04-01 12:43:13 +00:00
|
|
|
if (_spriteTable[i].groupNum == spriteGroupId) {
|
2005-02-23 03:22:05 +00:00
|
|
|
if (value)
|
2005-03-24 03:47:54 +00:00
|
|
|
_spriteTable[i].flags |= kSFDelayed;
|
2005-02-23 03:22:05 +00:00
|
|
|
else
|
2005-03-24 03:47:54 +00:00
|
|
|
_spriteTable[i].flags &= ~kSFDelayed;
|
2005-02-23 03:22:05 +00:00
|
|
|
}
|
|
|
|
}
|
2005-02-23 01:08:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ScummEngine_v90he::spriteGroupSet_case0_7(int spriteGroupId, int value) {
|
2005-02-27 06:07:09 +00:00
|
|
|
checkRange(_varNumSpriteGroups, 1, spriteGroupId, "Invalid sprite group %d");
|
2005-02-23 03:22:05 +00:00
|
|
|
|
|
|
|
for (int i = 1; i < _varNumSprites; i++) {
|
2005-04-01 12:43:13 +00:00
|
|
|
if (_spriteTable[i].groupNum == spriteGroupId) {
|
|
|
|
_spriteTable[i].xmapNum = value;
|
|
|
|
if (_spriteTable[i].resId)
|
2005-02-24 21:05:29 +00:00
|
|
|
_spriteTable[i].flags |= kSFChanged | kSFNeedRedraw;
|
2005-02-23 03:22:05 +00:00
|
|
|
}
|
|
|
|
}
|
2005-02-23 01:08:29 +00:00
|
|
|
}
|
|
|
|
|
2005-02-28 04:17:17 +00:00
|
|
|
void ScummEngine_v90he::spriteGroupSet_bbox(int spriteGroupId, int x1, int y1, int x2, int y2) {
|
2005-02-27 06:07:09 +00:00
|
|
|
checkRange(_varNumSpriteGroups, 1, spriteGroupId, "Invalid sprite group %d");
|
2005-02-23 04:05:22 +00:00
|
|
|
|
2005-02-28 04:17:17 +00:00
|
|
|
_spriteGroups[spriteGroupId].flags |= kSGFClipBox;
|
|
|
|
_spriteGroups[spriteGroupId].bbox.left = x1;
|
|
|
|
_spriteGroups[spriteGroupId].bbox.top = y1;
|
|
|
|
_spriteGroups[spriteGroupId].bbox.right = x2;
|
|
|
|
_spriteGroups[spriteGroupId].bbox.bottom = y2;
|
2005-02-23 04:05:22 +00:00
|
|
|
|
2005-02-23 04:35:20 +00:00
|
|
|
redrawSpriteGroup(spriteGroupId);
|
2005-02-23 01:08:29 +00:00
|
|
|
}
|
|
|
|
|
2005-02-28 04:17:17 +00:00
|
|
|
void ScummEngine_v90he::spriteGroupSet_zorderPriority(int spriteGroupId, int value) {
|
2005-02-27 06:07:09 +00:00
|
|
|
checkRange(_varNumSpriteGroups, 1, spriteGroupId, "Invalid sprite group %d");
|
2005-02-23 04:05:22 +00:00
|
|
|
|
2005-02-28 04:34:22 +00:00
|
|
|
if (_spriteGroups[spriteGroupId].zorderPriority != value) {
|
|
|
|
_spriteGroups[spriteGroupId].zorderPriority = value;
|
|
|
|
redrawSpriteGroup(spriteGroupId);
|
|
|
|
}
|
2005-02-23 01:08:29 +00:00
|
|
|
}
|
|
|
|
|
2005-02-28 04:17:17 +00:00
|
|
|
void ScummEngine_v90he::spriteGroupSet_tx_ty(int spriteGroupId, int value1, int value2) {
|
2005-02-27 06:07:09 +00:00
|
|
|
checkRange(_varNumSpriteGroups, 1, spriteGroupId, "Invalid sprite group %d");
|
2005-02-23 04:05:22 +00:00
|
|
|
|
2005-02-28 04:34:22 +00:00
|
|
|
if (_spriteGroups[spriteGroupId].tx != value1 || _spriteGroups[spriteGroupId].ty != value2) {
|
|
|
|
_spriteGroups[spriteGroupId].tx = value1;
|
|
|
|
_spriteGroups[spriteGroupId].ty = value2;
|
|
|
|
redrawSpriteGroup(spriteGroupId);
|
|
|
|
}
|
2005-02-23 01:08:29 +00:00
|
|
|
}
|
|
|
|
|
2005-02-28 04:17:17 +00:00
|
|
|
void ScummEngine_v90he::spriteGroupSet_inc_tx_ty(int spriteGroupId, int value1, int value2) {
|
2005-02-27 06:07:09 +00:00
|
|
|
checkRange(_varNumSpriteGroups, 1, spriteGroupId, "Invalid sprite group %d");
|
2005-02-23 04:05:22 +00:00
|
|
|
|
2005-03-09 06:28:46 +00:00
|
|
|
if (value1 || value2) {
|
|
|
|
_spriteGroups[spriteGroupId].tx += value1;
|
|
|
|
_spriteGroups[spriteGroupId].ty += value2;
|
|
|
|
redrawSpriteGroup(spriteGroupId);
|
|
|
|
}
|
2005-02-23 01:08:29 +00:00
|
|
|
}
|
|
|
|
|
2005-04-03 02:24:28 +00:00
|
|
|
void ScummEngine_v90he::spriteGroupSet_dstResNum(int spriteGroupId, int value) {
|
2005-02-27 06:07:09 +00:00
|
|
|
checkRange(_varNumSpriteGroups, 1, spriteGroupId, "Invalid sprite group %d");
|
2005-02-23 03:22:05 +00:00
|
|
|
|
2005-04-01 08:51:13 +00:00
|
|
|
if (_spriteGroups[spriteGroupId].dstResNum != value) {
|
|
|
|
_spriteGroups[spriteGroupId].dstResNum = value;
|
2005-02-28 04:34:22 +00:00
|
|
|
redrawSpriteGroup(spriteGroupId);
|
|
|
|
}
|
2005-02-23 01:08:29 +00:00
|
|
|
}
|
|
|
|
|
2005-02-28 04:34:22 +00:00
|
|
|
void ScummEngine_v90he::spriteGroupSet_scaling(int spriteGroupId) {
|
2005-02-28 04:17:17 +00:00
|
|
|
if ((_spriteGroups[spriteGroupId].scale_x_ratio_mul != _spriteGroups[spriteGroupId].scale_x_ratio_div) || (_spriteGroups[spriteGroupId].scale_y_ratio_mul != _spriteGroups[spriteGroupId].scale_y_ratio_div))
|
|
|
|
_spriteGroups[spriteGroupId].scaling = 1;
|
|
|
|
else
|
|
|
|
_spriteGroups[spriteGroupId].scaling = 0;
|
2005-02-23 03:22:05 +00:00
|
|
|
|
2005-02-23 01:08:29 +00:00
|
|
|
}
|
|
|
|
|
2005-02-28 04:34:22 +00:00
|
|
|
void ScummEngine_v90he::spriteGroupSet_scale_x_ratio_mul(int spriteGroupId, int value) {
|
2005-02-27 06:07:09 +00:00
|
|
|
checkRange(_varNumSpriteGroups, 1, spriteGroupId, "Invalid sprite group %d");
|
2005-02-23 03:22:05 +00:00
|
|
|
|
2005-02-28 04:34:22 +00:00
|
|
|
if (_spriteGroups[spriteGroupId].scale_x_ratio_mul != value) {
|
|
|
|
_spriteGroups[spriteGroupId].scale_x_ratio_mul = value;
|
|
|
|
spriteGroupSet_scaling(spriteGroupId);
|
|
|
|
redrawSpriteGroup(spriteGroupId);
|
|
|
|
}
|
|
|
|
}
|
2005-02-23 03:22:05 +00:00
|
|
|
|
2005-02-28 04:34:22 +00:00
|
|
|
void ScummEngine_v90he::spriteGroupSet_scale_x_ratio_div(int spriteGroupId, int value) {
|
|
|
|
checkRange(_varNumSpriteGroups, 1, spriteGroupId, "Invalid sprite group %d");
|
2005-02-28 04:17:17 +00:00
|
|
|
|
2005-03-09 06:28:46 +00:00
|
|
|
if (value == 0)
|
|
|
|
error("spriteGroupSet_scale_x_ratio_div: Divisor must not be 0");
|
|
|
|
|
2005-02-28 04:34:22 +00:00
|
|
|
if (_spriteGroups[spriteGroupId].scale_x_ratio_div != value) {
|
|
|
|
_spriteGroups[spriteGroupId].scale_x_ratio_div = value;
|
|
|
|
spriteGroupSet_scaling(spriteGroupId);
|
|
|
|
redrawSpriteGroup(spriteGroupId);
|
|
|
|
}
|
2005-02-23 01:08:29 +00:00
|
|
|
}
|
|
|
|
|
2005-02-28 04:17:17 +00:00
|
|
|
void ScummEngine_v90he::spriteGroupSet_scale_y_ratio_mul(int spriteGroupId, int value) {
|
2005-02-27 06:07:09 +00:00
|
|
|
checkRange(_varNumSpriteGroups, 1, spriteGroupId, "Invalid sprite group %d");
|
2005-02-23 03:22:05 +00:00
|
|
|
|
2005-02-28 04:34:22 +00:00
|
|
|
if (_spriteGroups[spriteGroupId].scale_y_ratio_mul != value) {
|
|
|
|
_spriteGroups[spriteGroupId].scale_y_ratio_mul = value;
|
|
|
|
spriteGroupSet_scaling(spriteGroupId);
|
|
|
|
redrawSpriteGroup(spriteGroupId);
|
|
|
|
}
|
2005-02-23 01:08:29 +00:00
|
|
|
}
|
|
|
|
|
2005-02-28 04:17:17 +00:00
|
|
|
void ScummEngine_v90he::spriteGroupSet_scale_y_ratio_div(int spriteGroupId, int value) {
|
2005-02-27 06:07:09 +00:00
|
|
|
checkRange(_varNumSpriteGroups, 1, spriteGroupId, "Invalid sprite group %d");
|
2005-02-23 03:22:05 +00:00
|
|
|
|
2005-03-09 06:28:46 +00:00
|
|
|
if (value == 0)
|
|
|
|
error("spriteGroupSet_scale_y_ratio_div: Divisor must not be 0");
|
|
|
|
|
2005-02-28 04:34:22 +00:00
|
|
|
if (_spriteGroups[spriteGroupId].scale_y_ratio_div != value) {
|
|
|
|
_spriteGroups[spriteGroupId].scale_y_ratio_div = value;
|
|
|
|
spriteGroupSet_scaling(spriteGroupId);
|
|
|
|
redrawSpriteGroup(spriteGroupId);
|
|
|
|
}
|
2005-02-23 01:08:29 +00:00
|
|
|
}
|
|
|
|
|
2005-03-17 09:28:36 +00:00
|
|
|
void ScummEngine_v90he::spriteGroupSet_flagClipBoxAnd(int spriteGroupId) {
|
2005-02-27 06:07:09 +00:00
|
|
|
checkRange(_varNumSpriteGroups, 1, spriteGroupId, "Invalid sprite group %d");
|
2005-02-23 03:22:05 +00:00
|
|
|
|
2005-03-17 09:28:36 +00:00
|
|
|
_spriteGroups[spriteGroupId].flags &= ~(kSGFClipBox);
|
2005-02-23 04:35:20 +00:00
|
|
|
redrawSpriteGroup(spriteGroupId);
|
2005-02-23 01:08:29 +00:00
|
|
|
}
|
|
|
|
|
2005-02-22 21:38:44 +00:00
|
|
|
void ScummEngine_v90he::spritesAllocTables(int numSprites, int numGroups, int numMaxSprites) {
|
2005-02-20 22:16:31 +00:00
|
|
|
_varNumSpriteGroups = numGroups;
|
|
|
|
_numSpritesToProcess = 0;
|
|
|
|
_varNumSprites = numSprites;
|
2005-02-22 21:38:44 +00:00
|
|
|
_varMaxSprites = numMaxSprites;
|
2005-02-20 22:16:31 +00:00
|
|
|
_spriteGroups = (SpriteGroup *)malloc((_varNumSpriteGroups + 1) * sizeof(SpriteGroup));
|
|
|
|
_spriteTable = (SpriteInfo *)malloc((_varNumSprites + 1) * sizeof(SpriteInfo));
|
|
|
|
_activeSpritesTable = (SpriteInfo **)malloc((_varNumSprites + 1) * sizeof(SpriteInfo *));
|
|
|
|
}
|
|
|
|
|
2005-02-26 04:20:47 +00:00
|
|
|
void ScummEngine_v90he::spritesResetGroup(int spriteGroupId) {
|
2005-02-27 06:07:09 +00:00
|
|
|
checkRange(_varNumSpriteGroups, 1, spriteGroupId, "Invalid sprite group %d");
|
2005-03-09 06:29:31 +00:00
|
|
|
SpriteGroup *spg = &_spriteGroups[spriteGroupId];
|
2005-02-27 06:01:11 +00:00
|
|
|
|
|
|
|
spg->zorderPriority = 0;
|
|
|
|
spg->tx = spg->ty = 0;
|
|
|
|
|
2005-03-17 09:28:36 +00:00
|
|
|
spg->flags &= ~kSGFClipBox;
|
2005-02-27 06:01:11 +00:00
|
|
|
redrawSpriteGroup(spriteGroupId);
|
|
|
|
|
2005-04-01 08:51:13 +00:00
|
|
|
spg->dstResNum = 0;
|
2005-02-26 04:20:47 +00:00
|
|
|
spg->scaling = 0;
|
2005-02-27 06:01:11 +00:00
|
|
|
spg->scale_x_ratio_mul = 1;
|
|
|
|
spg->scale_x_ratio_div = 1;
|
|
|
|
spg->scale_y_ratio_mul = 1;
|
|
|
|
spg->scale_y_ratio_div = 1;
|
2005-02-23 04:35:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ScummEngine_v90he::spritesResetTables(bool refreshScreen) {
|
|
|
|
memset(_spriteTable, 0, (_varNumSprites + 1) * sizeof(SpriteInfo));
|
|
|
|
memset(_spriteGroups, 0, (_varNumSpriteGroups + 1) * sizeof(SpriteGroup));
|
2005-02-26 04:20:47 +00:00
|
|
|
for (int curGrp = 1; curGrp < _varNumSpriteGroups; ++curGrp)
|
|
|
|
spritesResetGroup(curGrp);
|
|
|
|
|
2005-02-20 22:16:31 +00:00
|
|
|
if (refreshScreen) {
|
|
|
|
gdi.copyVirtScreenBuffers(Common::Rect(_screenWidth, _screenHeight));
|
|
|
|
}
|
|
|
|
_numSpritesToProcess = 0;
|
|
|
|
}
|
|
|
|
|
2005-02-22 01:16:41 +00:00
|
|
|
void ScummEngine_v90he::spritesBlitToScreen() {
|
|
|
|
int xmin, xmax, ymin, ymax;
|
|
|
|
xmin = ymin = 1234;
|
|
|
|
xmax = ymax = -1234;
|
|
|
|
bool firstLoop = true;
|
|
|
|
bool refreshScreen = false;
|
2005-02-24 05:11:37 +00:00
|
|
|
|
2005-02-22 01:16:41 +00:00
|
|
|
for (int i = 0; i < _numSpritesToProcess; ++i) {
|
|
|
|
SpriteInfo *spi = _activeSpritesTable[i];
|
2005-02-26 11:05:13 +00:00
|
|
|
if (!(spi->flags & kSFImageless) && (spi->flags & kSFChanged)) {
|
2005-02-24 21:05:29 +00:00
|
|
|
spi->flags &= ~kSFChanged;
|
2005-02-24 04:04:17 +00:00
|
|
|
if (spi->bbox.left <= spi->bbox.right && spi->bbox.top <= spi->bbox.bottom) {
|
2005-02-22 01:23:15 +00:00
|
|
|
if (spi->flags & kSFBlitDirectly) {
|
2005-04-02 14:24:43 +00:00
|
|
|
gdi.copyVirtScreenBuffers(spi->bbox, USAGE_BIT_RESTORED);
|
2005-02-26 10:02:22 +00:00
|
|
|
} else if (firstLoop) {
|
2005-02-24 04:04:17 +00:00
|
|
|
xmin = spi->bbox.left;
|
|
|
|
ymin = spi->bbox.top;
|
|
|
|
xmax = spi->bbox.right;
|
|
|
|
ymax = spi->bbox.bottom;
|
2005-02-26 10:02:22 +00:00
|
|
|
firstLoop = false;
|
|
|
|
refreshScreen = true;
|
|
|
|
} else {
|
2005-03-06 01:41:25 +00:00
|
|
|
if (xmin > spi->bbox.left) {
|
2005-02-26 10:02:22 +00:00
|
|
|
xmin = spi->bbox.left;
|
|
|
|
}
|
2005-03-06 01:41:25 +00:00
|
|
|
if (ymin > spi->bbox.top) {
|
2005-02-26 10:02:22 +00:00
|
|
|
ymin = spi->bbox.top;
|
|
|
|
}
|
2005-03-06 01:41:25 +00:00
|
|
|
if (xmax < spi->bbox.right) {
|
2005-02-26 10:02:22 +00:00
|
|
|
xmax = spi->bbox.right;
|
|
|
|
}
|
2005-03-06 01:41:25 +00:00
|
|
|
if (ymax < spi->bbox.bottom) {
|
2005-02-26 10:02:22 +00:00
|
|
|
ymax = spi->bbox.bottom;
|
|
|
|
}
|
|
|
|
refreshScreen = true;
|
2005-02-22 01:16:41 +00:00
|
|
|
}
|
2005-04-01 12:43:13 +00:00
|
|
|
if (!(spi->flags & (kSFNeedRedraw | kSF30)) && spi->resId)
|
2005-03-09 01:05:08 +00:00
|
|
|
spi->flags |= kSFNeedRedraw;
|
2005-02-22 01:16:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (refreshScreen) {
|
2005-04-02 14:24:43 +00:00
|
|
|
gdi.copyVirtScreenBuffers(Common::Rect(xmin, ymin, xmax, ymax), USAGE_BIT_RESTORED);
|
2005-02-22 01:16:41 +00:00
|
|
|
}
|
2005-02-20 22:16:31 +00:00
|
|
|
}
|
|
|
|
|
2005-02-22 21:38:44 +00:00
|
|
|
void ScummEngine_v90he::spritesMarkDirty(bool unkFlag) {
|
2005-04-02 15:59:02 +00:00
|
|
|
VirtScreen *vs = &virtscr[kMainVirtScreen];
|
2005-02-22 21:38:44 +00:00
|
|
|
for (int i = 0; i < _numSpritesToProcess; ++i) {
|
|
|
|
SpriteInfo *spi = _activeSpritesTable[i];
|
|
|
|
if (!(spi->flags & (kSFNeedRedraw | kSF30))) {
|
2005-04-01 06:30:46 +00:00
|
|
|
if ((!unkFlag || spi->zorderPriority >= 0) && (spi->flags & kSFMarkDirty)) {
|
2005-04-02 15:59:02 +00:00
|
|
|
int lp, rp;
|
2005-04-15 15:19:41 +00:00
|
|
|
lp = MAX(0, spi->bbox.left / 8);
|
|
|
|
lp = MIN(79, spi->bbox.left / 8);
|
|
|
|
rp = MAX(0, (spi->bbox.right + 7) / 8);
|
|
|
|
rp = MIN(79, (spi->bbox.right + 7) / 8);
|
2005-02-22 21:38:44 +00:00
|
|
|
for (; lp <= rp; ++lp) {
|
2005-04-02 15:59:02 +00:00
|
|
|
if (vs->tdirty[lp] < vs->h && spi->bbox.bottom >= vs->tdirty[lp] && spi->bbox.top <= vs->bdirty[lp]) {
|
2005-04-05 12:52:43 +00:00
|
|
|
spi->flags |= kSFNeedRedraw;
|
2005-02-22 21:38:44 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScummEngine_v90he::spritesUpdateImages() {
|
|
|
|
for (int i = 0; i < _numSpritesToProcess; ++i) {
|
|
|
|
SpriteInfo *spi = _activeSpritesTable[i];
|
2005-02-27 06:01:11 +00:00
|
|
|
if (spi->dx || spi->dy) {
|
2005-02-22 21:38:44 +00:00
|
|
|
int tx = spi->tx;
|
|
|
|
int ty = spi->ty;
|
|
|
|
spi->tx += spi->dx;
|
|
|
|
spi->ty += spi->dy;
|
|
|
|
if (tx != spi->tx || ty != spi->ty) {
|
2005-02-24 21:05:29 +00:00
|
|
|
spi->flags |= kSFChanged | kSFNeedRedraw;
|
2005-02-22 21:38:44 +00:00
|
|
|
}
|
|
|
|
}
|
2005-03-24 03:47:54 +00:00
|
|
|
if (spi->flags & kSFDelayed) {
|
2005-03-14 12:54:24 +00:00
|
|
|
if (spi->delayAmount) {
|
|
|
|
--spi->delayCount;
|
|
|
|
if (spi->delayCount)
|
2005-02-22 21:38:44 +00:00
|
|
|
continue;
|
2005-02-26 03:57:11 +00:00
|
|
|
|
2005-03-14 12:54:24 +00:00
|
|
|
spi->delayCount = spi->delayAmount;
|
2005-02-22 21:38:44 +00:00
|
|
|
}
|
2005-04-01 12:43:13 +00:00
|
|
|
int resState = spi->resState;
|
|
|
|
++spi->resState;
|
|
|
|
if (spi->resState >= spi->res_wiz_states) {
|
|
|
|
spi->resState = 0;
|
|
|
|
if (resState == 0)
|
2005-02-22 21:38:44 +00:00
|
|
|
continue;
|
|
|
|
}
|
2005-02-24 21:05:29 +00:00
|
|
|
spi->flags |= kSFChanged | kSFNeedRedraw;
|
2005-02-22 21:38:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-02-23 23:28:53 +00:00
|
|
|
static int compareSprTable(const void *a, const void *b) {
|
|
|
|
const SpriteInfo *spr1 = *(const SpriteInfo *const*)a;
|
|
|
|
const SpriteInfo *spr2 = *(const SpriteInfo *const*)b;
|
|
|
|
|
2005-02-26 11:22:00 +00:00
|
|
|
if (spr1->zorder > spr2->zorder)
|
2005-02-23 23:28:53 +00:00
|
|
|
return 1;
|
|
|
|
|
2005-02-26 11:22:00 +00:00
|
|
|
if (spr1->zorder < spr2->zorder)
|
2005-02-23 23:28:53 +00:00
|
|
|
return -1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScummEngine_v90he::spritesSortActiveSprites() {
|
2005-02-26 11:22:00 +00:00
|
|
|
int groupZorder;
|
2005-02-23 23:28:53 +00:00
|
|
|
|
|
|
|
_numSpritesToProcess = 0;
|
|
|
|
|
|
|
|
if (_varNumSprites <= 1)
|
|
|
|
return;
|
|
|
|
|
|
|
|
for (int i = 1; i < _varNumSprites; i++) {
|
|
|
|
SpriteInfo *spi = &_spriteTable[i];
|
|
|
|
|
2005-02-24 21:05:29 +00:00
|
|
|
if (spi->flags & kSFActive) {
|
2005-04-01 06:30:46 +00:00
|
|
|
if (!(spi->flags & kSFMarkDirty)) {
|
2005-02-24 08:00:30 +00:00
|
|
|
if (!(spi->flags & kSF30))
|
2005-02-23 23:28:53 +00:00
|
|
|
spi->flags |= kSFNeedRedraw;
|
2005-02-26 11:05:13 +00:00
|
|
|
if (!(spi->flags & kSFImageless))
|
2005-02-24 21:05:29 +00:00
|
|
|
spi->flags |= kSFChanged;
|
2005-02-23 23:28:53 +00:00
|
|
|
}
|
2005-04-01 12:43:13 +00:00
|
|
|
if (spi->groupNum)
|
|
|
|
groupZorder = _spriteGroups[spi->groupNum].zorderPriority;
|
2005-02-23 23:28:53 +00:00
|
|
|
else
|
2005-02-26 11:22:00 +00:00
|
|
|
groupZorder = 0;
|
2005-02-23 23:28:53 +00:00
|
|
|
|
2005-03-07 11:34:23 +00:00
|
|
|
spi->id = i;
|
2005-03-14 12:54:24 +00:00
|
|
|
spi->zorder = spi->zorderPriority + groupZorder;
|
2005-02-23 23:28:53 +00:00
|
|
|
|
|
|
|
_activeSpritesTable[_numSpritesToProcess++] = spi;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_numSpritesToProcess < 2)
|
|
|
|
return;
|
|
|
|
|
|
|
|
qsort(_activeSpritesTable, _numSpritesToProcess, sizeof(SpriteInfo *), compareSprTable);
|
|
|
|
}
|
|
|
|
|
2005-02-24 04:04:17 +00:00
|
|
|
void ScummEngine_v90he::spritesProcessWiz(bool arg) {
|
2005-02-25 01:20:46 +00:00
|
|
|
int spr_flags;
|
2005-02-24 04:04:17 +00:00
|
|
|
int16 spr_wiz_x, spr_wiz_y;
|
2005-04-01 12:43:13 +00:00
|
|
|
int resId, resState;
|
2005-02-24 04:04:17 +00:00
|
|
|
Common::Rect *bboxPtr;
|
2005-04-01 12:43:13 +00:00
|
|
|
int angle, zoom;
|
2005-02-25 20:15:01 +00:00
|
|
|
int32 w, h;
|
2005-02-24 04:04:17 +00:00
|
|
|
WizParameters wiz;
|
|
|
|
|
|
|
|
for (int i = 0; i < _numSpritesToProcess; i++) {
|
|
|
|
SpriteInfo *spi = _activeSpritesTable[i];
|
|
|
|
|
2005-04-02 14:24:43 +00:00
|
|
|
if (!(spi->flags & kSFNeedRedraw))
|
|
|
|
continue;
|
2005-02-24 04:04:17 +00:00
|
|
|
|
|
|
|
spr_flags = spi->flags;
|
|
|
|
|
|
|
|
if (arg) {
|
2005-02-26 11:22:00 +00:00
|
|
|
if (spi->zorder >= 0)
|
2005-02-26 00:35:23 +00:00
|
|
|
return;
|
2005-02-24 04:04:17 +00:00
|
|
|
} else {
|
2005-02-26 11:22:00 +00:00
|
|
|
if (spi->zorder < 0)
|
2005-02-26 00:35:23 +00:00
|
|
|
continue;
|
2005-02-24 04:04:17 +00:00
|
|
|
}
|
|
|
|
|
2005-03-17 09:28:36 +00:00
|
|
|
spi->flags &= ~kSFNeedRedraw;
|
2005-04-01 12:43:13 +00:00
|
|
|
resId = spi->resId;
|
|
|
|
resState = spi->resState;
|
|
|
|
loadImgSpot(spi->resId, spi->resState, spr_wiz_x, spr_wiz_y);
|
2005-02-24 04:04:17 +00:00
|
|
|
|
2005-04-01 12:43:13 +00:00
|
|
|
if (spi->groupNum) {
|
|
|
|
SpriteGroup *spg = &_spriteGroups[spi->groupNum];
|
2005-02-24 04:04:17 +00:00
|
|
|
|
|
|
|
if (spg->scaling) {
|
2005-04-15 08:34:18 +00:00
|
|
|
wiz.img.x1 = spi->tx * spg->scale_x_ratio_mul / spg->scale_x_ratio_div - spr_wiz_x + spg->tx;
|
|
|
|
wiz.img.y1 = spi->ty * spg->scale_y_ratio_mul / spg->scale_y_ratio_div - spr_wiz_y + spg->ty;
|
2005-02-24 04:04:17 +00:00
|
|
|
} else {
|
|
|
|
wiz.img.x1 = spi->tx - spr_wiz_x + spg->tx;
|
|
|
|
wiz.img.y1 = spi->ty - spr_wiz_y + spg->ty;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
wiz.img.x1 = spi->tx - spr_wiz_x;
|
|
|
|
wiz.img.y1 = spi->ty - spr_wiz_y;
|
|
|
|
}
|
2005-02-24 05:11:37 +00:00
|
|
|
|
2005-04-30 05:34:31 +00:00
|
|
|
wiz.spriteId = spi->id;
|
|
|
|
wiz.groupNum = spi->groupNum;
|
2005-04-30 05:25:06 +00:00
|
|
|
wiz.field_23EA = spi->field_90;
|
2005-04-01 12:43:13 +00:00
|
|
|
spi->curImageState = wiz.img.state = resState;
|
|
|
|
spi->curResId = wiz.img.resNum = resId;
|
2005-02-24 20:20:35 +00:00
|
|
|
wiz.processFlags = kWPFNewState | kWPFSetPos;
|
2005-04-01 12:43:13 +00:00
|
|
|
spi->curAngle = spi->angle;
|
2005-04-03 02:24:28 +00:00
|
|
|
spi->curZoom = spi->zoom;
|
2005-02-27 03:36:33 +00:00
|
|
|
spi->pos.x = wiz.img.x1;
|
|
|
|
spi->pos.y = wiz.img.y1;
|
2005-02-24 04:04:17 +00:00
|
|
|
bboxPtr = &spi->bbox;
|
2005-04-01 12:43:13 +00:00
|
|
|
if (resId) {
|
|
|
|
angle = spi->angle;
|
2005-02-24 04:04:17 +00:00
|
|
|
zoom = spi->zoom;
|
2005-04-01 12:43:13 +00:00
|
|
|
getWizImageDim(resId, resState, w, h);
|
2005-03-31 02:28:14 +00:00
|
|
|
if (!(spi->flags & (kSFZoomed | kSFRotated))) {
|
2005-02-24 04:04:17 +00:00
|
|
|
bboxPtr->left = wiz.img.x1;
|
|
|
|
bboxPtr->top = wiz.img.y1;
|
2005-02-25 01:15:16 +00:00
|
|
|
bboxPtr->right = wiz.img.x1 + w;
|
|
|
|
bboxPtr->bottom = wiz.img.y1 + h;
|
2005-02-24 04:04:17 +00:00
|
|
|
} else {
|
2005-02-25 01:15:16 +00:00
|
|
|
Common::Point pts[4];
|
|
|
|
|
|
|
|
pts[1].x = pts[2].x = w / 2 - 1;
|
|
|
|
pts[0].x = pts[0].y = pts[1].y = pts[3].x = -w / 2;
|
|
|
|
pts[2].y = pts[3].y = h / 2 - 1;
|
|
|
|
|
2005-03-31 02:28:14 +00:00
|
|
|
if ((spi->flags & kSFZoomed) && zoom) {
|
2005-02-25 01:15:16 +00:00
|
|
|
for (int j = 0; j < 4; ++j) {
|
2005-03-31 02:28:14 +00:00
|
|
|
pts[j].x = pts[j].x * zoom / 256;
|
|
|
|
pts[j].y = pts[j].y * zoom / 256;
|
2005-02-25 01:15:16 +00:00
|
|
|
}
|
|
|
|
}
|
2005-04-01 12:43:13 +00:00
|
|
|
if ((spi->flags & kSFRotated) && angle)
|
|
|
|
_wiz.polygonRotatePoints(pts, 4, angle);
|
2005-02-25 01:15:16 +00:00
|
|
|
|
|
|
|
for (int j = 0; j < 4; ++j) {
|
|
|
|
pts[j].x += wiz.img.x1;
|
|
|
|
pts[j].y += wiz.img.y1;
|
|
|
|
}
|
|
|
|
|
2005-02-25 11:23:27 +00:00
|
|
|
_wiz.polygonCalcBoundBox(pts, 4, spi->bbox);
|
2005-02-24 04:04:17 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
bboxPtr->left = 1234;
|
|
|
|
bboxPtr->top = 1234;
|
|
|
|
bboxPtr->right = -1234;
|
|
|
|
bboxPtr->bottom = -1234;
|
|
|
|
}
|
|
|
|
|
2005-03-23 21:55:11 +00:00
|
|
|
wiz.img.flags = kWIFMarkBufferDirty;
|
2005-03-13 13:10:39 +00:00
|
|
|
if (spr_flags & kSFXFlipped)
|
2005-02-24 20:20:35 +00:00
|
|
|
wiz.img.flags |= kWIFFlipX;
|
2005-03-13 13:10:39 +00:00
|
|
|
if (spr_flags & kSFYFlipped)
|
2005-02-24 20:20:35 +00:00
|
|
|
wiz.img.flags |= kWIFFlipY;
|
2005-03-24 03:47:54 +00:00
|
|
|
if (spr_flags & kSFDoubleBuffered) {
|
2005-03-23 21:55:11 +00:00
|
|
|
wiz.img.flags &= ~kWIFMarkBufferDirty;
|
2005-02-24 20:20:35 +00:00
|
|
|
wiz.img.flags |= kWIFBlitToFrontVideoBuffer;
|
2005-02-24 04:04:17 +00:00
|
|
|
}
|
2005-04-01 12:43:13 +00:00
|
|
|
if (spi->xmapNum) {
|
2005-02-24 04:04:17 +00:00
|
|
|
wiz.img.flags |= 0x200;
|
2005-04-20 06:55:30 +00:00
|
|
|
wiz.processFlags |= kWPFXmapNum;
|
2005-04-01 12:43:13 +00:00
|
|
|
wiz.xmapNum = spi->xmapNum;
|
2005-02-24 04:04:17 +00:00
|
|
|
}
|
2005-03-24 03:47:54 +00:00
|
|
|
if (spr_flags & kSFNeedPaletteRemap)
|
2005-03-23 21:55:11 +00:00
|
|
|
wiz.img.flags |= kWIFRemapPalette;
|
2005-04-20 10:33:20 +00:00
|
|
|
if (spi->field_84) {
|
|
|
|
wiz.processFlags |= 0x200000;
|
2005-04-30 05:25:06 +00:00
|
|
|
wiz.img.field_390 = spi->field_84;
|
|
|
|
wiz.img.zorder = spi->zorderPriority;
|
2005-04-20 10:33:20 +00:00
|
|
|
}
|
2005-04-20 05:24:02 +00:00
|
|
|
if (spi->maskImgResNum) {
|
2005-04-19 17:55:09 +00:00
|
|
|
wiz.processFlags |= kWPFMaskImg;
|
2005-04-20 05:24:02 +00:00
|
|
|
wiz.maskImgResNum = spi->maskImgResNum;
|
2005-02-24 04:04:17 +00:00
|
|
|
}
|
2005-02-24 20:20:35 +00:00
|
|
|
wiz.processFlags |= kWPFNewFlags;
|
2005-04-20 10:33:20 +00:00
|
|
|
wiz.img.flags |= spi->imgFlags;
|
2005-02-24 04:04:17 +00:00
|
|
|
|
|
|
|
if (spr_flags & kSFRotated) {
|
2005-02-24 20:20:35 +00:00
|
|
|
wiz.processFlags |= kWPFRotate;
|
2005-04-01 12:43:13 +00:00
|
|
|
wiz.angle = spi->angle;
|
2005-02-24 04:04:17 +00:00
|
|
|
}
|
|
|
|
if (spr_flags & kSFZoomed) {
|
2005-02-24 20:20:35 +00:00
|
|
|
wiz.processFlags |= kWPFZoom;
|
2005-02-24 04:04:17 +00:00
|
|
|
wiz.zoom = spi->zoom;
|
|
|
|
}
|
2005-04-20 10:33:20 +00:00
|
|
|
spi->curImgFlags = wiz.img.flags;
|
2005-02-24 04:04:17 +00:00
|
|
|
|
2005-04-01 12:43:13 +00:00
|
|
|
if (spi->groupNum && (_spriteGroups[spi->groupNum].flags & kSGFClipBox)) {
|
|
|
|
if (spi->bbox.intersects(_spriteGroups[spi->groupNum].bbox)) {
|
|
|
|
spi->bbox.clip(_spriteGroups[spi->groupNum].bbox);
|
2005-02-27 03:36:33 +00:00
|
|
|
wiz.processFlags |= kWPFClipBox;
|
2005-02-24 23:28:56 +00:00
|
|
|
wiz.box = spi->bbox;
|
|
|
|
} else {
|
|
|
|
bboxPtr->left = 1234;
|
|
|
|
bboxPtr->top = 1234;
|
|
|
|
bboxPtr->right = -1234;
|
|
|
|
bboxPtr->bottom = -1234;
|
|
|
|
continue;
|
|
|
|
}
|
2005-02-24 04:04:17 +00:00
|
|
|
}
|
2005-03-31 22:51:54 +00:00
|
|
|
if (spi->paletteNum) {
|
|
|
|
wiz.processFlags |= kWPFPaletteNum;
|
|
|
|
wiz.img.paletteNum = spi->paletteNum;
|
2005-02-24 04:04:17 +00:00
|
|
|
}
|
2005-04-01 12:43:13 +00:00
|
|
|
if (spi->resId && spi->groupNum && _spriteGroups[spi->groupNum].dstResNum) {
|
2005-04-01 08:51:13 +00:00
|
|
|
wiz.processFlags |= kWPFDstResNum;
|
2005-04-01 12:43:13 +00:00
|
|
|
wiz.dstResNum = _spriteGroups[spi->groupNum].dstResNum;
|
2005-02-24 04:04:17 +00:00
|
|
|
}
|
|
|
|
displayWizComplexImage(&wiz);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-04-08 23:27:36 +00:00
|
|
|
void ScummEngine_v90he::saveOrLoadSpriteData(Serializer *s, uint32 savegameVersion) {
|
|
|
|
static const SaveLoadEntry spriteEntries[] = {
|
|
|
|
MKLINE(SpriteInfo, id, sleInt32, VER(48)),
|
|
|
|
MKLINE(SpriteInfo, zorder, sleInt32, VER(48)),
|
|
|
|
MKLINE(SpriteInfo, flags, sleInt32, VER(48)),
|
|
|
|
MKLINE(SpriteInfo, resId, sleInt32, VER(48)),
|
|
|
|
MKLINE(SpriteInfo, resState, sleInt32, VER(48)),
|
|
|
|
MKLINE(SpriteInfo, groupNum, sleInt32, VER(48)),
|
|
|
|
MKLINE(SpriteInfo, paletteNum, sleInt32, VER(48)),
|
|
|
|
MKLINE(SpriteInfo, zorderPriority, sleInt32, VER(48)),
|
|
|
|
MKLINE(SpriteInfo, bbox.left, sleInt32, VER(48)),
|
|
|
|
MKLINE(SpriteInfo, bbox.top, sleInt32, VER(48)),
|
|
|
|
MKLINE(SpriteInfo, bbox.right, sleInt32, VER(48)),
|
|
|
|
MKLINE(SpriteInfo, bbox.bottom, sleInt32, VER(48)),
|
|
|
|
MKLINE(SpriteInfo, dx, sleInt32, VER(48)),
|
|
|
|
MKLINE(SpriteInfo, dy, sleInt32, VER(48)),
|
|
|
|
MKLINE(SpriteInfo, pos.x, sleInt32, VER(48)),
|
|
|
|
MKLINE(SpriteInfo, pos.y, sleInt32, VER(48)),
|
|
|
|
MKLINE(SpriteInfo, tx, sleInt32, VER(48)),
|
|
|
|
MKLINE(SpriteInfo, ty, sleInt32, VER(48)),
|
|
|
|
MKLINE(SpriteInfo, field_44, sleInt32, VER(48)),
|
|
|
|
MKLINE(SpriteInfo, curImageState, sleInt32, VER(48)),
|
|
|
|
MKLINE(SpriteInfo, curResId, sleInt32, VER(48)),
|
|
|
|
MKLINE(SpriteInfo, imglistNum, sleInt32, VER(48)),
|
|
|
|
MKLINE(SpriteInfo, xmapNum, sleInt32, VER(48)),
|
|
|
|
MKLINE(SpriteInfo, res_wiz_states, sleInt32, VER(48)),
|
|
|
|
MKLINE(SpriteInfo, angle, sleInt32, VER(48)),
|
|
|
|
MKLINE(SpriteInfo, zoom, sleInt32, VER(48)),
|
|
|
|
MKLINE(SpriteInfo, delayCount, sleInt32, VER(48)),
|
|
|
|
MKLINE(SpriteInfo, curAngle, sleInt32, VER(48)),
|
|
|
|
MKLINE(SpriteInfo, curZoom, sleInt32, VER(48)),
|
2005-04-20 10:33:20 +00:00
|
|
|
MKLINE(SpriteInfo, curImgFlags, sleInt32, VER(48)),
|
2005-04-08 23:27:36 +00:00
|
|
|
MKLINE(SpriteInfo, field_74, sleInt32, VER(48)),
|
|
|
|
MKLINE(SpriteInfo, delayAmount, sleInt32, VER(48)),
|
2005-04-20 05:24:02 +00:00
|
|
|
MKLINE(SpriteInfo, maskImgResNum, sleInt32, VER(48)),
|
2005-04-08 23:27:36 +00:00
|
|
|
MKLINE(SpriteInfo, field_80, sleInt32, VER(48)),
|
2005-04-11 07:40:14 +00:00
|
|
|
MKLINE(SpriteInfo, field_84, sleInt32, VER(48)),
|
2005-04-08 23:27:36 +00:00
|
|
|
MKLINE(SpriteInfo, classFlags, sleInt32, VER(48)),
|
2005-04-20 10:33:20 +00:00
|
|
|
MKLINE(SpriteInfo, imgFlags, sleInt32, VER(48)),
|
2005-04-08 23:27:36 +00:00
|
|
|
MKLINE(SpriteInfo, field_90, sleInt32, VER(48)),
|
|
|
|
MKEND()
|
|
|
|
};
|
|
|
|
|
|
|
|
static const SaveLoadEntry spriteGroupEntries[] = {
|
|
|
|
MKLINE(SpriteGroup, bbox.left, sleInt32, VER(48)),
|
|
|
|
MKLINE(SpriteGroup, bbox.top, sleInt32, VER(48)),
|
|
|
|
MKLINE(SpriteGroup, bbox.right, sleInt32, VER(48)),
|
|
|
|
MKLINE(SpriteGroup, bbox.bottom, sleInt32, VER(48)),
|
|
|
|
MKLINE(SpriteGroup, zorderPriority, sleInt32, VER(48)),
|
|
|
|
MKLINE(SpriteGroup, flags, sleInt32, VER(48)),
|
|
|
|
MKLINE(SpriteGroup, tx, sleInt32, VER(48)),
|
|
|
|
MKLINE(SpriteGroup, ty, sleInt32, VER(48)),
|
|
|
|
MKLINE(SpriteGroup, dstResNum, sleInt32, VER(48)),
|
|
|
|
MKLINE(SpriteGroup, scaling, sleInt32, VER(48)),
|
|
|
|
MKLINE(SpriteGroup, scale_x_ratio_mul, sleInt32, VER(48)),
|
|
|
|
MKLINE(SpriteGroup, scale_x_ratio_div, sleInt32, VER(48)),
|
|
|
|
MKLINE(SpriteGroup, scale_y_ratio_mul, sleInt32, VER(48)),
|
|
|
|
MKLINE(SpriteGroup, scale_y_ratio_div, sleInt32, VER(48)),
|
|
|
|
MKEND()
|
|
|
|
};
|
|
|
|
|
|
|
|
s->saveLoadArrayOf(_activeSpritesTable, _varNumSprites, sizeof(_activeSpritesTable[0]), spriteEntries);
|
|
|
|
s->saveLoadArrayOf(_spriteTable, _varNumSprites, sizeof(_spriteTable[0]), spriteEntries);
|
|
|
|
s->saveLoadArrayOf(_spriteGroups, _varNumSpriteGroups, sizeof(_spriteGroups[0]), spriteGroupEntries);
|
|
|
|
}
|
|
|
|
|
2005-02-20 10:56:59 +00:00
|
|
|
} // End of namespace Scumm
|