Fix display of icons in Elvira 1

svn-id: r24284
This commit is contained in:
Travis Howell 2006-10-13 02:22:33 +00:00
parent 929375ae21
commit 1ab09fd79b
3 changed files with 56 additions and 37 deletions

View File

@ -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() {

View File

@ -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;
byte *i, *o, *srcPtr, 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;
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
}

View File

@ -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;
}