[Scummvm-cvs-logs] scummvm master -> 35243a235a62230e80f3df982a78ca523ff61abb

sev- sev at scummvm.org
Wed Aug 24 22:40:58 CEST 2016


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
35243a235a DIRECTOR: Implemented uncompressed 1bpp pictures. Works sometimes


Commit: 35243a235a62230e80f3df982a78ca523ff61abb
    https://github.com/scummvm/scummvm/commit/35243a235a62230e80f3df982a78ca523ff61abb
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-08-24T22:40:35+02:00

Commit Message:
DIRECTOR: Implemented uncompressed 1bpp pictures. Works sometimes

Changed paths:
    engines/director/director.cpp
    engines/director/director.h
    engines/director/frame.cpp
    engines/director/frame.h
    engines/director/images.cpp
    engines/director/images.h
    engines/director/score.cpp
    engines/director/score.h



diff --git a/engines/director/director.cpp b/engines/director/director.cpp
index 9aeba71..4e2973b 100644
--- a/engines/director/director.cpp
+++ b/engines/director/director.cpp
@@ -41,6 +41,7 @@ DirectorEngine::DirectorEngine(OSystem *syst, const DirectorGameDescription *gam
 	DebugMan.addDebugChannel(kDebugLingoExec, "lingoexec", "Lingo Execution");
 	DebugMan.addDebugChannel(kDebugLingoCompile, "lingocompile", "Lingo Compilation");
 	DebugMan.addDebugChannel(kDebugLoading, "loading", "Loading");
+	DebugMan.addDebugChannel(kDebugImages, "images", "Image drawing");
 
 	if (!_mixer->isReady())
 		error("Sound initialization failed");
diff --git a/engines/director/director.h b/engines/director/director.h
index 23519f1..97f8a70 100644
--- a/engines/director/director.h
+++ b/engines/director/director.h
@@ -54,7 +54,8 @@ struct Cast;
 enum {
 	kDebugLingoExec		= 1 << 0,
 	kDebugLingoCompile	= 1 << 1,
-	kDebugLoading		= 1 << 2
+	kDebugLoading		= 1 << 2,
+	kDebugImages		= 1 << 3
 };
 
 
diff --git a/engines/director/frame.cpp b/engines/director/frame.cpp
index 018cb79..4bae61f 100644
--- a/engines/director/frame.cpp
+++ b/engines/director/frame.cpp
@@ -435,7 +435,7 @@ void Frame::renderSprites(Graphics::ManagedSurface &surface, bool renderTrail) {
 				continue;
 			}
 
-			Image::ImageDecoder *img = getImageFrom(_sprites[i]->_castId, _sprites[i]->_width, _sprites[i]->_height);
+			Image::ImageDecoder *img = getImageFrom(_sprites[i]->_castId);
 
 			if (!img) {
 				warning("Image with id %d not found", _sprites[i]->_castId);
@@ -534,7 +534,7 @@ static const int corrections[] = {
 	0, 0, 0
 };
 
-Image::ImageDecoder *Frame::getImageFrom(uint16 spriteId, int w, int h) {
+Image::ImageDecoder *Frame::getImageFrom(uint16 spriteId) {
 	uint16 imgId = spriteId + 1024;
 	Image::ImageDecoder *img = NULL;
 
@@ -551,7 +551,15 @@ Image::ImageDecoder *Frame::getImageFrom(uint16 spriteId, int w, int h) {
 	}
 
 	if (_vm->_currentScore->getArchive()->hasResource(MKTAG('B', 'I', 'T', 'D'), imgId)) {
+		Common::SeekableReadStream *pic = _vm->_currentScore->getArchive()->getResource(MKTAG('B', 'I', 'T', 'D'), imgId);
+
 		if (_vm->getVersion() < 4) {
+			BitmapCast *bc = static_cast<BitmapCast *>(_vm->_currentScore->_casts[spriteId]);
+			int w = bc->initialRect.width(), h = bc->initialRect.height();
+
+			debugC(2, kDebugImages, "id: %d, w: %d, h: %d, flags: %x, some: %x, unk1: %d, unk2: %d",
+				imgId, w, h, bc->flags, bc->someFlaggyThing, bc->unk1, bc->unk2);
+
 			bool c = false;
 			for (int i = 0; corrections[i]; i += 3)
 				if (corrections[i] == imgId) {
@@ -561,20 +569,28 @@ Image::ImageDecoder *Frame::getImageFrom(uint16 spriteId, int w, int h) {
 				}
 
 			if (!c)
-				warning("%d, %d, %d,", imgId, w, w);
-			img = new BITDDecoder(w, h);
+				debugC(4, kDebugImages, "%d, %d, %d", imgId, w, h);
+
+			if (bc->flags & 0x20) {
+				int w1 = w + 8 - w % 8 + 8;
+				debugC(3, kDebugImages, "Disabling compression for %d: %d x %d", imgId, w1, h);
+
+				img = new BITDDecoder(w1, h, false);
+			} else {
+				img = new BITDDecoder(w, h, true);
+			}
 		} else {
 			img = new Image::BitmapDecoder();
 		}
 
 		if (debugChannelSet(8, kDebugLoading)) {
-			Common::SeekableReadStream *s = _vm->_currentScore->getArchive()->getResource(MKTAG('B', 'I', 'T', 'D'), imgId);
+			Common::SeekableReadStream *s = pic;
 			byte buf[1024];
 			int n = s->read(buf, 1024);
 			Common::hexdump(buf, n);
 		}
 
-		img->loadStream(*_vm->_currentScore->getArchive()->getResource(MKTAG('B', 'I', 'T', 'D'), imgId));
+		img->loadStream(*pic);
 		return img;
 	}
 
diff --git a/engines/director/frame.h b/engines/director/frame.h
index c06157c..8c6f82f 100644
--- a/engines/director/frame.h
+++ b/engines/director/frame.h
@@ -118,7 +118,7 @@ private:
 	void readPaletteInfo(Common::SeekableSubReadStreamEndian &stream);
 	void readSprite(Common::SeekableSubReadStreamEndian &stream, uint16 offset, uint16 size);
 	void readMainChannels(Common::SeekableSubReadStreamEndian &stream, uint16 offset, uint16 size);
-	Image::ImageDecoder *getImageFrom(uint16 spriteID, int w, int h);
+	Image::ImageDecoder *getImageFrom(uint16 spriteID);
 	void drawBackgndTransSprite(Graphics::ManagedSurface &target, const Graphics::Surface &sprite, Common::Rect &drawRect);
 	void drawMatteSprite(Graphics::ManagedSurface &target, const Graphics::Surface &sprite, Common::Rect &drawRect);
 	void drawGhostSprite(Graphics::ManagedSurface &target, const Graphics::Surface &sprite, Common::Rect &drawRect);
diff --git a/engines/director/images.cpp b/engines/director/images.cpp
index db429af..2c2553f 100644
--- a/engines/director/images.cpp
+++ b/engines/director/images.cpp
@@ -21,8 +21,10 @@
  */
 
 #include "common/substream.h"
+#include "common/debug.h"
 #include "common/textconsole.h"
 
+#include "director/director.h"
 #include "director/images.h"
 
 namespace Director {
@@ -102,11 +104,7 @@ bool DIBDecoder::loadStream(Common::SeekableReadStream &stream) {
  * BITD
  ****************************/
 
-BITDDecoder::BITDDecoder(int w, int h) {
-	int oldw = w;
-	//w += 8 - (w + 7) % 8;
-
-	//warning("W: %d -> %d, %d", oldw, w, h);
+BITDDecoder::BITDDecoder(int w, int h, bool comp) {
 	_surface = new Graphics::Surface();
 	_surface->create(w, h, Graphics::PixelFormat::createFormatCLUT8());
 
@@ -116,6 +114,8 @@ BITDDecoder::BITDDecoder(int w, int h) {
 	_palette[255 * 3 + 0] = _palette[255 * 3 + 1] = _palette[255 * 3 + 2] = 0xff;
 
 	_paletteColorCount = 2;
+
+	_comp = comp;
 }
 
 BITDDecoder::~BITDDecoder() {
@@ -137,6 +137,19 @@ void BITDDecoder::loadPalette(Common::SeekableReadStream &stream) {
 bool BITDDecoder::loadStream(Common::SeekableReadStream &stream) {
 	int x = 0, y = 0;
 
+	if (!_comp) {
+		debugC(3, kDebugImages, "Skipping compression");
+		for (y = 0; y < _surface->h; y++) {
+			for (x = 0; x < _surface->w; x++) {
+				byte color = stream.readByte();
+				for (int c = 0; c < 8; c++, x++)
+					*((byte *)_surface->getBasePtr(x, y)) = (color & (1 << (7 - c))) ? 0 : 0xff;
+			}
+		}
+
+		return true;
+	}
+
 	while (y < _surface->h) {
 		int n = stream.readSByte();
 		int count;
diff --git a/engines/director/images.h b/engines/director/images.h
index 54e8245..4c2bfc8 100644
--- a/engines/director/images.h
+++ b/engines/director/images.h
@@ -64,7 +64,7 @@ private:
 
 class BITDDecoder : public Image::ImageDecoder {
 public:
-	BITDDecoder(int w, int h);
+	BITDDecoder(int w, int h, bool comp);
 	virtual ~BITDDecoder();
 
 	// ImageDecoder API
@@ -79,6 +79,7 @@ private:
 	Graphics::Surface *_surface;
 	byte *_palette;
 	uint8 _paletteColorCount;
+	bool _comp;
 };
 
 } // End of namespace Director
diff --git a/engines/director/score.cpp b/engines/director/score.cpp
index 9b4f572..2448ab0 100644
--- a/engines/director/score.cpp
+++ b/engines/director/score.cpp
@@ -642,16 +642,17 @@ void Score::loadFontMap(Common::SeekableSubReadStreamEndian &stream) {
 }
 
 BitmapCast::BitmapCast(Common::SeekableSubReadStreamEndian &stream) {
-	/*byte flags = */ stream.readByte();
-	uint16 someFlaggyThing = stream.readUint16();
+	flags = stream.readByte();
+	someFlaggyThing = stream.readUint16();
 	initialRect = Score::readRect(stream);
 	boundingRect = Score::readRect(stream);
 	regY = stream.readUint16();
 	regX = stream.readUint16();
+	unk1 = unk2 = 0;
 
 	if (someFlaggyThing & 0x8000) {
-		/*uint16 unk1 =*/ stream.readUint16();
-		/*uint16 unk2 =*/ stream.readUint16();
+		unk1 = stream.readUint16();
+		unk2 = stream.readUint16();
 	}
 	modified = 0;
 }
diff --git a/engines/director/score.h b/engines/director/score.h
index dc6a62b..11f885d 100644
--- a/engines/director/score.h
+++ b/engines/director/score.h
@@ -74,6 +74,8 @@ struct BitmapCast : Cast {
 	uint16 regX;
 	uint16 regY;
 	uint8 flags;
+	uint16 someFlaggyThing;
+	uint16 unk1, unk2;
 };
 
 enum ShapeType {






More information about the Scummvm-git-logs mailing list