[Scummvm-git-logs] scummvm master -> 946fa1678ec2bc82914636cf1d153e64b87c3729

mgerhardy martin.gerhardy at gmail.com
Mon Sep 6 17:54:21 UTC 2021


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

Summary:
5a0365738b TWINE: no need to create a copy of the domain string
326a08ed26 TWINE: set the debugger after all game components are set up already
f7ecae3c2c TWINE: comments
2caaa9380a TWINE: added disassembled code to render methods
9f36ac4309 TWINE: removed labels in renderPolygonsMarble
3a05eb228c TWINE: further fixes in renderPolygonsMarble
76d496578a TWINE: fixed alignment issues for polytab access
aa89e09dfe TWINE: renderPolygonsMarble renamed variables
a095e97e1a TWINE: renderPolygonsMarble cleanup
f4e5730cdc TWINE: translated french comment
334a5c3109 TWINE: comments
946fa1678e TWINE: re-did the renderPolygonsBopper method


Commit: 5a0365738bdc62f2af127d7175e2ebd28ba36bd0
    https://github.com/scummvm/scummvm/commit/5a0365738bdc62f2af127d7175e2ebd28ba36bd0
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2021-09-06T19:50:31+02:00

Commit Message:
TWINE: no need to create a copy of the domain string

Changed paths:
    engines/twine/twine.cpp


