[Scummvm-git-logs] scummvm master -> 379ddd1ff2727712e2a14ecf18636434f95d4071

mgerhardy martin.gerhardy at gmail.com
Sun Oct 10 17:35:48 UTC 2021


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:
379ddd1ff2 TWINE: converted more render methods


Commit: 379ddd1ff2727712e2a14ecf18636434f95d4071
    https://github.com/scummvm/scummvm/commit/379ddd1ff2727712e2a14ecf18636434f95d4071
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2021-10-10T16:24:51+02:00

Commit Message:
TWINE: converted more render methods

Changed paths:
    engines/twine/parser/body.cpp
    engines/twine/parser/bodytypes.h
    engines/twine/renderer/renderer.cpp


diff --git a/engines/twine/parser/body.cpp b/engines/twine/parser/body.cpp
index ed70811d1d..02ad85ebee 100644
--- a/engines/twine/parser/body.cpp
+++ b/engines/twine/parser/body.cpp
@@ -148,9 +148,9 @@ void BodyData::loadLines(Common::SeekableReadStream &stream) {
 	_lines.reserve(numLines);
 	for (uint16 i = 0; i < numLines; ++i) {
 		BodyLine line;
-		line.unk1 = stream.readByte();
+		stream.skip(1);
 		line.color = stream.readByte();
-		line.unk2 = stream.readUint16LE();
+		stream.skip(2);
 		line.vertex1 = stream.readUint16LE() / 6;
 		line.vertex2 = stream.readUint16LE() / 6;
 		_lines.push_back(line);
diff --git a/engines/twine/parser/bodytypes.h b/engines/twine/parser/bodytypes.h
index 4dc94cf40a..b2fec04bbf 100644
--- a/engines/twine/parser/bodytypes.h
+++ b/engines/twine/parser/bodytypes.h
@@ -37,10 +37,9 @@ struct BodyVertex {
 };
 
 struct BodyLine {
-	// TODO: intensity??
-	uint8 unk1;
+	// fill byte here
 	uint8 color;
-	uint16 unk2;
+	// 2 fill bytes here
 	uint16 vertex1;
 	uint16 vertex2;
 };
@@ -49,7 +48,7 @@ struct BodySphere {
 	uint8 fillType;
 	uint16 color; // start and end color index
 	// fill byte here
-	int16 radius;
+	uint16 radius;
 	uint16 vertex;
 };
 
diff --git a/engines/twine/renderer/renderer.cpp b/engines/twine/renderer/renderer.cpp
index e01d8ed64e..fcb11c5bee 100644
--- a/engines/twine/renderer/renderer.cpp
+++ b/engines/twine/renderer/renderer.cpp
@@ -566,81 +566,41 @@ void Renderer::renderPolygonsFlat(int vtop, int32 vsize, uint16 color) const {
 	}
 }
 
+#define ROL16(x, b) (((x) << (b)) | ((x) >> (16 - (b))))
+
 void Renderer::renderPolygonsTele(int vtop, int32 vsize, uint16 color) const {
 	uint8 *out = (uint8 *)_engine->_frontVideoBuffer.getBasePtr(0, vtop);
 	const int16 *ptr1 = &_polyTab[vtop];
-	int bx = (uint16)color << 16;
 	const int screenWidth = _engine->width();
 	const int screenHeight = _engine->height();
 
 	int32 renderLoop = vsize;
-	do {
-		int16 start;
-		int16 stop;
-		int32 hsize;
-		while (1) {
-			start = ptr1[0];
-			stop = ptr1[screenHeight];
-			ptr1++;
-			hsize = stop - start;
-
-			if (hsize) {
-				break;
-			}
-
-			uint8 *out2 = start + out;
-			*out2 = ((uint16)(bx / 24)) & 0x0F;
-
-			color = *(out2 + 1);
-
-			out += screenWidth;
-
-			--renderLoop;
-			if (!renderLoop) {
-				return;
-			}
-		}
-
-		if (stop >= start) {
-			hsize++;
-			bx = (uint16)(color / 16);
-			uint8 *out2 = start + out;
-
-			int ax = (bx & 0xF0) * 256;
-			bx = bx * 256;
-			ax += (bx & 0x0F);
-			ax -= bx;
-			ax++;
-			ax = ax >> 16;
-
-			ax = ax / hsize;
-			uint16 temp = (ax & 0xF0);
-			temp = temp / 256;
-			temp += (ax & 0x0F);
-			ax = temp;
-
-			uint16 dx = ax;
-
-			ax = (ax & 0x0F) + (bx & 0xF0);
-			hsize++;
+	if (vtop < 0) {
+		out += screenWidth * ABS(vtop);
+		renderLoop -= ABS(vtop);
+	}
+	if (renderLoop > screenHeight) {
+		renderLoop = screenHeight;
+	}
 
-			if (hsize & 1) {
-				ax = 0; // not sure about this
-			}
+	uint16 acc = 17371;
+	color &= 0xFF;
+	uint16 col;
+	for (int32 currentLine = 0; currentLine < renderLoop; ++currentLine) {
+		int16 xMin = ptr1[0];
+		int16 xMax = ptr1[screenHeight];
+		++ptr1;
+		uint8 *pDest = out + xMin;
+		col = xMin;
 
-			for (int32 j = hsize >> 1; j > 0; --j) {
-				*(out2++) = ax & 0x0F;
-				ax += dx;
+		for (; xMin <= xMax; xMin++) {
+			col = ((col + acc) & 0xFF03) + (uint16)color;
+			acc = ROL16(acc, 2) + 1;
 
-				*(out2++) = ax & 0x0F;
-				ax += dx;
-			}
+			*pDest++ = (uint8)col;
 		}
-
 		out += screenWidth;
-		--renderLoop;
-
-	} while (renderLoop);
+	}
 }
 
 void Renderer::renderPolygonsTrans(int vtop, int32 vsize, uint16 color) const {




More information about the Scummvm-git-logs mailing list