aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTravis Howell2006-10-13 02:22:33 +0000
committerTravis Howell2006-10-13 02:22:33 +0000
commit1ab09fd79becbdc07ee0313a6e82c3d5124a3c83 (patch)
tree0bf4a8ff719b6485597b7c69a60ee716293df1db
parent929375ae21f92ef1b56908aba92ac6ca4563526f (diff)
downloadscummvm-rg350-1ab09fd79becbdc07ee0313a6e82c3d5124a3c83.tar.gz
scummvm-rg350-1ab09fd79becbdc07ee0313a6e82c3d5124a3c83.tar.bz2
scummvm-rg350-1ab09fd79becbdc07ee0313a6e82c3d5124a3c83.zip
Fix display of icons in Elvira 1
svn-id: r24284
-rw-r--r--engines/agos/agos.cpp24
-rw-r--r--engines/agos/icons.cpp67
-rw-r--r--engines/agos/window.cpp4
3 files changed, 57 insertions, 38 deletions
diff --git a/engines/agos/agos.cpp b/engines/agos/agos.cpp
index df1f07b3de..e85172f9ff 100644
--- a/engines/agos/agos.cpp
+++ b/engines/agos/agos.cpp
@@ -800,7 +800,7 @@ int AGOSEngine::getUserFlag(Item *item, int a) {
if (subUserFlag == NULL)
return 0;
- if (a < 0 || a > 3)
+ if (a < 0 || a > 7)
return 0;
return subUserFlag->userFlags[a];
@@ -814,8 +814,10 @@ void AGOSEngine::setUserFlag(Item *item, int a, int b) {
subUserFlag = (SubUserFlag *) allocateChildBlock(item, 9, sizeof(SubUserFlag));
}
- if (a >= 0 && a <= 3)
- subUserFlag->userFlags[a] = b;
+ if (a < 0 || a > 7)
+ return;
+
+ subUserFlag->userFlags[a] = b;
}
int AGOSEngine::getUserItem(Item *item, int n) {
@@ -1300,14 +1302,18 @@ bool AGOSEngine::has_item_childflag_0x10(Item *item) {
}
uint AGOSEngine::itemGetIconNumber(Item *item) {
- SubObject *child = (SubObject *)findChildOfType(item, 2);
- uint offs;
+ if (getGameType() == GType_ELVIRA1) {
+ return getUserFlag(item, 7);
+ } else {
+ SubObject *child = (SubObject *)findChildOfType(item, 2);
+ uint offs;
- if (child == NULL || !(child->objectFlags & kOFIcon))
- return 0;
+ if (child == NULL || !(child->objectFlags & kOFIcon))
+ return 0;
- offs = getOffsetOfChild2Param(child, 0x10);
- return child->objectFlagValue[offs];
+ offs = getOffsetOfChild2Param(child, 0x10);
+ return child->objectFlagValue[offs];
+ }
}
void AGOSEngine::hitarea_stuff() {
diff --git a/engines/agos/icons.cpp b/engines/agos/icons.cpp
index a25f968b7b..eeee459af3 100644
--- a/engines/agos/icons.cpp
+++ b/engines/agos/icons.cpp
@@ -63,40 +63,44 @@ void AGOSEngine::loadIconData() {
// Thanks to Stuart Caie for providing the original
// C conversion upon which this function is based.
-void decompressIconAmiga (byte *dst, byte *src, byte base, uint pitch) {
+static void decompressIconAmiga(byte *dst, byte *src, byte base, uint pitch, bool decompress = true) {
byte icon_pln[288];
- byte *i, *o, x, y;
-
- // Decode RLE planar icon data
- i = src;
- o = icon_pln;
- while (o < &icon_pln[288]) {
- x = *i++;
- if (x < 128) {
- do {
- *o++ = *i++;
- *o++ = *i++;
- *o++ = *i++;
- } while (x-- > 0);
- } else {
- x = 256 - x;
- do {
- *o++ = i[0];
- *o++ = i[1];
- *o++ = i[2];
- } while (x-- > 0);
- i += 3;
+ byte *i, *o, *srcPtr, x, y;
+
+ srcPtr = src;
+ if (decompress) {
+ // Decode RLE planar icon data
+ i = src;
+ o = icon_pln;
+ while (o < &icon_pln[288]) {
+ x = *i++;
+ if (x < 128) {
+ do {
+ *o++ = *i++;
+ *o++ = *i++;
+ *o++ = *i++;
+ } while (x-- > 0);
+ } else {
+ x = 256 - x;
+ do {
+ *o++ = i[0];
+ *o++ = i[1];
+ *o++ = i[2];
+ } while (x-- > 0);
+ i += 3;
+ }
}
+ srcPtr = icon_pln;
}
// Translate planar data to chunky (very slow method)
for (y = 0; y < 24; y++) {
for (x = 0; x < 24; x++) {
byte pixel =
- (icon_pln[(( y) * 3) + (x >> 3)] & (1 << (7 - (x & 7))) ? 1 : 0)
- | (icon_pln[((24 + y) * 3) + (x >> 3)] & (1 << (7 - (x & 7))) ? 2 : 0)
- | (icon_pln[((48 + y) * 3) + (x >> 3)] & (1 << (7 - (x & 7))) ? 4 : 0)
- | (icon_pln[((72 + y) * 3) + (x >> 3)] & (1 << (7 - (x & 7))) ? 8 : 0);
+ (srcPtr[(( y) * 3) + (x >> 3)] & (1 << (7 - (x & 7))) ? 1 : 0)
+ | (srcPtr[((24 + y) * 3) + (x >> 3)] & (1 << (7 - (x & 7))) ? 2 : 0)
+ | (srcPtr[((48 + y) * 3) + (x >> 3)] & (1 << (7 - (x & 7))) ? 4 : 0)
+ | (srcPtr[((72 + y) * 3) + (x >> 3)] & (1 << (7 - (x & 7))) ? 8 : 0);
if (pixel)
dst[x] = pixel | base;
}
@@ -171,7 +175,6 @@ void AGOSEngine::draw_icon_c(WindowBlock *window, uint icon, uint x, uint y) {
dst = getFrontBuf();
if (getGameType() == GType_SIMON2) {
- // Simon 2
dst += 110;
dst += x;
dst += (y + window->y) * _dxSurfacePitch;
@@ -184,19 +187,25 @@ void AGOSEngine::draw_icon_c(WindowBlock *window, uint icon, uint x, uint y) {
src += READ_LE_UINT16(&((uint16 *)src)[icon * 2 + 1]);
decompressIcon(dst, src, 20, 10, 208, _dxSurfacePitch);
} else if (getGameType() == GType_SIMON1) {
- // Simon 1
dst += (x + window->x) * 8;
dst += (y * 25 + window->y) * _dxSurfacePitch;
if (getPlatform() == Common::kPlatformAmiga) {
src = _iconFilePtr;
src += READ_BE_UINT32(&((uint32 *)src)[icon]);
- decompressIconAmiga (dst, src, 16, _dxSurfacePitch);
+ decompressIconAmiga(dst, src, 16, _dxSurfacePitch);
} else {
src = _iconFilePtr;
src += READ_LE_UINT16(&((uint16 *)src)[icon]);
decompressIcon(dst, src, 24, 12, 224, _dxSurfacePitch);
}
+ } else if (getGameType() == GType_ELVIRA1) {
+ dst += (x + window->x) * 8;
+ dst += (y * 8 + window->y) * _dxSurfacePitch;
+
+ src = _iconFilePtr;
+ src += icon * 288;
+ decompressIconAmiga(dst, src, 16, _dxSurfacePitch, false);
} else {
// TODO
}
diff --git a/engines/agos/window.cpp b/engines/agos/window.cpp
index c863d59cdf..9bdec84b74 100644
--- a/engines/agos/window.cpp
+++ b/engines/agos/window.cpp
@@ -59,6 +59,10 @@ WindowBlock *AGOSEngine::openWindow(uint x, uint y, uint w, uint h, uint flags,
window->textColumnOffset = 0;
window->textMaxLength = window->width * 8 / 6; // characters are 6 pixels
window->scrollY = 0;
+
+ if (getGameType() == GType_ELVIRA1)
+ clearWindow(window);
+
return window;
}