diff options
-rw-r--r-- | engines/agos/detection_tables.h | 1 | ||||
-rw-r--r-- | engines/agos/icons.cpp | 60 |
2 files changed, 40 insertions, 21 deletions
diff --git a/engines/agos/detection_tables.h b/engines/agos/detection_tables.h index 6c762b5e1e..cceae8043f 100644 --- a/engines/agos/detection_tables.h +++ b/engines/agos/detection_tables.h @@ -443,7 +443,6 @@ static const AGOSGameDescription gameDescriptions[] = { { "icon.pkd", GAME_ICONFILE, "4822a91c18b1b2005ac17fc617f7dcbe", -1}, { "menus.dat", GAME_MENUFILE, "3409eeb8ca8b46fc04da99de67573f5e", -1}, { "start", GAME_RESTFILE, "b575b336e741dde1725edd4079d5ab67", -1}, - { "statelst", GAME_STATFILE, "469e98c69f00928a8366ba415d91902d", -1}, { "stripped.txt", GAME_STRFILE, "6faaebff2786216900061eeb978f10af", -1}, { "tbllist", GAME_TBLFILE, "95c44bfc380770a6b6dd0dfcc69e80a0", -1}, { "xtbllist", GAME_XTBLFILE, "6c7b3db345d46349a5226f695c03e20f", -1}, diff --git a/engines/agos/icons.cpp b/engines/agos/icons.cpp index 9c8938bb97..e01d10a1c4 100644 --- a/engines/agos/icons.cpp +++ b/engines/agos/icons.cpp @@ -33,19 +33,32 @@ namespace AGOS { void AGOSEngine::loadIconFile() { Common::File in; - uint size; + uint32 srcSize; in.open(getFileName(GAME_ICONFILE)); if (in.isOpen() == false) error("Can't open icons file '%s'", getFileName(GAME_ICONFILE)); - size = in.size(); + srcSize = in.size(); - _iconFilePtr = (byte *)malloc(size); - if (_iconFilePtr == NULL) - error("Out of icon memory"); + if (getGameType() == GType_WW && getPlatform() == Common::kPlatformAmiga) { + byte *srcBuf = (byte *)malloc(srcSize); + in.read(srcBuf, srcSize); + + uint32 dstSize = READ_BE_UINT32(srcBuf + srcSize - 4); + _iconFilePtr = (byte *)malloc(dstSize); + if (_iconFilePtr == NULL) + error("Out of icon memory"); - in.read(_iconFilePtr, size); + decrunchFile(srcBuf, _iconFilePtr, srcSize); + free(srcBuf); + } else { + _iconFilePtr = (byte *)malloc(srcSize); + if (_iconFilePtr == NULL) + error("Out of icon memory"); + + in.read(_iconFilePtr, srcSize); + } in.close(); } @@ -66,15 +79,19 @@ void AGOSEngine::loadIconData() { // Thanks to Stuart Caie for providing the original // C conversion upon which this function is based. static void decompressIconPlanar(byte *dst, byte *src, uint width, uint height, byte base, uint pitch, bool decompress = true) { - byte icon_pln[288]; - byte *i, *o, *srcPtr, x, y; + byte *i, *icon_pln, *o, *srcPtr; + byte x, y; + icon_pln = 0; srcPtr = src; + if (decompress) { + icon_pln = (byte *)calloc(width * height, 1); + // Decode RLE planar icon data i = src; o = icon_pln; - while (o < &icon_pln[288]) { + while (o < &icon_pln[width * height]) { x = *i++; if (x < 128) { do { @@ -96,18 +113,20 @@ static void decompressIconPlanar(byte *dst, byte *src, uint width, uint height, } // Translate planar data to chunky (very slow method) - for (y = 0; y < 24; y++) { + for (y = 0; y < height * 2; y++) { for (x = 0; x < 24; x++) { byte pixel = - (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); + (srcPtr[((height * 0 + y) * 3) + (x >> 3)] & (1 << (7 - (x & 7))) ? 1 : 0) + | (srcPtr[((height * 2 + y) * 3) + (x >> 3)] & (1 << (7 - (x & 7))) ? 2 : 0) + | (srcPtr[((height * 4 + y) * 3) + (x >> 3)] & (1 << (7 - (x & 7))) ? 4 : 0) + | (srcPtr[((height * 6 + y) * 3) + (x >> 3)] & (1 << (7 - (x & 7))) ? 8 : 0); if (pixel) dst[x] = pixel | base; } dst += pitch; } + + free(icon_pln); } static void decompressIcon(byte *dst, byte *src, uint width, uint height, byte base, uint pitch) { @@ -205,7 +224,7 @@ void AGOSEngine_Simon1::drawIcon(WindowBlock *window, uint icon, uint x, uint y) src = _iconFilePtr; src += READ_BE_UINT32(&((uint32 *)src)[icon]); uint8 color = (getFeatures() & GF_32COLOR) ? 16 : 240; - decompressIconPlanar(dst, src, 24, 24, color, _dxSurfacePitch); + decompressIconPlanar(dst, src, 24, 12, color, _dxSurfacePitch); } else { src = _iconFilePtr; src += READ_LE_UINT16(&((uint16 *)src)[icon]); @@ -227,8 +246,9 @@ void AGOSEngine_Waxworks::drawIcon(WindowBlock *window, uint icon, uint x, uint uint8 color = dst[0] & 0xF0; if (getPlatform() == Common::kPlatformAmiga) { - // TODO - return; + src = _iconFilePtr; + src += READ_BE_UINT32(&((uint32 *)src)[icon]); + decompressIconPlanar(dst, src, 24, 10, color, _dxSurfacePitch); } else { src = _iconFilePtr; src += READ_LE_UINT16(&((uint16 *)src)[icon]); @@ -252,7 +272,7 @@ void AGOSEngine_Elvira2::drawIcon(WindowBlock *window, uint icon, uint x, uint y if (getFeatures() & GF_PLANAR) { src = _iconFilePtr; src += READ_BE_UINT32(&((uint32 *)src)[icon]); - decompressIconPlanar(dst, src, 24, 24, color, _dxSurfacePitch); + decompressIconPlanar(dst, src, 24, 12, color, _dxSurfacePitch); } else { src = _iconFilePtr; src += READ_LE_UINT16(&((uint16 *)src)[icon]); @@ -275,11 +295,11 @@ void AGOSEngine::drawIcon(WindowBlock *window, uint icon, uint x, uint y) { if (getFeatures() & GF_PLANAR) { src = _iconFilePtr; src += READ_BE_UINT16(&((uint16 *)src)[icon]); - decompressIconPlanar(dst, src, 24, 24, 16, _dxSurfacePitch); + decompressIconPlanar(dst, src, 24, 12, 16, _dxSurfacePitch); } else { src = _iconFilePtr; src += icon * 288; - decompressIconPlanar(dst, src, 24, 24, 16, _dxSurfacePitch, false); + decompressIconPlanar(dst, src, 24, 12, 16, _dxSurfacePitch, false); } _lockWord &= ~0x8000; |