diff --git a/engines/twine/twine.cpp b/engines/twine/twine.cpp
index cc4cd9097b..f0960c6c51 100644
--- a/engines/twine/twine.cpp
+++ b/engines/twine/twine.cpp
@@ -238,7 +238,7 @@ Common::Error TwinEEngine::run() {
 	ConfMan.registerDefault("usehighres", false);
 	ConfMan.registerDefault("wallcollision", false);
 
-	Common::String gameTarget = ConfMan.getActiveDomainName();
+	const Common::String &gameTarget = ConfMan.getActiveDomainName();
 	AchMan.setActiveDomain(getMetaEngine()->getAchievementsInfo(gameTarget));
 
 	syncSoundSettings();


Commit: 326a08ed26252a25f97712aab4d6ce6625b737d4
    https://github.com/scummvm/scummvm/commit/326a08ed26252a25f97712aab4d6ce6625b737d4
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2021-09-06T19:50:31+02:00

Commit Message:
TWINE: set the debugger after all game components are set up already

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


diff --git a/engines/twine/scene/gamestate.cpp b/engines/twine/scene/gamestate.cpp
index fc2cecd4e7..18255cca4a 100644
--- a/engines/twine/scene/gamestate.cpp
+++ b/engines/twine/scene/gamestate.cpp
@@ -111,9 +111,9 @@ void GameState::initEngineVars() {
 	initGameStateVars();
 	initHeroVars();
 
-	_engine->_scene->_newHeroPos.x = 0x2000;
-	_engine->_scene->_newHeroPos.y = 0x1800;
-	_engine->_scene->_newHeroPos.z = 0x2000;
+	_engine->_scene->_newHeroPos.x = 16 * BRICK_SIZE;
+	_engine->_scene->_newHeroPos.y = 24 * BRICK_HEIGHT;
+	_engine->_scene->_newHeroPos.z = 16 * BRICK_SIZE;
 
 	_engine->_scene->_currentSceneIdx = SCENE_CEILING_GRID_FADE_1;
 	_engine->_scene->_needChangeScene = LBA1SceneId::Citadel_Island_Prison;
diff --git a/engines/twine/twine.cpp b/engines/twine/twine.cpp
index f0960c6c51..b6beeac15b 100644
--- a/engines/twine/twine.cpp
+++ b/engines/twine/twine.cpp
@@ -151,7 +151,6 @@ TwinEEngine::TwinEEngine(OSystem *system, Common::Language language, uint32 flag
 #endif
 	}
 
-	setDebugger(new TwinEConsole(this));
 	_actor = new Actor(this);
 	_animations = new Animations(this);
 	_collision = new Collision(this);
@@ -178,6 +177,7 @@ TwinEEngine::TwinEEngine(OSystem *system, Common::Language language, uint32 flag
 	_input = new Input(this);
 	_debug = new Debug(this);
 	_debugScene = new DebugScene(this);
+	setDebugger(new TwinEConsole(this));
 }
 
 TwinEEngine::~TwinEEngine() {


Commit: f7ecae3c2c4b95886227ef1712c6df601dd510f4
    https://github.com/scummvm/scummvm/commit/f7ecae3c2c4b95886227ef1712c6df601dd510f4
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2021-09-06T19:51:50+02:00

Commit Message:
TWINE: comments

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


diff --git a/engines/twine/renderer/renderer.cpp b/engines/twine/renderer/renderer.cpp
index 2d7c2ece4a..0abe972677 100644
--- a/engines/twine/renderer/renderer.cpp
+++ b/engines/twine/renderer/renderer.cpp
@@ -680,6 +680,7 @@ void Renderer::renderPolygonsTras(int vtop, int32 vsize, uint8 color) const {
 }
 
 // FIXME: buggy
+// Used e.g for the legs of the horse or the ears of most characters
 void Renderer::renderPolygonsTrame(int vtop, int32 vsize, uint8 color) const {
 	uint8 *out = (uint8 *)_engine->_frontVideoBuffer.getBasePtr(0, vtop);
 	const int16 *ptr1 = &_polyTab[vtop];
@@ -823,6 +824,7 @@ void Renderer::renderPolygonsGouraud(int vtop, int32 vsize) const {
 	}
 }
 
+// used for the most of the heads of the characters and the horse body
 void Renderer::renderPolygonsDither(int vtop, int32 vsize) const {
 	uint8 *out = (uint8 *)_engine->_frontVideoBuffer.getBasePtr(0, vtop);
 	const int16 *ptr1 = &_polyTab[vtop];


Commit: 2caaa9380a6d92028062a0448981abbe2c77bce5
    https://github.com/scummvm/scummvm/commit/2caaa9380a6d92028062a0448981abbe2c77bce5
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2021-09-06T19:51:50+02:00

Commit Message:
TWINE: added disassembled code to render methods

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


diff --git a/engines/twine/renderer/renderer.cpp b/engines/twine/renderer/renderer.cpp
index 0abe972677..88f0e7aaca 100644
--- a/engines/twine/renderer/renderer.cpp
+++ b/engines/twine/renderer/renderer.cpp
@@ -504,6 +504,75 @@ void Renderer::renderPolygonsCopper(int vtop, int32 vsize, uint8 color) const {
 }
 
 void Renderer::renderPolygonsBopper(int vtop, int32 vsize, uint8 color) const {
+#if 0
+	LOBYTE(v14) = a2;
+	HIWORD(j) = 0;
+	do {
+		stop = *(uint16 *)(polytab + 960);
+		start = *(uint16 *)polytab;
+		polytab += 2;
+		v34 = stop < (unsigned __int16)start;
+		v17 = stop - start;
+		if (!v34) {
+			LOWORD(j) = j + 1;
+			v18 = (void *)(start + v2);
+			HIBYTE(v14) = v14;
+			LOWORD(start) = v14;
+			start <<= 16;
+			LOWORD(start) = v14;
+			if ((unsigned __int8)v18 & 1) {
+				*(uint8 *)v18 = v14;
+				v18 = (char *)v18 + 1;
+				--j;
+			}
+			v19 = j;
+			v20 = (unsigned int)j >> 2;
+			memset32(v18, start, v20);
+			v21 = (int)((char *)v18 + 4 * v20);
+			for (j = v19 & 2; j; --j)
+				*(uint8 *)v21++ = start;
+			LOBYTE(v14) = v14 + 1;
+			if (!(v14 & 0xF)) {
+				while (1) {
+					LOBYTE(v14) = v14 - 1;
+					if (!(v14 & 0xF))
+						break;
+					v2 += 640;
+					--v5;
+					if (!v5)
+						return start;
+					v22 = *(uint16 *)(polytab + 960);
+					start = *(uint16 *)polytab;
+					polytab += 2;
+					v34 = v22 < (unsigned __int16)start;
+					v23 = v22 - start;
+					if (!v34) {
+						LOWORD(j) = j + 1;
+						v24 = (void *)(start + v2);
+						HIBYTE(v14) = v14;
+						LOWORD(start) = v14;
+						start <<= 16;
+						LOWORD(start) = v14;
+						if ((unsigned __int8)v24 & 1) {
+							*(uint8 *)v24 = v14;
+							v24 = (char *)v24 + 1;
+							--j;
+						}
+						v25 = j;
+						v26 = (unsigned int)j >> 2;
+						memset32(v24, start, v26);
+						v27 = (int)((char *)v24 + 4 * v26);
+						for (j = v25 & 2; j; --j)
+							*(uint8 *)v27++ = start;
+					}
+				}
+			}
+		}
+		v2 += 640;
+		--v5;
+	} while (v5);
+	return start;
+#endif
 	uint8 *out = (uint8 *)_engine->_frontVideoBuffer.getBasePtr(0, vtop);
 	const int16 *ptr1 = &_polyTab[vtop];
 	const int screenWidth = _engine->width();
@@ -959,6 +1028,89 @@ void Renderer::renderPolygonsDither(int vtop, int32 vsize) const {
 }
 
 void Renderer::renderPolygonsMarble(int vtop, int32 vsize, uint8 color) const {
+#if 0
+	const int screenWidth = _engine->width();
+	const int screenHeight = _engine->height();
+
+	uint8 *v2 = (uint8 *)_engine->_frontVideoBuffer.getBasePtr(0, vtop);
+	//v2 = screenLockupTable[(uint16)vtop] + frontVideoBuffer;
+	int8 *v3 = (int8 *)&_polyTab[(uint16)vtop];
+	int v5 = vsize; //(uint16)vbottom - (uint16)vtop + 1;
+
+	uint16 v28 = color;
+	uint16 v29 = 2;
+	while (2) {
+		uint16 v30 = *(uint16 *)(v3 + screenHeight * 2);
+		uint16 v7 = *(uint16 *)v3;
+		v3 += 2;
+		uint16 v34 = v30 < v7;
+		uint16 v31 = v30 - v7;
+		if (v34)
+			goto LABEL_40;
+		uint16 v32 = v31 + 1;
+		uint8 *v33 = v7 + v2;
+		LOBYTE(v7) = v28;
+		BYTE1(v7) = v28;
+		if (v33 & 1) {
+			*(uint8 *)v33++ = v28;
+			--v32;
+		}
+		v34 = v32 & 1;
+		for (k = v32 >> 1; k; --k) {
+			*(uint16 *)v33 = v7;
+			v33 += 2;
+		}
+		for (l = __RCL__(0, v34); l; --l)
+			*(uint8 *)v33++ = v28;
+		--v29;
+		if (v29 || (v29 = 2, ++v28, v28 & 0xF))
+			goto LABEL_40;
+	LABEL_52:
+		v29 = 2;
+		--v28;
+		if (!(v28 & 0xF)) {
+		LABEL_40:
+			v2 += screenWidth;
+			--v5;
+			if (!v5)
+				return v7;
+			continue;
+		}
+		break;
+	}
+	while (1) {
+		v2 += screenWidth;
+		--v5;
+		if (!v5)
+			return v7;
+		uint16 v37 = *(uint16 *)(v3 + screenHeight * 2);
+		uint16 v7 = *(uint16 *)v3;
+		v3 += 2;
+		uint16 v34 = v37 < v7;
+		uint16 v38 = v37 - v7;
+		if (!v34) {
+			uint16 v39 = v38 + 1;
+			uint16 v40 = v7 + v2;
+			LOBYTE(v7) = v28;
+			BYTE1(v7) = v28;
+			if (v40 & 1) {
+				*(uint8 *)v40++ = v28;
+				--v39;
+			}
+			v41 = v39 & 1;
+			for (m = v39 >> 1; m; --m) {
+				*(uint16 *)v40 = v7;
+				v40 += 2;
+			}
+			for (n = __RCL__(0, v41); n; --n)
+				*(uint8 *)v40++ = v28;
+			--v29;
+			if (v29)
+				continue;
+		}
+		goto LABEL_52;
+	}
+#endif
 }
 
 void Renderer::renderPolygons(const CmdRenderPolygon &polygon, Vertex *vertices, int vtop, int vbottom) {


Commit: 9f36ac43092b0ebf67b58c2fb2301ee073e8d10c
    https://github.com/scummvm/scummvm/commit/9f36ac43092b0ebf67b58c2fb2301ee073e8d10c
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2021-09-06T19:51:50+02:00

Commit Message:
TWINE: removed labels in renderPolygonsMarble

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


diff --git a/engines/twine/renderer/renderer.cpp b/engines/twine/renderer/renderer.cpp
index 88f0e7aaca..07428aa6bf 100644
--- a/engines/twine/renderer/renderer.cpp
+++ b/engines/twine/renderer/renderer.cpp
@@ -1045,8 +1045,13 @@ void Renderer::renderPolygonsMarble(int vtop, int32 vsize, uint8 color) const {
 		v3 += 2;
 		uint16 v34 = v30 < v7;
 		uint16 v31 = v30 - v7;
-		if (v34)
-			goto LABEL_40;
+		if (v34) {
+			v2 += screenWidth;
+			--v5;
+			if (!v5)
+				return v7;
+			continue;
+		}
 		uint16 v32 = v31 + 1;
 		uint8 *v33 = v7 + v2;
 		LOBYTE(v7) = v28;
@@ -1063,13 +1068,16 @@ void Renderer::renderPolygonsMarble(int vtop, int32 vsize, uint8 color) const {
 		for (l = __RCL__(0, v34); l; --l)
 			*(uint8 *)v33++ = v28;
 		--v29;
-		if (v29 || (v29 = 2, ++v28, v28 & 0xF))
-			goto LABEL_40;
-	LABEL_52:
+		if (v29 || (v29 = 2, ++v28, v28 & 0xF)) {
+			v2 += screenWidth;
+			--v5;
+			if (!v5)
+				return v7;
+			continue;
+		}
 		v29 = 2;
 		--v28;
 		if (!(v28 & 0xF)) {
-		LABEL_40:
 			v2 += screenWidth;
 			--v5;
 			if (!v5)
@@ -1108,7 +1116,16 @@ void Renderer::renderPolygonsMarble(int vtop, int32 vsize, uint8 color) const {
 			if (v29)
 				continue;
 		}
-		goto LABEL_52;
+		v29 = 2;
+		--v28;
+		if (!(v28 & 0xF)) {
+			v2 += screenWidth;
+			--v5;
+			if (!v5)
+				return v7;
+			continue;
+		}
+		break;
 	}
 #endif
 }


Commit: 3a05eb228c0e7c65f21ee47eaad88a844c5264bd
    https://github.com/scummvm/scummvm/commit/3a05eb228c0e7c65f21ee47eaad88a844c5264bd
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2021-09-06T19:51:50+02:00

Commit Message:
TWINE: further fixes in renderPolygonsMarble

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


diff --git a/engines/twine/renderer/renderer.cpp b/engines/twine/renderer/renderer.cpp
index 07428aa6bf..a0c8a37f7d 100644
--- a/engines/twine/renderer/renderer.cpp
+++ b/engines/twine/renderer/renderer.cpp
@@ -1028,7 +1028,6 @@ void Renderer::renderPolygonsDither(int vtop, int32 vsize) const {
 }
 
 void Renderer::renderPolygonsMarble(int vtop, int32 vsize, uint8 color) const {
-#if 0
 	const int screenWidth = _engine->width();
 	const int screenHeight = _engine->height();
 
@@ -1040,39 +1039,42 @@ void Renderer::renderPolygonsMarble(int vtop, int32 vsize, uint8 color) const {
 	uint16 v28 = color;
 	uint16 v29 = 2;
 	while (2) {
-		uint16 v30 = *(uint16 *)(v3 + screenHeight * 2);
-		uint16 v7 = *(uint16 *)v3;
+		uint16 v30 = *(const uint16 *)(v3 + screenHeight * 2);
+		uint16 v7 = *(const uint16 *)v3;
 		v3 += 2;
 		uint16 v34 = v30 < v7;
 		uint16 v31 = v30 - v7;
 		if (v34) {
 			v2 += screenWidth;
 			--v5;
-			if (!v5)
-				return v7;
+			if (!v5) {
+				return;
+			}
 			continue;
 		}
 		uint16 v32 = v31 + 1;
 		uint8 *v33 = v7 + v2;
-		LOBYTE(v7) = v28;
-		BYTE1(v7) = v28;
-		if (v33 & 1) {
+		(*((uint8 *)&(v7) + (0))) = v28;
+		(*((uint8 *)&(v7) + (1))) = v28;
+		if ((uintptr)v33 & 1) {
 			*(uint8 *)v33++ = v28;
 			--v32;
 		}
 		v34 = v32 & 1;
-		for (k = v32 >> 1; k; --k) {
+		for (uint16 k = v32 >> 1; k; --k) {
 			*(uint16 *)v33 = v7;
 			v33 += 2;
 		}
-		for (l = __RCL__(0, v34); l; --l)
+		for (uint16 l = v34; l; --l) {
 			*(uint8 *)v33++ = v28;
+		}
 		--v29;
 		if (v29 || (v29 = 2, ++v28, v28 & 0xF)) {
 			v2 += screenWidth;
 			--v5;
-			if (!v5)
-				return v7;
+			if (!v5) {
+				return;
+			}
 			continue;
 		}
 		v29 = 2;
@@ -1080,8 +1082,9 @@ void Renderer::renderPolygonsMarble(int vtop, int32 vsize, uint8 color) const {
 		if (!(v28 & 0xF)) {
 			v2 += screenWidth;
 			--v5;
-			if (!v5)
-				return v7;
+			if (!v5) {
+				return;
+			}
 			continue;
 		}
 		break;
@@ -1089,45 +1092,48 @@ void Renderer::renderPolygonsMarble(int vtop, int32 vsize, uint8 color) const {
 	while (1) {
 		v2 += screenWidth;
 		--v5;
-		if (!v5)
-			return v7;
-		uint16 v37 = *(uint16 *)(v3 + screenHeight * 2);
-		uint16 v7 = *(uint16 *)v3;
+		if (!v5) {
+			return;
+		}
+		uint16 v37 = *(const uint16 *)(v3 + screenHeight * 2);
+		uint16 v7 = *(const uint16 *)v3;
 		v3 += 2;
 		uint16 v34 = v37 < v7;
 		uint16 v38 = v37 - v7;
 		if (!v34) {
 			uint16 v39 = v38 + 1;
-			uint16 v40 = v7 + v2;
-			LOBYTE(v7) = v28;
-			BYTE1(v7) = v28;
-			if (v40 & 1) {
+			uint8 *v40 = v7 + v2;
+			(*((uint8 *)&(v7) + (0))) = v28;
+			(*((uint8 *)&(v7) + (1))) = v28;
+			if ((uintptr)v40 & 1) {
 				*(uint8 *)v40++ = v28;
 				--v39;
 			}
-			v41 = v39 & 1;
-			for (m = v39 >> 1; m; --m) {
+			uint16 v41 = v39 & 1;
+			for (uint16 m = v39 >> 1; m; --m) {
 				*(uint16 *)v40 = v7;
 				v40 += 2;
 			}
-			for (n = __RCL__(0, v41); n; --n)
+			for (uint16 n = v41; n; --n) {
 				*(uint8 *)v40++ = v28;
+			}
 			--v29;
-			if (v29)
+			if (v29) {
 				continue;
+			}
 		}
 		v29 = 2;
 		--v28;
 		if (!(v28 & 0xF)) {
 			v2 += screenWidth;
 			--v5;
-			if (!v5)
-				return v7;
+			if (!v5) {
+				return;
+			}
 			continue;
 		}
 		break;
 	}
-#endif
 }
 
 void Renderer::renderPolygons(const CmdRenderPolygon &polygon, Vertex *vertices, int vtop, int vbottom) {


Commit: 76d496578a5b1ed62d34c33afbf4584f343e8e92
    https://github.com/scummvm/scummvm/commit/76d496578a5b1ed62d34c33afbf4584f343e8e92
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2021-09-06T19:51:50+02:00

Commit Message:
TWINE: fixed alignment issues for polytab access

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


diff --git a/engines/twine/renderer/renderer.cpp b/engines/twine/renderer/renderer.cpp
index a0c8a37f7d..5dcfb7f9ba 100644
--- a/engines/twine/renderer/renderer.cpp
+++ b/engines/twine/renderer/renderer.cpp
@@ -1032,16 +1032,15 @@ void Renderer::renderPolygonsMarble(int vtop, int32 vsize, uint8 color) const {
 	const int screenHeight = _engine->height();
 
 	uint8 *v2 = (uint8 *)_engine->_frontVideoBuffer.getBasePtr(0, vtop);
-	//v2 = screenLockupTable[(uint16)vtop] + frontVideoBuffer;
-	int8 *v3 = (int8 *)&_polyTab[(uint16)vtop];
-	int v5 = vsize; //(uint16)vbottom - (uint16)vtop + 1;
+	const int16 *v3 = &_polyTab[vtop];
+	int v5 = vsize;
 
 	uint16 v28 = color;
 	uint16 v29 = 2;
 	while (2) {
-		uint16 v30 = *(const uint16 *)(v3 + screenHeight * 2);
+		uint16 v30 = *(const uint16 *)(v3 + screenHeight);
 		uint16 v7 = *(const uint16 *)v3;
-		v3 += 2;
+		++v3;
 		uint16 v34 = v30 < v7;
 		uint16 v31 = v30 - v7;
 		if (v34) {
@@ -1054,8 +1053,8 @@ void Renderer::renderPolygonsMarble(int vtop, int32 vsize, uint8 color) const {
 		}
 		uint16 v32 = v31 + 1;
 		uint8 *v33 = v7 + v2;
-		(*((uint8 *)&(v7) + (0))) = v28;
-		(*((uint8 *)&(v7) + (1))) = v28;
+		(*((uint8 *)&v7)) = v28;
+		(*((uint8 *)&(v7) + 1)) = v28;
 		if ((uintptr)v33 & 1) {
 			*(uint8 *)v33++ = v28;
 			--v32;
@@ -1095,16 +1094,16 @@ void Renderer::renderPolygonsMarble(int vtop, int32 vsize, uint8 color) const {
 		if (!v5) {
 			return;
 		}
-		uint16 v37 = *(const uint16 *)(v3 + screenHeight * 2);
+		uint16 v37 = *(const uint16 *)(v3 + screenHeight);
 		uint16 v7 = *(const uint16 *)v3;
-		v3 += 2;
+		++v3;
 		uint16 v34 = v37 < v7;
 		uint16 v38 = v37 - v7;
 		if (!v34) {
 			uint16 v39 = v38 + 1;
 			uint8 *v40 = v7 + v2;
-			(*((uint8 *)&(v7) + (0))) = v28;
-			(*((uint8 *)&(v7) + (1))) = v28;
+			(*((uint8 *)&v7)) = v28;
+			(*((uint8 *)&(v7) + 1)) = v28;
 			if ((uintptr)v40 & 1) {
 				*(uint8 *)v40++ = v28;
 				--v39;


Commit: aa89e09dfec4773d702b2d4b89f930819962f48d
    https://github.com/scummvm/scummvm/commit/aa89e09dfec4773d702b2d4b89f930819962f48d
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2021-09-06T19:51:50+02:00

Commit Message:
TWINE: renderPolygonsMarble renamed variables

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


diff --git a/engines/twine/renderer/renderer.cpp b/engines/twine/renderer/renderer.cpp
index 5dcfb7f9ba..00c5a41b51 100644
--- a/engines/twine/renderer/renderer.cpp
+++ b/engines/twine/renderer/renderer.cpp
@@ -1031,57 +1031,56 @@ void Renderer::renderPolygonsMarble(int vtop, int32 vsize, uint8 color) const {
 	const int screenWidth = _engine->width();
 	const int screenHeight = _engine->height();
 
-	uint8 *v2 = (uint8 *)_engine->_frontVideoBuffer.getBasePtr(0, vtop);
-	const int16 *v3 = &_polyTab[vtop];
-	int v5 = vsize;
+	uint8 *out = (uint8 *)_engine->_frontVideoBuffer.getBasePtr(0, vtop);
+	const int16 *ptr1 = &_polyTab[vtop];
+	int height = vsize;
 
-	uint16 v28 = color;
+	uint16 color2 = color;
 	uint16 v29 = 2;
 	while (2) {
-		uint16 v30 = *(const uint16 *)(v3 + screenHeight);
-		uint16 v7 = *(const uint16 *)v3;
-		++v3;
-		uint16 v34 = v30 < v7;
-		uint16 v31 = v30 - v7;
-		if (v34) {
-			v2 += screenWidth;
-			--v5;
-			if (!v5) {
+		uint16 stop = *(const uint16 *)(ptr1 + screenHeight);
+		uint16 start = *(const uint16 *)ptr1;
+		++ptr1;
+		if (stop < start) {
+			out += screenWidth;
+			--height;
+			if (!height) {
 				return;
 			}
 			continue;
 		}
-		uint16 v32 = v31 + 1;
-		uint8 *v33 = v7 + v2;
-		(*((uint8 *)&v7)) = v28;
-		(*((uint8 *)&(v7) + 1)) = v28;
-		if ((uintptr)v33 & 1) {
-			*(uint8 *)v33++ = v28;
-			--v32;
+		uint16 hsize = stop - start;
+		uint16 width = hsize + 1;
+		uint8 *out2 = start + out;
+		(*((uint8 *)&start)) = color2;
+		(*((uint8 *)&(start) + 1)) = color2;
+		if ((uintptr)out2 & 1) {
+			*(uint8 *)out2++ = color2;
+			--width;
 		}
-		v34 = v32 & 1;
-		for (uint16 k = v32 >> 1; k; --k) {
-			*(uint16 *)v33 = v7;
-			v33 += 2;
+		uint16 v34 = width & 1;
+		for (uint16 k = width >> 1; k; --k) {
+			*(uint16 *)out2 = start;
+			out2 += 2;
 		}
 		for (uint16 l = v34; l; --l) {
-			*(uint8 *)v33++ = v28;
+			*(uint8 *)out2++ = color2;
 		}
 		--v29;
-		if (v29 || (v29 = 2, ++v28, v28 & 0xF)) {
-			v2 += screenWidth;
-			--v5;
-			if (!v5) {
+		if (v29 || (v29 = 2, ++color2, color2 & 0xF)) {
+			out += screenWidth;
+			--height;
+			if (!height) {
 				return;
 			}
 			continue;
 		}
 		v29 = 2;
-		--v28;
-		if (!(v28 & 0xF)) {
-			v2 += screenWidth;
-			--v5;
-			if (!v5) {
+		--color2;
+		if (!(color2 & 0xF)) {
+			out += screenWidth;
+			--height;
+			if (!height) {
 				return;
 			}
 			continue;
@@ -1089,32 +1088,31 @@ void Renderer::renderPolygonsMarble(int vtop, int32 vsize, uint8 color) const {
 		break;
 	}
 	while (1) {
-		v2 += screenWidth;
-		--v5;
-		if (!v5) {
+		out += screenWidth;
+		--height;
+		if (!height) {
 			return;
 		}
-		uint16 v37 = *(const uint16 *)(v3 + screenHeight);
-		uint16 v7 = *(const uint16 *)v3;
-		++v3;
-		uint16 v34 = v37 < v7;
-		uint16 v38 = v37 - v7;
-		if (!v34) {
-			uint16 v39 = v38 + 1;
-			uint8 *v40 = v7 + v2;
-			(*((uint8 *)&v7)) = v28;
-			(*((uint8 *)&(v7) + 1)) = v28;
-			if ((uintptr)v40 & 1) {
-				*(uint8 *)v40++ = v28;
-				--v39;
+		uint16 stop = *(const uint16 *)(ptr1 + screenHeight);
+		uint16 start = *(const uint16 *)ptr1;
+		++ptr1;
+		if (stop >= start) {
+			uint16 hsize = stop - start;
+			uint16 width = hsize + 1;
+			uint8 *out2 = start + out;
+			(*((uint8 *)&start)) = color2;
+			(*((uint8 *)&(start) + 1)) = color2;
+			if ((uintptr)out2 & 1) {
+				*(uint8 *)out2++ = color2;
+				--width;
 			}
-			uint16 v41 = v39 & 1;
-			for (uint16 m = v39 >> 1; m; --m) {
-				*(uint16 *)v40 = v7;
-				v40 += 2;
+			uint16 v41 = width & 1;
+			for (uint16 m = width >> 1; m; --m) {
+				*(uint16 *)out2 = start;
+				out2 += 2;
 			}
 			for (uint16 n = v41; n; --n) {
-				*(uint8 *)v40++ = v28;
+				*(uint8 *)out2++ = color2;
 			}
 			--v29;
 			if (v29) {
@@ -1122,11 +1120,11 @@ void Renderer::renderPolygonsMarble(int vtop, int32 vsize, uint8 color) const {
 			}
 		}
 		v29 = 2;
-		--v28;
-		if (!(v28 & 0xF)) {
-			v2 += screenWidth;
-			--v5;
-			if (!v5) {
+		--color2;
+		if (!(color2 & 0xF)) {
+			out += screenWidth;
+			--height;
+			if (!height) {
 				return;
 			}
 			continue;


Commit: a095e97e1adedf51ce6160e29299b782f81a8d33
    https://github.com/scummvm/scummvm/commit/a095e97e1adedf51ce6160e29299b782f81a8d33
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2021-09-06T19:51:50+02:00

Commit Message:
TWINE: renderPolygonsMarble cleanup

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


diff --git a/engines/twine/renderer/renderer.cpp b/engines/twine/renderer/renderer.cpp
index 00c5a41b51..9d5ad2ca5e 100644
--- a/engines/twine/renderer/renderer.cpp
+++ b/engines/twine/renderer/renderer.cpp
@@ -1038,8 +1038,8 @@ void Renderer::renderPolygonsMarble(int vtop, int32 vsize, uint8 color) const {
 	uint16 color2 = color;
 	uint16 v29 = 2;
 	while (2) {
-		uint16 stop = *(const uint16 *)(ptr1 + screenHeight);
-		uint16 start = *(const uint16 *)ptr1;
+		const uint16 stop = *(const uint16 *)(ptr1 + screenHeight);
+		const uint16 start = *(const uint16 *)ptr1;
 		++ptr1;
 		if (stop < start) {
 			out += screenWidth;
@@ -1049,22 +1049,20 @@ void Renderer::renderPolygonsMarble(int vtop, int32 vsize, uint8 color) const {
 			}
 			continue;
 		}
-		uint16 hsize = stop - start;
+		const uint16 hsize = stop - start;
 		uint16 width = hsize + 1;
 		uint8 *out2 = start + out;
-		(*((uint8 *)&start)) = color2;
-		(*((uint8 *)&(start) + 1)) = color2;
 		if ((uintptr)out2 & 1) {
-			*(uint8 *)out2++ = color2;
+			*out2++ = color2;
 			--width;
 		}
-		uint16 v34 = width & 1;
-		for (uint16 k = width >> 1; k; --k) {
-			*(uint16 *)out2 = start;
-			out2 += 2;
+		for (uint16 k = width / 2; k; --k) {
+			*out2++ = color2;
+			*out2++ = color2;
 		}
+		const uint16 v34 = width & 1;
 		for (uint16 l = v34; l; --l) {
-			*(uint8 *)out2++ = color2;
+			*out2++ = color2;
 		}
 		--v29;
 		if (v29 || (v29 = 2, ++color2, color2 & 0xF)) {
@@ -1093,26 +1091,24 @@ void Renderer::renderPolygonsMarble(int vtop, int32 vsize, uint8 color) const {
 		if (!height) {
 			return;
 		}
-		uint16 stop = *(const uint16 *)(ptr1 + screenHeight);
-		uint16 start = *(const uint16 *)ptr1;
+		const uint16 stop = *(const uint16 *)(ptr1 + screenHeight);
+		const uint16 start = *(const uint16 *)ptr1;
 		++ptr1;
 		if (stop >= start) {
-			uint16 hsize = stop - start;
+			const uint16 hsize = stop - start;
 			uint16 width = hsize + 1;
 			uint8 *out2 = start + out;
-			(*((uint8 *)&start)) = color2;
-			(*((uint8 *)&(start) + 1)) = color2;
 			if ((uintptr)out2 & 1) {
-				*(uint8 *)out2++ = color2;
+				*out2++ = color2;
 				--width;
 			}
-			uint16 v41 = width & 1;
-			for (uint16 m = width >> 1; m; --m) {
-				*(uint16 *)out2 = start;
-				out2 += 2;
+			for (uint16 m = width / 2; m; --m) {
+				*out2++ = color2;
+				*out2++ = color2;
 			}
+			const uint16 v41 = width & 1;
 			for (uint16 n = v41; n; --n) {
-				*(uint8 *)out2++ = color2;
+				*out2++ = color2;
 			}
 			--v29;
 			if (v29) {


Commit: f4e5730cdce0eb3fec034ca3ba393bce5466766c
    https://github.com/scummvm/scummvm/commit/f4e5730cdce0eb3fec034ca3ba393bce5466766c
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2021-09-06T19:51:50+02:00

Commit Message:
TWINE: translated french comment

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


diff --git a/engines/twine/renderer/renderer.cpp b/engines/twine/renderer/renderer.cpp
index 9d5ad2ca5e..9490351baf 100644
--- a/engines/twine/renderer/renderer.cpp
+++ b/engines/twine/renderer/renderer.cpp
@@ -815,8 +815,8 @@ void Renderer::renderPolygonsGouraud(int vtop, int32 vsize) const {
 
 		int16 colorSize = stopColor - startColor;
 
-		int16 stop = ptr1[screenHeight]; // stop
-		int16 start = ptr1[0];           // start
+		int16 stop = ptr1[screenHeight];
+		int16 start = ptr1[0];
 
 		ptr1++;
 		uint8 *out2 = start + out;
@@ -831,7 +831,7 @@ void Renderer::renderPolygonsGouraud(int vtop, int32 vsize) const {
 
 		if (hsize == 0) {
 			if (start >= 0 && start < screenWidth) {
-				*out2 = ((startColor + stopColor) / 2) / 256; // moyenne des 2 couleurs
+				*out2 = ((startColor + stopColor) / 2) / 256; // average of the 2 colors
 			}
 		} else if (hsize > 0) {
 			if (hsize == 1) {
@@ -840,7 +840,7 @@ void Renderer::renderPolygonsGouraud(int vtop, int32 vsize) const {
 				}
 
 				if (start >= 0 && start < screenWidth) {
-					*(out2) = startColor / 256;
+					*out2 = startColor / 256;
 				}
 			} else if (hsize == 2) {
 				if (start >= -2 && start < screenWidth - 2) {
@@ -852,7 +852,7 @@ void Renderer::renderPolygonsGouraud(int vtop, int32 vsize) const {
 				}
 
 				if (start >= 0 && start < screenWidth) {
-					*(out2) = startColor / 256;
+					*out2 = startColor / 256;
 				}
 			} else {
 				int32 currentXPos = start;


Commit: 334a5c310913fc2bb652769048480ed3e5ddae4c
    https://github.com/scummvm/scummvm/commit/334a5c310913fc2bb652769048480ed3e5ddae4c
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2021-09-06T19:52:46+02:00

Commit Message:
TWINE: comments

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


diff --git a/engines/twine/renderer/renderer.cpp b/engines/twine/renderer/renderer.cpp
index 9490351baf..83d5804b34 100644
--- a/engines/twine/renderer/renderer.cpp
+++ b/engines/twine/renderer/renderer.cpp
@@ -798,7 +798,7 @@ void Renderer::renderPolygonsTrame(int vtop, int32 vsize, uint8 color) const {
 void Renderer::renderPolygonsGouraud(int vtop, int32 vsize) const {
 	uint8 *out = (uint8 *)_engine->_frontVideoBuffer.getBasePtr(0, vtop);
 	const int16 *ptr1 = &_polyTab[vtop];
-	const int16 *ptr2 = &_polyTab2[vtop];
+	const int16 *ptr2 = &_polyTab2[vtop]; // color progression
 	const int screenWidth = _engine->width();
 	const int screenHeight = _engine->height();
 	int32 renderLoop = vsize;
@@ -897,7 +897,7 @@ void Renderer::renderPolygonsGouraud(int vtop, int32 vsize) const {
 void Renderer::renderPolygonsDither(int vtop, int32 vsize) const {
 	uint8 *out = (uint8 *)_engine->_frontVideoBuffer.getBasePtr(0, vtop);
 	const int16 *ptr1 = &_polyTab[vtop];
-	const int16 *ptr2 = &_polyTab2[vtop];
+	const int16 *ptr2 = &_polyTab2[vtop]; // color progression
 	const int screenWidth = _engine->width();
 	const int screenHeight = _engine->height();
 
@@ -910,8 +910,8 @@ void Renderer::renderPolygonsDither(int vtop, int32 vsize) const {
 		renderLoop = screenHeight;
 	}
 	for (int32 currentLine = 0; currentLine < renderLoop; ++currentLine) {
-		int16 stop = ptr1[screenHeight]; // stop
-		int16 start = ptr1[0];           // start
+		int16 stop = ptr1[screenHeight];
+		int16 start = ptr1[0];
 		ptr1++;
 		int32 hsize = stop - start;
 		if (hsize < 0) {
@@ -927,7 +927,7 @@ void Renderer::renderPolygonsDither(int vtop, int32 vsize) const {
 
 		if (hsize == 0) {
 			if (currentXPos >= 0 && currentXPos < screenWidth) {
-				*out2 = (uint8)(((startColor + stopColor) / 2) / 256);
+				*out2 = (uint8)(((startColor + stopColor) / 2) / 256); // average of the 2 colors
 			}
 		} else {
 			int16 colorSize = stopColor - startColor;


Commit: 946fa1678ec2bc82914636cf1d153e64b87c3729
    https://github.com/scummvm/scummvm/commit/946fa1678ec2bc82914636cf1d153e64b87c3729
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2021-09-06T19:53:11+02:00

Commit Message:
TWINE: re-did the renderPolygonsBopper method

better - but still not yet there. Try it with:

  set_holomap_trajectory 15

and check the boat windows

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


diff --git a/engines/twine/renderer/renderer.cpp b/engines/twine/renderer/renderer.cpp
index 83d5804b34..d76a7d8c0f 100644
--- a/engines/twine/renderer/renderer.cpp
+++ b/engines/twine/renderer/renderer.cpp
@@ -505,74 +505,49 @@ void Renderer::renderPolygonsCopper(int vtop, int32 vsize, uint8 color) const {
 
 void Renderer::renderPolygonsBopper(int vtop, int32 vsize, uint8 color) const {
 #if 0
-	LOBYTE(v14) = a2;
-	HIWORD(j) = 0;
+	uint8 *out = (uint8 *)_engine->_frontVideoBuffer.getBasePtr(0, vtop);
+	const int16 *ptr1 = &_polyTab[vtop];
+
+	const int screenWidth = _engine->width();
+	const int screenHeight = _engine->height();
+
+	int32 j = 0;
+
 	do {
-		stop = *(uint16 *)(polytab + 960);
-		start = *(uint16 *)polytab;
-		polytab += 2;
-		v34 = stop < (unsigned __int16)start;
-		v17 = stop - start;
-		if (!v34) {
-			LOWORD(j) = j + 1;
-			v18 = (void *)(start + v2);
-			HIBYTE(v14) = v14;
-			LOWORD(start) = v14;
-			start <<= 16;
-			LOWORD(start) = v14;
-			if ((unsigned __int8)v18 & 1) {
-				*(uint8 *)v18 = v14;
-				v18 = (char *)v18 + 1;
-				--j;
-			}
-			v19 = j;
-			v20 = (unsigned int)j >> 2;
-			memset32(v18, start, v20);
-			v21 = (int)((char *)v18 + 4 * v20);
-			for (j = v19 & 2; j; --j)
-				*(uint8 *)v21++ = start;
-			LOBYTE(v14) = v14 + 1;
-			if (!(v14 & 0xF)) {
+		uint16 stop = *(const uint16 *)(ptr1 + screenHeight);
+		uint16 start = *(const uint16 *)ptr1;
+		++ptr1;
+		if (stop >= start) {
+			++j;
+			uint8 *out2 = out + start;
+			memset(out2, color, j);
+			++color;
+			if (!(color & 0xF)) {
 				while (1) {
-					LOBYTE(v14) = v14 - 1;
-					if (!(v14 & 0xF))
+					--color;
+					if (!(color & 0xF)) {
 						break;
-					v2 += 640;
-					--v5;
-					if (!v5)
-						return start;
-					v22 = *(uint16 *)(polytab + 960);
-					start = *(uint16 *)polytab;
-					polytab += 2;
-					v34 = v22 < (unsigned __int16)start;
-					v23 = v22 - start;
-					if (!v34) {
-						LOWORD(j) = j + 1;
-						v24 = (void *)(start + v2);
-						HIBYTE(v14) = v14;
-						LOWORD(start) = v14;
-						start <<= 16;
-						LOWORD(start) = v14;
-						if ((unsigned __int8)v24 & 1) {
-							*(uint8 *)v24 = v14;
-							v24 = (char *)v24 + 1;
-							--j;
-						}
-						v25 = j;
-						v26 = (unsigned int)j >> 2;
-						memset32(v24, start, v26);
-						v27 = (int)((char *)v24 + 4 * v26);
-						for (j = v25 & 2; j; --j)
-							*(uint8 *)v27++ = start;
+					}
+					out += screenWidth;
+					--vsize;
+					if (!vsize) {
+						return;
+					}
+					stop = *(const uint16 *)(ptr1 + screenHeight);
+					start = *(const uint16 *)ptr1;
+					++ptr1;
+					if (stop >= start) {
+						++j;
+						out2 = out + start;
+						memset(out2, color, j);
 					}
 				}
 			}
 		}
-		v2 += 640;
-		--v5;
-	} while (v5);
-	return start;
-#endif
+		out += screenWidth;
+		--vsize;
+	} while (vsize);
+#else
 	uint8 *out = (uint8 *)_engine->_frontVideoBuffer.getBasePtr(0, vtop);
 	const int16 *ptr1 = &_polyTab[vtop];
 	const int screenWidth = _engine->width();
@@ -602,6 +577,7 @@ void Renderer::renderPolygonsBopper(int vtop, int32 vsize, uint8 color) const {
 		}
 		out += screenWidth;
 	}
+#endif
 }
 
 void Renderer::renderPolygonsFlat(int vtop, int32 vsize, uint8 color) const {




More information about the Scummvm-git-logs mailing list