[Scummvm-git-logs] scummvm master -> c1827f1f42e252b9c6073202ea0a49c8644e5d03

mgerhardy martin.gerhardy at gmail.com
Wed Dec 23 11:08:11 UTC 2020


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

Summary:
ea4f7c90d0 TWINE: use bits() helper
b839057ade TWINE: todo comment
c7b81b62b6 TWINE: optimized depthSortRenderCommands by using Common::sort
c228cadbe7 TWINE: minor cleanup and optimizations in Interface::blitBox
75b9419f42 TWINE: cleanup clipping methods
3371ede756 TWINE: cleanup drawSplittedBox
29c325464b TWINE: const in Interface::drawLine
dce8ff6995 TWINE: further cleanup in drawLine
b015dd95f1 TWINE: clipping in blitBox
8e6e405a11 TWINE: cleanup in drawSplittedBox
b9705f2e82 TWINE: renamed variable
98c7d81bb7 TWINE: flip branch conditions
ff22b784cb TWINE: replaced loop with memcpy
3ac48a5df0 TWINE: minor cleanup in drawTransparentBox
58971cdfad TWINE: replaced outer do while with for loop
92e822bc6c TWINE: cleanup loops in drawTransparentBox
2626073bef TWINE: const in drawTransparentBox
0f2d9ca5db TWINE: todo comment about holomap input
9d4fcfc0f3 TWINE: extract bbox computing into own method
c1827f1f42 TWINE: const


Commit: ea4f7c90d03e3153e1db6b4790d7547039c91ef4
    https://github.com/scummvm/scummvm/commit/ea4f7c90d03e3153e1db6b4790d7547039c91ef4
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-12-23T09:33:05+01:00

Commit Message:
TWINE: use bits() helper

Changed paths:
    engines/twine/scene/grid.cpp


