aboutsummaryrefslogtreecommitdiff
path: root/engines/agos/icons.cpp
diff options
context:
space:
mode:
authorTravis Howell2007-06-02 05:27:34 +0000
committerTravis Howell2007-06-02 05:27:34 +0000
commita7fb55c028dd71cf79baa9402337912ae6252a34 (patch)
tree9a1b01d5f3e7abc4abde9910ac914fd2c7e0b830 /engines/agos/icons.cpp
parentc983e879e11a38d98f038a43943f92e93fdc58b1 (diff)
downloadscummvm-rg350-a7fb55c028dd71cf79baa9402337912ae6252a34.tar.gz
scummvm-rg350-a7fb55c028dd71cf79baa9402337912ae6252a34.tar.bz2
scummvm-rg350-a7fb55c028dd71cf79baa9402337912ae6252a34.zip
Fix inventory icons display in Amiga version of Waxworks.
svn-id: r27045
Diffstat (limited to 'engines/agos/icons.cpp')
-rw-r--r--engines/agos/icons.cpp60
1 files changed, 40 insertions, 20 deletions
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;