[Scummvm-cvs-logs] SF.net SVN: scummvm:[39572] scummvm/trunk/engines/parallaction/disk_br.cpp

peres001 at users.sourceforge.net peres001 at users.sourceforge.net
Fri Mar 20 21:37:58 CET 2009


Revision: 39572
          http://scummvm.svn.sourceforge.net/scummvm/?rev=39572&view=rev
Author:   peres001
Date:     2009-03-20 20:37:58 +0000 (Fri, 20 Mar 2009)

Log Message:
-----------
* Reimplemented routine using the old ILBM decoder to use the new one
* Fixed all remaining issues with masks.

Modified Paths:
--------------
    scummvm/trunk/engines/parallaction/disk_br.cpp

Modified: scummvm/trunk/engines/parallaction/disk_br.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/disk_br.cpp	2009-03-20 20:37:06 UTC (rev 39571)
+++ scummvm/trunk/engines/parallaction/disk_br.cpp	2009-03-20 20:37:58 UTC (rev 39572)
@@ -27,6 +27,7 @@
 
 #include "common/config-manager.h"
 #include "parallaction/parallaction.h"
+#include "parallaction/iff.h"
 
 
 namespace Parallaction {
@@ -483,12 +484,19 @@
 	}
 
 	stream = openFile("backs/" + Common::String(filename), ".bkg");
-	Graphics::ILBMDecoder decoder(*stream, info.bg, pal);
-	decoder.decode();
+	ILBMDecoder decoder(stream, true);
 
+	info.bg.w = decoder.getWidth();
+	info.bg.h = decoder.getHeight();
+	info.bg.pitch = info.bg.w;
+
+	info.bg.pixels = decoder.getBitmap();
+	assert(info.bg.pixels);
+
 	info.width = info.bg.w;
 	info.height = info.bg.h;
 
+	pal = decoder.getPalette();
 	p = pal;
 	for (i = 16; i < 32; i++) {
 		r = *p >> 2;
@@ -509,24 +517,44 @@
 	adjustForPalette(info.bg);
 }
 
+void finalpass(byte *buffer, uint32 size) {
+	byte b = 0xC0;
+	byte r1 = 0x40;
+	byte r2 = 0x80;
+	for (uint32 i = 0; i < size*4; i++) {
+		byte s = buffer[i/4];
+		s &= b;
 
+		if (s == r1) {
+			buffer[i/4] |= b;
+		} else
+		if (s == b) {
+			buffer[i/4] ^= r2;
+		}
+
+		b >>= 2; if (b == 0) { b = 0xC0; }
+		r1 >>= 2; if (r1 == 0) { r1 = 0x40; }
+		r2 >>= 2; if (r2 == 0) { r2 = 0x80; }
+	}
+}
+
 void AmigaDisk_br::loadMask(const char *name, MaskBuffer &buffer) {
 	if (!name) {
 		return;
 	}
+	debugC(1, kDebugDisk, "AmigaDisk_br::loadMask '%s'", name);
 
 	Common::SeekableReadStream *stream = openFile("msk/" + Common::String(name), ".msk");
+	ILBMDecoder decoder(stream, true);
 
-	byte *pal = 0;
-	Graphics::Surface* surf = new Graphics::Surface;
-	Graphics::ILBMDecoder decoder(*stream, *surf, pal);
-	decoder.decode();
-	free(pal);
+	// TODO: the buffer is allocated by the caller, so a copy here is
+	// unavoidable... a better solution would be inform the function
+	// of the size of the mask (the size in the mask file is not valid!)
+	byte *bitmap = decoder.getBitmap(2, true);
+	memcpy(buffer.data, bitmap, buffer.size);
+	finalpass(buffer.data, buffer.size);
 
-	buffer.create(surf->w, surf->h);
-	memcpy(buffer.data, surf->pixels, buffer.size);
-	buffer.bigEndian = false;
-	delete stream;
+	buffer.bigEndian = true;
 }
 
 void AmigaDisk_br::loadScenery(BackgroundInfo& info, const char* name, const char* mask, const char* path) {
@@ -536,10 +564,9 @@
 		loadBackground(info, name);
 	}
 	if (mask) {
-#if 0
 		info._mask = new MaskBuffer;
+		info._mask->create(info.width, info.height);
 		loadMask(mask, *info._mask);
-#endif
 	}
 
 	if (path) {
@@ -562,13 +589,17 @@
 	Common::String sName = name;
 
 	Common::SeekableReadStream *stream = openFile("ras/" + sName, ".ras");
-	byte *pal = 0;
+	ILBMDecoder decoder(stream);
+
 	Graphics::Surface* surf = new Graphics::Surface;
-	Graphics::ILBMDecoder decoder(*stream, *surf, pal);
-	decoder.decode();
-	free(pal);
-	delete stream;
+	assert(surf);
 
+	surf->w = decoder.getWidth();
+	surf->h = decoder.getHeight();
+	surf->pitch = surf->w;
+	surf->pixels = decoder.getBitmap();
+	assert(surf->pixels);
+
 	// Static pictures are drawn used the upper half of the palette: this must be
 	// done before shadow mask is applied. This way, only really transparent pixels
 	// will have zero as a color.
@@ -692,16 +723,16 @@
 	debugC(5, kDebugDisk, "AmigaDisk_br::loadObjects");
 
 	Common::SeekableReadStream *stream = openFile(name);
+	ILBMDecoder decoder(stream);
 
-	byte *pal = 0;
 	Graphics::Surface* surf = new Graphics::Surface;
+	assert(surf);
+	surf->w = decoder.getWidth();
+	surf->h = decoder.getHeight();
+	surf->pitch = surf->w;
+	surf->pixels = decoder.getBitmap();
+	assert(surf->pixels);
 
-	Graphics::ILBMDecoder decoder(*stream, *surf, pal);
-	decoder.decode();
-
-	delete stream;
-	free(pal);
-
 	uint16 max = objectsMax[part];
 	if (_vm->getFeatures() & GF_DEMO)
 		max = 72;


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