scummvm/scumm/sprite_he.cpp
Travis Howell 8ae3fe1ffe Add more sprite functions
svn-id: r16833
2005-02-20 23:30:37 +00:00

235 lines
7.4 KiB
C++

/* 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"
#include "scumm/scumm.h"
#include "scumm/sprite_he.h"
#include "scumm/wiz_he.h"
namespace Scumm {
void ScummEngine_v90he::allocateArrays() {
ScummEngine::allocateArrays();
spritesAllocTables(_numSprites, 64, 64);
}
int ScummEngine_v90he::spriteInfoGet_flags_1(int spriteNum) {
checkRange(_numSprites, 1, spriteNum, "_spriteTableGet_flags_1: Invalid sprite %d");
return ((_spriteTable[spriteNum].flags & kSF15) != 0) ? 1 : 0;
}
int ScummEngine_v90he::spriteInfoGet_flags_2(int spriteNum) {
checkRange(_numSprites, 1, spriteNum, "_spriteTableGet_flags_2: Invalid sprite %d");
return ((_spriteTable[spriteNum].flags & kSF14) != 0) ? 1 : 0;
}
int ScummEngine_v90he::spriteInfoGet_flags_3(int spriteNum) {
checkRange(_numSprites, 1, spriteNum, "_spriteTableGet_flags_3: Invalid sprite %d");
return ((_spriteTable[spriteNum].flags & kSF16) != 0) ? 1 : 0;
}
int ScummEngine_v90he::spriteInfoGet_flags_4(int spriteNum) {
checkRange(_numSprites, 1, spriteNum, "_spriteTableGet_flags_4: Invalid sprite %d");
return ((_spriteTable[spriteNum].flags & kSF13) != 0) ? 1 : 0;
}
int ScummEngine_v90he::spriteInfoGet_flags_5(int spriteNum) {
checkRange(_numSprites, 1, spriteNum, "_spriteTableGet_flags_5: Invalid sprite %d");
return ((_spriteTable[spriteNum].flags & kSF20) != 0) ? 1 : 0;
}
int ScummEngine_v90he::spriteInfoGet_flags_6(int spriteNum) {
checkRange(_numSprites, 1, spriteNum, "_spriteTableGet_flags_6: Invalid sprite %d");
return _spriteTable[spriteNum].flags & kSF22;
}
int ScummEngine_v90he::spriteInfoGet_flags_7(int spriteNum) {
checkRange(_numSprites, 1, spriteNum, "_spriteTableGet_flags_7: Invalid sprite %d");
return ((_spriteTable[spriteNum].flags & kSF23) != 0) ? 1 : 0;
}
int ScummEngine_v90he::spriteInfoGet_flags_8(int spriteNum) {
checkRange(_numSprites, 1, spriteNum, "_spriteTableGet_flags_8: Invalid sprite %d");
return ((_spriteTable[spriteNum].flags & kSF31) != 0) ? 1 : 0;
}
int ScummEngine_v90he::spriteInfoGet_resId(int spriteNum) {
checkRange(_numSprites, 1, spriteNum, "spriteInfoGet_resId: Invalid sprite %d");
return _spriteTable[spriteNum].res_id;
}
int ScummEngine_v90he::spriteInfoGet_resState(int spriteNum) {
checkRange(_numSprites, 1, spriteNum, "spriteInfoGet_resState: Invalid sprite %d");
return _spriteTable[spriteNum].res_state;
}
int ScummEngine_v90he::spriteInfoGet_groupNum(int spriteNum) {
checkRange(_numSprites, 1, spriteNum, "spriteInfoGet_groupNum: Invalid sprite %d");
return _spriteTable[spriteNum].group_num;
}
int ScummEngine_v90he::spriteInfoGet_field_18(int spriteNum) {
checkRange(_numSprites, 1, spriteNum, "spriteInfoGet_field_18: Invalid sprite %d");
return _spriteTable[spriteNum].field_18;
}
int ScummEngine_v90he::spriteInfoGet_grp_tx(int spriteNum) {
checkRange(_numSprites, 1, spriteNum, "spriteInfoGet_grp_tx: Invalid sprite %d");
return _spriteTable[spriteNum].tx;
}
int ScummEngine_v90he::spriteInfoGet_grp_ty(int spriteNum) {
checkRange(_numSprites, 1, spriteNum, "spriteInfoGet_grp_ty: Invalid sprite %d");
return _spriteTable[spriteNum].ty;
}
int ScummEngine_v90he::spriteInfoGet_field_44(int spriteNum) {
checkRange(_numSprites, 1, spriteNum, "spriteInfoGet_field_44: Invalid sprite %d");
return _spriteTable[spriteNum].field_44;
}
int ScummEngine_v90he::spriteInfoGet_field_54(int spriteNum) {
checkRange(_numSprites, 1, spriteNum, "spriteInfoGet_field_54: Invalid sprite %d");
return _spriteTable[spriteNum].field_54;
}
int ScummEngine_v90he::spriteInfoGet_wizSize(int spriteNum) {
checkRange(_numSprites, 1, spriteNum, "spriteInfoGet_wizSize: Invalid sprite %d");
return _spriteTable[spriteNum].res_wiz_states;
}
int ScummEngine_v90he::spriteInfoGet_zoom(int spriteNum) {
checkRange(_numSprites, 1, spriteNum, "spriteInfoGet_zoom: Invalid sprite %d");
return _spriteTable[spriteNum].zoom;
}
int ScummEngine_v90he::spriteInfoGet_field_78(int spriteNum) {
checkRange(_numSprites, 1, spriteNum, "spriteInfoGet_field_78: Invalid sprite %d");
return _spriteTable[spriteNum].field_78;
}
int ScummEngine_v90he::spriteInfoGet_field_80(int spriteNum) {
checkRange(_numSprites, 1, spriteNum, "spriteInfoGet_field_80: Invalid sprite %d");
return _spriteTable[spriteNum].field_80;
}
void ScummEngine_v90he::spritesAllocTables(int numSprites, int numGroups, int numImgLists) {
_varNumSpriteGroups = numGroups;
_numSpritesToProcess = 0;
_varNumSprites = numSprites;
_varNumImgLists = numImgLists;
_spriteGroups = (SpriteGroup *)malloc((_varNumSpriteGroups + 1) * sizeof(SpriteGroup));
_spriteTable = (SpriteInfo *)malloc((_varNumSprites + 1) * sizeof(SpriteInfo));
_activeSpritesTable = (SpriteInfo **)malloc((_varNumSprites + 1) * sizeof(SpriteInfo *));
_imageListTable = (uint32 *)malloc((_varNumImgLists + 1) * sizeof(uint32)); // XXX
_imageListStack = (uint16 *)malloc((_varNumImgLists + 1) * sizeof(uint16));
}
void ScummEngine_v90he::spritesResetTables(bool refreshScreen) {
int i;
for (i = 0; i < _varNumImgLists; ++i) {
_imageListStack[i] = i;
}
memset(_spriteTable, 0, (_varNumSprites + 1) * sizeof(SpriteInfo));
memset(_spriteGroups, 0, (_varNumSpriteGroups + 1) * sizeof(SpriteGroup));
for (int curGrp = 1; curGrp < _varNumSpriteGroups; ++curGrp) {
SpriteGroup *spg = &_spriteGroups[curGrp];
checkRange(_varNumSpriteGroups, 1, curGrp, "Invalid sprite group %d");
if (spg->field_10 != 0) {
spg->field_10 = 0;
spriteGroupCheck(curGrp);
for (i = 0; i < _numSpritesToProcess; ++i) {
SpriteInfo *spi = _activeSpritesTable[i];
if (spi->group_num == curGrp) {
spi->flags |= kSF1 | kSF2;
}
}
}
if (spg->tx != 0 || spg->ty != 0) {
spg->tx = spg->ty = 0;
spriteGroupCheck(curGrp);
for (i = 0; i < _numSpritesToProcess; ++i) {
SpriteInfo *spi = _activeSpritesTable[i];
if (spi->group_num == curGrp) {
spi->flags |= kSF1 | kSF2;
}
}
}
spg->flags &= ~kSGF1;
spriteMarkIfInGroup(curGrp, kSF1 | kSF2);
if (spg->field_20 != 0) {
spriteGroupCheck(curGrp);
for (i = 0; i < _numSpritesToProcess; ++i) {
SpriteInfo *spi = _activeSpritesTable[i];
if (spi->group_num == curGrp) {
spi->flags |= kSF1 | kSF2;
}
}
}
spriteGroupCheck(curGrp);
spg->scaling = 0;
spg->scale_x = 0x3F800000;
spg->field_30 = 0;
spg->field_34 = 0;
spg->scale_y = 0x3F800000;
spg->field_38 = 0;
spg->field_3C = 0;
}
if (refreshScreen) {
gdi.copyVirtScreenBuffers(Common::Rect(_screenWidth, _screenHeight));
}
_numSpritesToProcess = 0;
}
void ScummEngine_v90he::spriteGroupCheck(int sprGrpId) {
// XXX
}
void ScummEngine_v90he::spriteMarkIfInGroup(int sprGrpId, uint32 flags) {
// XXX
}
} // End of namespace Scumm