[Scummvm-git-logs] scummvm master -> 7fb14af6f97c80d1372bcdb9310e53f784350f69

moralrecordings code at moral.net.au
Sat Jan 4 14:49:33 UTC 2020


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

Summary:
b32d0f2ad9 DIRECTOR: Render shapes with transparency
7fb14af6f9 DIRECTOR: Fix margins on shape rendering


Commit: b32d0f2ad99b526d72d47523eb642f8bc70fc91a
    https://github.com/scummvm/scummvm/commit/b32d0f2ad99b526d72d47523eb642f8bc70fc91a
Author: Scott Percival (code at moral.net.au)
Date: 2020-01-04T22:49:14+08:00

Commit Message:
DIRECTOR: Render shapes with transparency

Changed paths:
    engines/director/cast.cpp
    engines/director/frame.cpp
    engines/director/frame.h
    engines/director/sprite.h


diff --git a/engines/director/cast.cpp b/engines/director/cast.cpp
index dc1170b..1d22da7 100644
--- a/engines/director/cast.cpp
+++ b/engines/director/cast.cpp
@@ -288,8 +288,8 @@ ShapeCast::ShapeCast(Common::ReadStreamEndian &stream, uint16 version) {
 		_shapeType = static_cast<ShapeType>(stream.readByte());
 		_initialRect = Score::readRect(stream);
 		_pattern = stream.readUint16BE();
-		_fgCol = (uint8)stream.readByte();
-		_bgCol = (uint8)stream.readByte();
+		_fgCol = (127 - stream.readByte()) & 0xff; // -128 -> 0, 127 -> 256
+		_bgCol = (127 - stream.readByte()) & 0xff;
 		_fillType = stream.readByte();
 		_ink = static_cast<InkType>(_fillType & 0x3f);
 		_lineThickness = stream.readByte();
diff --git a/engines/director/frame.cpp b/engines/director/frame.cpp
index b73146a..fe332ad 100644
--- a/engines/director/frame.cpp
+++ b/engines/director/frame.cpp
@@ -309,7 +309,7 @@ void Frame::readMainChannels(Common::SeekableSubReadStreamEndian &stream, uint16
 			_soundType2 = stream.readByte();
 			offset += 1;
 			break;
-		case kPaletePosition:
+		case kPalettePosition:
 			if (stream.readUint16())
 				readPaletteInfo(stream);
 			offset += 16;
@@ -644,7 +644,7 @@ void Frame::renderSprites(Graphics::ManagedSurface &surface, bool renderTrail) {
 				int width = _vm->getVersion() > 4 ? bc->_initialRect.width() : _sprites[i]->_width;
 				Common::Rect drawRect(x, y, x + width, y + height);
 				addDrawRect(i, drawRect);
-				inkBasedBlit(surface, *(bc->_surface), i, drawRect);
+				inkBasedBlit(surface, *(bc->_surface), _sprites[i]->_ink, drawRect);
 			}
 		}
 	}
