aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--scumm/intern.h2
-rw-r--r--scumm/script_v100he.cpp2
-rw-r--r--scumm/script_v90he.cpp20
-rw-r--r--scumm/sprite_he.cpp82
4 files changed, 92 insertions, 14 deletions
diff --git a/scumm/intern.h b/scumm/intern.h
index 3e48bdf504..f7ffe5f31c 100644
--- a/scumm/intern.h
+++ b/scumm/intern.h
@@ -875,7 +875,7 @@ protected:
uint8 getWizPixelColor(int restype, int resnum, int state, int x, int y, int flags);
int computeWizHistogram(int resnum, int state, int x, int y, int w, int h);
- int spriteInfoGet_case15(int a, int b, int c, int d, int num, int *args);
+ int findSpriteWithClassOf(int x, int y, int spriteGroup, int d, int num, int *args);
int spriteInfoGet_classFlags(int spriteId, int num);
int spriteInfoGet_classFlagsAnd(int spriteId, int num, int *args);
int spriteInfoGet_flags_13(int spriteId);
diff --git a/scumm/script_v100he.cpp b/scumm/script_v100he.cpp
index 9180e27a53..f61e880dd8 100644
--- a/scumm/script_v100he.cpp
+++ b/scumm/script_v100he.cpp
@@ -2425,7 +2425,7 @@ void ScummEngine_v100he::o100_getSpriteInfo() {
d = pop();
e = pop();
f = pop();
- push(spriteInfoGet_case15(f, e, d, c, flags, args));
+ push(findSpriteWithClassOf(f, e, d, c, flags, args));
break;
case 38:
spriteId = pop();
diff --git a/scumm/script_v90he.cpp b/scumm/script_v90he.cpp
index 90276a1934..8df4eccf18 100644
--- a/scumm/script_v90he.cpp
+++ b/scumm/script_v90he.cpp
@@ -829,18 +829,18 @@ void ScummEngine_v90he::o90_getSpriteInfo() {
d = pop();
e = pop();
f = pop();
- push(spriteInfoGet_case15(f, e, d, c, flags, args));
+ push(findSpriteWithClassOf(f, e, d, c, flags, args));
} else if (_heversion == 98) {
- pop();
- pop();
- pop();
- pop();
- push(0);
+ c = pop();
+ d = pop();
+ e = pop();
+ f = pop();
+ push(findSpriteWithClassOf(f, e, d, c, 0, 0));
} else {
- pop();
- pop();
- pop();
- push(0);
+ d = pop();
+ e = pop();
+ f = pop();
+ push(findSpriteWithClassOf(f, e, d, 0, 0, 0));
}
break;
case 22:
diff --git a/scumm/sprite_he.cpp b/scumm/sprite_he.cpp
index 1ac7a21e61..4afbbbca72 100644
--- a/scumm/sprite_he.cpp
+++ b/scumm/sprite_he.cpp
@@ -39,8 +39,86 @@ void ScummEngine_v90he::allocateArrays() {
//
// spriteInfoGet functions
//
-int ScummEngine_v90he::spriteInfoGet_case15(int a, int b, int c, int d, int num, int *args) {
- // TODO
+int ScummEngine_v90he::findSpriteWithClassOf(int x, int y, int spriteGroup, int d, int num, int *args) {
+ int classId;
+ debug(1, "findSprite: x %d, y %d, spriteGroup %d, d %d, num %d\n", x, y, spriteGroup, d, num);
+
+ for (int i = 0; i < _numSpritesToProcess; ++i) {
+ SpriteInfo *spi = _activeSpritesTable[i];
+ if (!spi->field_4C)
+ continue;
+
+ if (spriteGroup && spi->group_num != spi->field_4C)
+ continue;
+
+ for (int j = 0; j < num; j++) {
+ classId = args[j] & 0x7F;
+ checkRange(32, 1, classId, "class %d out of range in statement");
+ if (!(spi->class_flags & (1 << classId)))
+ continue;
+ }
+
+ if (d != 0) {
+ if (spi->bbox.left > spi->bbox.right)
+ continue;
+ if (spi->bbox.top > spi->bbox.bottom)
+ continue;
+ if (spi->bbox.left > x)
+ continue;
+ if (spi->bbox.top > y)
+ continue;
+ if (spi->bbox.right < x)
+ continue;
+ if (spi->bbox.bottom < y)
+ continue;
+ return i;
+ } else {
+ int state;
+ int resId = spi->field_4C;
+
+ if (spi->field_80) {
+ int16 x1, x2, y1, y2;
+
+ state = getWizImageStates(spi->field_80);
+ state /= spi->field_48;
+
+ x -= spi->field_34;
+ y -= spi->field_38;
+
+ loadImgSpot(spi->field_4C, state, x1, y1);
+ loadImgSpot(spi->field_80, state, x2, y2);
+
+ x += (x2 - x1);
+ y += (y2 - y1);
+ } else {
+ if (spi->bbox.left > spi->bbox.right)
+ continue;
+ if (spi->bbox.top > spi->bbox.bottom)
+ continue;
+ if (spi->bbox.left > x)
+ continue;
+ if (spi->bbox.top > y)
+ continue;
+ if (spi->bbox.right < x)
+ continue;
+ if (spi->bbox.bottom < y)
+ continue;
+
+ x -= spi->field_34;
+ y -= spi->field_38;
+ state = spi->field_48;
+ }
+
+ if ((spi->flags & kSFZoomed) || (spi->flags & kSFRotated)) {
+ // TODO
+
+ }
+
+ if(isWizPixelNonTransparent(rtImage, resId, state, x, y, spi->imgFlags));
+ return i;
+ }
+ }
+
return 0;
}