[Scummvm-cvs-logs] SF.net SVN: scummvm: [25433] scummvm/trunk/engines/agos

kirben at users.sourceforge.net kirben at users.sourceforge.net
Fri Feb 9 00:37:19 CET 2007


Revision: 25433
          http://scummvm.svn.sourceforge.net/scummvm/?rev=25433&view=rev
Author:   kirben
Date:     2007-02-08 15:37:17 -0800 (Thu, 08 Feb 2007)

Log Message:
-----------
Convert planar images, only when required for drawing.

Modified Paths:
--------------
    scummvm/trunk/engines/agos/agos.cpp
    scummvm/trunk/engines/agos/agos.h
    scummvm/trunk/engines/agos/agosgame.cpp
    scummvm/trunk/engines/agos/intern.h
    scummvm/trunk/engines/agos/res.cpp
    scummvm/trunk/engines/agos/res_ami.cpp
    scummvm/trunk/engines/agos/vga.cpp

Modified: scummvm/trunk/engines/agos/agos.cpp
===================================================================
--- scummvm/trunk/engines/agos/agos.cpp	2007-02-08 23:25:07 UTC (rev 25432)
+++ scummvm/trunk/engines/agos/agos.cpp	2007-02-08 23:37:17 UTC (rev 25433)
@@ -419,6 +419,8 @@
 
 	memset(_lettersToPrintBuf, 0, sizeof(_lettersToPrintBuf));
 
+	_planarBuf = 0;
+
 	_vgaTickCounter = 0;
 
 	_moviePlay = 0;

Modified: scummvm/trunk/engines/agos/agos.h
===================================================================
--- scummvm/trunk/engines/agos/agos.h	2007-02-08 23:25:07 UTC (rev 25432)
+++ scummvm/trunk/engines/agos/agos.h	2007-02-08 23:37:17 UTC (rev 25433)
@@ -479,6 +479,7 @@
 	uint8 _currentPalette[1024];
 	uint8 _displayPalette[1024];
 
+	byte *_planarBuf;
 	byte _videoBuf1[32000];
 	uint16 _videoWindows[128];
 
@@ -1335,7 +1336,8 @@
 	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);

Modified: scummvm/trunk/engines/agos/agosgame.cpp
===================================================================
--- scummvm/trunk/engines/agos/agosgame.cpp	2007-02-08 23:25:07 UTC (rev 25432)
+++ scummvm/trunk/engines/agos/agosgame.cpp	2007-02-08 23:37:17 UTC (rev 25433)
@@ -16,7 +16,7 @@
 
 		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 @@
 
 		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 @@
 
 		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 @@
 
 		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 @@
 
 		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 @@
 
 		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 @@
 
 		GType_ELVIRA2,
 		GID_ELVIRA2,
-		GF_OLD_BUNDLE | GF_CRUNCHED
+		GF_OLD_BUNDLE | GF_CRUNCHED | GF_PLANAR
 	},
 
 
@@ -365,7 +365,7 @@
 
 		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 @@
 
 		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 @@
 
 		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 @@
 
 		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 @@
 
 		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 @@
 
 		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 @@
 
 		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 @@
 
 		GType_SIMON1,
 		GID_SIMON1CD32,
-		GF_TALKIE | GF_OLD_BUNDLE
+		GF_TALKIE | GF_OLD_BUNDLE | GF_PLANAR
 	},
 
 	// Simon the Sorcerer 1 - English DOS Floppy Demo

Modified: scummvm/trunk/engines/agos/intern.h
===================================================================
--- scummvm/trunk/engines/agos/intern.h	2007-02-08 23:25:07 UTC (rev 25432)
+++ scummvm/trunk/engines/agos/intern.h	2007-02-08 23:37:17 UTC (rev 25433)
@@ -210,7 +210,8 @@
 	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 {

Modified: scummvm/trunk/engines/agos/res.cpp
===================================================================
--- scummvm/trunk/engines/agos/res.cpp	2007-02-08 23:25:07 UTC (rev 25432)
+++ scummvm/trunk/engines/agos/res.cpp	2007-02-08 23:37:17 UTC (rev 25433)
@@ -718,28 +718,13 @@
 				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 {

Modified: scummvm/trunk/engines/agos/res_ami.cpp
===================================================================
--- scummvm/trunk/engines/agos/res_ami.cpp	2007-02-08 23:25:07 UTC (rev 25432)
+++ scummvm/trunk/engines/agos/res_ami.cpp	2007-02-08 23:37:17 UTC (rev 25433)
@@ -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 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 @@
 	
 	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 @@
 	cliplength = 0;
 	while(1) {
 		if (length == 1) {
-			*clipoutptr++ = 0xFF; bufoutend++;
-			*clipoutptr++ = *uncbuffer; bufoutend++;
+			*dst++ = 0xFF;
+			*dst++ = *uncbuffer;
 			cliplength += 2;
 			break;
 		}
@@ -164,8 +145,8 @@
 			n = 1;
 			y = *uncbuffer++;
 			if (length == 0) {
-				*clipoutptr++ = n; bufoutend++;
-				*clipoutptr++ = x; bufoutend++;
+				*dst++ = n;
+				*dst++ = x;
 				cliplength += 2;
 				break;
 			}
@@ -179,8 +160,8 @@
 				if(n == 127)
 					break;
 			}
-			*clipoutptr++ = n; bufoutend++;
-			*clipoutptr++ = x; bufoutend++;
+			*dst++ = n;
+			*dst++ = x;
 			cliplength += 2;
 			uncbuffer--;
 			if (length == 0)
@@ -188,10 +169,9 @@
 			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 @@
 				if (n == -127)
 					break;
 				n--;
-				*clipoutptr++ = x; bufoutend++;
+				*dst++ = x;
 				cliplength++;
 				x = y;
 				y = *uncbuffer++;
@@ -219,33 +199,30 @@
 			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 @@
 				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

Modified: scummvm/trunk/engines/agos/vga.cpp
===================================================================
--- scummvm/trunk/engines/agos/vga.cpp	2007-02-08 23:25:07 UTC (rev 25432)
+++ scummvm/trunk/engines/agos/vga.cpp	2007-02-08 23:37:17 UTC (rev 25433)
@@ -617,6 +617,10 @@
 	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);


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list