[Scummvm-cvs-logs] SF.net SVN: scummvm: [32281] scummvm/trunk/engines/made

john_doe at users.sourceforge.net john_doe at users.sourceforge.net
Mon May 26 13:07:19 CEST 2008


Revision: 32281
          http://scummvm.svn.sourceforge.net/scummvm/?rev=32281&view=rev
Author:   john_doe
Date:     2008-05-26 04:07:18 -0700 (Mon, 26 May 2008)

Log Message:
-----------
Fixed graphics decoding bug in Manhole: N&E

Modified Paths:
--------------
    scummvm/trunk/engines/made/graphics.cpp
    scummvm/trunk/engines/made/graphics.h
    scummvm/trunk/engines/made/resource.cpp

Modified: scummvm/trunk/engines/made/graphics.cpp
===================================================================
--- scummvm/trunk/engines/made/graphics.cpp	2008-05-26 11:03:21 UTC (rev 32280)
+++ scummvm/trunk/engines/made/graphics.cpp	2008-05-26 11:07:18 UTC (rev 32281)
@@ -29,8 +29,25 @@
 
 namespace Made {
 
-void decompressImage(byte *source, Graphics::Surface &surface, uint16 cmdOffs, uint16 pixelOffs, uint16 maskOffs, uint16 lineSize, bool deltaFrame) {
+byte ValueReader::readPixel() {
+	byte value;
+	if (_nibbleMode) {
+		if (_nibbleSwitch) {
+			value = (_buffer[0] >> 4) & 0x0F;
+			_buffer++;
+		} else {
+			value = _buffer[0] & 0x0F;
+		}
+		_nibbleSwitch = !_nibbleSwitch;
+	} else {
+		value = _buffer[0];
+		_buffer++;
+	}
+	return value;
+}
 
+void decompressImage(byte *source, Graphics::Surface &surface, uint16 cmdOffs, uint16 pixelOffs, uint16 maskOffs, uint16 lineSize, byte cmdFlags, byte pixelFlags, byte maskFlags, bool deltaFrame) {
+
 	const int offsets[] = {
 		0, 1, 2, 3,
 		320, 321, 322, 323,
@@ -43,7 +60,7 @@
 
 	byte *cmdBuffer = source + cmdOffs;
 	byte *maskBuffer = source + maskOffs;
-	byte *pixelBuffer = source + pixelOffs;
+	ValueReader pixelReader(source + pixelOffs, pixelFlags & 2);
 
 	byte *destPtr = (byte*)surface.getBasePtr(0, 0);
 
@@ -84,14 +101,14 @@
 				switch (cmd) {
 
 				case 0:
-					pixels[0] = *pixelBuffer++;
+					pixels[0] = pixelReader.readPixel();
 					for (int i = 0; i < 16; i++)
 						lineBuf[drawDestOfs + offsets[i]] = pixels[0];
 					break;
 
 				case 1:
-					pixels[0] = *pixelBuffer++;
-					pixels[1] = *pixelBuffer++;
+					pixels[0] = pixelReader.readPixel();
+					pixels[1] = pixelReader.readPixel();
 					mask = READ_LE_UINT16(maskBuffer);
 					maskBuffer += 2;
 					for (int i = 0; i < 16; i++) {
@@ -101,10 +118,10 @@
 					break;
 
 				case 2:
-					pixels[0] = *pixelBuffer++;
-					pixels[1] = *pixelBuffer++;
-					pixels[2] = *pixelBuffer++;
-					pixels[3] = *pixelBuffer++;
+					pixels[0] = pixelReader.readPixel();
+					pixels[1] = pixelReader.readPixel();
+					pixels[2] = pixelReader.readPixel();
+					pixels[3] = pixelReader.readPixel();
 					mask = READ_LE_UINT32(maskBuffer);
 					maskBuffer += 4;
 					for (int i = 0; i < 16; i++) {

Modified: scummvm/trunk/engines/made/graphics.h
===================================================================
--- scummvm/trunk/engines/made/graphics.h	2008-05-26 11:03:21 UTC (rev 32280)
+++ scummvm/trunk/engines/made/graphics.h	2008-05-26 11:07:18 UTC (rev 32281)
@@ -33,7 +33,17 @@
 
 namespace Made {
 
-void decompressImage(byte *source, Graphics::Surface &surface, uint16 cmdOffs, uint16 pixelOffs, uint16 maskOffs, uint16 lineSize, bool deltaFrame = false);
+class ValueReader {
+public:
+	ValueReader(byte *source, bool nibbleMode) : _buffer(source), _nibbleBuf(0), _nibbleMode(nibbleMode), _nibbleSwitch(false) {}
+	byte readPixel();
+protected:
+	byte _nibbleBuf;
+	bool _nibbleMode, _nibbleSwitch;
+	byte *_buffer;
+};
+
+void decompressImage(byte *source, Graphics::Surface &surface, uint16 cmdOffs, uint16 pixelOffs, uint16 maskOffs, uint16 lineSize, byte cmdFlags, byte pixelFlags, byte maskFlags, bool deltaFrame = false);
 void decompressMovieImage(byte *source, Graphics::Surface &surface, uint16 cmdOffs, uint16 pixelOffs, uint16 maskOffs, uint16 lineSize);
 
 } // End of namespace Made

Modified: scummvm/trunk/engines/made/resource.cpp
===================================================================
--- scummvm/trunk/engines/made/resource.cpp	2008-05-26 11:03:21 UTC (rev 32280)
+++ scummvm/trunk/engines/made/resource.cpp	2008-05-26 11:07:18 UTC (rev 32281)
@@ -59,9 +59,9 @@
 	Common::MemoryReadStream *sourceS = new Common::MemoryReadStream(source, size);
 	
 	_hasPalette = (sourceS->readByte() != 0);
-	sourceS->readByte();
-	sourceS->readByte();
-	sourceS->readByte();
+	byte cmdFlags = sourceS->readByte();
+	byte pixelFlags = sourceS->readByte();
+	byte maskFlags = sourceS->readByte();
 	uint16 cmdOffs = sourceS->readUint16LE();
 	uint16 pixelOffs = sourceS->readUint16LE();
 	uint16 maskOffs = sourceS->readUint16LE();
@@ -69,7 +69,11 @@
 	/*uint16 u = */sourceS->readUint16LE();
 	uint16 width = sourceS->readUint16LE();
 	uint16 height = sourceS->readUint16LE();
-	
+
+	if (cmdFlags || pixelFlags || maskFlags) {
+		warning("PictureResource::load() Graphic has flags set");
+	}
+
 	_paletteColorCount = (cmdOffs - 18) / 3; // 18 = sizeof header
 
 	debug(2, "width = %d; height = %d\n", width, height);
@@ -82,7 +86,7 @@
 	_picture = new Graphics::Surface();
 	_picture->create(width, height, 1);
 
-	decompressImage(source, *_picture, cmdOffs, pixelOffs, maskOffs, lineSize);
+	decompressImage(source, *_picture, cmdOffs, pixelOffs, maskOffs, lineSize, cmdFlags, pixelFlags, maskFlags);
 
 	delete sourceS;
 
@@ -137,7 +141,7 @@
 		Graphics::Surface *frame = new Graphics::Surface();
 		frame->create(frameWidth, frameHeight, 1);
 
-		decompressImage(source + frameOffs, *frame, cmdOffs, pixelOffs, maskOffs, lineSize, _flags & 1);
+		decompressImage(source + frameOffs, *frame, cmdOffs, pixelOffs, maskOffs, lineSize, 0, 0, 0, _flags & 1);
 
 		_frames.push_back(frame);
 


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