aboutsummaryrefslogtreecommitdiff
path: root/engines/agos
diff options
context:
space:
mode:
authorTravis Howell2007-02-08 23:37:17 +0000
committerTravis Howell2007-02-08 23:37:17 +0000
commitf8052bb650719b8a716e686e6a08ae75b513a903 (patch)
tree26e610e1f137d8987793e028dac55e03a6a7f190 /engines/agos
parent956affd3d23cc8030775dc1a81984891a344d134 (diff)
downloadscummvm-rg350-f8052bb650719b8a716e686e6a08ae75b513a903.tar.gz
scummvm-rg350-f8052bb650719b8a716e686e6a08ae75b513a903.tar.bz2
scummvm-rg350-f8052bb650719b8a716e686e6a08ae75b513a903.zip
Convert planar images, only when required for drawing.
svn-id: r25433
Diffstat (limited to 'engines/agos')
-rw-r--r--engines/agos/agos.cpp2
-rw-r--r--engines/agos/agos.h4
-rw-r--r--engines/agos/agosgame.cpp30
-rw-r--r--engines/agos/intern.h3
-rw-r--r--engines/agos/res.cpp25
-rw-r--r--engines/agos/res_ami.cpp150
-rw-r--r--engines/agos/vga.cpp4
7 files changed, 67 insertions, 151 deletions
diff --git a/engines/agos/agos.cpp b/engines/agos/agos.cpp
index 8003c2843c..eb5c15238f 100644
--- a/engines/agos/agos.cpp
+++ b/engines/agos/agos.cpp
@@ -419,6 +419,8 @@ AGOSEngine::AGOSEngine(OSystem *syst)
memset(_lettersToPrintBuf, 0, sizeof(_lettersToPrintBuf));
+ _planarBuf = 0;
+
_vgaTickCounter = 0;
_moviePlay = 0;
diff --git a/engines/agos/agos.h b/engines/agos/agos.h
index 48df0472f6..ad46fe572d 100644
--- a/engines/agos/agos.h
+++ b/engines/agos/agos.h
@@ -479,6 +479,7 @@ protected:
uint8 _currentPalette[1024];
uint8 _displayPalette[1024];
+ byte *_planarBuf;
byte _videoBuf1[32000];
uint16 _videoWindows[128];
@@ -1335,7 +1336,8 @@ protected:
byte *getBackGround();
byte *getScaleBuf();
- void convertAmiga(byte *srcBuf, int32 fileSize);
+ byte *convertclip(const byte *src, uint height, uint width, byte flags);
+
bool decrunchFile(byte *src, byte *dst, uint32 size);
void loadVGABeardFile(uint id);
void loadVGAVideoFile(uint id, uint type);
diff --git a/engines/agos/agosgame.cpp b/engines/agos/agosgame.cpp
index 3632eb2de8..d2befaa218 100644
--- a/engines/agos/agosgame.cpp
+++ b/engines/agos/agosgame.cpp
@@ -16,7 +16,7 @@ static const AGOSGameDescription gameDescriptions[] = {
GType_ELVIRA1,
GID_ELVIRA1,
- GF_OLD_BUNDLE | GF_CRUNCHED
+ GF_OLD_BUNDLE | GF_CRUNCHED | GF_PLANAR
},
// Elvira 1 - English Amiga Demo
@@ -37,7 +37,7 @@ static const AGOSGameDescription gameDescriptions[] = {
GType_ELVIRA1,
GID_ELVIRA1,
- GF_OLD_BUNDLE | GF_CRUNCHED | GF_DEMO
+ GF_OLD_BUNDLE | GF_CRUNCHED | GF_PLANAR | GF_DEMO
},
// Elvira 1 - English Atari ST Floppy
@@ -59,7 +59,7 @@ static const AGOSGameDescription gameDescriptions[] = {
GType_ELVIRA1,
GID_ELVIRA1,
- GF_OLD_BUNDLE | GF_CRUNCHED
+ GF_OLD_BUNDLE | GF_CRUNCHED | GF_PLANAR
},
// Elvira 1 - French Atari ST Floppy
@@ -81,7 +81,7 @@ static const AGOSGameDescription gameDescriptions[] = {
GType_ELVIRA1,
GID_ELVIRA1,
- GF_OLD_BUNDLE | GF_CRUNCHED
+ GF_OLD_BUNDLE | GF_CRUNCHED | GF_PLANAR
},
// Elvira 1 - English DOS Floppy
@@ -171,7 +171,7 @@ static const AGOSGameDescription gameDescriptions[] = {
GType_ELVIRA2,
GID_ELVIRA2,
- GF_OLD_BUNDLE | GF_CRUNCHED
+ GF_OLD_BUNDLE | GF_CRUNCHED | GF_PLANAR
},
// Elvira 2 - English Atari ST Floppy
@@ -195,7 +195,7 @@ static const AGOSGameDescription gameDescriptions[] = {
GType_ELVIRA2,
GID_ELVIRA2,
- GF_OLD_BUNDLE | GF_CRUNCHED
+ GF_OLD_BUNDLE | GF_CRUNCHED | GF_PLANAR
},
// Elvira 2 - French Atari ST Floppy
@@ -219,7 +219,7 @@ static const AGOSGameDescription gameDescriptions[] = {
GType_ELVIRA2,
GID_ELVIRA2,
- GF_OLD_BUNDLE | GF_CRUNCHED
+ GF_OLD_BUNDLE | GF_CRUNCHED | GF_PLANAR
},
@@ -365,7 +365,7 @@ static const AGOSGameDescription gameDescriptions[] = {
GType_WW,
GID_WAXWORKS,
- GF_OLD_BUNDLE | GF_CRUNCHED | GF_CRUNCHED_GAMEPC
+ GF_OLD_BUNDLE | GF_CRUNCHED | GF_CRUNCHED_GAMEPC | GF_PLANAR
},
// Waxworks - English DOS Floppy
@@ -459,7 +459,7 @@ static const AGOSGameDescription gameDescriptions[] = {
GType_SIMON1,
GID_SIMON1AMIGA,
- GF_32COLOR | GF_CRUNCHED | GF_OLD_BUNDLE
+ GF_32COLOR | GF_CRUNCHED | GF_OLD_BUNDLE | GF_PLANAR
},
// Simon the Sorcerer 1 - English Amiga ECS Demo
@@ -481,7 +481,7 @@ static const AGOSGameDescription gameDescriptions[] = {
GType_SIMON1,
GID_SIMON1AMIGA,
- GF_32COLOR | GF_CRUNCHED | GF_CRUNCHED_GAMEPC | GF_OLD_BUNDLE | GF_DEMO
+ GF_32COLOR | GF_CRUNCHED | GF_CRUNCHED_GAMEPC | GF_OLD_BUNDLE | GF_PLANAR | GF_DEMO
},
// Simon the Sorcerer 1 - English Amiga AGA Floppy
@@ -503,7 +503,7 @@ static const AGOSGameDescription gameDescriptions[] = {
GType_SIMON1,
GID_SIMON1AMIGA,
- GF_CRUNCHED | GF_OLD_BUNDLE
+ GF_CRUNCHED | GF_OLD_BUNDLE | GF_PLANAR
},
// Simon the Sorcerer 1 - French Amiga AGA Floppy
@@ -525,7 +525,7 @@ static const AGOSGameDescription gameDescriptions[] = {
GType_SIMON1,
GID_SIMON1AMIGA,
- GF_CRUNCHED | GF_OLD_BUNDLE
+ GF_CRUNCHED | GF_OLD_BUNDLE | GF_PLANAR
},
// Simon the Sorcerer 1 - German Amiga AGA Floppy
@@ -547,7 +547,7 @@ static const AGOSGameDescription gameDescriptions[] = {
GType_SIMON1,
GID_SIMON1AMIGA,
- GF_CRUNCHED | GF_OLD_BUNDLE
+ GF_CRUNCHED | GF_OLD_BUNDLE | GF_PLANAR
},
// Simon the Sorcerer 1 - English Amiga CD32
@@ -569,7 +569,7 @@ static const AGOSGameDescription gameDescriptions[] = {
GType_SIMON1,
GID_SIMON1CD32,
- GF_TALKIE | GF_OLD_BUNDLE
+ GF_TALKIE | GF_OLD_BUNDLE | GF_PLANAR
},
// Simon the Sorcerer 1 - English Amiga CD32 alternative?
@@ -591,7 +591,7 @@ static const AGOSGameDescription gameDescriptions[] = {
GType_SIMON1,
GID_SIMON1CD32,
- GF_TALKIE | GF_OLD_BUNDLE
+ GF_TALKIE | GF_OLD_BUNDLE | GF_PLANAR
},
// Simon the Sorcerer 1 - English DOS Floppy Demo
diff --git a/engines/agos/intern.h b/engines/agos/intern.h
index d5501e65b6..b413807e6c 100644
--- a/engines/agos/intern.h
+++ b/engines/agos/intern.h
@@ -210,7 +210,8 @@ enum GameFeatures {
GF_CRUNCHED_GAMEPC = 1 << 3,
GF_ZLIBCOMP = 1 << 4,
GF_32COLOR = 1 << 5,
- GF_DEMO = 1 << 6
+ GF_PLANAR = 1 << 6,
+ GF_DEMO = 1 << 7
};
enum GameFileTypes {
diff --git a/engines/agos/res.cpp b/engines/agos/res.cpp
index cb25e79c12..a4d003b29a 100644
--- a/engines/agos/res.cpp
+++ b/engines/agos/res.cpp
@@ -718,28 +718,13 @@ void AGOSEngine::loadVGAVideoFile(uint id, uint type) {
error("loadVGAVideoFile: Read failed");
dstSize = READ_BE_UINT32(srcBuffer + srcSize - 4);
- if (type == 2) {
- dst = (byte *)malloc(dstSize);
- decrunchFile(srcBuffer, dst, srcSize);
- convertAmiga(dst, dstSize);
- free(dst);
- } else {
- dst = allocBlock (dstSize + extraBuffer);
- decrunchFile(srcBuffer, dst, srcSize);
- }
+ dst = allocBlock (dstSize + extraBuffer);
+ decrunchFile(srcBuffer, dst, srcSize);
free(srcBuffer);
} else {
- if (getGameId() == GID_SIMON1CD32 && type == 2) {
- dst = (byte *)malloc(dstSize);
- if (in.read(dst, dstSize) != dstSize)
- error("loadVGAVideoFile: Read failed");
- convertAmiga(dst, dstSize);
- free(dst);
- } else {
- dst = allocBlock(dstSize + extraBuffer);
- if (in.read(dst, dstSize) != dstSize)
- error("loadVGAVideoFile: Read failed");
- }
+ dst = allocBlock(dstSize + extraBuffer);
+ if (in.read(dst, dstSize) != dstSize)
+ error("loadVGAVideoFile: Read failed");
}
in.close();
} else {
diff --git a/engines/agos/res_ami.cpp b/engines/agos/res_ami.cpp
index 28e1357fef..6afe08e61e 100644
--- a/engines/agos/res_ami.cpp
+++ b/engines/agos/res_ami.cpp
@@ -29,18 +29,7 @@
namespace AGOS {
-byte *buffer;
-byte *bufptr;
-byte *bufferout;
-byte *bufptrout;
-uint32 bufoutend;
-byte *clipptr;
-byte *clipoutptr;
-int clipnumber;
-
-static void uncompressplane(byte *plane, byte *outptr, uint16 length) {
- debug(10, "uncompressplane: length %d", length);
-
+static void uncompressplane(const byte *plane, byte *outptr, uint16 length) {
char x;
byte y, z;
while (length) {
@@ -70,18 +59,10 @@ static void uncompressplane(byte *plane, byte *outptr, uint16 length) {
}
}
-static void convertcompressedclip(uint16 height, uint16 width) {
- debug(10, "convertcompressedclip: height %d width %d", height, width);
-
- byte *plane0;
- byte *plane1;
- byte *plane2;
- byte *plane3;
+static void convertcompressedclip(const byte *src, byte *dst, uint16 height, uint16 width) {
+ const byte *plane0, *plane1, *plane2, *plane3;
byte *uncbuffer;
- byte *uncptr0;
- byte *uncptr1;
- byte *uncptr2;
- byte *uncptr3;
+ byte *uncptr0, *uncptr1, *uncptr2, *uncptr3;
byte *uncbfrout;
byte *uncbfroutptr;
uint16 length, i, j, k, word1, word2, word3, word4, cliplength;
@@ -95,18 +76,18 @@ static void convertcompressedclip(uint16 height, uint16 width) {
length = width / 16;
length *= height;
- plane0 = READ_BE_UINT16(clipptr) + READ_BE_UINT16(clipptr + 2) + clipptr; clipptr += 4; plane0 += 4;
- plane1 = READ_BE_UINT16(clipptr) + READ_BE_UINT16(clipptr + 2) + clipptr; clipptr += 4; plane1 += 4;
- plane2 = READ_BE_UINT16(clipptr) + READ_BE_UINT16(clipptr + 2) + clipptr; clipptr += 4; plane2 += 4;
- plane3 = READ_BE_UINT16(clipptr) + READ_BE_UINT16(clipptr + 2) + clipptr; clipptr += 4; plane3 += 4;
+ plane0 = READ_BE_UINT16(src) + READ_BE_UINT16(src + 2) + src; src += 4; plane0 += 4;
+ plane1 = READ_BE_UINT16(src) + READ_BE_UINT16(src + 2) + src; src += 4; plane1 += 4;
+ plane2 = READ_BE_UINT16(src) + READ_BE_UINT16(src + 2) + src; src += 4; plane2 += 4;
+ plane3 = READ_BE_UINT16(src) + READ_BE_UINT16(src + 2) + src; src += 4; plane3 += 4;
plane0 -= 4;
plane1 -= 8;
plane2 -= 12;
plane3 -= 16;
uncptr0 = uncbuffer;
- uncptr1 = uncptr0+(length*2);
- uncptr2 = uncptr1+(length*2);
- uncptr3 = uncptr2+(length*2);
+ uncptr1 = uncptr0+(length * 2);
+ uncptr2 = uncptr1+(length * 2);
+ uncptr3 = uncptr2+(length * 2);
uncompressplane(plane0, uncptr0, length);
uncompressplane(plane1, uncptr1, length);
uncompressplane(plane2, uncptr2, length);
@@ -152,8 +133,8 @@ static void convertcompressedclip(uint16 height, uint16 width) {
cliplength = 0;
while(1) {
if (length == 1) {
- *clipoutptr++ = 0xFF; bufoutend++;
- *clipoutptr++ = *uncbuffer; bufoutend++;
+ *dst++ = 0xFF;
+ *dst++ = *uncbuffer;
cliplength += 2;
break;
}
@@ -164,8 +145,8 @@ static void convertcompressedclip(uint16 height, uint16 width) {
n = 1;
y = *uncbuffer++;
if (length == 0) {
- *clipoutptr++ = n; bufoutend++;
- *clipoutptr++ = x; bufoutend++;
+ *dst++ = n;
+ *dst++ = x;
cliplength += 2;
break;
}
@@ -179,8 +160,8 @@ static void convertcompressedclip(uint16 height, uint16 width) {
if(n == 127)
break;
}
- *clipoutptr++ = n; bufoutend++;
- *clipoutptr++ = x; bufoutend++;
+ *dst++ = n;
+ *dst++ = x;
cliplength += 2;
uncbuffer--;
if (length == 0)
@@ -188,10 +169,9 @@ static void convertcompressedclip(uint16 height, uint16 width) {
length++;
} else {
n =- 1;
- uncptr0 = clipoutptr;
- clipoutptr++;
- bufoutend++;
- *clipoutptr++ = x; bufoutend++;
+ uncptr0 = dst;
+ dst++;
+ *dst++ = x;
cliplength += 2;
x = y;
y = *uncbuffer++;
@@ -204,7 +184,7 @@ static void convertcompressedclip(uint16 height, uint16 width) {
if (n == -127)
break;
n--;
- *clipoutptr++ = x; bufoutend++;
+ *dst++ = x;
cliplength++;
x = y;
y = *uncbuffer++;
@@ -219,33 +199,30 @@ static void convertcompressedclip(uint16 height, uint16 width) {
length += 2;
}
}
- if (cliplength > (height * width / 2))
- warning("Negative compression. Clip %d. %d bytes bigger.",clipnumber,(cliplength-(height*width/2)));
+
free(free_uncbuffer);
free(free_uncbfrout);
}
-static void convertclip(uint32 offset, uint16 height, uint16 width) {
- debug(10, "convertclip: height %d width %d", height, width);
-
+byte *AGOSEngine::convertclip(const byte *src, uint height, uint width, byte flags) {
uint32 length, i, j;
uint16 word1, word2, word3, word4;
byte outbyte, outbyte1;
- clipptr = offset + buffer;
- clipoutptr = bufoutend + bufferout;
- WRITE_BE_UINT32(bufptrout, bufoutend); bufptrout += 4;
- WRITE_BE_UINT16(bufptrout, height); bufptrout += 2;
- WRITE_BE_UINT16(bufptrout, width); bufptrout += 2;
- if (height > 32000) {
- convertcompressedclip((uint16)(height - 32768), width);
+
+ free(_planarBuf);
+ _planarBuf = (byte *)malloc(width * height);
+ byte *dst = _planarBuf;
+
+ if (flags & 0x80) {
+ convertcompressedclip(src, dst, height, width);
} else {
width /= 16;
length = height * width;
for (i = 0; i < length; i++) {
- word1 = READ_BE_UINT16(clipptr); clipptr += 2;
- word2 = READ_BE_UINT16(clipptr); clipptr += 2;
- word3 = READ_BE_UINT16(clipptr); clipptr += 2;
- word4 = READ_BE_UINT16(clipptr); clipptr += 2;
+ word1 = READ_BE_UINT16(src); src += 2;
+ word2 = READ_BE_UINT16(src); src += 2;
+ word3 = READ_BE_UINT16(src); src += 2;
+ word4 = READ_BE_UINT16(src); src += 2;
for (j = 0; j < 8; j++) {
outbyte = ((word1 / 32768) + ((word2 / 32768) * 2) + ((word3 / 32768) * 4) + ((word4 / 32768) * 8));
word1 <<= 1;
@@ -257,67 +234,12 @@ static void convertclip(uint32 offset, uint16 height, uint16 width) {
word2 <<= 1;
word3 <<= 1;
word4 <<= 1;
- *clipoutptr++ = (outbyte * 16 + outbyte1); bufoutend++;
+ *dst++ = (outbyte * 16 + outbyte1);
}
}
}
-}
-
-void AGOSEngine::convertAmiga(byte *srcBuf, int32 fileSize) {
- // TODO Better detection of full screen images
- if ((getGameType() == GType_WW && fileSize == 178624) ||
- fileSize == 64800) {
- byte *dstBuf = allocBlock (fileSize);
- memcpy(dstBuf, srcBuf, fileSize);
- return;
- }
-
- uint32 clipoffset, outlength;
- uint16 clipwidth, clipheight;
- byte *clipsend;
-
- debug(10, "convertAmiga: fizeSize %d", fileSize);
-
- buffer = (byte *)malloc((int32)fileSize);
- memcpy(buffer, srcBuf, fileSize);
- bufptr = buffer;
-
- bufferout = (byte *)malloc((int32)(fileSize * 2));
- bufptr = buffer;
- bufptrout = bufferout;
- clipnumber = 0;
- while(1) {
- clipoffset = READ_BE_UINT32(bufptr); bufptr += 4;
- clipheight = READ_BE_UINT16(bufptr); bufptr += 2;
- clipwidth = READ_BE_UINT16(bufptr); bufptr += 2;
- if (clipoffset != 0)
- break;
- WRITE_BE_UINT32(bufptrout, 0); bufptrout += 4;
- WRITE_BE_UINT32(bufptrout, 0); bufptrout += 4;
- clipnumber++;
- }
-
- clipsend = buffer + clipoffset;
- bufoutend = clipoffset;
- while (bufptr <= clipsend) {
- if (clipoffset != 0) {
- convertclip(clipoffset, clipheight, clipwidth);
- } else {
- WRITE_BE_UINT32(bufptrout, 0); bufptrout += 4;
- WRITE_BE_UINT32(bufptrout, 0); bufptrout += 4;
- }
- clipoffset = READ_BE_UINT32(bufptr); bufptr += 4;
- clipheight = READ_BE_UINT16(bufptr); bufptr += 2;
- clipwidth = READ_BE_UINT16(bufptr); bufptr += 2;
- clipnumber++;
- }
- outlength = bufoutend;
- debug(10, "convertAmiga: outlength %d",outlength);
- byte *dstBuf = allocBlock (outlength);
- memcpy(dstBuf, bufferout, outlength);
- free(buffer);
- free(bufferout);
+ return _planarBuf;
}
} // End of namespace AGOS
diff --git a/engines/agos/vga.cpp b/engines/agos/vga.cpp
index 6765ae10c5..93aeda6c5e 100644
--- a/engines/agos/vga.cpp
+++ b/engines/agos/vga.cpp
@@ -617,6 +617,10 @@ void AGOSEngine::vc10_draw() {
if (height == 0 || width == 0)
return;
+ if (getFeatures() & GF_PLANAR) {
+ state.depack_src = convertclip(state.depack_src, height, width * 16, flags);
+ }
+
if (_dumpImages)
dumpSingleBitmap(_vgaCurZoneNum, state.image, state.depack_src, width, height,
state.palette);