[Scummvm-cvs-logs] SF.net SVN: scummvm:[50053] scummvm/trunk/engines/sci/graphics/view.cpp

m_kiewitz at users.sourceforge.net m_kiewitz at users.sourceforge.net
Sat Jun 19 19:12:18 CEST 2010


Revision: 50053
          http://scummvm.svn.sourceforge.net/scummvm/?rev=50053&view=rev
Author:   m_kiewitz
Date:     2010-06-19 17:12:17 +0000 (Sat, 19 Jun 2010)

Log Message:
-----------
SCI: cleanup view decompression code

Modified Paths:
--------------
    scummvm/trunk/engines/sci/graphics/view.cpp

Modified: scummvm/trunk/engines/sci/graphics/view.cpp
===================================================================
--- scummvm/trunk/engines/sci/graphics/view.cpp	2010-06-19 17:08:17 UTC (rev 50052)
+++ scummvm/trunk/engines/sci/graphics/view.cpp	2010-06-19 17:12:17 UTC (rev 50053)
@@ -323,78 +323,41 @@
 			memset(outPtr + pixelNo, pixel & 0x0F, MIN<uint32>(runLength, pixelCount - pixelNo));
 			pixelNo += runLength;
 		}
-		return;
-	}
-
-	rlePtr = _resourceData + celInfo->offsetRLE;
-	if (!celInfo->offsetLiteral) { // no additional literal data
-		if (_resMan->isAmiga32color()) {
-			// decompression for amiga views
-			while (pixelNo < pixelCount) {
-				pixel = *rlePtr++;
-				if (pixel & 0x07) { // fill with color
-					runLength = pixel & 0x07;
-					pixel = pixel >> 3;
-					while (runLength-- && pixelNo < pixelCount) {
-						outPtr[pixelNo++] = pixel;
-					}
-				} else { // fill with transparent
-					runLength = pixel >> 3;
-					pixelNo += runLength;
-				}
-			}
-			return;
-		} else {
-			// decompression for data that has just one combined stream
-			while (pixelNo < pixelCount) {
-				pixel = *rlePtr++;
-				runLength = pixel & 0x3F;
-				switch (pixel & 0xC0) {
-				case 0: // copy bytes as-is
-					while (runLength-- && pixelNo < pixelCount)
-						outPtr[pixelNo++] = *rlePtr++;
-					break;
-				case 0x80: // fill with color
-					memset(outPtr + pixelNo, *rlePtr++, MIN<uint32>(runLength, pixelCount - pixelNo));
-					pixelNo += runLength;
-					break;
-				case 0xC0: // fill with transparent
-					pixelNo += runLength;
-					break;
-				}
-			}
-			return;
-		}
 	} else {
-		literalPtr = _resourceData + celInfo->offsetLiteral;
-		if (celInfo->offsetRLE) {
-			if (g_sci->getPlatform() == Common::kPlatformMacintosh && getSciVersion() >= SCI_VERSION_1_1) {
-				// Crazy-Ass compression for SCI1.1+ Mac
+		// we skip over transparent pixels, so the buffer needs to be already filled with it
+		//  also some RLE compressed cels are possibly ending with the last non-transparent pixel
+		//  (is this even possible with the current code?)
+		memset(outPtr, _loop[loopNo].cel[celNo].clearKey, pixelCount);
+
+		rlePtr = _resourceData + celInfo->offsetRLE;
+		if (!celInfo->offsetLiteral) { // no additional literal data
+			if (_resMan->isAmiga32color()) {
+				// decompression for amiga views
 				while (pixelNo < pixelCount) {
-					uint32 pixelLine = pixelNo;
-					runLength = *rlePtr++;
-					pixelNo += runLength;
-					runLength = *rlePtr++;
-					while (runLength-- && pixelNo < pixelCount) {
-						outPtr[pixelNo] = *literalPtr++;
-						if (outPtr[pixelNo] == 255)
-							outPtr[pixelNo] = 0;
-						pixelNo++;
+					pixel = *rlePtr++;
+					if (pixel & 0x07) { // fill with color
+						runLength = pixel & 0x07;
+						pixel = pixel >> 3;
+						while (runLength-- && pixelNo < pixelCount) {
+							outPtr[pixelNo++] = pixel;
+						}
+					} else { // fill with transparent
+						runLength = pixel >> 3;
+						pixelNo += runLength;
 					}
-					pixelNo = pixelLine + celInfo->width;
 				}
 			} else {
-				// decompression for data that has separate rle and literal streams
+				// decompression for data that has just one combined stream
 				while (pixelNo < pixelCount) {
 					pixel = *rlePtr++;
 					runLength = pixel & 0x3F;
 					switch (pixel & 0xC0) {
 					case 0: // copy bytes as-is
 						while (runLength-- && pixelNo < pixelCount)
-							outPtr[pixelNo++] = *literalPtr++;
+							outPtr[pixelNo++] = *rlePtr++;
 						break;
 					case 0x80: // fill with color
-						memset(outPtr + pixelNo, *literalPtr++, MIN<uint32>(runLength, pixelCount - pixelNo));
+						memset(outPtr + pixelNo, *rlePtr++, MIN<uint32>(runLength, pixelCount - pixelNo));
 						pixelNo += runLength;
 						break;
 					case 0xC0: // fill with transparent
@@ -404,12 +367,50 @@
 				}
 			}
 		} else {
-			// literal stream only, so no compression
-			memcpy(outPtr, literalPtr, pixelCount);
+			literalPtr = _resourceData + celInfo->offsetLiteral;
+			if (celInfo->offsetRLE) {
+				if (g_sci->getPlatform() == Common::kPlatformMacintosh && getSciVersion() >= SCI_VERSION_1_1) {
+					// Crazy-Ass compression for SCI1.1+ Mac
+					while (pixelNo < pixelCount) {
+						uint32 pixelLine = pixelNo;
+						runLength = *rlePtr++;
+						pixelNo += runLength;
+						runLength = *rlePtr++;
+						while (runLength-- && pixelNo < pixelCount) {
+							outPtr[pixelNo] = *literalPtr++;
+							if (outPtr[pixelNo] == 255)
+								outPtr[pixelNo] = 0;
+							pixelNo++;
+						}
+						pixelNo = pixelLine + celInfo->width;
+					}
+				} else {
+					// decompression for data that has separate rle and literal streams
+					while (pixelNo < pixelCount) {
+						pixel = *rlePtr++;
+						runLength = pixel & 0x3F;
+						switch (pixel & 0xC0) {
+						case 0: // copy bytes as-is
+							while (runLength-- && pixelNo < pixelCount)
+								outPtr[pixelNo++] = *literalPtr++;
+							break;
+						case 0x80: // fill with color
+							memset(outPtr + pixelNo, *literalPtr++, MIN<uint32>(runLength, pixelCount - pixelNo));
+							pixelNo += runLength;
+							break;
+						case 0xC0: // fill with transparent
+							pixelNo += runLength;
+							break;
+						}
+					}
+				}
+			} else {
+				// literal stream only, so no compression
+				memcpy(outPtr, literalPtr, pixelCount);
+				pixelNo = pixelCount;
+			}
 		}
-		return;
 	}
-	error("Unable to decompress view");
 }
 
 byte *GfxView::getBitmap(int16 loopNo, int16 celNo) {
@@ -425,9 +426,7 @@
 	_loop[loopNo].cel[celNo].rawBitmap = new byte[pixelCount];
 	byte *pBitmap = _loop[loopNo].cel[celNo].rawBitmap;
 
-	// Some RLE compressed cels end with the last non-transparent pixel, thats why we fill it up here
-	//  FIXME: change this to fill the remaining bytes within unpackCel()
-	memset(pBitmap, _loop[loopNo].cel[celNo].clearKey, pixelCount);
+	// unpack the actual cel bitmap data
 	unpackCel(loopNo, celNo, pBitmap, pixelCount);
 
 	if (!_resMan->isVGA()) {


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