@@ -660,6 +660,7 @@ void Frame::addDrawRect(uint16 spriteId, Common::Rect &rect) {
 void Frame::renderShape(Graphics::ManagedSurface &surface, uint16 spriteId) {
 	Sprite *sp = _sprites[spriteId];
 
+	InkType ink = sp->_ink;
 	byte spriteType = sp->_spriteType;
 	byte foreColor = sp->_foreColor;
 	byte backColor = sp->_backColor;
@@ -688,6 +689,11 @@ void Frame::renderShape(Graphics::ManagedSurface &surface, uint16 spriteId) {
 				foreColor = sc->_fgCol;
 				backColor = sc->_bgCol;
 				lineSize = sc->_lineThickness;
+				ink = sc->_ink;
+				// shapes should be rendered with transparency by default
+				if (ink == kInkTypeCopy) {
+					ink = kInkTypeTransparent;
+				}
 			}
 			break;
 		default:
@@ -703,6 +709,7 @@ void Frame::renderShape(Graphics::ManagedSurface &surface, uint16 spriteId) {
 
 	Graphics::ManagedSurface tmpSurface;
 	tmpSurface.create(shapeRect.width(), shapeRect.height(), Graphics::PixelFormat::createFormatCLUT8());
+	tmpSurface.clear(255);
 
 	// No minus one on the pattern here! MacPlotData will do that for us!
 	//Graphics::MacPlotData pd(&tmpSurface, &_vm->getPatterns(), 1, 1, sp->_backColor);
@@ -743,7 +750,8 @@ void Frame::renderShape(Graphics::ManagedSurface &surface, uint16 spriteId) {
 	}
 
 	addDrawRect(spriteId, shapeRect);
-	inkBasedBlit(surface, tmpSurface, spriteId, shapeRect);
+	inkBasedBlit(surface, tmpSurface, ink, shapeRect);
+
 }
 
 void Frame::renderButton(Graphics::ManagedSurface &surface, uint16 spriteId) {
@@ -910,16 +918,16 @@ void Frame::renderText(Graphics::ManagedSurface &surface, uint16 spriteId, Commo
 
 	textWithFeatures.transBlitFrom(textSurface->rawSurface(), Common::Point(textX, textY), 0xff);
 
-	inkBasedBlit(surface, textWithFeatures, spriteId, Common::Rect(x, y, x + width, y + height));
+	inkBasedBlit(surface, textWithFeatures, _sprites[spriteId]->_ink, Common::Rect(x, y, x + width, y + height));
 }
 
-void Frame::inkBasedBlit(Graphics::ManagedSurface &targetSurface, const Graphics::Surface &spriteSurface, uint16 spriteId, Common::Rect drawRect) {
+void Frame::inkBasedBlit(Graphics::ManagedSurface &targetSurface, const Graphics::Surface &spriteSurface, InkType ink, Common::Rect drawRect) {
 	// drawRect could be bigger than the spriteSurface. Clip it
 	Common::Rect t(spriteSurface.w, spriteSurface.h);
 	t.moveTo(drawRect.left, drawRect.top);
 	drawRect.clip(t);
 
-	switch (_sprites[spriteId]->_ink) {
+	switch (ink) {
 	case kInkTypeCopy:
 		targetSurface.blitFrom(spriteSurface, Common::Point(drawRect.left, drawRect.top));
 		break;
@@ -940,7 +948,7 @@ void Frame::inkBasedBlit(Graphics::ManagedSurface &targetSurface, const Graphics
 		drawReverseSprite(targetSurface, spriteSurface, drawRect);
 		break;
 	default:
-		warning("Frame::inkBasedBlit(): Unhandled ink type %d", _sprites[spriteId]->_ink);
+		warning("Frame::inkBasedBlit(): Unhandled ink type %d", ink);
 		targetSurface.blitFrom(spriteSurface, Common::Point(drawRect.left, drawRect.top));
 		break;
 	}
diff --git a/engines/director/frame.h b/engines/director/frame.h
index 3c20dea..25192af 100644
--- a/engines/director/frame.h
+++ b/engines/director/frame.h
@@ -147,7 +147,7 @@ private:
 	void drawMatteSprite(Graphics::ManagedSurface &target, const Graphics::Surface &sprite, Common::Rect &drawRect);
 	void drawGhostSprite(Graphics::ManagedSurface &target, const Graphics::Surface &sprite, Common::Rect &drawRect);
 	void drawReverseSprite(Graphics::ManagedSurface &target, const Graphics::Surface &sprite, Common::Rect &drawRect);
-	void inkBasedBlit(Graphics::ManagedSurface &targetSurface, const Graphics::Surface &spriteSurface, uint16 spriteId, Common::Rect drawRect);
+	void inkBasedBlit(Graphics::ManagedSurface &targetSurface, const Graphics::Surface &spriteSurface, InkType ink, Common::Rect drawRect);
 	void addDrawRect(uint16 entityId, Common::Rect &rect);
 
 public:
diff --git a/engines/director/sprite.h b/engines/director/sprite.h
index 0c12a0d..8ac0dcb 100644
--- a/engines/director/sprite.h
+++ b/engines/director/sprite.h
@@ -54,7 +54,7 @@ enum MainChannelsPosition {
 	kBlendPosition,
 	kSound2Position,
 	kSound2TypePosition = 11,
-	kPaletePosition = 15
+	kPalettePosition = 15
 };
 
 class Sprite {


Commit: 7fb14af6f97c80d1372bcdb9310e53f784350f69
    https://github.com/scummvm/scummvm/commit/7fb14af6f97c80d1372bcdb9310e53f784350f69
Author: Scott Percival (code at moral.net.au)
Date: 2020-01-04T22:49:14+08:00

Commit Message:
DIRECTOR: Fix margins on shape rendering

Changed paths:
    engines/director/frame.cpp


diff --git a/engines/director/frame.cpp b/engines/director/frame.cpp
index fe332ad..9a15554 100644
--- a/engines/director/frame.cpp
+++ b/engines/director/frame.cpp
@@ -664,7 +664,7 @@ void Frame::renderShape(Graphics::ManagedSurface &surface, uint16 spriteId) {
 	byte spriteType = sp->_spriteType;
 	byte foreColor = sp->_foreColor;
 	byte backColor = sp->_backColor;
-	byte lineSize = sp->_lineSize + 1;
+	int lineSize = sp->_lineSize - 1;
 	if (spriteType == kCastMemberSprite && sp->_cast != NULL) {
 		switch (sp->_cast->_type) {
 		case kCastShape:
@@ -688,7 +688,7 @@ void Frame::renderShape(Graphics::ManagedSurface &surface, uint16 spriteId) {
 				}
 				foreColor = sc->_fgCol;
 				backColor = sc->_bgCol;
-				lineSize = sc->_lineThickness;
+				lineSize = sc->_lineThickness - 1;
 				ink = sc->_ink;
 				// shapes should be rendered with transparency by default
 				if (ink == kInkTypeCopy) {
@@ -714,7 +714,7 @@ void Frame::renderShape(Graphics::ManagedSurface &surface, uint16 spriteId) {
 	// No minus one on the pattern here! MacPlotData will do that for us!
 	//Graphics::MacPlotData pd(&tmpSurface, &_vm->getPatterns(), 1, 1, sp->_backColor);
 	Graphics::MacPlotData pd(&tmpSurface, &_vm->getPatterns(), sp->getPattern(), lineSize, backColor);
-	Common::Rect fillRect(shapeRect.width(), shapeRect.height());
+	Common::Rect fillRect(MAX((int)shapeRect.width() - lineSize, 0), MAX((int)shapeRect.height() - lineSize, 0));
 
 	switch (spriteType) {
 	case kRectangleSprite:




More information about the Scummvm-git-logs mailing list