diff --git a/engines/twine/scene/grid.cpp b/engines/twine/scene/grid.cpp
index 3d2f97682a..6afcbfd290 100644
--- a/engines/twine/scene/grid.cpp
+++ b/engines/twine/scene/grid.cpp
@@ -338,18 +338,18 @@ void Grid::createGridColumn(const uint8 *gridEntry, uint32 gridEntrySize, uint8
 
 	do {
 		const int32 flag = stream.readByte();
-		const int32 blockCount = (flag & 0x3F) + 1;
-
-		if (!(flag & 0xC0)) {
+		const int32 blockCount = bits(flag, 0, 6) + 1;
+		const int32 type = bits(flag, 6, 2);
+		if (type == 0) {
 			for (int32 i = 0; i < blockCount; i++) {
 				outstream.writeUint16LE(0);
 			}
-		} else if (flag & 0x40) {
+		} else if (type == 1) {
 			for (int32 i = 0; i < blockCount; i++) {
 				outstream.writeUint16LE(stream.readUint16LE());
 			}
 		} else {
-			int32 gridIdx = stream.readUint16LE();
+			const int32 gridIdx = stream.readUint16LE();
 			for (int32 i = 0; i < blockCount; i++) {
 				outstream.writeUint16LE(gridIdx);
 			}
@@ -366,18 +366,19 @@ void Grid::createCellingGridColumn(const uint8 *gridEntry, uint32 gridEntrySize,
 
 	do {
 		const int32 flag = stream.readByte();
-		const int32 blockCount = (flag & 0x3F) + 1;
+		const int32 blockCount = bits(flag, 0, 6) + 1;
+		const int32 type = bits(flag, 6, 2);
 
-		if (!(flag & 0xC0)) {
+		if (type == 0) {
 			for (int32 i = 0; i < blockCount; i++) {
 				outstream.seek(outstream.pos() + 2);
 			}
-		} else if (flag & 0x40) {
+		} else if (type == 1) {
 			for (int32 i = 0; i < blockCount; i++) {
 				outstream.writeUint16LE(stream.readUint16LE());
 			}
 		} else {
-			int32 gridIdx = stream.readUint16LE();
+			const int32 gridIdx = stream.readUint16LE();
 			for (int32 i = 0; i < blockCount; i++) {
 				outstream.writeUint16LE(gridIdx);
 			}


Commit: b839057ade4897755725e3eb5cd0b94119fc046f
    https://github.com/scummvm/scummvm/commit/b839057ade4897755725e3eb5cd0b94119fc046f
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-12-23T09:52:26+01:00

Commit Message:
TWINE: todo comment

Changed paths:
    engines/twine/menu/interface.cpp


diff --git a/engines/twine/menu/interface.cpp b/engines/twine/menu/interface.cpp
index 7fe272e01d..cc06a732f8 100644
--- a/engines/twine/menu/interface.cpp
+++ b/engines/twine/menu/interface.cpp
@@ -152,6 +152,7 @@ void Interface::drawLine(int32 startWidth, int32 startHeight, int32 endWidth, in
 	}
 }
 
+// TODO: this should get replaced by the surface blitting functions
 void Interface::blitBox(const Common::Rect &rect, const Graphics::ManagedSurface &source, Graphics::ManagedSurface &dest) {
 	int32 left = rect.left;
 	const int32 top = rect.top;


Commit: c7b81b62b64a5f5b54cd573f32a5b70fded5cc17
    https://github.com/scummvm/scummvm/commit/c7b81b62b64a5f5b54cd573f32a5b70fded5cc17
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-12-23T09:54:26+01:00

Commit Message:
TWINE: optimized depthSortRenderCommands by using Common::sort

Changed paths:
    engines/twine/renderer/renderer.cpp
    engines/twine/renderer/renderer.h


diff --git a/engines/twine/renderer/renderer.cpp b/engines/twine/renderer/renderer.cpp
index 31d737fd18..60c12dc02d 100644
--- a/engines/twine/renderer/renderer.cpp
+++ b/engines/twine/renderer/renderer.cpp
@@ -1125,25 +1125,8 @@ uint8 *Renderer::preparePolygons(Common::MemoryReadStream &stream, int32 &numOfP
 }
 
 const Renderer::RenderCommand *Renderer::depthSortRenderCommands(int32 numOfPrimitives) {
-	RenderCommand *sortedCmd = _renderCmdsSortedByDepth;
-	int32 bestPoly = 0;
-	const int16 minDepth = -32767;
-	for (int32 i = 0; i < numOfPrimitives; i++) { // then we sort the polygones | WARNING: very slow | TODO: improve this
-		const RenderCommand *cmd = _renderCmds;
-		int16 bestZ = minDepth;
-		for (int32 j = 0; j < numOfPrimitives; j++) {
-			if (cmd->depth > bestZ) {
-				bestZ = cmd->depth;
-				bestPoly = j;
-			}
-			cmd++;
-		}
-		*sortedCmd = _renderCmds[bestPoly];
-		sortedCmd++;
-		_renderCmds[bestPoly].depth = minDepth;
-	}
-
-	return _renderCmdsSortedByDepth;
+	Common::sort(&_renderCmds[0], &_renderCmds[numOfPrimitives], [] (const RenderCommand &lhs, const RenderCommand &rhs) {return lhs.depth > rhs.depth;});
+	return _renderCmds;
 }
 
 bool Renderer::renderModelElements(int32 numOfPrimitives, const uint8 *polygonPtr, RenderCommand **renderCmds, ModelData *modelData) {
diff --git a/engines/twine/renderer/renderer.h b/engines/twine/renderer/renderer.h
index c6c85d64c8..5a72437bab 100644
--- a/engines/twine/renderer/renderer.h
+++ b/engines/twine/renderer/renderer.h
@@ -360,7 +360,6 @@ private:
 	Vec3 lightPos;
 
 	RenderCommand _renderCmds[1000];
-	RenderCommand _renderCmdsSortedByDepth[1000];
 	uint8 renderCoordinatesBuffer[10000]{0};
 
 	int16 polyTab[960]{0};


Commit: c228cadbe7bb9b57243875621c4e2f030b7a8720
    https://github.com/scummvm/scummvm/commit/c228cadbe7bb9b57243875621c4e2f030b7a8720
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-12-23T10:08:20+01:00

Commit Message:
TWINE: minor cleanup and optimizations in Interface::blitBox

Changed paths:
    engines/twine/menu/interface.cpp


diff --git a/engines/twine/menu/interface.cpp b/engines/twine/menu/interface.cpp
index cc06a732f8..913a32db2c 100644
--- a/engines/twine/menu/interface.cpp
+++ b/engines/twine/menu/interface.cpp
@@ -154,7 +154,7 @@ void Interface::drawLine(int32 startWidth, int32 startHeight, int32 endWidth, in
 
 // TODO: this should get replaced by the surface blitting functions
 void Interface::blitBox(const Common::Rect &rect, const Graphics::ManagedSurface &source, Graphics::ManagedSurface &dest) {
-	int32 left = rect.left;
+	const int32 left = rect.left;
 	const int32 top = rect.top;
 	const int32 right = rect.right;
 	const int32 bottom = rect.bottom;
@@ -162,22 +162,13 @@ void Interface::blitBox(const Common::Rect &rect, const Graphics::ManagedSurface
 	const int8 *s = (const int8 *)source.getBasePtr(left, top);
 	int8 *d = (int8 *)dest.getBasePtr(left, top);
 
-	int32 width = right - left + 1;
-	int32 height = bottom - top + 1;
-
-	int32 insideLine = SCREEN_WIDTH - width;
-	int32 temp3 = left;
-
-	left >>= 2;
-	temp3 &= 3;
+	const int32 width = right - left + 1;
+	const int32 height = bottom - top + 1;
 
 	for (int32 j = 0; j < height; j++) {
-		for (int32 i = 0; i < width; i++) {
-			*(d++) = *(s++);
-		}
-
-		d += insideLine;
-		s += insideLine;
+		memcpy(d, s, width);
+		d += SCREEN_WIDTH;
+		s += SCREEN_WIDTH;
 	}
 }
 


Commit: 75b9419f429c789567a0bf56f9014fa7127df07b
    https://github.com/scummvm/scummvm/commit/75b9419f429c789567a0bf56f9014fa7127df07b
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-12-23T11:07:51+01:00

Commit Message:
TWINE: cleanup clipping methods

Changed paths:
    engines/twine/menu/interface.cpp


diff --git a/engines/twine/menu/interface.cpp b/engines/twine/menu/interface.cpp
index 913a32db2c..578c7f6d4c 100644
--- a/engines/twine/menu/interface.cpp
+++ b/engines/twine/menu/interface.cpp
@@ -263,40 +263,20 @@ void Interface::drawSplittedBox(const Common::Rect &rect, uint8 colorIndex) {
 }
 
 void Interface::setClip(const Common::Rect &rect) {
-	int32 left = rect.left;
-	int32 top = rect.top;
-	int32 right = rect.right;
-	int32 bottom = rect.bottom;
-
-	if (left < 0) {
-		left = 0;
-	}
-	textWindow.left = left;
-
-	if (top < 0) {
-		top = 0;
-	}
-	textWindow.top = top;
-
-	if (right >= SCREEN_WIDTH) {
-		right = SCREEN_TEXTLIMIT_RIGHT;
-	}
-	textWindow.right = right;
-
-	if (bottom >= SCREEN_HEIGHT) {
-		bottom = SCREEN_TEXTLIMIT_BOTTOM;
-	}
-	textWindow.bottom = bottom;
+	textWindow.left = MAX(SCREEN_TEXTLIMIT_LEFT, (int32)rect.left);
+	textWindow.top = MAX(SCREEN_TEXTLIMIT_TOP, (int32)rect.top);
+	textWindow.right = MIN(SCREEN_TEXTLIMIT_RIGHT, (int32)rect.right);
+	textWindow.bottom = MIN(SCREEN_TEXTLIMIT_BOTTOM, (int32)rect.bottom);
 }
 
-void Interface::saveClip() { // saveTextWindow
+void Interface::saveClip() {
 	textWindowLeftSave = textWindow.left;
 	textWindowTopSave = textWindow.top;
 	textWindowRightSave = textWindow.right;
 	textWindowBottomSave = textWindow.bottom;
 }
 
-void Interface::loadClip() { // loadSavedTextWindow
+void Interface::loadClip() {
 	textWindow.left = textWindowLeftSave;
 	textWindow.top = textWindowTopSave;
 	textWindow.right = textWindowRightSave;
@@ -304,7 +284,8 @@ void Interface::loadClip() { // loadSavedTextWindow
 }
 
 void Interface::resetClip() {
-	textWindow.top = textWindow.left = SCREEN_TEXTLIMIT_TOP;
+	textWindow.top = SCREEN_TEXTLIMIT_TOP;
+	textWindow.left = SCREEN_TEXTLIMIT_LEFT;
 	textWindow.right = SCREEN_TEXTLIMIT_RIGHT;
 	textWindow.bottom = SCREEN_TEXTLIMIT_BOTTOM;
 }


Commit: 3371ede7568cdbe14e6b1855684649cfd89ce539
    https://github.com/scummvm/scummvm/commit/3371ede7568cdbe14e6b1855684649cfd89ce539
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-12-23T11:07:51+01:00

Commit Message:
TWINE: cleanup drawSplittedBox

Changed paths:
    engines/twine/menu/interface.cpp


diff --git a/engines/twine/menu/interface.cpp b/engines/twine/menu/interface.cpp
index 578c7f6d4c..944448b2f4 100644
--- a/engines/twine/menu/interface.cpp
+++ b/engines/twine/menu/interface.cpp
@@ -231,31 +231,24 @@ void Interface::drawTransparentBox(const Common::Rect &rect, int32 colorAdj) {
 }
 
 void Interface::drawSplittedBox(const Common::Rect &rect, uint8 colorIndex) {
-	const int32 left = rect.left;
-	const int32 top = rect.top;
-	const int32 right = rect.right;
-	const int32 bottom = rect.bottom;
-
-	if (left > SCREEN_TEXTLIMIT_RIGHT) {
+	if (rect.left > SCREEN_TEXTLIMIT_RIGHT) {
 		return;
 	}
-	if (right < SCREEN_TEXTLIMIT_LEFT) {
+	if (rect.right < SCREEN_TEXTLIMIT_LEFT) {
 		return;
 	}
-	if (top > SCREEN_TEXTLIMIT_BOTTOM) {
+	if (rect.top > SCREEN_TEXTLIMIT_BOTTOM) {
 		return;
 	}
-	if (bottom < SCREEN_TEXTLIMIT_TOP) {
+	if (rect.bottom < SCREEN_TEXTLIMIT_TOP) {
 		return;
 	}
 
-	// cropping
-	int32 offset = -((right - left) - SCREEN_WIDTH);
-
-	uint8 *ptr = (uint8*)_engine->frontVideoBuffer.getBasePtr(left, top);
+	const int32 offset = -((rect.right - rect.left) - SCREEN_WIDTH);
 
-	for (int32 x = top; x < bottom; x++) {
-		for (int32 y = left; y < right; y++) {
+	uint8 *ptr = (uint8*)_engine->frontVideoBuffer.getBasePtr(rect.left, rect.top);
+	for (int32 y = rect.top; y < rect.bottom; y++) {
+		for (int32 x = rect.left; x < rect.right; x++) {
 			*ptr++ = colorIndex;
 		}
 		ptr += offset;


Commit: 29c325464bf5b9c0147c568be515aa6a2cd26291
    https://github.com/scummvm/scummvm/commit/29c325464bf5b9c0147c568be515aa6a2cd26291
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-12-23T11:07:51+01:00

Commit Message:
TWINE: const in Interface::drawLine

Changed paths:
    engines/twine/menu/interface.cpp


diff --git a/engines/twine/menu/interface.cpp b/engines/twine/menu/interface.cpp
index 944448b2f4..a1d121aa85 100644
--- a/engines/twine/menu/interface.cpp
+++ b/engines/twine/menu/interface.cpp
@@ -74,7 +74,7 @@ void Interface::drawLine(int32 startWidth, int32 startHeight, int32 endWidth, in
 		}
 
 		// At least one endpoint is outside the clip rectangle; pick it.
-		int32 outcodeOut = outcode0 ? outcode0 : outcode1;
+		const int32 outcodeOut = outcode0 ? outcode0 : outcode1;
 
 		int32 x = 0;
 		int32 y = 0;
@@ -114,13 +114,12 @@ void Interface::drawLine(int32 startWidth, int32 startHeight, int32 endWidth, in
 
 	uint8 *out = (uint8*)_engine->frontVideoBuffer.getBasePtr(startWidth, startHeight);
 
-	uint8 color = currentLineColor;
+	const uint8 color = currentLineColor;
 	if (endWidth < endHeight) { // significant slope
-		int16 xchg = endWidth;
+		const int16 xchg = endWidth;
 		endWidth = endHeight;
 		endHeight = xchg;
-		int16 var2 = endWidth;
-		var2 <<= 1;
+		const int16 var2 = endWidth << 1;
 		startHeight = endWidth;
 		endHeight <<= 1;
 		endWidth++;
@@ -135,14 +134,12 @@ void Interface::drawLine(int32 startWidth, int32 startHeight, int32 endWidth, in
 			}
 		} while (--endWidth);
 	} else { // reduced slope
-		int16 var2 = endWidth;
-		var2 <<= 1;
+		const int16 var2 = endWidth << 1;
 		startHeight = endWidth;
 		endHeight <<= 1;
 		endWidth++;
 		do {
-			*out = color;
-			out++;
+			*out++ = color;
 			startHeight -= endHeight;
 			if (startHeight < 0) {
 				startHeight += var2;


Commit: dce8ff69952c69266ac652f541ee5589cda70e69
    https://github.com/scummvm/scummvm/commit/dce8ff69952c69266ac652f541ee5589cda70e69
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-12-23T11:07:55+01:00

Commit Message:
TWINE: further cleanup in drawLine

Changed paths:
    engines/twine/menu/interface.cpp


diff --git a/engines/twine/menu/interface.cpp b/engines/twine/menu/interface.cpp
index a1d121aa85..76668b879c 100644
--- a/engines/twine/menu/interface.cpp
+++ b/engines/twine/menu/interface.cpp
@@ -51,17 +51,11 @@ int32 Interface::checkClipping(int32 x, int32 y) {
 
 // TODO: check if Graphics::drawLine() works here
 void Interface::drawLine(int32 startWidth, int32 startHeight, int32 endWidth, int32 endHeight, uint8 lineColor) {
-	uint8 currentLineColor = lineColor;
 
 	// draw line from left to right
 	if (startWidth > endWidth) {
-		int32 temp = endWidth;
-		endWidth = startWidth;
-		startWidth = temp;
-
-		temp = endHeight;
-		endHeight = startHeight;
-		startHeight = temp;
+		SWAP(endWidth, startWidth);
+		SWAP(endHeight, startHeight);
 	}
 
 	// Perform proper clipping (CohenSutherland algorithm)
@@ -114,17 +108,14 @@ void Interface::drawLine(int32 startWidth, int32 startHeight, int32 endWidth, in
 
 	uint8 *out = (uint8*)_engine->frontVideoBuffer.getBasePtr(startWidth, startHeight);
 
-	const uint8 color = currentLineColor;
 	if (endWidth < endHeight) { // significant slope
-		const int16 xchg = endWidth;
-		endWidth = endHeight;
-		endHeight = xchg;
+		SWAP(endWidth, endHeight);
 		const int16 var2 = endWidth << 1;
 		startHeight = endWidth;
 		endHeight <<= 1;
 		endWidth++;
 		do {
-			*out = color;
+			*out = lineColor;
 			startHeight -= endHeight;
 			if (startHeight > 0) {
 				out += flag2;
@@ -139,7 +130,7 @@ void Interface::drawLine(int32 startWidth, int32 startHeight, int32 endWidth, in
 		endHeight <<= 1;
 		endWidth++;
 		do {
-			*out++ = color;
+			*out++ = lineColor;
 			startHeight -= endHeight;
 			if (startHeight < 0) {
 				startHeight += var2;


Commit: b015dd95f1d6419e653503bbec5381adda1ef35b
    https://github.com/scummvm/scummvm/commit/b015dd95f1d6419e653503bbec5381adda1ef35b
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-12-23T11:07:55+01:00

Commit Message:
TWINE: clipping in blitBox

Changed paths:
    engines/twine/menu/interface.cpp


diff --git a/engines/twine/menu/interface.cpp b/engines/twine/menu/interface.cpp
index 76668b879c..7a9ea5a31d 100644
--- a/engines/twine/menu/interface.cpp
+++ b/engines/twine/menu/interface.cpp
@@ -142,10 +142,23 @@ void Interface::drawLine(int32 startWidth, int32 startHeight, int32 endWidth, in
 
 // TODO: this should get replaced by the surface blitting functions
 void Interface::blitBox(const Common::Rect &rect, const Graphics::ManagedSurface &source, Graphics::ManagedSurface &dest) {
-	const int32 left = rect.left;
-	const int32 top = rect.top;
-	const int32 right = rect.right;
-	const int32 bottom = rect.bottom;
+	const int32 left = MAX(SCREEN_TEXTLIMIT_LEFT, (int32)rect.left);
+	const int32 top = MAX(SCREEN_TEXTLIMIT_TOP, (int32)rect.top);
+	const int32 right = MIN(SCREEN_TEXTLIMIT_RIGHT, (int32)rect.right);
+	const int32 bottom = MIN(SCREEN_TEXTLIMIT_BOTTOM, (int32)rect.bottom);
+
+	if (left > SCREEN_TEXTLIMIT_RIGHT) {
+		return;
+	}
+	if (right < SCREEN_TEXTLIMIT_LEFT) {
+		return;
+	}
+	if (top > SCREEN_TEXTLIMIT_BOTTOM) {
+		return;
+	}
+	if (bottom < SCREEN_TEXTLIMIT_TOP) {
+		return;
+	}
 
 	const int8 *s = (const int8 *)source.getBasePtr(left, top);
 	int8 *d = (int8 *)dest.getBasePtr(left, top);


Commit: 8e6e405a1160bf86e4afa9c8191ce6746de45f81
    https://github.com/scummvm/scummvm/commit/8e6e405a1160bf86e4afa9c8191ce6746de45f81
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-12-23T11:07:55+01:00

Commit Message:
TWINE: cleanup in drawSplittedBox

Changed paths:
    engines/twine/menu/interface.cpp


diff --git a/engines/twine/menu/interface.cpp b/engines/twine/menu/interface.cpp
index 7a9ea5a31d..3f8c66a7de 100644
--- a/engines/twine/menu/interface.cpp
+++ b/engines/twine/menu/interface.cpp
@@ -232,27 +232,28 @@ void Interface::drawTransparentBox(const Common::Rect &rect, int32 colorAdj) {
 }
 
 void Interface::drawSplittedBox(const Common::Rect &rect, uint8 colorIndex) {
-	if (rect.left > SCREEN_TEXTLIMIT_RIGHT) {
+	const int32 left = MAX(SCREEN_TEXTLIMIT_LEFT, (int32)rect.left);
+	const int32 top = MAX(SCREEN_TEXTLIMIT_TOP, (int32)rect.top);
+	const int32 right = MIN(SCREEN_TEXTLIMIT_RIGHT, (int32)rect.right);
+	const int32 bottom = MIN(SCREEN_TEXTLIMIT_BOTTOM, (int32)rect.bottom);
+
+	if (left > SCREEN_TEXTLIMIT_RIGHT) {
 		return;
 	}
-	if (rect.right < SCREEN_TEXTLIMIT_LEFT) {
+	if (right < SCREEN_TEXTLIMIT_LEFT) {
 		return;
 	}
-	if (rect.top > SCREEN_TEXTLIMIT_BOTTOM) {
+	if (top > SCREEN_TEXTLIMIT_BOTTOM) {
 		return;
 	}
-	if (rect.bottom < SCREEN_TEXTLIMIT_TOP) {
+	if (bottom < SCREEN_TEXTLIMIT_TOP) {
 		return;
 	}
 
-	const int32 offset = -((rect.right - rect.left) - SCREEN_WIDTH);
-
-	uint8 *ptr = (uint8*)_engine->frontVideoBuffer.getBasePtr(rect.left, rect.top);
-	for (int32 y = rect.top; y < rect.bottom; y++) {
-		for (int32 x = rect.left; x < rect.right; x++) {
-			*ptr++ = colorIndex;
-		}
-		ptr += offset;
+	uint8 *ptr = (uint8*)_engine->frontVideoBuffer.getBasePtr(left, top);
+	for (int32 y = top; y < bottom; y++) {
+		memset(ptr, colorIndex, right - left);
+		ptr += SCREEN_WIDTH;
 	}
 }
 


Commit: b9705f2e824e506cb3bb9bd9ead8a2c479cea287
    https://github.com/scummvm/scummvm/commit/b9705f2e824e506cb3bb9bd9ead8a2c479cea287
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-12-23T11:08:00+01:00

Commit Message:
TWINE: renamed variable

Changed paths:
    engines/twine/menu/interface.cpp


diff --git a/engines/twine/menu/interface.cpp b/engines/twine/menu/interface.cpp
index 3f8c66a7de..e43037e865 100644
--- a/engines/twine/menu/interface.cpp
+++ b/engines/twine/menu/interface.cpp
@@ -51,7 +51,6 @@ int32 Interface::checkClipping(int32 x, int32 y) {
 
 // TODO: check if Graphics::drawLine() works here
 void Interface::drawLine(int32 startWidth, int32 startHeight, int32 endWidth, int32 endHeight, uint8 lineColor) {
-
 	// draw line from left to right
 	if (startWidth > endWidth) {
 		SWAP(endWidth, startWidth);
@@ -98,11 +97,11 @@ void Interface::drawLine(int32 startWidth, int32 startHeight, int32 endWidth, in
 		}
 	}
 
-	int32 flag2 = SCREEN_WIDTH;
+	int32 pitch = SCREEN_WIDTH;
 	endWidth -= startWidth;
 	endHeight -= startHeight;
 	if (endHeight < 0) {
-		flag2 = -flag2;
+		pitch = -pitch;
 		endHeight = -endHeight;
 	}
 
@@ -118,10 +117,10 @@ void Interface::drawLine(int32 startWidth, int32 startHeight, int32 endWidth, in
 			*out = lineColor;
 			startHeight -= endHeight;
 			if (startHeight > 0) {
-				out += flag2;
+				out += pitch;
 			} else {
 				startHeight += var2;
-				out += flag2 + 1;
+				out += pitch + 1;
 			}
 		} while (--endWidth);
 	} else { // reduced slope
@@ -134,7 +133,7 @@ void Interface::drawLine(int32 startWidth, int32 startHeight, int32 endWidth, in
 			startHeight -= endHeight;
 			if (startHeight < 0) {
 				startHeight += var2;
-				out += flag2;
+				out += pitch;
 			}
 		} while (--endWidth);
 	}


Commit: 98c7d81bb7d7da51d36b2c86042861e524d2a738
    https://github.com/scummvm/scummvm/commit/98c7d81bb7d7da51d36b2c86042861e524d2a738
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-12-23T11:08:00+01:00

Commit Message:
TWINE: flip branch conditions

Changed paths:
    engines/twine/menu/menu.cpp


diff --git a/engines/twine/menu/menu.cpp b/engines/twine/menu/menu.cpp
index 4b0704b077..a62801841b 100644
--- a/engines/twine/menu/menu.cpp
+++ b/engines/twine/menu/menu.cpp
@@ -399,11 +399,11 @@ int32 Menu::processMenu(MenuSettings *menuSettings) {
 	_engine->_input->enableKeyMap(uiKeyMapId);
 
 	// if we are running the game already, the buttons are just rendered on top of the scene
-	if (!_engine->_scene->isGameRunning()) {
-		_engine->_screens->loadMenuImage(false);
-	} else {
+	if (_engine->_scene->isGameRunning()) {
 		_engine->_screens->copyScreen(_engine->workVideoBuffer, _engine->frontVideoBuffer);
 		_engine->flip();
+	} else {
+		_engine->_screens->loadMenuImage(false);
 	}
 	uint32 startMillis = _engine->_system->getMillis();
 	do {


Commit: ff22b784cb8a59a4639866eb3b82018ed0341c36
    https://github.com/scummvm/scummvm/commit/ff22b784cb8a59a4639866eb3b82018ed0341c36
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-12-23T11:08:00+01:00

Commit Message:
TWINE: replaced loop with memcpy

Changed paths:
    engines/twine/menu/menu.cpp


diff --git a/engines/twine/menu/menu.cpp b/engines/twine/menu/menu.cpp
index a62801841b..3ba0dc712d 100644
--- a/engines/twine/menu/menu.cpp
+++ b/engines/twine/menu/menu.cpp
@@ -205,11 +205,8 @@ void Menu::plasmaEffectRenderFrame() {
 	}
 
 	// flip the double-buffer while scrolling the effect vertically:
-	uint8 *dest = plasmaEffectPtr;
 	const uint8 *src = plasmaEffectPtr + (PLASMA_HEIGHT + 1) * PLASMA_WIDTH;
-	for (int32 i = 0; i < PLASMA_HEIGHT * PLASMA_WIDTH; i++) {
-		*(dest++) = *(src++);
-	}
+	memcpy(plasmaEffectPtr, src, PLASMA_HEIGHT * PLASMA_WIDTH);
 }
 
 void Menu::processPlasmaEffect(int32 left, int32 top, int32 color) {


Commit: 3ac48a5df0ddcbe155be707a6e5c7d3d4df93d67
    https://github.com/scummvm/scummvm/commit/3ac48a5df0ddcbe155be707a6e5c7d3d4df93d67
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-12-23T11:10:32+01:00

Commit Message:
TWINE: minor cleanup in drawTransparentBox

Changed paths:
    engines/twine/menu/interface.cpp


diff --git a/engines/twine/menu/interface.cpp b/engines/twine/menu/interface.cpp
index e43037e865..05acd33b73 100644
--- a/engines/twine/menu/interface.cpp
+++ b/engines/twine/menu/interface.cpp
@@ -173,10 +173,10 @@ void Interface::blitBox(const Common::Rect &rect, const Graphics::ManagedSurface
 }
 
 void Interface::drawTransparentBox(const Common::Rect &rect, int32 colorAdj) {
-	int32 left = rect.left;
-	int32 top = rect.top;
-	int32 right = rect.right;
-	int32 bottom = rect.bottom;
+	const int32 left = MAX(SCREEN_TEXTLIMIT_LEFT, (int32)rect.left);
+	const int32 top = MAX(SCREEN_TEXTLIMIT_TOP, (int32)rect.top);
+	const int32 right = MIN(SCREEN_TEXTLIMIT_RIGHT, (int32)rect.right);
+	const int32 bottom = MIN(SCREEN_TEXTLIMIT_BOTTOM, (int32)rect.bottom);
 
 	if (left > SCREEN_TEXTLIMIT_RIGHT) {
 		return;
@@ -191,19 +191,6 @@ void Interface::drawTransparentBox(const Common::Rect &rect, int32 colorAdj) {
 		return;
 	}
 
-	if (left < SCREEN_TEXTLIMIT_LEFT) {
-		left = SCREEN_TEXTLIMIT_LEFT;
-	}
-	if (right > SCREEN_TEXTLIMIT_RIGHT) {
-		right = SCREEN_TEXTLIMIT_RIGHT;
-	}
-	if (top < SCREEN_TEXTLIMIT_TOP) {
-		top = SCREEN_TEXTLIMIT_TOP;
-	}
-	if (bottom > SCREEN_TEXTLIMIT_BOTTOM) {
-		bottom = SCREEN_TEXTLIMIT_BOTTOM;
-	}
-
 	uint8 *pos = (uint8*)_engine->frontVideoBuffer.getBasePtr(left, top);
 	const int32 height = bottom - top;
 	int32 height2 = height + 1;


Commit: 58971cdfadf8ef2c45df191a2a2ef1fd9e79d1ed
    https://github.com/scummvm/scummvm/commit/58971cdfadf8ef2c45df191a2a2ef1fd9e79d1ed
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-12-23T11:13:26+01:00

Commit Message:
TWINE: replaced outer do while with for loop

Changed paths:
    engines/twine/menu/interface.cpp


diff --git a/engines/twine/menu/interface.cpp b/engines/twine/menu/interface.cpp
index 05acd33b73..b3712466e3 100644
--- a/engines/twine/menu/interface.cpp
+++ b/engines/twine/menu/interface.cpp
@@ -193,12 +193,11 @@ void Interface::drawTransparentBox(const Common::Rect &rect, int32 colorAdj) {
 
 	uint8 *pos = (uint8*)_engine->frontVideoBuffer.getBasePtr(left, top);
 	const int32 height = bottom - top;
-	int32 height2 = height + 1;
 	const int32 width = right - left + 1;
 	const int32 pitch = SCREEN_WIDTH - width;
 	const int32 localMode = colorAdj;
 
-	do {
+	for (int32 y = 0; y < height; ++y) {
 		int32 var1 = width;
 		do {
 			int8 color = *pos & 0x0F;
@@ -213,8 +212,7 @@ void Interface::drawTransparentBox(const Common::Rect &rect, int32 colorAdj) {
 			var1--;
 		} while (var1 > 0);
 		pos += pitch;
-		height2--;
-	} while (height2 > 0);
+	}
 }
 
 void Interface::drawSplittedBox(const Common::Rect &rect, uint8 colorIndex) {


Commit: 92e822bc6c42e27a86cd1d4db9bc4ce28ff39bb7
    https://github.com/scummvm/scummvm/commit/92e822bc6c42e27a86cd1d4db9bc4ce28ff39bb7
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-12-23T11:15:28+01:00

Commit Message:
TWINE: cleanup loops in drawTransparentBox

Changed paths:
    engines/twine/menu/interface.cpp


diff --git a/engines/twine/menu/interface.cpp b/engines/twine/menu/interface.cpp
index b3712466e3..880ec627c2 100644
--- a/engines/twine/menu/interface.cpp
+++ b/engines/twine/menu/interface.cpp
@@ -191,27 +191,21 @@ void Interface::drawTransparentBox(const Common::Rect &rect, int32 colorAdj) {
 		return;
 	}
 
-	uint8 *pos = (uint8*)_engine->frontVideoBuffer.getBasePtr(left, top);
-	const int32 height = bottom - top;
-	const int32 width = right - left + 1;
-	const int32 pitch = SCREEN_WIDTH - width;
-	const int32 localMode = colorAdj;
+	uint8 *pos = (uint8*)_engine->frontVideoBuffer.getBasePtr(0, top);
 
-	for (int32 y = 0; y < height; ++y) {
-		int32 var1 = width;
-		do {
-			int8 color = *pos & 0x0F;
-			const int8 color2 = *pos & 0xF0;
-			color -= localMode;
+	for (int32 y = top; y < bottom; ++y) {
+		for (int32 x = left; x < right; ++x) {
+			int8 color = pos[x] & 0x0F;
+			const int8 color2 = pos[x] & 0xF0;
+			color -= colorAdj;
 			if (color < 0) {
 				color = color2;
 			} else {
 				color += color2;
 			}
-			*pos++ = color;
-			var1--;
-		} while (var1 > 0);
-		pos += pitch;
+			pos[x] = color;
+		}
+		pos += SCREEN_WIDTH;
 	}
 }
 


Commit: 2626073befb20051e51f9e9d0f09d2d8b9af5104
    https://github.com/scummvm/scummvm/commit/2626073befb20051e51f9e9d0f09d2d8b9af5104
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-12-23T11:16:32+01:00

Commit Message:
TWINE: const in drawTransparentBox

Changed paths:
    engines/twine/menu/interface.cpp


diff --git a/engines/twine/menu/interface.cpp b/engines/twine/menu/interface.cpp
index 880ec627c2..fc48965631 100644
--- a/engines/twine/menu/interface.cpp
+++ b/engines/twine/menu/interface.cpp
@@ -195,15 +195,13 @@ void Interface::drawTransparentBox(const Common::Rect &rect, int32 colorAdj) {
 
 	for (int32 y = top; y < bottom; ++y) {
 		for (int32 x = left; x < right; ++x) {
-			int8 color = pos[x] & 0x0F;
+			const int8 color = (pos[x] & 0x0F) - colorAdj;
 			const int8 color2 = pos[x] & 0xF0;
-			color -= colorAdj;
 			if (color < 0) {
-				color = color2;
+				pos[x] = color2;
 			} else {
-				color += color2;
+				pos[x] = color + color2;
 			}
-			pos[x] = color;
 		}
 		pos += SCREEN_WIDTH;
 	}


Commit: 0f2d9ca5db132faa31e8997075b2ccf0765476ab
    https://github.com/scummvm/scummvm/commit/0f2d9ca5db132faa31e8997075b2ccf0765476ab
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-12-23T11:27:22+01:00

Commit Message:
TWINE: todo comment about holomap input

Changed paths:
    engines/twine/metaengine.cpp


diff --git a/engines/twine/metaengine.cpp b/engines/twine/metaengine.cpp
index ad8d813702..b6bbf29dd8 100644
--- a/engines/twine/metaengine.cpp
+++ b/engines/twine/metaengine.cpp
@@ -422,6 +422,9 @@ Common::KeymapArray TwinEMetaEngine::initKeymaps(const char *target) const {
 	{
 		Keymap *holomapKeyMap = new Keymap(Keymap::kKeymapTypeGame, holomapKeyMapId, "Little Big Adventure Holomap");
 
+		// TODO: CTRL + cursor rotates the globe
+		// just cursor keys switch the quest locations and print the text for the current selected location.
+
 		act = new Action("ABORT", _("Abort"));
 		act->setCustomEngineActionEvent(TwinEActionType::HolomapAbort);
 		act->addDefaultInputMapping("ESCAPE");


Commit: 9d4fcfc0f33f77df1aa7f157b248b0c7b912823e
    https://github.com/scummvm/scummvm/commit/9d4fcfc0f33f77df1aa7f157b248b0c7b912823e
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-12-23T11:51:24+01:00

Commit Message:
TWINE: extract bbox computing into own method

Changed paths:
    engines/twine/renderer/renderer.cpp
    engines/twine/renderer/renderer.h


diff --git a/engines/twine/renderer/renderer.cpp b/engines/twine/renderer/renderer.cpp
index 60c12dc02d..bcf48e4e90 100644
--- a/engines/twine/renderer/renderer.cpp
+++ b/engines/twine/renderer/renderer.cpp
@@ -369,33 +369,29 @@ FORCEINLINE int16 clamp(int16 x, int16 a, int16 b) {
 	return x < a ? a : (x > b ? b : x);
 }
 
-void Renderer::computePolygons(int16 polyRenderType, Vertex *vertices, int32 numVertices, int &vleft, int &vright, int &vtop, int &vbottom) {
+void Renderer::computeBoundingBox(Vertex *vertices, int32 numVertices, int &vleft, int &vright, int &vtop, int &vbottom) const {
 	vleft = vtop = 32767;
 	vright = vbottom = -32768;
 
 	for (int32 i = 0; i < numVertices; i++) {
 		vertices[i].x = clamp(vertices[i].x, 0, SCREEN_WIDTH - 1);
-		int16 vertexX = vertices[i].x;
-
-		if (vertexX < vleft) {
-			vleft = vertexX;
-		}
-		if (vertexX > vright) {
-			vright = vertexX;
-		}
-
 		vertices[i].y = clamp(vertices[i].y, 0, SCREEN_HEIGHT - 1);
-		int16 vertexY = vertices[i].y;
-		if (vertexY < vtop) {
-			vtop = vertexY;
-		}
-		if (vertexY > vbottom) {
-			vbottom = vertexY;
-		}
+		const int vertexX = vertices[i].x;
+		vleft = MIN(vleft, vertexX);
+		vright = MAX(vright, vertexX);
+		const int vertexY = vertices[i].y;
+		vtop = MIN(vtop, vertexY);
+		vbottom = MAX(vbottom, vertexY);
+	}
+}
+
+void Renderer::computePolygons(int16 polyRenderType, Vertex *vertices, int32 numVertices, int &vleft, int &vright, int &vtop, int &vbottom) {
+	if (numVertices <= 0) {
+		return;
 	}
+	computeBoundingBox(vertices, numVertices, vleft, vright, vtop, vbottom);
 
 	uint8 vertexParam1 = vertices[numVertices - 1].colorIndex;
-	uint8 vertexParam2 = vertexParam1;
 	int16 currentVertexX = vertices[numVertices - 1].x;
 	int16 currentVertexY = vertices[numVertices - 1].y;
 
@@ -404,7 +400,8 @@ void Renderer::computePolygons(int16 polyRenderType, Vertex *vertices, int32 num
 		int16 oldVertexX = currentVertexX;
 		uint8 oldVertexParam = vertexParam1;
 
-		vertexParam1 = vertexParam2 = vertices[nVertex].colorIndex;
+		vertexParam1 = vertices[nVertex].colorIndex;
+		uint8 vertexParam2 = vertexParam1;
 		currentVertexX = vertices[nVertex].x;
 		currentVertexY = vertices[nVertex].y;
 
diff --git a/engines/twine/renderer/renderer.h b/engines/twine/renderer/renderer.h
index 5a72437bab..407866d7e3 100644
--- a/engines/twine/renderer/renderer.h
+++ b/engines/twine/renderer/renderer.h
@@ -378,6 +378,7 @@ private:
 	void renderPolygonsDither(uint8 *out, int vtop, int32 vsize, int32 color) const;
 	void renderPolygonsMarble(uint8 *out, int vtop, int32 vsize, int32 color) const;
 
+	void computeBoundingBox(Vertex *vertices, int32 numVertices, int &vleft, int &vright, int &vtop, int &vbottom) const;
 	void computePolygons(int16 polyRenderType, Vertex *vertices, int32 numVertices, int &vleft, int &vright, int &vtop, int &vbottom);
 
 	const RenderCommand *depthSortRenderCommands(int32 numOfPrimitives);


Commit: c1827f1f42e252b9c6073202ea0a49c8644e5d03
    https://github.com/scummvm/scummvm/commit/c1827f1f42e252b9c6073202ea0a49c8644e5d03
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-12-23T12:03:06+01:00

Commit Message:
TWINE: const

Changed paths:
    engines/twine/renderer/renderer.cpp


diff --git a/engines/twine/renderer/renderer.cpp b/engines/twine/renderer/renderer.cpp
index bcf48e4e90..77767ca3d8 100644
--- a/engines/twine/renderer/renderer.cpp
+++ b/engines/twine/renderer/renderer.cpp
@@ -396,12 +396,12 @@ void Renderer::computePolygons(int16 polyRenderType, Vertex *vertices, int32 num
 	int16 currentVertexY = vertices[numVertices - 1].y;
 
 	for (int32 nVertex = 0; nVertex < numVertices; nVertex++) {
-		int16 oldVertexY = currentVertexY;
-		int16 oldVertexX = currentVertexX;
-		uint8 oldVertexParam = vertexParam1;
+		const int16 oldVertexY = currentVertexY;
+		const int16 oldVertexX = currentVertexX;
+		const uint8 oldVertexParam = vertexParam1;
 
 		vertexParam1 = vertices[nVertex].colorIndex;
-		uint8 vertexParam2 = vertexParam1;
+		const uint8 vertexParam2 = vertexParam1;
 		currentVertexX = vertices[nVertex].x;
 		currentVertexY = vertices[nVertex].y;
 




More information about the Scummvm-git-logs mailing list