aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregory Montoir2005-02-20 22:16:31 +0000
committerGregory Montoir2005-02-20 22:16:31 +0000
commitf1f7e6ce7a06ceaf53bd51933c71c95ad37fce7c (patch)
treeb58df47d6930ae4c99fff1732aba676a7f6f2e05
parent78533d416f63ffc236dfad3a3f838c0daca95da3 (diff)
downloadscummvm-rg350-f1f7e6ce7a06ceaf53bd51933c71c95ad37fce7c.tar.gz
scummvm-rg350-f1f7e6ce7a06ceaf53bd51933c71c95ad37fce7c.tar.bz2
scummvm-rg350-f1f7e6ce7a06ceaf53bd51933c71c95ad37fce7c.zip
some WIP HE sprites stuff
svn-id: r16832
-rw-r--r--scumm/intern.h4
-rw-r--r--scumm/sprite_he.cpp80
-rw-r--r--scumm/sprite_he.h14
3 files changed, 95 insertions, 3 deletions
diff --git a/scumm/intern.h b/scumm/intern.h
index b21e0f452a..f891eaccc0 100644
--- a/scumm/intern.h
+++ b/scumm/intern.h
@@ -879,6 +879,10 @@ protected:
int spriteInfoGet_flags_6(int spriteNum);
int spriteInfoGet_flags_7(int spriteNum);
int spriteInfoGet_flags_8(int spriteNum);
+ void spritesAllocTables(int numSprites, int numGroups, int numImgSprites);
+ void spritesResetTables(bool refreshScreen);
+ void spriteGroupCheck(int sprGrpId);
+ void spriteMarkIfInGroup(int sprGrpId, uint32 flags);
/* HE version 90 script opcodes */
void o90_dup();
diff --git a/scumm/sprite_he.cpp b/scumm/sprite_he.cpp
index 2e499b7f57..72d7433915 100644
--- a/scumm/sprite_he.cpp
+++ b/scumm/sprite_he.cpp
@@ -31,10 +31,8 @@
namespace Scumm {
void ScummEngine_v90he::allocateArrays() {
- _spriteGroups = (SpriteGroup *)calloc(_numSprites, sizeof(SpriteGroup));
- _spriteTable = (SpriteInfo *)calloc(_numSprites, sizeof(SpriteInfo));
-
ScummEngine::allocateArrays();
+ spritesAllocTables(_numSprites, 64, 64);
}
int ScummEngine_v90he::spriteInfoGet_flags_1(int spriteNum) {
@@ -85,4 +83,80 @@ int ScummEngine_v90he::spriteInfoGet_flags_8(int spriteNum) {
return ((_spriteTable[spriteNum].flags & kSF31) != 0) ? 1 : 0;
}
+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
diff --git a/scumm/sprite_he.h b/scumm/sprite_he.h
index 910ce1c490..a0c9700982 100644
--- a/scumm/sprite_he.h
+++ b/scumm/sprite_he.h
@@ -60,6 +60,11 @@ enum SpriteFlags {
kSF32 = (1 << 31)
};
+enum SpriteGroupFlags {
+ kSGF1 = 1 << 0,
+ kSFG2 = 1 << 1
+};
+
struct SpriteInfo {
int field_0;
int flags;
@@ -116,8 +121,17 @@ struct SpriteGroup {
int field_3C;
};
+ int _varNumSpriteGroups;
+ int _numSpritesToProcess;
+ int _varNumSprites;
+ int _varNumImgLists;
SpriteInfo *_spriteTable;
SpriteGroup *_spriteGroups;
+ SpriteInfo **_activeSpritesTable;
+ uint32 *_imageListTable; // XXX wrong type
+ uint16 *_imageListStack;
+ int _curSprImageListNum;
+
} // End of namespace Scumm