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

mgerhardy martin.gerhardy at gmail.com
Fri Nov 6 15:57:46 UTC 2020


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

Summary:
ddeb88bf44 TWINE: endian safe fla parsing
b167bae762 TWINE: const and minor cleanup
6533bfdf3a TWINE: removed member vars from Actor class
e909f51bf5 TWINE: use IS_HERO macro
09a589fb6f TWINE: invert the logic
e6058e9ada TWINE: endian safe actor bounding box parsing
e679672de4 TWINE: reduced scope and code duplication
d2aa0068ec TWINE: const
ac7ad91738 TWINE: reduced visibility
1b3da88113 TWINE: added comments and bonus zone structs
06f2fa1b58 TWINE: document gameflags according to the lba wiki
d10913cf1c TWINE: switched from unstable to testing and build by default
13acddb564 TWINE: comment for missing lHOLOMAP_TRAJ implementation
3de2bda92c TWINE: fixed compiler warnings
ec062fb112 TWINE: reduced scope
089c62b274 TWINE: reduced scope
2d0791a893 TWINE: reduced scope
11e76319c5 TWINE: reduced scope
d8f49ca4de TWINE: reduced scope and made members lowercase
c94c4d2878 TWINE: reduced scope
a372f14cf8 TWINE: reduced scope and members
471823b7d4 TWINE: replaced magic numbers
a33c61fcaa TWINE: converted to boolean
51534d74ec TWINE: removed unused members and reduced scope
1d2984678a TWINE: reduced scope
e08b7d6455 TWINE: reduced scope
ee0e586f7b TWINE: reduced cyclic complexity
89a9b97ae0 TWINE: reduced scope
5c423ecd2f TWINE: reduced scope
2ede9b688b TWINE: reduced scope and removed unused member
85ce25f671 TWINE: endian safe text and font parsing
73e2f2af8e TWINE: converted to bool
b13c10f0b4 TWINE: re-added detection entry from pull request 2557


Commit: ddeb88bf441c5d56c697ffdf8750739a54c88738
    https://github.com/scummvm/scummvm/commit/ddeb88bf441c5d56c697ffdf8750739a54c88738
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-06T16:52:45+01:00

Commit Message:
TWINE: endian safe fla parsing

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


diff --git a/engines/twine/flamovies.cpp b/engines/twine/flamovies.cpp
index e95177d496..d783d79d32 100644
--- a/engines/twine/flamovies.cpp
+++ b/engines/twine/flamovies.cpp
@@ -61,23 +61,23 @@ struct FLASampleStruct {
 /** FLA movie extension */
 #define FLA_EXT ".fla"
 
-void FlaMovies::drawKeyFrame(uint8 *ptr, int32 width, int32 height) {
+void FlaMovies::drawKeyFrame(Common::MemoryReadStream &stream, int32 width, int32 height) {
 	uint8 *destPtr = (uint8 *)flaBuffer;
 	uint8 *startOfLine = destPtr;
 
 	do {
-		int8 flag1 = *(ptr++);
+		int8 flag1 = stream.readByte();
 
 		for (int8 a = 0; a < flag1; a++) {
-			int8 flag2 = *(ptr++);
+			int8 flag2 = stream.readByte();
 
 			if (flag2 < 0) {
 				flag2 = -flag2;
 				for (int8 b = 0; b < flag2; b++) {
-					*(destPtr++) = *(ptr++);
+					*(destPtr++) = stream.readByte();
 				}
 			} else {
-				char colorFill = *(ptr++);
+				char colorFill = stream.readByte();
 
 				for (int8 b = 0; b < flag2; b++) {
 					*(destPtr++) = colorFill;
@@ -89,7 +89,7 @@ void FlaMovies::drawKeyFrame(uint8 *ptr, int32 width, int32 height) {
 	} while (--height);
 }
 
-void FlaMovies::drawDeltaFrame(uint8 *ptr, int32 width) {
+void FlaMovies::drawDeltaFrame(Common::MemoryReadStream &stream, int32 width) {
 	int32 a, b;
 	uint16 skip;
 	uint8 *destPtr;
@@ -99,29 +99,27 @@ void FlaMovies::drawDeltaFrame(uint8 *ptr, int32 width) {
 	int8 flag1;
 	int8 flag2;
 
-	skip = *((uint16 *)ptr);
-	ptr += 2;
+	skip = stream.readUint16LE();
 	skip *= width;
 	startOfLine = destPtr = (uint8 *)flaBuffer + skip;
-	height = *((int16 *)ptr);
-	ptr += 2;
+	height = stream.readSint16LE();
 
 	do {
-		flag1 = *(ptr++);
+		flag1 = stream.readByte();
 
 		for (a = 0; a < flag1; a++) {
-			destPtr += (unsigned char)*(ptr++);
-			flag2 = *(ptr++);
+			destPtr += stream.readByte();
+			flag2 = stream.readByte();
 
 			if (flag2 > 0) {
 				for (b = 0; b < flag2; b++) {
-					*(destPtr++) = *(ptr++);
+					*(destPtr++) = stream.readByte();
 				}
 			} else {
 				char colorFill;
 				flag2 = -flag2;
 
-				colorFill = *(ptr++);
+				colorFill = stream.readByte();
 
 				for (b = 0; b < flag2; b++) {
 					*(destPtr++) = colorFill;
@@ -185,23 +183,26 @@ void FlaMovies::processFrame() {
 		return;
 	}
 
-	uint8 *ptr = (uint8*)_engine->workVideoBuffer.getPixels();
-	file.read(ptr, frameData.frameVar0);
+	uint8 *outBuf = (uint8*)_engine->workVideoBuffer.getPixels();
+	file.read(outBuf, frameData.frameVar0);
 
-	if ((int32)frameData.videoSize <= 0)
+	if ((int32)frameData.videoSize <= 0) {
 		return;
+	}
 
+	Common::MemoryReadStream stream(outBuf, frameData.frameVar0);
 	do {
-		opcode = *((uint8 *)ptr);
-		ptr += 2;
-		opcodeBlockSize = *((uint16 *)ptr);
-		ptr += 2;
+		opcode = stream.readByte();
+		stream.skip(1);
+		opcodeBlockSize = stream.readUint16LE();
+		const int32 pos = stream.pos();
 
 		switch (opcode - 1) {
 		case kLoadPalette: {
-			int16 numOfColor = *((int16 *)ptr);
-			int16 startColor = *((int16 *)(ptr + 2));
-			memcpy((_engine->_screens->palette + (startColor * 3)), (ptr + 4), numOfColor * 3);
+			int16 numOfColor = stream.readSint16LE();
+			int16 startColor = stream.readSint16LE();
+			uint8 *dest = _engine->_screens->palette + (startColor * 3);
+			stream.read(dest, numOfColor * 3);
 			break;
 		}
 		case kFade: {
@@ -215,7 +216,12 @@ void FlaMovies::processFrame() {
 			break;
 		}
 		case kPlaySample: {
-			memcpy(&sample, ptr, sizeof(FLASampleStruct));
+			sample.sampleNum = stream.readSint16LE();
+			sample.freq = stream.readSint16LE();
+			sample.repeat = stream.readSint16LE();
+			sample.dummy = stream.readSByte();
+			sample.x = stream.readByte();
+			sample.y = stream.readByte();
 			_engine->_sound->playFlaSample(sample.sampleNum, sample.freq, sample.repeat, sample.x, sample.y);
 			break;
 		}
@@ -224,13 +230,13 @@ void FlaMovies::processFrame() {
 			break;
 		}
 		case kDeltaFrame: {
-			drawDeltaFrame(ptr, FLASCREEN_WIDTH);
+			drawDeltaFrame(stream, FLASCREEN_WIDTH);
 			if (_fadeOut == 1)
 				fadeOutFrames++;
 			break;
 		}
 		case kKeyFrame: {
-			drawKeyFrame(ptr, FLASCREEN_WIDTH, FLASCREEN_HEIGHT);
+			drawKeyFrame(stream, FLASCREEN_WIDTH, FLASCREEN_HEIGHT);
 			break;
 		}
 		default: {
@@ -239,7 +245,7 @@ void FlaMovies::processFrame() {
 		}
 
 		aux++;
-		ptr += opcodeBlockSize;
+		stream.seek(pos + opcodeBlockSize);
 
 	} while (aux < (int32)frameData.videoSize);
 	//free(workVideoBufferCopy);
diff --git a/engines/twine/flamovies.h b/engines/twine/flamovies.h
index c2d3e692d2..5bc985970e 100644
--- a/engines/twine/flamovies.h
+++ b/engines/twine/flamovies.h
@@ -23,6 +23,7 @@
 #ifndef TWINE_FLAMOVIES_H
 #define TWINE_FLAMOVIES_H
 
+#include "common/memstream.h"
 #include "common/scummsys.h"
 #include "common/file.h"
 
@@ -82,8 +83,8 @@ private:
 	/** FLA movie header data */
 	FLAFrameDataStruct frameData;
 
-	void drawKeyFrame(uint8 *ptr, int32 width, int32 height);
-	void drawDeltaFrame(uint8 *ptr, int32 width);
+	void drawKeyFrame(Common::MemoryReadStream &stream, int32 width, int32 height);
+	void drawDeltaFrame(Common::MemoryReadStream &stream, int32 width);
 	/**
 	 * Scale FLA movie 2 times
 	 * According with the settins we can put the original aspect radio stretch


Commit: b167bae762bcc23a79c41f5f8344b17874d9e491
    https://github.com/scummvm/scummvm/commit/b167bae762bcc23a79c41f5f8344b17874d9e491
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-06T16:52:45+01:00

Commit Message:
TWINE: const and minor cleanup

Changed paths:
    engines/twine/interface.cpp


diff --git a/engines/twine/interface.cpp b/engines/twine/interface.cpp
index 3872e1dff4..70f79f7bd1 100644
--- a/engines/twine/interface.cpp
+++ b/engines/twine/interface.cpp
@@ -35,14 +35,16 @@ const int32 BOTTOM = 8; // 1000
 
 int32 Interface::checkClipping(int32 x, int32 y) {
 	int32 code = INSIDE;
-	if (x < textWindowLeft)
+	if (x < textWindowLeft) {
 		code |= LEFT;
-	else if (x > textWindowRight)
+	} else if (x > textWindowRight) {
 		code |= RIGHT;
-	if (y < textWindowTop)
+	}
+	if (y < textWindowTop) {
 		code |= TOP;
-	else if (y > textWindowBottom)
+	} else if (y > textWindowBottom) {
 		code |= BOTTOM;
+	}
 	return code;
 }
 
@@ -67,8 +69,9 @@ void Interface::drawLine(int32 startWidth, int32 startHeight, int32 endWidth, in
 	int32 outcode1 = checkClipping(endWidth, endHeight);
 
 	while ((outcode0 | outcode1) != 0) {
-		if (((outcode0 & outcode1) != 0) && (outcode0 != INSIDE))
+		if ((outcode0 & outcode1) != 0 && outcode0 != INSIDE) {
 			return; // Reject lines which are behind one clipping plane
+		}
 
 		// At least one endpoint is outside the clip rectangle; pick it.
 		int32 outcodeOut = outcode0 ? outcode0 : outcode1;
@@ -173,30 +176,38 @@ void Interface::blitBox(int32 left, int32 top, int32 right, int32 bottom, const
 }
 
 void Interface::drawTransparentBox(int32 left, int32 top, int32 right, int32 bottom, int32 colorAdj) {
-	if (left > SCREEN_TEXTLIMIT_RIGHT)
+	if (left > SCREEN_TEXTLIMIT_RIGHT) {
 		return;
-	if (right < SCREEN_TEXTLIMIT_LEFT)
+	}
+	if (right < SCREEN_TEXTLIMIT_LEFT) {
 		return;
-	if (top > SCREEN_TEXTLIMIT_BOTTOM)
+	}
+	if (top > SCREEN_TEXTLIMIT_BOTTOM) {
 		return;
-	if (bottom < SCREEN_TEXTLIMIT_TOP)
+	}
+	if (bottom < SCREEN_TEXTLIMIT_TOP) {
 		return;
+	}
 
-	if (left < SCREEN_TEXTLIMIT_LEFT)
+	if (left < SCREEN_TEXTLIMIT_LEFT) {
 		left = SCREEN_TEXTLIMIT_LEFT;
-	if (right > SCREEN_TEXTLIMIT_RIGHT)
+	}
+	if (right > SCREEN_TEXTLIMIT_RIGHT) {
 		right = SCREEN_TEXTLIMIT_RIGHT;
-	if (top < SCREEN_TEXTLIMIT_TOP)
+	}
+	if (top < SCREEN_TEXTLIMIT_TOP) {
 		top = SCREEN_TEXTLIMIT_TOP;
-	if (bottom > SCREEN_TEXTLIMIT_BOTTOM)
+	}
+	if (bottom > SCREEN_TEXTLIMIT_BOTTOM) {
 		bottom = SCREEN_TEXTLIMIT_BOTTOM;
+	}
 
 	uint8 *pos = (uint8*)_engine->frontVideoBuffer.getPixels() + _engine->screenLookupTable[top] + left;
-	int32 height = bottom - top;
+	const int32 height = bottom - top;
 	int32 height2 = height + 1;
-	int32 width = right - left + 1;
-	int32 pitch = DEFAULT_SCREEN_WIDTH - width;
-	int32 localMode = colorAdj;
+	const int32 width = right - left + 1;
+	const int32 pitch = DEFAULT_SCREEN_WIDTH - width;
+	const int32 localMode = colorAdj;
 
 	do {
 		int32 var1 = width;
@@ -218,14 +229,18 @@ void Interface::drawTransparentBox(int32 left, int32 top, int32 right, int32 bot
 }
 
 void Interface::drawSplittedBox(int32 left, int32 top, int32 right, int32 bottom, uint8 e) { // Box
-	if (left > SCREEN_TEXTLIMIT_RIGHT)
+	if (left > SCREEN_TEXTLIMIT_RIGHT) {
 		return;
-	if (right < SCREEN_TEXTLIMIT_LEFT)
+	}
+	if (right < SCREEN_TEXTLIMIT_LEFT) {
 		return;
-	if (top > SCREEN_TEXTLIMIT_BOTTOM)
+	}
+	if (top > SCREEN_TEXTLIMIT_BOTTOM) {
 		return;
-	if (bottom < SCREEN_TEXTLIMIT_TOP)
+	}
+	if (bottom < SCREEN_TEXTLIMIT_TOP) {
 		return;
+	}
 
 	// cropping
 	int32 offset = -((right - left) - SCREEN_WIDTH);


Commit: 6533bfdf3a7b4c92e1dbbd25279457b2e9aea006
    https://github.com/scummvm/scummvm/commit/6533bfdf3a7b4c92e1dbbd25279457b2e9aea006
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-06T16:52:45+01:00

Commit Message:
TWINE: removed member vars from Actor class

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


diff --git a/engines/twine/actor.cpp b/engines/twine/actor.cpp
index 280214a018..efca183136 100644
--- a/engines/twine/actor.cpp
+++ b/engines/twine/actor.cpp
@@ -186,7 +186,10 @@ int32 Actor::getTextIdForBehaviour() const {
 	return _engine->_actor->heroBehaviour;
 }
 
-int32 Actor::initBody(int32 bodyIdx, int32 actorIdx) {
+int32 Actor::initBody(int32 bodyIdx, int32 actorIdx, ActorBoundingBox &actorBoundingBox) {
+	if (bodyIdx == -1) {
+		return -1;
+	}
 	ActorStruct *actor = _engine->_scene->getActor(actorIdx);
 	Common::MemorySeekableReadWriteStream stream(actor->entityDataPtr, actor->entityDataSize);
 	do {
@@ -220,10 +223,8 @@ int32 Actor::initBody(int32 bodyIdx, int32 actorIdx) {
 					index = bodyIndex & 0x7FFF;
 				}
 
-				bottomLeftX = -32000;
-
-				const bool hasBox = stream.readByte();
-				if (!hasBox) {
+				actorBoundingBox.hasBoundingBox = stream.readByte();
+				if (!actorBoundingBox.hasBoundingBox) {
 					return index;
 				}
 
@@ -231,13 +232,13 @@ int32 Actor::initBody(int32 bodyIdx, int32 actorIdx) {
 					return index;
 				}
 
-				bottomLeftX = stream.readUint16LE();
-				bottomLeftY = stream.readUint16LE();
-				bottomLeftZ = stream.readUint16LE();
+				actorBoundingBox.bottomLeftX = stream.readUint16LE();
+				actorBoundingBox.bottomLeftY = stream.readUint16LE();
+				actorBoundingBox.bottomLeftZ = stream.readUint16LE();
 
-				topRightX = stream.readUint16LE();
-				topRightY = stream.readUint16LE();
-				topRightZ = stream.readUint16LE();
+				actorBoundingBox.topRightX = stream.readUint16LE();
+				actorBoundingBox.topRightY = stream.readUint16LE();
+				actorBoundingBox.topRightZ = stream.readUint16LE();
 
 				return index;
 			}
@@ -256,13 +257,8 @@ void Actor::initModelActor(int32 bodyIdx, int16 actorIdx) {
 		setBehaviour(kNormal);
 	}
 
-	int32 entityIdx;
-	if (bodyIdx != -1) {
-		entityIdx = initBody(bodyIdx, actorIdx);
-	} else {
-		entityIdx = -1;
-	}
-
+	ActorBoundingBox actorBoundingBox;
+	const int32 entityIdx = initBody(bodyIdx, actorIdx, actorBoundingBox);
 	if (entityIdx != -1) {
 		if (localActor->entity == entityIdx) {
 			return;
@@ -272,8 +268,7 @@ void Actor::initModelActor(int32 bodyIdx, int16 actorIdx) {
 		localActor->body = bodyIdx;
 		int currentIndex = localActor->entity;
 
-		// -32000 means no bounding box in the entity data
-		if (bottomLeftX == -32000) {
+		if (!actorBoundingBox.hasBoundingBox) {
 			uint16 *ptr = (uint16 *)bodyTable[localActor->entity];
 			ptr++;
 
@@ -307,12 +302,12 @@ void Actor::initModelActor(int32 bodyIdx, int16 actorIdx) {
 			localActor->boudingBox.z.bottomLeft = -result;
 			localActor->boudingBox.z.topRight = result;
 		} else {
-			localActor->boudingBox.x.bottomLeft = bottomLeftX;
-			localActor->boudingBox.x.topRight = topRightX;
-			localActor->boudingBox.y.bottomLeft = bottomLeftY;
-			localActor->boudingBox.y.topRight = topRightY;
-			localActor->boudingBox.z.bottomLeft = bottomLeftZ;
-			localActor->boudingBox.z.topRight = topRightZ;
+			localActor->boudingBox.x.bottomLeft = actorBoundingBox.bottomLeftX;
+			localActor->boudingBox.x.topRight = actorBoundingBox.topRightX;
+			localActor->boudingBox.y.bottomLeft = actorBoundingBox.bottomLeftY;
+			localActor->boudingBox.y.topRight = actorBoundingBox.topRightY;
+			localActor->boudingBox.z.bottomLeft = actorBoundingBox.bottomLeftZ;
+			localActor->boudingBox.z.topRight = actorBoundingBox.topRightZ;
 		}
 
 		if (currentIndex == -1)
diff --git a/engines/twine/actor.h b/engines/twine/actor.h
index 80816337ba..d3f6d9c2df 100644
--- a/engines/twine/actor.h
+++ b/engines/twine/actor.h
@@ -254,20 +254,31 @@ private:
 	uint8 *heroEntityPROTOPACK = nullptr; // file3D4
 	int32 heroEntityPROTOPACKSize = 0;
 
-	/** Actor bounding box bottom left X coordinate */
-	int16 bottomLeftX; // loadCostumeVar
-	/** Actor bounding box bottom left Y coordinate */
-	int16 bottomLeftY; // loadCostumeVar2
-	/** Actor bounding box bottom left Z coordinate */
-	int16 bottomLeftZ; // loadCostumeVar3
-	/** Actor bounding box top left X coordinate */
-	int16 topRightX; // loadCostumeVar4
-	/** Actor bounding box top left Y coordinate */
-	int16 topRightY; // loadCostumeVar5
-	/** Actor bounding box top left Z coordinate */
-	int16 topRightZ; // loadCostumeVar6
+	struct ActorBoundingBox {
+		/** Bottom left X coordinate */
+		int16 bottomLeftX = 0;
+		/** Bottom left Y coordinate */
+		int16 bottomLeftY = 0;
+		/** Bottom left Z coordinate */
+		int16 bottomLeftZ = 0;
+		/** Top left X coordinate */
+		int16 topRightX = 0;
+		/** Top left Y coordinate */
+		int16 topRightY = 0;
+		/** Top left Z coordinate */
+		int16 topRightZ = 0;
+		bool hasBoundingBox = false;
+	};
 
 	void initSpriteActor(int32 actorIdx);
+
+	/**
+	 * Initialize 3D actor body
+	 * @param bodyIdx 3D actor body index
+	 * @param actorIdx 3D actor index
+	 */
+	int32 initBody(int32 bodyIdx, int32 actorIdx, ActorBoundingBox &actorBoundingBox);
+
 public:
 	Actor(TwinEEngine* engine);
 	~Actor();
@@ -328,13 +339,6 @@ public:
 	 */
 	void setBehaviour(int32 behaviour);
 
-	/**
-	 * Initialize 3D actor body
-	 * @param bodyIdx 3D actor body index
-	 * @param actorIdx 3D actor index
-	 */
-	int32 initBody(int32 bodyIdx, int32 actorIdx);
-
 	/** Preload all sprites */
 	void preloadSprites();
 


Commit: e909f51bf55f06a4464cd54441244b308c528ef4
    https://github.com/scummvm/scummvm/commit/e909f51bf55f06a4464cd54441244b308c528ef4
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-06T16:52:45+01:00

Commit Message:
TWINE: use IS_HERO macro

Changed paths:
    engines/twine/actor.cpp


diff --git a/engines/twine/actor.cpp b/engines/twine/actor.cpp
index efca183136..d343251c42 100644
--- a/engines/twine/actor.cpp
+++ b/engines/twine/actor.cpp
@@ -253,7 +253,7 @@ void Actor::initModelActor(int32 bodyIdx, int16 actorIdx) {
 		return;
 	}
 
-	if (actorIdx == 0 && heroBehaviour == kProtoPack && localActor->armor != 0 && localActor->armor != 1) { // if hero
+	if (IS_HERO(actorIdx) && heroBehaviour == kProtoPack && localActor->armor != 0 && localActor->armor != 1) {
 		setBehaviour(kNormal);
 	}
 


Commit: 09a589fb6fb42e8681c8334fd740477bddf1b5de
    https://github.com/scummvm/scummvm/commit/09a589fb6fb42e8681c8334fd740477bddf1b5de
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-06T16:52:45+01:00

Commit Message:
TWINE: invert the logic

Changed paths:
    engines/twine/actor.cpp


diff --git a/engines/twine/actor.cpp b/engines/twine/actor.cpp
index d343251c42..14689845fd 100644
--- a/engines/twine/actor.cpp
+++ b/engines/twine/actor.cpp
@@ -259,77 +259,76 @@ void Actor::initModelActor(int32 bodyIdx, int16 actorIdx) {
 
 	ActorBoundingBox actorBoundingBox;
 	const int32 entityIdx = initBody(bodyIdx, actorIdx, actorBoundingBox);
-	if (entityIdx != -1) {
-		if (localActor->entity == entityIdx) {
-			return;
-		}
-
-		localActor->entity = entityIdx;
-		localActor->body = bodyIdx;
-		int currentIndex = localActor->entity;
-
-		if (!actorBoundingBox.hasBoundingBox) {
-			uint16 *ptr = (uint16 *)bodyTable[localActor->entity];
-			ptr++;
+	if (entityIdx == -1) {
+		localActor->body = -1;
+		localActor->entity = -1;
+
+		localActor->boudingBox.x.bottomLeft = 0;
+		localActor->boudingBox.x.topRight = 0;
+		localActor->boudingBox.y.bottomLeft = 0;
+		localActor->boudingBox.y.topRight = 0;
+		localActor->boudingBox.z.bottomLeft = 0;
+		localActor->boudingBox.z.topRight = 0;
+		return;
+	}
 
-			int16 var1 = *((int16 *)ptr++);
-			int16 var2 = *((int16 *)ptr++);
-			localActor->boudingBox.y.bottomLeft = *((int16 *)ptr++);
-			localActor->boudingBox.y.topRight = *((int16 *)ptr++);
-			int16 var3 = *((int16 *)ptr++);
-			int16 var4 = *((int16 *)ptr++);
+	if (localActor->entity == entityIdx) {
+		return;
+	}
 
-			int32 result = 0;
-			if (localActor->staticFlags.bUseMiniZv) {
-				int32 result1 = var2 - var1; // take smaller for bound
-				int32 result2 = var4 - var3;
+	localActor->entity = entityIdx;
+	localActor->body = bodyIdx;
+	int currentIndex = localActor->entity;
+
+	if (actorBoundingBox.hasBoundingBox) {
+		localActor->boudingBox.x.bottomLeft = actorBoundingBox.bottomLeftX;
+		localActor->boudingBox.x.topRight = actorBoundingBox.topRightX;
+		localActor->boudingBox.y.bottomLeft = actorBoundingBox.bottomLeftY;
+		localActor->boudingBox.y.topRight = actorBoundingBox.topRightY;
+		localActor->boudingBox.z.bottomLeft = actorBoundingBox.bottomLeftZ;
+		localActor->boudingBox.z.topRight = actorBoundingBox.topRightZ;
+	} else {
+		uint16 *ptr = (uint16 *)bodyTable[localActor->entity];
+		ptr++;
 
-				result = MIN(result1, result2);
+		int16 var1 = *((int16 *)ptr++);
+		int16 var2 = *((int16 *)ptr++);
+		localActor->boudingBox.y.bottomLeft = *((int16 *)ptr++);
+		localActor->boudingBox.y.topRight = *((int16 *)ptr++);
+		int16 var3 = *((int16 *)ptr++);
+		int16 var4 = *((int16 *)ptr++);
 
-				result = ABS(result);
-				result >>= 1;
-			} else {
-				int32 result1 = var2 - var1; // take average for bound
-				int32 result2 = var4 - var3;
+		int32 result = 0;
+		if (localActor->staticFlags.bUseMiniZv) {
+			int32 result1 = var2 - var1; // take smaller for bound
+			int32 result2 = var4 - var3;
 
-				result = result2 + result1;
-				result = ABS(result);
-				result >>= 2;
-			}
+			result = MIN(result1, result2);
 
-			localActor->boudingBox.x.bottomLeft = -result;
-			localActor->boudingBox.x.topRight = result;
-			localActor->boudingBox.z.bottomLeft = -result;
-			localActor->boudingBox.z.topRight = result;
+			result = ABS(result);
+			result >>= 1;
 		} else {
-			localActor->boudingBox.x.bottomLeft = actorBoundingBox.bottomLeftX;
-			localActor->boudingBox.x.topRight = actorBoundingBox.topRightX;
-			localActor->boudingBox.y.bottomLeft = actorBoundingBox.bottomLeftY;
-			localActor->boudingBox.y.topRight = actorBoundingBox.topRightY;
-			localActor->boudingBox.z.bottomLeft = actorBoundingBox.bottomLeftZ;
-			localActor->boudingBox.z.topRight = actorBoundingBox.topRightZ;
-		}
-
-		if (currentIndex == -1)
-			return;
+			int32 result1 = var2 - var1; // take average for bound
+			int32 result2 = var4 - var3;
 
-		if (localActor->previousAnimIdx == -1)
-			return;
+			result = result2 + result1;
+			result = ABS(result);
+			result >>= 2;
+		}
 
-		_engine->_renderer->copyActorInternAnim(bodyTable[currentIndex], bodyTable[localActor->entity]);
+		localActor->boudingBox.x.bottomLeft = -result;
+		localActor->boudingBox.x.topRight = result;
+		localActor->boudingBox.z.bottomLeft = -result;
+		localActor->boudingBox.z.topRight = result;
+	}
 
+	if (currentIndex == -1)
 		return;
-	}
 
-	localActor->body = -1;
-	localActor->entity = -1;
+	if (localActor->previousAnimIdx == -1)
+		return;
 
-	localActor->boudingBox.x.bottomLeft = 0;
-	localActor->boudingBox.x.topRight = 0;
-	localActor->boudingBox.y.bottomLeft = 0;
-	localActor->boudingBox.y.topRight = 0;
-	localActor->boudingBox.z.bottomLeft = 0;
-	localActor->boudingBox.z.topRight = 0;
+	_engine->_renderer->copyActorInternAnim(bodyTable[currentIndex], bodyTable[localActor->entity]);
 }
 
 void Actor::initActor(int16 actorIdx) {


Commit: e6058e9adab660f3f09dff603008be0ea1220d91
    https://github.com/scummvm/scummvm/commit/e6058e9adab660f3f09dff603008be0ea1220d91
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-06T16:52:45+01:00

Commit Message:
TWINE: endian safe actor bounding box parsing

Changed paths:
    engines/twine/actor.cpp


diff --git a/engines/twine/actor.cpp b/engines/twine/actor.cpp
index 14689845fd..dfdb697b90 100644
--- a/engines/twine/actor.cpp
+++ b/engines/twine/actor.cpp
@@ -288,15 +288,14 @@ void Actor::initModelActor(int32 bodyIdx, int16 actorIdx) {
 		localActor->boudingBox.z.bottomLeft = actorBoundingBox.bottomLeftZ;
 		localActor->boudingBox.z.topRight = actorBoundingBox.topRightZ;
 	} else {
-		uint16 *ptr = (uint16 *)bodyTable[localActor->entity];
-		ptr++;
-
-		int16 var1 = *((int16 *)ptr++);
-		int16 var2 = *((int16 *)ptr++);
-		localActor->boudingBox.y.bottomLeft = *((int16 *)ptr++);
-		localActor->boudingBox.y.topRight = *((int16 *)ptr++);
-		int16 var3 = *((int16 *)ptr++);
-		int16 var4 = *((int16 *)ptr++);
+		Common::MemoryReadStream stream(bodyTable[localActor->entity], bodyTableSize[localActor->entity]);
+		stream.skip(2);
+		int16 var1 = stream.readSint16LE();
+		int16 var2 = stream.readSint16LE();
+		localActor->boudingBox.y.bottomLeft = stream.readSint16LE();
+		localActor->boudingBox.y.topRight = stream.readSint16LE();
+		int16 var3 = stream.readSint16LE();
+		int16 var4 = stream.readSint16LE();
 
 		int32 result = 0;
 		if (localActor->staticFlags.bUseMiniZv) {


Commit: e679672de4aac5db8098ab26e89f9eba91a2f4c7
    https://github.com/scummvm/scummvm/commit/e679672de4aac5db8098ab26e89f9eba91a2f4c7
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-06T16:52:45+01:00

Commit Message:
TWINE: reduced scope and code duplication

Changed paths:
    engines/twine/animations.cpp


diff --git a/engines/twine/animations.cpp b/engines/twine/animations.cpp
index 00235bfbb9..00d7065098 100644
--- a/engines/twine/animations.cpp
+++ b/engines/twine/animations.cpp
@@ -77,55 +77,44 @@ Animations::~Animations() {
 }
 
 int32 Animations::setAnimAtKeyframe(int32 keyframeIdx, uint8 *animPtr, uint8 *bodyPtr, AnimTimerDataStruct *animTimerDataPtr) {
-	int16 numOfKeyframeInAnim;
-	int16 numOfBonesInAnim;
-	uint8 *ptrToData;
-	uint8 *ptrToDataBackup;
-	uint8 *ptrToBodyData;
-	int16 bodyHeader;
-	int16 numOfElementInBody;
-	int16 numOfPointInBody;
-	int32 i;
-
-	numOfKeyframeInAnim = *(int16 *)(animPtr);
-
+	const int16 numOfKeyframeInAnim = *(int16 *)(animPtr);
 	if (keyframeIdx >= numOfKeyframeInAnim) {
 		return numOfKeyframeInAnim;
 	}
 
-	numOfBonesInAnim = *(int16 *)(animPtr + 2);
+	int16 numOfBonesInAnim = *(int16 *)(animPtr + 2);
 
-	ptrToData = (uint8 *)((numOfBonesInAnim * 8 + 8) * keyframeIdx + animPtr + 8);
+	uint8 *ptrToData = (uint8 *)((numOfBonesInAnim * 8 + 8) * keyframeIdx + animPtr + 8);
 
-	bodyHeader = *(int16 *)(bodyPtr);
+	const int16 bodyHeader = *(int16 *)(bodyPtr);
 
 	if (!(bodyHeader & 2)) {
 		return 0;
 	}
 
-	ptrToBodyData = bodyPtr + 14;
+	uint8 *ptrToBodyData = bodyPtr + 14;
 
 	animTimerDataPtr->ptr = ptrToData;
 	animTimerDataPtr->time = _engine->lbaTime;
 
 	ptrToBodyData = ptrToBodyData + *(int16 *)(ptrToBodyData) + 2;
 
-	numOfElementInBody = *(int16 *)(ptrToBodyData);
+	const int16 numOfElementInBody = *(int16 *)(ptrToBodyData);
 
 	ptrToBodyData = ptrToBodyData + numOfElementInBody * 6 + 12;
 
-	numOfPointInBody = *(int16 *)(ptrToBodyData - 10); // num elements
+	const int16 numOfPointInBody = *(int16 *)(ptrToBodyData - 10); // num elements
 
 	if (numOfBonesInAnim > numOfPointInBody) {
 		numOfBonesInAnim = numOfPointInBody;
 	}
 
-	ptrToDataBackup = ptrToData;
+	uint8 *ptrToDataBackup = ptrToData;
 
 	ptrToData += 8;
 
 	do {
-		for (i = 0; i < 8; i++) {
+		for (int32 i = 0; i < 8; i++) {
 			*(ptrToBodyData++) = *(ptrToData++);
 		}
 
@@ -146,31 +135,26 @@ int32 Animations::setAnimAtKeyframe(int32 keyframeIdx, uint8 *animPtr, uint8 *bo
 }
 
 int32 Animations::getNumKeyframes(uint8 *animPtr) {
-	return (*(int16 *)(animPtr));
+	return READ_LE_INT16(animPtr);
 }
 
 int32 Animations::getStartKeyframe(uint8 *animPtr) {
-	return (*(int16 *)(animPtr + 4));
+	return READ_LE_INT16(animPtr + 4);
 }
 
 void Animations::applyAnimStepRotation(uint8 **ptr, int32 bp, int32 bx) {
-	int16 *dest;
-	int16 lastAngle;
-	int16 newAngle;
-	int16 angleDif;
-	int16 computedAngle;
-
-	lastAngle = *(const int16 *)(lastKeyFramePtr);
+	int16 lastAngle = *(const int16 *)(lastKeyFramePtr);
 	lastKeyFramePtr += 2;
 
-	newAngle = *(const int16 *)(keyFramePtr);
+	int16 newAngle = *(const int16 *)(keyFramePtr);
 	keyFramePtr += 2;
 
 	lastAngle &= 0x3FF;
 	newAngle &= 0x3FF;
 
-	angleDif = newAngle - lastAngle;
+	int16 angleDif = newAngle - lastAngle;
 
+	int16 computedAngle;
 	if (angleDif) {
 		if (angleDif < -0x200) {
 			angleDif += 0x400;
@@ -183,44 +167,35 @@ void Animations::applyAnimStepRotation(uint8 **ptr, int32 bp, int32 bx) {
 		computedAngle = lastAngle;
 	}
 
-	dest = (int16 *)*(ptr);
+	int16 *dest = (int16 *)*(ptr);
 	*dest = computedAngle & 0x3FF;
 	*(ptr) = *(ptr) + 2;
 }
 
 void Animations::applyAnimStep(uint8 **ptr, int32 bp, int32 bx) {
-	int16 *dest;
-	int16 lastAngle;
-	int16 newAngle;
-	int16 angleDif;
-	int16 computedAngle;
-
-	lastAngle = *(const int16 *)lastKeyFramePtr;
+	int16 lastAngle = *(const int16 *)lastKeyFramePtr;
 	lastKeyFramePtr += 2;
 
-	newAngle = *(const int16 *)keyFramePtr;
+	int16 newAngle = *(const int16 *)keyFramePtr;
 	keyFramePtr += 2;
 
-	angleDif = newAngle - lastAngle;
+	int16 angleDif = newAngle - lastAngle;
 
+	int16 computedAngle;
 	if (angleDif) {
 		computedAngle = lastAngle + (angleDif * bp) / bx;
 	} else {
 		computedAngle = lastAngle;
 	}
 
-	dest = (int16 *)*(ptr);
+	int16 *dest = (int16 *)*(ptr);
 	*dest = computedAngle;
 	*(ptr) = *(ptr) + 2;
 }
 
 int32 Animations::getAnimMode(uint8 **ptr) {
-	int16 *lptr;
-	int16 opcode;
-
-	lptr = (int16 *)*ptr;
-
-	opcode = *(int16 *)(keyFramePtr);
+	int16 *lptr = (int16 *)*ptr;
+	int16 opcode = *(int16 *)(keyFramePtr);
 	*(int16 *)(lptr) = opcode;
 
 	keyFramePtr += 2;
@@ -315,28 +290,20 @@ int32 Animations::setModelAnimation(int32 animState, uint8 *animPtr, uint8 *body
 			int16 animOpcode = getAnimMode(&edi);
 
 			switch (animOpcode) {
-			case 0: { // allow global rotate
+			case 0:  // allow global rotate
 				applyAnimStepRotation(&edi, eax, keyFrameLength);
 				applyAnimStepRotation(&edi, eax, keyFrameLength);
 				applyAnimStepRotation(&edi, eax, keyFrameLength);
 				break;
-			}
-			case 1: { // dissallow global rotate
-				applyAnimStep(&edi, eax, keyFrameLength);
-				applyAnimStep(&edi, eax, keyFrameLength);
-				applyAnimStep(&edi, eax, keyFrameLength);
-				break;
-			}
-			case 2: { // dissallow global rotate + hide
+			case 1:  // dissallow global rotate
+			case 2:  // dissallow global rotate + hide
 				applyAnimStep(&edi, eax, keyFrameLength);
 				applyAnimStep(&edi, eax, keyFrameLength);
 				applyAnimStep(&edi, eax, keyFrameLength);
 				break;
-			}
-			default: {
+			default:
 				error("Unsupported animation rotation mode %d!\n", animOpcode);
 			}
-			}
 
 			edi += 30;
 		} while (--tmpNumOfPoints);
@@ -350,7 +317,7 @@ int32 Animations::setModelAnimation(int32 animState, uint8 *animPtr, uint8 *body
 }
 
 int32 Animations::getBodyAnimIndex(AnimationTypes animIdx, int32 actorIdx) {
-	uint8 *costumePtr = NULL;
+	uint8 *costumePtr = nullptr;
 
 	ActorStruct *actor = _engine->_scene->getActor(actorIdx);
 	uint8 *bodyPtr = actor->entityDataPtr;


Commit: d2aa0068ec987f2a2b50b5ea23a315a2d6ef8c75
    https://github.com/scummvm/scummvm/commit/d2aa0068ec987f2a2b50b5ea23a315a2d6ef8c75
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-06T16:52:45+01:00

Commit Message:
TWINE: const

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


diff --git a/engines/twine/animations.cpp b/engines/twine/animations.cpp
index 00d7065098..eac0e82b88 100644
--- a/engines/twine/animations.cpp
+++ b/engines/twine/animations.cpp
@@ -134,11 +134,11 @@ int32 Animations::setAnimAtKeyframe(int32 keyframeIdx, uint8 *animPtr, uint8 *bo
 	return 1;
 }
 
-int32 Animations::getNumKeyframes(uint8 *animPtr) {
+int32 Animations::getNumKeyframes(const uint8 *animPtr) {
 	return READ_LE_INT16(animPtr);
 }
 
-int32 Animations::getStartKeyframe(uint8 *animPtr) {
+int32 Animations::getStartKeyframe(const uint8 *animPtr) {
 	return READ_LE_INT16(animPtr + 4);
 }
 
@@ -814,15 +814,15 @@ void Animations::processActorAnimations(int32 actorIdx) { // DoAnim
 							if (_engine->_movements->processActorZ <= actor->lastZ) {
 								updatePos = 1;
 							}
-						} else if (actor->angle == 0x100) {
+						} else if (actor->angle == 256) {
 							if (_engine->_movements->processActorX <= actor->lastX) {
 								updatePos = 1;
 							}
-						} else if (actor->angle == 0x200) {
+						} else if (actor->angle == 512) {
 							if (_engine->_movements->processActorZ >= actor->lastZ) {
 								updatePos = 1;
 							}
-						} else if (actor->angle == 0x300) {
+						} else if (actor->angle == 768) {
 							if (_engine->_movements->processActorX >= actor->lastX) {
 								updatePos = 1;
 							}
@@ -1006,7 +1006,7 @@ void Animations::processActorAnimations(int32 actorIdx) { // DoAnim
 			_engine->_renderer->destZ += _engine->_movements->processActorZ;
 
 			if (_engine->_renderer->destX >= 0 && _engine->_renderer->destZ >= 0 && _engine->_renderer->destX <= 0x7E00 && _engine->_renderer->destZ <= 0x7E00) {
-				if (_engine->_grid->getBrickShape(_engine->_renderer->destX, _engine->_movements->processActorY + 0x100, _engine->_renderer->destZ) && _engine->cfgfile.WallCollision == 1) { // avoid wall hit damage
+				if (_engine->_grid->getBrickShape(_engine->_renderer->destX, _engine->_movements->processActorY + 256, _engine->_renderer->destZ) && _engine->cfgfile.WallCollision == 1) { // avoid wall hit damage
 					_engine->_extra->addExtraSpecial(actor->x, actor->y + 1000, actor->z, kHitStars);
 					initAnim(kBigHit, 2, 0, currentlyProcessedActorIdx);
 
diff --git a/engines/twine/animations.h b/engines/twine/animations.h
index cb6b7e854f..8e125b114b 100644
--- a/engines/twine/animations.h
+++ b/engines/twine/animations.h
@@ -80,13 +80,13 @@ public:
 	 * Get total number of keyframes in animation
 	 * @param animPtr Pointer to animation
 	 */
-	int32 getNumKeyframes(uint8 *animPtr);
+	int32 getNumKeyframes(const uint8 *animPtr);
 
 	/**
 	 * Get first keyframes in animation
 	 * @param animPtr Pointer to animation
 	 */
-	int32 getStartKeyframe(uint8 *animPtr);
+	int32 getStartKeyframe(const uint8 *animPtr);
 
 	/**
 	 * Set new body animation


Commit: ac7ad917388807d86b7fd1c280e9762f47e79c9f
    https://github.com/scummvm/scummvm/commit/ac7ad917388807d86b7fd1c280e9762f47e79c9f
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-06T16:52:45+01:00

Commit Message:
TWINE: reduced visibility

Changed paths:
    engines/twine/animations.h


diff --git a/engines/twine/animations.h b/engines/twine/animations.h
index 8e125b114b..9a15238bd8 100644
--- a/engines/twine/animations.h
+++ b/engines/twine/animations.h
@@ -38,6 +38,15 @@ private:
 	int32 getAnimMode(uint8 **ptr);
 	void applyAnimStep(uint8 **ptr, int32 bp, int32 bx);
 
+	/**
+	 * Verify animation at keyframe
+	 * @param animIdx Animation index
+	 * @param animPtr Animation pointer
+	 * @param bodyPtr Body model poitner
+	 * @param animTimerDataPtr Animation time data
+	 */
+	int32 verifyAnimAtKeyframe(int32 animPos, uint8 *animPtr, uint8 *bodyPtr, AnimTimerDataStruct *animTimerDataPtr);
+
 	uint8 *animBuffer1 = nullptr;
 	uint8 *animBuffer2 = nullptr;
 
@@ -111,15 +120,6 @@ public:
 	 */
 	int32 stockAnimation(uint8 *bodyPtr, AnimTimerDataStruct *animTimerDataPtr);
 
-	/**
-	 * Verify animation at keyframe
-	 * @param animIdx Animation index
-	 * @param animPtr Animation pointer
-	 * @param bodyPtr Body model poitner
-	 * @param animTimerDataPtr Animation time data
-	 */
-	int32 verifyAnimAtKeyframe(int32 animPos, uint8 *animPtr, uint8 *bodyPtr, AnimTimerDataStruct *animTimerDataPtr);
-
 	/**
 	 * Initialize animation
 	 * @param newAnim animation to init


Commit: 1b3da881137f36503ddf0efcac823787a1b71d19
    https://github.com/scummvm/scummvm/commit/1b3da881137f36503ddf0efcac823787a1b71d19
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-06T16:52:45+01:00

Commit Message:
TWINE: added comments and bonus zone structs

source http://lbafileinfo.kazekr.net

Changed paths:
    engines/twine/movements.cpp
    engines/twine/movements.h
    engines/twine/scene.cpp
    engines/twine/scene.h


diff --git a/engines/twine/movements.cpp b/engines/twine/movements.cpp
index 6818ca9761..27c5c099bc 100644
--- a/engines/twine/movements.cpp
+++ b/engines/twine/movements.cpp
@@ -449,6 +449,12 @@ void Movements::processActorMovements(int32 actorIdx) {
 	}
 
 	switch (actor->controlMode) {
+	/**
+	 * The Actor's Track Script is stopped. Track Script execution may be started with Life Script of
+	 * the Actor or other Actors (with SET_TRACK(_OBJ) command). This mode does not mean the Actor
+	 * will literally not move, but rather that it's Track Script (also called Move Script) is
+	 * initially stopped. The Actor may move if it is assigned a moving animation.
+	 */
 	case kNoMove:
 	case kFollow2:     // unused
 	case kTrackAttack: // unused
diff --git a/engines/twine/movements.h b/engines/twine/movements.h
index 8c713eb4d6..9a46c8c5e8 100644
--- a/engines/twine/movements.h
+++ b/engines/twine/movements.h
@@ -45,10 +45,41 @@ private:
 	// cursor keys
 	int32 previousLoopActionKey = 0;
 
+	/**
+	 * The Actor is controlled by the player. This works well only for the Hero Actor in general.
+	 * To use it for other Actors they would have to have necessary animations that would be also
+	 * correctly indexed. The primary purpose for this mode is to re-enable player's control over
+	 * the Hero after it has been disabled for some reasons.
+	 */
 	void processManualAction(int actorIdx);
+	/**
+	 * The Actor tries to move towards the target Actor. This only means that it will always face
+	 * in its direction (as fast as the Rotation delay property allows). To make it really follow
+	 * anything it must be assigned a moving Animation first, and the Actor will not stop by itself
+	 * after reaching the target. To make a real following, the Actor's animation must be changed
+	 * for example to standing animation when the Actor is near the target, and changed back to a
+	 * moving animation when it's far from it. The Follow mode handles only the facing angle.
+	 */
 	void processFollowAction(int actorIdx);
+	/**
+	 * Makes the Actor walk and turn by random angles and at random moments. In original game it is
+	 * only used for Nitro-Mecha-Penguins, but it can be used for any 3-D Actor that has standing
+	 * and walking animation (with virtual indexes 0 and 1 respectively). This mode requires the
+	 * Randomize interval (Info1) property to be less or equal to 117, otherwise the Actor will just
+	 * walk without turning. Exact meaning of the property is not known.
+	 */
 	void processRandomAction(int actorIdx);
+	/**
+	 * The Actor's Track Script is run from the first command, and when it reaches END or STOP it
+	 * starts over again.
+	 */
 	void processTrackAction(int actorIdx);
+	/**
+	 * This mode is used to make an Actor follow specified Actor's X and Z (horizontal) coordinates.
+	 * This is mainly used for Sprite Actors to be always above other Sprite Actors (like platforms).
+	 * Unlike the Follow mode, this mode sets the Actor's position. If the Actor is a Sprite Actor,
+	 * its speed is not taken into consideration in this mode.
+	 */
 	void processSameXZAction(int actorIdx);
 
 public:
diff --git a/engines/twine/scene.cpp b/engines/twine/scene.cpp
index a1a3a38af7..ad1c15536b 100644
--- a/engines/twine/scene.cpp
+++ b/engines/twine/scene.cpp
@@ -400,19 +400,18 @@ void Scene::processEnvironmentSound() {
 
 void Scene::processZoneExtraBonus(ZoneStruct *zone) {
 	// bonus not used yet
-	if (zone->infoData.generic.info3) {
+	if (zone->infoData.Bonus.used) {
 		return;
 	}
 	int8 bonusTable[8];
 	int32 numBonus = 0;
 	for (int32 a = 0; a < 5; a++) {
-		if (zone->infoData.generic.info1 & (1 << (a + 4))) {
+		if (zone->infoData.Bonus.typesFlag & (1 << (a + 4))) {
 			bonusTable[numBonus++] = a;
 		}
 	}
 
 	if (numBonus) {
-		int32 angle, index;
 		int8 currentBonus = bonusTable[_engine->getRandomNumber(numBonus)];
 
 		// if bonus is magic an no magic level yet, then give life points
@@ -420,12 +419,13 @@ void Scene::processZoneExtraBonus(ZoneStruct *zone) {
 			currentBonus = 1;
 		}
 
-		angle = _engine->_movements->getAngleAndSetTargetActorDistance(ABS(zone->topRight.x + zone->bottomLeft.x) / 2, ABS(zone->topRight.z + zone->bottomLeft.z) / 2, sceneHero->x, sceneHero->z);
-		index = _engine->_extra->addExtraBonus(ABS(zone->topRight.x + zone->bottomLeft.x) / 2, zone->topRight.y, ABS(zone->topRight.z + zone->bottomLeft.z) / 2, 180, angle, currentBonus + 3, zone->infoData.generic.info2);
+		const int16 amount = zone->infoData.Bonus.amount;
+		const int32 angle = _engine->_movements->getAngleAndSetTargetActorDistance(ABS(zone->topRight.x + zone->bottomLeft.x) / 2, ABS(zone->topRight.z + zone->bottomLeft.z) / 2, sceneHero->x, sceneHero->z);
+		const int32 index = _engine->_extra->addExtraBonus(ABS(zone->topRight.x + zone->bottomLeft.x) / 2, zone->topRight.y, ABS(zone->topRight.z + zone->bottomLeft.z) / 2, 180, angle, currentBonus + 3, amount);
 
 		if (index != -1) {
 			_engine->_extra->extraList[index].type |= 0x400;
-			zone->infoData.generic.info3 = 1; // set as used
+			zone->infoData.Bonus.used = 1; // set as used
 		}
 	}
 }
diff --git a/engines/twine/scene.h b/engines/twine/scene.h
index 15ab840690..6f40621d33 100644
--- a/engines/twine/scene.h
+++ b/engines/twine/scene.h
@@ -78,6 +78,25 @@ struct ZoneStruct {
 			int16 textIdx;
 			int16 textColor;
 		} DisplayText;
+		struct {
+			int16 info0;
+			/**
+			 * Bonus type flags - a bitfield value, of which the bits mean:
+			 * bit 8: clover leaf,
+			 * bit 7: small key,
+			 * bit 6: magic,
+			 * bit 5: life,
+			 * bit 4: money,
+			 * If more than one type of bonus is selected, the actual type of bonus
+			 * will be chosen randomly each time player uses Action.
+			 */
+			int16 typesFlag;
+			int16 amount;
+			/**
+			 * Already used
+			 */
+			int16 used;
+		} Bonus;
 		struct {
 			int16 info0;
 			int16 info1;


Commit: 06f2fa1b58c9960fd25c2b7d4d9e5e74b456ec35
    https://github.com/scummvm/scummvm/commit/06f2fa1b58c9960fd25c2b7d4d9e5e74b456ec35
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-06T16:52:45+01:00

Commit Message:
TWINE: document gameflags according to the lba wiki

http://lbafileinfo.kazekr.net/

Changed paths:
    engines/twine/gamestate.h


diff --git a/engines/twine/gamestate.h b/engines/twine/gamestate.h
index 97dbb72d83..8d6f2d5dee 100644
--- a/engines/twine/gamestate.h
+++ b/engines/twine/gamestate.h
@@ -34,6 +34,9 @@ namespace TwinE {
 #define NUM_GAME_FLAGS 255
 #define NUM_INVENTORY_ITEMS 28
 
+/**
+ * This gameflag indicates that the inventory items are taken from Twinson because he went to jail
+ */
 #define GAMEFLAG_INVENTORY_DISABLED 70
 
 enum InventoryItems {
@@ -89,7 +92,24 @@ private:
 public:
 	GameState(TwinEEngine *engine);
 
-	/** LBA engine game flags to save quest states */
+	/**
+	 * LBA engine game flags to save quest states
+	 *
+	 * 0-27: inventory related
+	 * 28-199: story related
+	 * 200-255: video related
+	 *
+	 * 35: If 0, a zommed sequence of opening the ventilation shaft will be played when Twinsen escapes
+	 * his house after arresting Zoe. Set to 1 after the sequence (also if Twinsen is killed during the arrest).
+	 * 47: Value of 1 indicates that Twinsen has opened the door to the Citadel Island Tavern's basement.
+	 * The door will be always open from now on.
+	 * 70: Set to 1 if inventory items are taken from Twinsen when he goes to jail (inventory is empty),
+	 * set to 0 after he gets back his stuff.
+	 * 92: Set to 1 if the green grobo in the Citadel Island Tavern has told Twinsen about taking Zoe to the
+	 * port and leaving for another island.
+	 * 107: Set to 1 after Twinsen kills yellow groboclone in the Citadel Island Tavern (after the Tavern has
+	 * been closed down). Makes the Tavern open again and groboclone not appear any more.
+	 */
 	// TODO: why not NUM_GAME_FLAGS?
 	uint8 gameFlags[256];
 


Commit: d10913cf1cbcd75a44f4707d3062b5e2ed6a8c37
    https://github.com/scummvm/scummvm/commit/d10913cf1cbcd75a44f4707d3062b5e2ed6a8c37
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-06T16:52:45+01:00

Commit Message:
TWINE: switched from unstable to testing and build by default

Changed paths:
    engines/twine/configure.engine
    engines/twine/detection.cpp


diff --git a/engines/twine/configure.engine b/engines/twine/configure.engine
index 4d301185a2..a1f5eb7fac 100644
--- a/engines/twine/configure.engine
+++ b/engines/twine/configure.engine
@@ -1,3 +1,3 @@
 # This file is included from the main "configure" script
 # add_engine [name] [desc] [build-by-default] [subengines] [base games] [deps]
-add_engine twine "Little Big Adventure" no "" "" "cxx11 highres"
+add_engine twine "Little Big Adventure" yes "" "" "cxx11 highres"
diff --git a/engines/twine/detection.cpp b/engines/twine/detection.cpp
index cca4caf114..69b9c0a04c 100644
--- a/engines/twine/detection.cpp
+++ b/engines/twine/detection.cpp
@@ -42,7 +42,7 @@ static const ADGameDescription twineGameDescriptions[] = {
 		AD_ENTRY1s("LBA.EXE", "c1a887e38283d43f271249ad9f2a73ef", 294025),
 		Common::EN_ANY,
 		Common::kPlatformDOS,
-		ADGF_UNSTABLE,
+		ADGF_TESTING,
 		GUIO1(GUIO_NONE)
 	},
 	{
@@ -51,7 +51,7 @@ static const ADGameDescription twineGameDescriptions[] = {
 		AD_ENTRY1s("LBA.EXE", "c1a887e38283d43f271249ad9f2a73ef", 294025),
 		Common::FR_FRA,
 		Common::kPlatformDOS,
-		ADGF_UNSTABLE,
+		ADGF_TESTING,
 		GUIO1(GUIO_NONE)
 	},
 
@@ -64,7 +64,7 @@ static const ADGameDescription twineGameDescriptions[] = {
 		AD_ENTRY1s("RELENT.EXE", "c1a887e38283d43f271249ad9f2a73ef", 245961),
 		Common::EN_ANY,
 		Common::kPlatformDOS,
-		ADGF_UNSTABLE,
+		ADGF_TESTING,
 		GUIO1(GUIO_NONE)
 	},
 	{
@@ -73,7 +73,7 @@ static const ADGameDescription twineGameDescriptions[] = {
 		AD_ENTRY1s("RELENT.EXE", "c1a887e38283d43f271249ad9f2a73ef", 245961),
 		Common::FR_FRA,
 		Common::kPlatformDOS,
-		ADGF_UNSTABLE,
+		ADGF_TESTING,
 		GUIO1(GUIO_NONE)
 	},
 	{
@@ -82,7 +82,7 @@ static const ADGameDescription twineGameDescriptions[] = {
 		AD_ENTRY1s("RELENT.EXE", "c1a887e38283d43f271249ad9f2a73ef", 245961),
 		Common::DE_DEU,
 		Common::kPlatformDOS,
-		ADGF_UNSTABLE,
+		ADGF_TESTING,
 		GUIO1(GUIO_NONE)
 	},
 	{
@@ -91,7 +91,7 @@ static const ADGameDescription twineGameDescriptions[] = {
 		AD_ENTRY1s("RELENT.EXE", "c1a887e38283d43f271249ad9f2a73ef", 245961),
 		Common::IT_ITA,
 		Common::kPlatformDOS,
-		ADGF_UNSTABLE,
+		ADGF_TESTING,
 		GUIO1(GUIO_NONE)
 	},
 	{
@@ -100,7 +100,7 @@ static const ADGameDescription twineGameDescriptions[] = {
 		AD_ENTRY1s("RELENT.EXE", "c1a887e38283d43f271249ad9f2a73ef", 245961),
 		Common::ES_ESP,
 		Common::kPlatformDOS,
-		ADGF_UNSTABLE,
+		ADGF_TESTING,
 		GUIO1(GUIO_NONE)
 	},
 
@@ -113,7 +113,7 @@ static const ADGameDescription twineGameDescriptions[] = {
 		AD_ENTRY1s("LBA.EXE", "c1a887e38283d43f271249ad9f2a73ef", 258513),
 		Common::EN_ANY,
 		Common::kPlatformDOS,
-		ADGF_UNSTABLE,
+		ADGF_TESTING,
 		GUIO1(GUIO_NONE)
 	},
 	{
@@ -122,7 +122,7 @@ static const ADGameDescription twineGameDescriptions[] = {
 		AD_ENTRY1s("LBA.EXE", "c1a887e38283d43f271249ad9f2a73ef", 258513),
 		Common::FR_FRA,
 		Common::kPlatformDOS,
-		ADGF_UNSTABLE,
+		ADGF_TESTING,
 		GUIO1(GUIO_NONE)
 	},
 	{
@@ -131,7 +131,7 @@ static const ADGameDescription twineGameDescriptions[] = {
 		AD_ENTRY1s("LBA.EXE", "c1a887e38283d43f271249ad9f2a73ef", 258513),
 		Common::DE_DEU,
 		Common::kPlatformDOS,
-		ADGF_UNSTABLE,
+		ADGF_TESTING,
 		GUIO1(GUIO_NONE)
 	},
 	{
@@ -140,7 +140,7 @@ static const ADGameDescription twineGameDescriptions[] = {
 		AD_ENTRY1s("LBA.EXE", "c1a887e38283d43f271249ad9f2a73ef", 258513),
 		Common::IT_ITA,
 		Common::kPlatformDOS,
-		ADGF_UNSTABLE,
+		ADGF_TESTING,
 		GUIO1(GUIO_NONE)
 	},
 	{
@@ -149,7 +149,7 @@ static const ADGameDescription twineGameDescriptions[] = {
 		AD_ENTRY1s("LBA.EXE", "c1a887e38283d43f271249ad9f2a73ef", 258513),
 		Common::ES_ESP,
 		Common::kPlatformDOS,
-		ADGF_UNSTABLE,
+		ADGF_TESTING,
 		GUIO1(GUIO_NONE)
 	},
 
@@ -162,7 +162,7 @@ static const ADGameDescription twineGameDescriptions[] = {
 		AD_ENTRY1s("RELENT.EXE", "c1a887e38283d43f271249ad9f2a73ef", 258513),
 		Common::EN_ANY,
 		Common::kPlatformDOS,
-		ADGF_UNSTABLE,
+		ADGF_TESTING,
 		GUIO1(GUIO_NONE)
 	},
 	{
@@ -171,7 +171,7 @@ static const ADGameDescription twineGameDescriptions[] = {
 		AD_ENTRY1s("RELENT.EXE", "c1a887e38283d43f271249ad9f2a73ef", 258513),
 		Common::FR_FRA,
 		Common::kPlatformDOS,
-		ADGF_UNSTABLE,
+		ADGF_TESTING,
 		GUIO1(GUIO_NONE)
 	},
 	{
@@ -180,7 +180,7 @@ static const ADGameDescription twineGameDescriptions[] = {
 		AD_ENTRY1s("RELENT.EXE", "c1a887e38283d43f271249ad9f2a73ef", 258513),
 		Common::DE_DEU,
 		Common::kPlatformDOS,
-		ADGF_UNSTABLE,
+		ADGF_TESTING,
 		GUIO1(GUIO_NONE)
 	},
 	{
@@ -189,7 +189,7 @@ static const ADGameDescription twineGameDescriptions[] = {
 		AD_ENTRY1s("RELENT.EXE", "c1a887e38283d43f271249ad9f2a73ef", 258513),
 		Common::IT_ITA,
 		Common::kPlatformDOS,
-		ADGF_UNSTABLE,
+		ADGF_TESTING,
 		GUIO1(GUIO_NONE)
 	},
 	{
@@ -198,7 +198,7 @@ static const ADGameDescription twineGameDescriptions[] = {
 		AD_ENTRY1s("RELENT.EXE", "c1a887e38283d43f271249ad9f2a73ef", 258513),
 		Common::ES_ESP,
 		Common::kPlatformDOS,
-		ADGF_UNSTABLE,
+		ADGF_TESTING,
 		GUIO1(GUIO_NONE)
 	},
 
@@ -211,7 +211,7 @@ static const ADGameDescription twineGameDescriptions[] = {
 		AD_ENTRY1s("FLA_GIF.HQR", "3f7383f65afa212e3eec430627828b64", 1784466),
 		Common::EN_ANY,
 		Common::kPlatformDOS,
-		ADGF_UNSTABLE,
+		ADGF_TESTING,
 		GUIO1(GUIO_NONE)
 	},
 
@@ -224,7 +224,7 @@ static const ADGameDescription twineGameDescriptions[] = {
 		AD_ENTRY1s("LBAJ.EXE", "54a1e8749448e08086a1929510ec4b6a", 278043),
 		Common::JA_JPN,
 		Common::kPlatformDOS,
-		ADGF_UNSTABLE,
+		ADGF_TESTING,
 		GUIO1(GUIO_NONE)
 	},
 
@@ -237,7 +237,7 @@ static const ADGameDescription twineGameDescriptions[] = {
 		AD_ENTRY1s("LBA.DOT", "6dc00342c80bc41b4ff5a43c560c7abc", 380666496),
 		Common::EN_ANY,
 		Common::kPlatformDOS,
-		ADGF_UNSTABLE,
+		ADGF_TESTING,
 		GUIO1(GUIO_NONE)
 	},
 	{
@@ -246,7 +246,7 @@ static const ADGameDescription twineGameDescriptions[] = {
 		AD_ENTRY1s("LBA.DOT", "6dc00342c80bc41b4ff5a43c560c7abc", 380666496),
 		Common::FR_FRA,
 		Common::kPlatformDOS,
-		ADGF_UNSTABLE,
+		ADGF_TESTING,
 		GUIO1(GUIO_NONE)
 	},
 	{
@@ -255,7 +255,7 @@ static const ADGameDescription twineGameDescriptions[] = {
 		AD_ENTRY1s("LBA.DOT", "6dc00342c80bc41b4ff5a43c560c7abc", 380666496),
 		Common::DE_DEU,
 		Common::kPlatformDOS,
-		ADGF_UNSTABLE,
+		ADGF_TESTING,
 		GUIO1(GUIO_NONE)
 	},
 	{
@@ -264,7 +264,7 @@ static const ADGameDescription twineGameDescriptions[] = {
 		AD_ENTRY1s("LBA.DOT", "6dc00342c80bc41b4ff5a43c560c7abc", 380666496),
 		Common::IT_ITA,
 		Common::kPlatformDOS,
-		ADGF_UNSTABLE,
+		ADGF_TESTING,
 		GUIO1(GUIO_NONE)
 	},
 	{
@@ -273,7 +273,7 @@ static const ADGameDescription twineGameDescriptions[] = {
 		AD_ENTRY1s("LBA.DOT", "6dc00342c80bc41b4ff5a43c560c7abc", 380666496),
 		Common::ES_ESP,
 		Common::kPlatformDOS,
-		ADGF_UNSTABLE,
+		ADGF_TESTING,
 		GUIO1(GUIO_NONE)
 	},
 
@@ -286,7 +286,7 @@ static const ADGameDescription twineGameDescriptions[] = {
 		AD_ENTRY1s("LBA.exe", "1f176b4329fbc7efc8f9f30f97013c5f", 1165728),
 		Common::EN_ANY,
 		Common::kPlatformWindows,
-		ADGF_UNSTABLE,
+		ADGF_TESTING,
 		GUIO1(GUIO_NONE)
 	},
 	{
@@ -295,7 +295,7 @@ static const ADGameDescription twineGameDescriptions[] = {
 		AD_ENTRY1s("LBA.exe", "1f176b4329fbc7efc8f9f30f97013c5f", 1165728),
 		Common::FR_FRA,
 		Common::kPlatformWindows,
-		ADGF_UNSTABLE,
+		ADGF_TESTING,
 		GUIO1(GUIO_NONE)
 	},
 	{
@@ -304,7 +304,7 @@ static const ADGameDescription twineGameDescriptions[] = {
 		AD_ENTRY1s("LBA.exe", "1f176b4329fbc7efc8f9f30f97013c5f", 1165728),
 		Common::DE_DEU,
 		Common::kPlatformWindows,
-		ADGF_UNSTABLE,
+		ADGF_TESTING,
 		GUIO1(GUIO_NONE)
 	},
 	{
@@ -313,7 +313,7 @@ static const ADGameDescription twineGameDescriptions[] = {
 		AD_ENTRY1s("LBA.exe", "1f176b4329fbc7efc8f9f30f97013c5f", 1165728),
 		Common::IT_ITA,
 		Common::kPlatformWindows,
-		ADGF_UNSTABLE,
+		ADGF_TESTING,
 		GUIO1(GUIO_NONE)
 	},
 	{
@@ -322,7 +322,7 @@ static const ADGameDescription twineGameDescriptions[] = {
 		AD_ENTRY1s("LBA.exe", "1f176b4329fbc7efc8f9f30f97013c5f", 1165728),
 		Common::ES_ESP,
 		Common::kPlatformWindows,
-		ADGF_UNSTABLE,
+		ADGF_TESTING,
 		GUIO1(GUIO_NONE)
 	},
 
@@ -335,7 +335,7 @@ static const ADGameDescription twineGameDescriptions[] = {
 		AD_ENTRY1s("LBA.GOG", "6dc00342c80bc41b4ff5a43c560c7abc", 380666496),
 		Common::EN_ANY,
 		Common::kPlatformDOS,
-		ADGF_UNSTABLE,
+		ADGF_TESTING,
 		GUIO1(GUIO_NONE)
 	},
 	{
@@ -344,7 +344,7 @@ static const ADGameDescription twineGameDescriptions[] = {
 		AD_ENTRY1s("LBA.GOG", "6dc00342c80bc41b4ff5a43c560c7abc", 380666496),
 		Common::FR_FRA,
 		Common::kPlatformDOS,
-		ADGF_UNSTABLE,
+		ADGF_TESTING,
 		GUIO1(GUIO_NONE)
 	},
 	{
@@ -353,7 +353,7 @@ static const ADGameDescription twineGameDescriptions[] = {
 		AD_ENTRY1s("LBA.GOG", "6dc00342c80bc41b4ff5a43c560c7abc", 380666496),
 		Common::DE_DEU,
 		Common::kPlatformDOS,
-		ADGF_UNSTABLE,
+		ADGF_TESTING,
 		GUIO1(GUIO_NONE)
 	},
 	{
@@ -362,7 +362,7 @@ static const ADGameDescription twineGameDescriptions[] = {
 		AD_ENTRY1s("LBA.GOG", "6dc00342c80bc41b4ff5a43c560c7abc", 380666496),
 		Common::IT_ITA,
 		Common::kPlatformDOS,
-		ADGF_UNSTABLE,
+		ADGF_TESTING,
 		GUIO1(GUIO_NONE)
 	},
 	{
@@ -371,7 +371,7 @@ static const ADGameDescription twineGameDescriptions[] = {
 		AD_ENTRY1s("LBA.GOG", "6dc00342c80bc41b4ff5a43c560c7abc", 380666496),
 		Common::ES_ESP,
 		Common::kPlatformDOS,
-		ADGF_UNSTABLE,
+		ADGF_TESTING,
 		GUIO1(GUIO_NONE)
 	},
 
@@ -384,7 +384,7 @@ static const ADGameDescription twineGameDescriptions[] = {
 		AD_ENTRY1s("TEXT.HQR", "2a8df71946aa9ee4c777a9d6414b89ce", 282308),
 		Common::PT_POR,
 		Common::kPlatformDOS,
-		ADGF_UNSTABLE,
+		ADGF_TESTING,
 		GUIO1(GUIO_NONE)
 	},
 
@@ -395,7 +395,7 @@ static const ADGameDescription twineGameDescriptions[] = {
 		AD_ENTRY1s("text.hqr", "7f41b5e8efb07dd413f59377e03b1b04", 413920),
 		Common::PL_POL,
 		Common::kPlatformDOS,
-		ADGF_UNSTABLE,
+		ADGF_TESTING,
 		GUIO1(GUIO_NONE)
 	},
 
@@ -406,7 +406,7 @@ static const ADGameDescription twineGameDescriptions[] = {
 		AD_ENTRY1s("TEXT.HQR", "31d760b41a424ec2926f494d7ecac14a", 410709),
 		Common::HU_HUN,
 		Common::kPlatformDOS,
-		ADGF_UNSTABLE,
+		ADGF_TESTING,
 		GUIO1(GUIO_NONE)
 	},
 
@@ -417,7 +417,7 @@ static const ADGameDescription twineGameDescriptions[] = {
 		AD_ENTRY1s("TEXT.HQR", "c1adf48ea71fead82d91c5b062eeeb99", 75866),
 		Common::HE_ISR,
 		Common::kPlatformDOS,
-		ADGF_UNSTABLE,
+		ADGF_TESTING,
 		GUIO1(GUIO_NONE)
 	},
 
@@ -428,7 +428,7 @@ static const ADGameDescription twineGameDescriptions[] = {
 		AD_ENTRY1s("TEXT.HQR", "2bf227f9e8fcdc7397372b68786c446e", 283631),
 		Common::PT_BRA,
 		Common::kPlatformDOS,
-		ADGF_UNSTABLE,
+		ADGF_TESTING,
 		GUIO1(GUIO_NONE)
 	},
 
@@ -439,7 +439,7 @@ static const ADGameDescription twineGameDescriptions[] = {
 		AD_ENTRY1s("TEXT.HQR", "93b1a29711f0750156280012e53fdcd2", 280306),
 		Common::RU_RUS,
 		Common::kPlatformDOS,
-		ADGF_UNSTABLE,
+		ADGF_TESTING,
 		GUIO1(GUIO_NONE)
 	},
 


Commit: 13acddb564b529096850ce0c0e93de2a46ed9f24
    https://github.com/scummvm/scummvm/commit/13acddb564b529096850ce0c0e93de2a46ed9f24
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-06T16:52:45+01:00

Commit Message:
TWINE: comment for missing lHOLOMAP_TRAJ implementation

Changed paths:
    engines/twine/script_life_v1.cpp


diff --git a/engines/twine/script_life_v1.cpp b/engines/twine/script_life_v1.cpp
index 4b07841902..70e22becdd 100644
--- a/engines/twine/script_life_v1.cpp
+++ b/engines/twine/script_life_v1.cpp
@@ -1378,9 +1378,10 @@ static int32 lANIM_SET(TwinEEngine *engine, LifeScriptContext &ctx) {
 	return 0;
 }
 
+/** Displays holomap travel animation */
 /*0x60*/
 static int32 lHOLOMAP_TRAJ(TwinEEngine *engine, LifeScriptContext &ctx) {
-	ctx.stream.skip(1);
+	ctx.stream.skip(1); // index of the holomap trajectory
 	return -1;
 }
 


Commit: 3de2bda92c974a1d5afcce6605794ad549396e7c
    https://github.com/scummvm/scummvm/commit/3de2bda92c974a1d5afcce6605794ad549396e7c
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-06T16:52:45+01:00

Commit Message:
TWINE: fixed compiler warnings

Changed paths:
    engines/twine/movements.cpp


diff --git a/engines/twine/movements.cpp b/engines/twine/movements.cpp
index 27c5c099bc..4e79279acc 100644
--- a/engines/twine/movements.cpp
+++ b/engines/twine/movements.cpp
@@ -106,7 +106,7 @@ int32 Movements::getAngleAndSetTargetActorDistance(int32 x1, int32 z1, int32 x2,
 		flag = 0;
 	}
 
-	targetActorDistance = (int32)sqrt((int64)(newX + newZ));
+	targetActorDistance = (int32)sqrt((int64)newX + (int64)newZ);
 
 	if (!targetActorDistance) {
 		return 0;
@@ -191,11 +191,11 @@ void Movements::rotateActor(int32 x, int32 z, int32 angle) {
 }
 
 int32 Movements::getDistance2D(int32 x1, int32 z1, int32 x2, int32 z2) {
-	return (int32)sqrt((int64)((x2 - x1) * (x2 - x1) + (z2 - z1) * (z2 - z1)));
+	return (int32)sqrt(((int64)(x2 - x1) * (int64)(x2 - x1) + (int64)(z2 - z1) * (int64)(z2 - z1)));
 }
 
 int32 Movements::getDistance3D(int32 x1, int32 y1, int32 z1, int32 x2, int32 y2, int32 z2) {
-	return (int32)sqrt((int64)((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1) + (z2 - z1) * (z2 - z1)));
+	return (int32)sqrt(((int64)(x2 - x1) * (int64)(x2 - x1) + (int64)(y2 - y1) * (int64)(y2 - y1) + (int64)(z2 - z1) * (int64)(z2 - z1)));
 }
 
 void Movements::moveActor(int32 angleFrom, int32 angleTo, int32 speed, ActorMoveStruct *movePtr) { // ManualRealAngle


Commit: ec062fb11216236d1eefe0d793bacaa75d3d7ffb
    https://github.com/scummvm/scummvm/commit/ec062fb11216236d1eefe0d793bacaa75d3d7ffb
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-06T16:52:45+01:00

Commit Message:
TWINE: reduced scope

Changed paths:
    engines/twine/renderer.cpp


diff --git a/engines/twine/renderer.cpp b/engines/twine/renderer.cpp
index 058651d295..1a49cab4df 100644
--- a/engines/twine/renderer.cpp
+++ b/engines/twine/renderer.cpp
@@ -1005,15 +1005,10 @@ int32 Renderer::renderModelElements(uint8 *pointer) {
 	const lineData *lineDataPtr;
 	lineCoordinates *lineCoordinatesPtr;
 
-	int32 point1;
-
-	int32 point2;
-
 	int32 depth;
 	int32 bestDepth;
 	int32 currentDepth;
 	int16 bestZ;
-	int32 j;
 	int32 bestPoly = 0;
 	int16 shadeEntry;
 	int16 shadeValue;
@@ -1021,7 +1016,6 @@ int32 Renderer::renderModelElements(uint8 *pointer) {
 	int16 ax, bx, cx;
 
 	uint8 *destPtr;
-	int32 i;
 
 	uint8 *render23;
 	uint8 *render24;
@@ -1086,8 +1080,9 @@ int32 Renderer::renderModelElements(uint8 *pointer) {
 
 					currentDepth = currentVertex->Z;
 
-					if (currentDepth > bestDepth)
+					if (currentDepth > bestDepth) {
 						bestDepth = currentDepth;
+					}
 				} while (--counter);
 			} else if (polyRenderType >= 7) { // only 1 shade value is used
 				destinationHeader = (polyHeader *)edi;
@@ -1123,8 +1118,9 @@ int32 Renderer::renderModelElements(uint8 *pointer) {
 
 					currentDepth = currentVertex->Z;
 
-					if (currentDepth > bestDepth)
+					if (currentDepth > bestDepth) {
 						bestDepth = currentDepth;
+					}
 				} while (--counter);
 			} else { // no shade is used
 				destinationHeader = (polyHeader *)edi;
@@ -1210,7 +1206,6 @@ int32 Renderer::renderModelElements(uint8 *pointer) {
 	if (temp) {
 		numOfPrimitives += temp;
 		do {
-			int32 param;
 			lineDataPtr = (const lineData *)pointer;
 			lineCoordinatesPtr = (lineCoordinates *)edi;
 
@@ -1218,9 +1213,9 @@ int32 Renderer::renderModelElements(uint8 *pointer) {
 				error("RENDER ERROR: lineDataPtr reference is malformed!");
 			}
 
-			point1 = *((const int16 *)&lineDataPtr->p1) / 6;
-			point2 = *((const int16 *)&lineDataPtr->p2) / 6;
-			param = *((const int32 *)&lineDataPtr->data);
+			const int32 point1 = *((const int16 *)&lineDataPtr->p1) / 6;
+			const int32 point2 = *((const int16 *)&lineDataPtr->p2) / 6;
+			const int32 param = *((const int32 *)&lineDataPtr->data);
 			*((int32 *)&lineCoordinatesPtr->data) = param;
 			*((int16 *)&lineCoordinatesPtr->x1) = flattenPoints[point1].X;
 			*((int16 *)&lineCoordinatesPtr->y1) = flattenPoints[point1].Y;
@@ -1229,8 +1224,9 @@ int32 Renderer::renderModelElements(uint8 *pointer) {
 			bestDepth = flattenPoints[point1].Z;
 			depth = flattenPoints[point2].Z;
 
-			if (depth >= bestDepth)
+			if (depth >= bestDepth) {
 				bestDepth = depth;
+			}
 
 			renderTabEntryPtr->depth = bestDepth;
 			renderTabEntryPtr->renderType = 0;
@@ -1271,10 +1267,10 @@ int32 Renderer::renderModelElements(uint8 *pointer) {
 	renderTabEntryPtr2 = renderTab;
 
 	renderTabSortedPtr = renderTabSorted;
-	for (i = 0; i < numOfPrimitives; i++) { // then we sort the polygones | WARNING: very slow | TODO: improve this
+	for (int32 i = 0; i < numOfPrimitives; i++) { // then we sort the polygones | WARNING: very slow | TODO: improve this
 		renderTabEntryPtr2 = renderTab;
 		bestZ = -0x7FFF;
-		for (j = 0; j < numOfPrimitives; j++) {
+		for (int32 j = 0; j < numOfPrimitives; j++) {
 			if (renderTabEntryPtr2->depth > bestZ) {
 				bestZ = renderTabEntryPtr2->depth;
 				bestPoly = j;
@@ -1302,18 +1298,13 @@ int32 Renderer::renderModelElements(uint8 *pointer) {
 
 			switch (type) {
 			case RENDERTYPE_DRAWLINE: { // draw a line
-				int32 x1;
-				int32 y1;
-				int32 x2;
-				int32 y2;
-
 				lineCoordinatesPtr = (lineCoordinates *)pointer;
 				color = (*((int32 *)&lineCoordinatesPtr->data) & 0xFF00) >> 8;
 
-				x1 = *((const int16 *)&lineCoordinatesPtr->x1);
-				y1 = *((const int16 *)&lineCoordinatesPtr->y1);
-				x2 = *((const int16 *)&lineCoordinatesPtr->x2);
-				y2 = *((const int16 *)&lineCoordinatesPtr->y2);
+				const int32 x1 = *((const int16 *)&lineCoordinatesPtr->x1);
+				const int32 y1 = *((const int16 *)&lineCoordinatesPtr->y1);
+				const int32 x2 = *((const int16 *)&lineCoordinatesPtr->x2);
+				const int32 y2 = *((const int16 *)&lineCoordinatesPtr->y2);
 
 				_engine->_interface->drawLine(x1, y1, x2, y2, color);
 				break;
@@ -1328,7 +1319,7 @@ int32 Renderer::renderModelElements(uint8 *pointer) {
 
 				destPtr = (uint8 *)vertexCoordinates;
 
-				for (i = 0; i < (numOfVertex * 3); i++) {
+				for (int32 i = 0; i < (numOfVertex * 3); i++) {
 					*((int16 *)destPtr) = *((const int16 *)pointer);
 					destPtr += 2;
 					pointer += 2;
@@ -1341,18 +1332,12 @@ int32 Renderer::renderModelElements(uint8 *pointer) {
 				break;
 			}
 			case RENDERTYPE_DRAWSPHERE: { // draw a sphere
-				int32 circleParam1;
-				//int32 circleParam2;
-				int32 circleParam3;
-				int32 circleParam4;
-				int32 circleParam5;
-
 				eax = *(const int *)pointer;
 
-				circleParam1 = *(const uint8 *)pointer;
-				circleParam4 = *((const int16 *)(pointer + 1));
-				circleParam5 = *((const int16 *)(pointer + 3));
-				circleParam3 = *((const int16 *)(pointer + 5));
+				const int32 circleParam1 = *(const uint8 *)pointer;
+				const int32 circleParam4 = *((const int16 *)(pointer + 1));
+				const int32 circleParam5 = *((const int16 *)(pointer + 3));
+				int32 circleParam3 = *((const int16 *)(pointer + 5));
 
 				if (!isUsingOrhoProjection) {
 					circleParam3 = (circleParam3 * cameraPosY) / (cameraPosX + *(const int16 *)pointer);
@@ -1362,25 +1347,29 @@ int32 Renderer::renderModelElements(uint8 *pointer) {
 
 				circleParam3 += 3;
 
-				if (circleParam4 + circleParam3 > _engine->_redraw->renderRight)
+				if (circleParam4 + circleParam3 > _engine->_redraw->renderRight) {
 					_engine->_redraw->renderRight = circleParam4 + circleParam3;
+				}
 
-				if (circleParam4 - circleParam3 < _engine->_redraw->renderLeft)
+				if (circleParam4 - circleParam3 < _engine->_redraw->renderLeft) {
 					_engine->_redraw->renderLeft = circleParam4 - circleParam3;
+				}
 
-				if (circleParam5 + circleParam3 > _engine->_redraw->renderBottom)
+				if (circleParam5 + circleParam3 > _engine->_redraw->renderBottom) {
 					_engine->_redraw->renderBottom = circleParam5 + circleParam3;
+				}
 
-				if (circleParam5 - circleParam3 < _engine->_redraw->renderTop)
+				if (circleParam5 - circleParam3 < _engine->_redraw->renderTop) {
 					_engine->_redraw->renderTop = circleParam5 - circleParam3;
+				}
 
 				circleParam3 -= 3;
 
 				circleFill(circleParam4, circleParam5, circleParam3, circleParam1);
-			}
-			default: {
 				break;
 			}
+			default:
+				break;
 			}
 
 			pointer = renderV19;
@@ -1391,10 +1380,10 @@ int32 Renderer::renderModelElements(uint8 *pointer) {
 		_engine->_redraw->renderBottom = -1;
 		_engine->_redraw->renderLeft = -1;
 		_engine->_redraw->renderTop = -1;
-		return (-1);
+		return -1;
 	}
 
-	return (0);
+	return 0;
 }
 
 int32 Renderer::renderAnimatedModel(uint8 *bodyPtr) {


Commit: 089c62b274868ccfdadb630ac1041e8a96901814
    https://github.com/scummvm/scummvm/commit/089c62b274868ccfdadb630ac1041e8a96901814
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-06T16:52:45+01:00

Commit Message:
TWINE: reduced scope

Changed paths:
    engines/twine/renderer.cpp


diff --git a/engines/twine/renderer.cpp b/engines/twine/renderer.cpp
index 1a49cab4df..d70f68a598 100644
--- a/engines/twine/renderer.cpp
+++ b/engines/twine/renderer.cpp
@@ -1013,8 +1013,6 @@ int32 Renderer::renderModelElements(uint8 *pointer) {
 	int16 shadeEntry;
 	int16 shadeValue;
 
-	int16 ax, bx, cx;
-
 	uint8 *destPtr;
 
 	uint8 *render23;
@@ -1162,8 +1160,8 @@ int32 Renderer::renderModelElements(uint8 *pointer) {
 
 			render25 = bestDepth;
 
-			ax = *((int16 *)(edi + 4));
-			bx = *((int16 *)(edi + 8));
+			int16 ax = *((int16 *)(edi + 4));
+			int16 bx = *((int16 *)(edi + 8));
 
 			ax -= *((int16 *)(edi + 16));
 			bx -= *((int16 *)(edi + 2));
@@ -1174,7 +1172,7 @@ int32 Renderer::renderModelElements(uint8 *pointer) {
 			bx = currentDepth;
 
 			ax = *((int16 *)(edi + 2));
-			cx = *((int16 *)(edi + 10));
+			int16 cx = *((int16 *)(edi + 10));
 
 			ax -= *((int16 *)(edi + 14));
 			cx -= *((int16 *)(edi + 4));


Commit: 2d0791a893fdfd6c1f018523843e96ca855dd2c6
    https://github.com/scummvm/scummvm/commit/2d0791a893fdfd6c1f018523843e96ca855dd2c6
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-06T16:52:45+01:00

Commit Message:
TWINE: reduced scope

Changed paths:
    engines/twine/renderer.cpp


diff --git a/engines/twine/renderer.cpp b/engines/twine/renderer.cpp
index d70f68a598..8ca1f726dd 100644
--- a/engines/twine/renderer.cpp
+++ b/engines/twine/renderer.cpp
@@ -1002,9 +1002,6 @@ int32 Renderer::renderModelElements(uint8 *pointer) {
 	int16 type;
 	int16 color;
 
-	const lineData *lineDataPtr;
-	lineCoordinates *lineCoordinatesPtr;
-
 	int32 depth;
 	int32 bestDepth;
 	int32 currentDepth;
@@ -1013,8 +1010,6 @@ int32 Renderer::renderModelElements(uint8 *pointer) {
 	int16 shadeEntry;
 	int16 shadeValue;
 
-	uint8 *destPtr;
-
 	uint8 *render23;
 	uint8 *render24;
 	int32 render25;
@@ -1150,8 +1145,9 @@ int32 Renderer::renderModelElements(uint8 *pointer) {
 
 					currentDepth = currentVertex->Z;
 
-					if (currentDepth > bestDepth)
+					if (currentDepth > bestDepth) {
 						bestDepth = currentDepth;
+					}
 				} while (--(counter));
 			}
 
@@ -1204,8 +1200,8 @@ int32 Renderer::renderModelElements(uint8 *pointer) {
 	if (temp) {
 		numOfPrimitives += temp;
 		do {
-			lineDataPtr = (const lineData *)pointer;
-			lineCoordinatesPtr = (lineCoordinates *)edi;
+			const lineData *lineDataPtr = (const lineData *)pointer;
+			lineCoordinates *lineCoordinatesPtr = (lineCoordinates *)edi;
 
 			if (*((const int16 *)&lineDataPtr->p1) % 6 != 0 || *((const int16 *)&lineDataPtr->p2) % 6 != 0) {
 				error("RENDER ERROR: lineDataPtr reference is malformed!");
@@ -1296,7 +1292,7 @@ int32 Renderer::renderModelElements(uint8 *pointer) {
 
 			switch (type) {
 			case RENDERTYPE_DRAWLINE: { // draw a line
-				lineCoordinatesPtr = (lineCoordinates *)pointer;
+				lineCoordinates *lineCoordinatesPtr = (lineCoordinates *)pointer;
 				color = (*((int32 *)&lineCoordinatesPtr->data) & 0xFF00) >> 8;
 
 				const int32 x1 = *((const int16 *)&lineCoordinatesPtr->x1);
@@ -1315,7 +1311,7 @@ int32 Renderer::renderModelElements(uint8 *pointer) {
 				numOfVertex = (eax & 0xFF00) >> 8;
 				color = (eax & 0xFF0000) >> 16;
 
-				destPtr = (uint8 *)vertexCoordinates;
+				uint8 *destPtr = (uint8 *)vertexCoordinates;
 
 				for (int32 i = 0; i < (numOfVertex * 3); i++) {
 					*((int16 *)destPtr) = *((const int16 *)pointer);


Commit: 11e76319c5cc15077f02df228a62cd73f44690e4
    https://github.com/scummvm/scummvm/commit/11e76319c5cc15077f02df228a62cd73f44690e4
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-06T16:52:45+01:00

Commit Message:
TWINE: reduced scope

Changed paths:
    engines/twine/renderer.cpp


diff --git a/engines/twine/renderer.cpp b/engines/twine/renderer.cpp
index 8ca1f726dd..8abf72383c 100644
--- a/engines/twine/renderer.cpp
+++ b/engines/twine/renderer.cpp
@@ -993,26 +993,23 @@ void Renderer::circleFill(int32 x, int32 y, int32 radius, int8 color) {
 }
 
 int32 Renderer::renderModelElements(uint8 *pointer) {
-	uint8 *edi;
-	int16 temp;
-	int32 eax;
-	//	int32 ecx;
-
 	int16 counter;
 	int16 type;
 	int16 color;
+	int16 bestZ;
+	int16 shadeEntry;
+	int16 shadeValue;
 
 	int32 depth;
 	int32 bestDepth;
 	int32 currentDepth;
-	int16 bestZ;
 	int32 bestPoly = 0;
-	int16 shadeEntry;
-	int16 shadeValue;
+	int32 render25;
+	int32 eax;
+	//	int32 ecx;
 
 	uint8 *render23;
 	uint8 *render24;
-	int32 render25;
 
 	polyVertexHeader *currentPolyVertex;
 	polyHeader *currentPolyHeader;
@@ -1023,8 +1020,8 @@ int32 Renderer::renderModelElements(uint8 *pointer) {
 
 	// prepare polygons
 
-	edi = renderTab7;           // renderTab7 coordinates buffer
-	temp = *((int16 *)pointer); // we read the number of polygons
+	uint8 *edi = renderTab7;           // renderTab7 coordinates buffer
+	int16 temp = *((int16 *)pointer); // we read the number of polygons
 	pointer += 2;
 
 	if (temp) {


Commit: d8f49ca4de20e8d9bc73f709cf38543a9b7007cd
    https://github.com/scummvm/scummvm/commit/d8f49ca4de20e8d9bc73f709cf38543a9b7007cd
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-06T16:52:45+01:00

Commit Message:
TWINE: reduced scope and made members lowercase

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


diff --git a/engines/twine/renderer.cpp b/engines/twine/renderer.cpp
index 8abf72383c..0049432a64 100644
--- a/engines/twine/renderer.cpp
+++ b/engines/twine/renderer.cpp
@@ -250,9 +250,9 @@ void Renderer::applyPointsRotation(const uint8 *firstPointsPtr, int32 numPoints,
 		const int16 tmpY = tempPtr[1];
 		const int16 tmpZ = tempPtr[2];
 
-		destPoints->X = ((rotationMatrix[0] * tmpX + rotationMatrix[1] * tmpY + rotationMatrix[2] * tmpZ) >> 14) + destX;
-		destPoints->Y = ((rotationMatrix[3] * tmpX + rotationMatrix[4] * tmpY + rotationMatrix[5] * tmpZ) >> 14) + destY;
-		destPoints->Z = ((rotationMatrix[6] * tmpX + rotationMatrix[7] * tmpY + rotationMatrix[8] * tmpZ) >> 14) + destZ;
+		destPoints->x = ((rotationMatrix[0] * tmpX + rotationMatrix[1] * tmpY + rotationMatrix[2] * tmpZ) >> 14) + destX;
+		destPoints->y = ((rotationMatrix[3] * tmpX + rotationMatrix[4] * tmpY + rotationMatrix[5] * tmpZ) >> 14) + destY;
+		destPoints->z = ((rotationMatrix[6] * tmpX + rotationMatrix[7] * tmpY + rotationMatrix[8] * tmpZ) >> 14) + destZ;
 
 		destPoints++;
 		firstPointsPtr = pointsPtr2 + 6;
@@ -286,9 +286,9 @@ void Renderer::processRotatedElement(int32 rotZ, int32 rotY, int32 rotX, const e
 		int32 pointIdx = (elemPtr->basePoint) / 6;
 		currentMatrix = (const int32 *)((const uint8 *)matricesTable + baseElement);
 
-		destX = computedPoints[pointIdx].X;
-		destY = computedPoints[pointIdx].Y;
-		destZ = computedPoints[pointIdx].Z;
+		destX = computedPoints[pointIdx].x;
+		destY = computedPoints[pointIdx].y;
+		destZ = computedPoints[pointIdx].z;
 	}
 
 	applyRotation((int32 *)currentMatrixTableEntry, currentMatrix);
@@ -311,9 +311,9 @@ void Renderer::applyPointsTranslation(const uint8 *firstPointsPtr, int32 numPoin
 		const int16 tmpY = tempPtr[1] + renderAngleY;
 		const int16 tmpZ = tempPtr[2] + renderAngleX;
 
-		destPoints->X = ((translationMatrix[0] * tmpX + translationMatrix[1] * tmpY + translationMatrix[2] * tmpZ) >> 14) + destX;
-		destPoints->Y = ((translationMatrix[3] * tmpX + translationMatrix[4] * tmpY + translationMatrix[5] * tmpZ) >> 14) + destY;
-		destPoints->Z = ((translationMatrix[6] * tmpX + translationMatrix[7] * tmpY + translationMatrix[8] * tmpZ) >> 14) + destZ;
+		destPoints->x = ((translationMatrix[0] * tmpX + translationMatrix[1] * tmpY + translationMatrix[2] * tmpZ) >> 14) + destX;
+		destPoints->y = ((translationMatrix[3] * tmpX + translationMatrix[4] * tmpY + translationMatrix[5] * tmpZ) >> 14) + destY;
+		destPoints->z = ((translationMatrix[6] * tmpX + translationMatrix[7] * tmpY + translationMatrix[8] * tmpZ) >> 14) + destZ;
 
 		destPoints++;
 		firstPointsPtr = pointsPtr2 + 6;
@@ -336,9 +336,9 @@ void Renderer::processTranslatedElement(int32 rotX, int32 rotY, int32 rotZ, cons
 			dest[i] = baseMatrix[i];
 		}
 	} else { // dependent
-		destX = computedPoints[(elemPtr->basePoint) / 6].X;
-		destY = computedPoints[(elemPtr->basePoint) / 6].Y;
-		destZ = computedPoints[(elemPtr->basePoint) / 6].Z;
+		destX = computedPoints[(elemPtr->basePoint) / 6].x;
+		destY = computedPoints[(elemPtr->basePoint) / 6].y;
+		destZ = computedPoints[(elemPtr->basePoint) / 6].z;
 
 		const int32 *source = (const int32 *)((const uint8 *)matricesTable + elemPtr->baseElement);
 		int32 *dest = (int32 *)currentMatrixTableEntry;
@@ -1011,10 +1011,6 @@ int32 Renderer::renderModelElements(uint8 *pointer) {
 	uint8 *render23;
 	uint8 *render24;
 
-	polyVertexHeader *currentPolyVertex;
-	polyHeader *currentPolyHeader;
-	polyHeader *destinationHeader;
-	computedVertex *currentComputedVertex;
 	pointTab *currentVertex;
 	pointTab *destinationVertex;
 
@@ -1029,14 +1025,14 @@ int32 Renderer::renderModelElements(uint8 *pointer) {
 
 		do { // loop that load all the polygons
 			render23 = edi;
-			currentPolyHeader = (polyHeader *)pointer;
+			polyHeader *currentPolyHeader = (polyHeader *)pointer;
 			//ecx = *((int32*) pointer);
 			pointer += 2;
 			polyRenderType = currentPolyHeader->renderType;
 
 			// TODO: RECHECK coordinates axis
 			if (polyRenderType >= 9) {
-				destinationHeader = (polyHeader *)edi;
+				polyHeader *destinationHeader = (polyHeader *)edi;
 
 				destinationHeader->renderType = currentPolyHeader->renderType - 2;
 				destinationHeader->numOfVertex = currentPolyHeader->numOfVertex;
@@ -1051,31 +1047,31 @@ int32 Renderer::renderModelElements(uint8 *pointer) {
 				renderV19 = edi;
 
 				do {
-					currentPolyVertex = (polyVertexHeader *)pointer;
+					polyVertexHeader *currentPolyVertex = (polyVertexHeader *)pointer;
 
 					shadeValue = currentPolyHeader->colorIndex + shadeTable[currentPolyVertex->shadeEntry];
 
-					currentComputedVertex = (computedVertex *)edi;
+					computedVertex *currentComputedVertex = (computedVertex *)edi;
 
 					currentComputedVertex->shadeValue = shadeValue;
 
 					currentVertex = &flattenPoints[currentPolyVertex->dataOffset / 6];
 					destinationVertex = (pointTab *)(edi + 2);
 
-					destinationVertex->X = currentVertex->X;
-					destinationVertex->Y = currentVertex->Y;
+					destinationVertex->x = currentVertex->x;
+					destinationVertex->y = currentVertex->y;
 
 					edi += 6;
 					pointer += 4;
 
-					currentDepth = currentVertex->Z;
+					currentDepth = currentVertex->z;
 
 					if (currentDepth > bestDepth) {
 						bestDepth = currentDepth;
 					}
 				} while (--counter);
 			} else if (polyRenderType >= 7) { // only 1 shade value is used
-				destinationHeader = (polyHeader *)edi;
+				polyHeader *destinationHeader = (polyHeader *)edi;
 
 				destinationHeader->renderType = currentPolyHeader->renderType - 7;
 				destinationHeader->numOfVertex = currentPolyHeader->numOfVertex;
@@ -1101,19 +1097,19 @@ int32 Renderer::renderModelElements(uint8 *pointer) {
 
 					destinationVertex = (pointTab *)(edi + 2);
 
-					destinationVertex->X = currentVertex->X;
-					destinationVertex->Y = currentVertex->Y;
+					destinationVertex->x = currentVertex->x;
+					destinationVertex->y = currentVertex->y;
 
 					edi += 6;
 
-					currentDepth = currentVertex->Z;
+					currentDepth = currentVertex->z;
 
 					if (currentDepth > bestDepth) {
 						bestDepth = currentDepth;
 					}
 				} while (--counter);
 			} else { // no shade is used
-				destinationHeader = (polyHeader *)edi;
+				polyHeader *destinationHeader = (polyHeader *)edi;
 
 				destinationHeader->renderType = currentPolyHeader->renderType;
 				destinationHeader->numOfVertex = currentPolyHeader->numOfVertex;
@@ -1135,12 +1131,12 @@ int32 Renderer::renderModelElements(uint8 *pointer) {
 
 					destinationVertex = (pointTab *)(edi + 2);
 
-					destinationVertex->X = currentVertex->X;
-					destinationVertex->Y = currentVertex->Y;
+					destinationVertex->x = currentVertex->x;
+					destinationVertex->y = currentVertex->y;
 
 					edi += 6;
 
-					currentDepth = currentVertex->Z;
+					currentDepth = currentVertex->z;
 
 					if (currentDepth > bestDepth) {
 						bestDepth = currentDepth;
@@ -1208,12 +1204,12 @@ int32 Renderer::renderModelElements(uint8 *pointer) {
 			const int32 point2 = *((const int16 *)&lineDataPtr->p2) / 6;
 			const int32 param = *((const int32 *)&lineDataPtr->data);
 			*((int32 *)&lineCoordinatesPtr->data) = param;
-			*((int16 *)&lineCoordinatesPtr->x1) = flattenPoints[point1].X;
-			*((int16 *)&lineCoordinatesPtr->y1) = flattenPoints[point1].Y;
-			*((int16 *)&lineCoordinatesPtr->x2) = flattenPoints[point2].X;
-			*((int16 *)&lineCoordinatesPtr->y2) = flattenPoints[point2].Y;
-			bestDepth = flattenPoints[point1].Z;
-			depth = flattenPoints[point2].Z;
+			*((int16 *)&lineCoordinatesPtr->x1) = flattenPoints[point1].x;
+			*((int16 *)&lineCoordinatesPtr->y1) = flattenPoints[point1].y;
+			*((int16 *)&lineCoordinatesPtr->x2) = flattenPoints[point2].x;
+			*((int16 *)&lineCoordinatesPtr->y2) = flattenPoints[point2].y;
+			bestDepth = flattenPoints[point1].z;
+			depth = flattenPoints[point2].z;
 
 			if (depth >= bestDepth) {
 				bestDepth = depth;
@@ -1241,11 +1237,11 @@ int32 Renderer::renderModelElements(uint8 *pointer) {
 			int16 size = *((uint16 *)(pointer + 4));
 
 			*(uint8 *)edi = color2;
-			*((int16 *)(edi + 1)) = flattenPoints[center / 6].X;
-			*((int16 *)(edi + 3)) = flattenPoints[center / 6].Y;
+			*((int16 *)(edi + 1)) = flattenPoints[center / 6].x;
+			*((int16 *)(edi + 3)) = flattenPoints[center / 6].y;
 			*((int16 *)(edi + 5)) = size;
 
-			renderTabEntryPtr->depth = flattenPoints[center / 6].Z;
+			renderTabEntryPtr->depth = flattenPoints[center / 6].z;
 			renderTabEntryPtr->renderType = 2;
 			renderTabEntryPtr->dataPtr = edi;
 			renderTabEntryPtr++;
@@ -1433,26 +1429,26 @@ int32 Renderer::renderAnimatedModel(uint8 *bodyPtr) {
 
 	if (isUsingOrhoProjection != 0) { // use standard projection
 		do {
-			coX = pointPtr->X + renderX;
-			coY = pointPtr->Y + renderY;
-			coZ = -(pointPtr->Z + renderZ);
+			coX = pointPtr->x + renderX;
+			coY = pointPtr->y + renderY;
+			coZ = -(pointPtr->z + renderZ);
 
-			pointPtrDest->X = (coX + coZ) * 24 / 512 + orthoProjX;
-			pointPtrDest->Y = (((coX - coZ) * 12) - coY * 30) / 512 + orthoProjY;
-			pointPtrDest->Z = coZ - coX - coY;
+			pointPtrDest->x = (coX + coZ) * 24 / 512 + orthoProjX;
+			pointPtrDest->y = (((coX - coZ) * 12) - coY * 30) / 512 + orthoProjY;
+			pointPtrDest->z = coZ - coX - coY;
 
-			if (pointPtrDest->X < _engine->_redraw->renderLeft) {
-				_engine->_redraw->renderLeft = pointPtrDest->X;
+			if (pointPtrDest->x < _engine->_redraw->renderLeft) {
+				_engine->_redraw->renderLeft = pointPtrDest->x;
 			}
-			if (pointPtrDest->X > _engine->_redraw->renderRight) {
-				_engine->_redraw->renderRight = pointPtrDest->X;
+			if (pointPtrDest->x > _engine->_redraw->renderRight) {
+				_engine->_redraw->renderRight = pointPtrDest->x;
 			}
 
-			if (pointPtrDest->Y < _engine->_redraw->renderTop) {
-				_engine->_redraw->renderTop = pointPtrDest->Y;
+			if (pointPtrDest->y < _engine->_redraw->renderTop) {
+				_engine->_redraw->renderTop = pointPtrDest->y;
 			}
-			if (pointPtrDest->Y > _engine->_redraw->renderBottom) {
-				_engine->_redraw->renderBottom = pointPtrDest->Y;
+			if (pointPtrDest->y > _engine->_redraw->renderBottom) {
+				_engine->_redraw->renderBottom = pointPtrDest->y;
 			}
 
 			pointPtr++;
@@ -1460,9 +1456,9 @@ int32 Renderer::renderAnimatedModel(uint8 *bodyPtr) {
 		} while (--numOfPrimitives);
 	} else {
 		do {
-			coX = pointPtr->X + renderX;
-			coY = pointPtr->Y + renderY;
-			coZ = -(pointPtr->Z + renderZ);
+			coX = pointPtr->x + renderX;
+			coY = pointPtr->y + renderY;
+			coZ = -(pointPtr->z + renderZ);
 
 			coZ += cameraPosX;
 
@@ -1473,39 +1469,44 @@ int32 Renderer::renderAnimatedModel(uint8 *bodyPtr) {
 			{
 				coX = orthoProjX + ((coX * cameraPosY) / coZ);
 
-				if (coX > 0xFFFF)
+				if (coX > 0xFFFF) {
 					coX = 0x7FFF;
+				}
 
-				pointPtrDest->X = coX;
+				pointPtrDest->x = coX;
 
-				if (pointPtrDest->X < _engine->_redraw->renderLeft)
-					_engine->_redraw->renderLeft = pointPtrDest->X;
+				if (pointPtrDest->x < _engine->_redraw->renderLeft) {
+					_engine->_redraw->renderLeft = pointPtrDest->x;
+				}
 
-				if (pointPtrDest->X > _engine->_redraw->renderRight)
-					_engine->_redraw->renderRight = pointPtrDest->X;
+				if (pointPtrDest->x > _engine->_redraw->renderRight) {
+					_engine->_redraw->renderRight = pointPtrDest->x;
+				}
 			}
 
 			// Y projection
 			{
 				coY = orthoProjY + ((-coY * cameraPosZ) / coZ);
 
-				if (coY > 0xFFFF)
+				if (coY > 0xFFFF) {
 					coY = 0x7FFF;
+				}
 
-				pointPtrDest->Y = coY;
+				pointPtrDest->y = coY;
 
-				if (pointPtrDest->Y < _engine->_redraw->renderTop)
-					_engine->_redraw->renderTop = pointPtrDest->Y;
-				if (pointPtrDest->Y > _engine->_redraw->renderBottom)
-					_engine->_redraw->renderBottom = pointPtrDest->Y;
+				if (pointPtrDest->y < _engine->_redraw->renderTop)
+					_engine->_redraw->renderTop = pointPtrDest->y;
+				if (pointPtrDest->y > _engine->_redraw->renderBottom)
+					_engine->_redraw->renderBottom = pointPtrDest->y;
 			}
 
 			// Z projection
 			{
-				if (coZ > 0xFFFF)
+				if (coZ > 0xFFFF) {
 					coZ = 0x7FFF;
+				}
 
-				pointPtrDest->Z = coZ;
+				pointPtrDest->z = coZ;
 			}
 
 			pointPtr++;
diff --git a/engines/twine/renderer.h b/engines/twine/renderer.h
index 72bd360f69..30fefbce17 100644
--- a/engines/twine/renderer.h
+++ b/engines/twine/renderer.h
@@ -38,9 +38,9 @@ private:
 	};
 
 	struct pointTab {
-		int16 X = 0;
-		int16 Y = 0;
-		int16 Z = 0;
+		int16 x = 0;
+		int16 y = 0;
+		int16 z = 0;
 	};
 
 	struct elementEntry {


Commit: c94c4d2878bc9565789d21dae3949506dc80f36c
    https://github.com/scummvm/scummvm/commit/c94c4d2878bc9565789d21dae3949506dc80f36c
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-06T16:52:45+01:00

Commit Message:
TWINE: reduced scope

Changed paths:
    engines/twine/renderer.cpp


diff --git a/engines/twine/renderer.cpp b/engines/twine/renderer.cpp
index 0049432a64..0e95ed8c89 100644
--- a/engines/twine/renderer.cpp
+++ b/engines/twine/renderer.cpp
@@ -1377,10 +1377,6 @@ int32 Renderer::renderAnimatedModel(uint8 *bodyPtr) {
 	elementEntry *elemEntryPtr;
 	const pointTab *pointPtr;
 	pointTab *pointPtrDest;
-	int32 coX;
-	int32 coY;
-	int32 coZ;
-	const uint8 *tmpElemPtr;
 	//	int32 *tmpLightMatrix;
 	const uint8 *tmpShadePtr;
 	int32 numOfShades;
@@ -1429,9 +1425,9 @@ int32 Renderer::renderAnimatedModel(uint8 *bodyPtr) {
 
 	if (isUsingOrhoProjection != 0) { // use standard projection
 		do {
-			coX = pointPtr->x + renderX;
-			coY = pointPtr->y + renderY;
-			coZ = -(pointPtr->z + renderZ);
+			const int32 coX = pointPtr->x + renderX;
+			const int32 coY = pointPtr->y + renderY;
+			const int32 coZ = -(pointPtr->z + renderZ);
 
 			pointPtrDest->x = (coX + coZ) * 24 / 512 + orthoProjX;
 			pointPtrDest->y = (((coX - coZ) * 12) - coY * 30) / 512 + orthoProjY;
@@ -1456,9 +1452,9 @@ int32 Renderer::renderAnimatedModel(uint8 *bodyPtr) {
 		} while (--numOfPrimitives);
 	} else {
 		do {
-			coX = pointPtr->x + renderX;
-			coY = pointPtr->y + renderY;
-			coZ = -(pointPtr->z + renderZ);
+			int32 coX = pointPtr->x + renderX;
+			int32 coY = pointPtr->y + renderY;
+			int32 coZ = -(pointPtr->z + renderZ);
 
 			coZ += cameraPosX;
 
@@ -1523,7 +1519,6 @@ int32 Renderer::renderAnimatedModel(uint8 *bodyPtr) {
 
 	if (numOfShades) { // process normal data
 		int32 color;
-		int32 shade;
 
 		uint8 *currentShadeDestination = (uint8 *)shadeTable;
 		int32 *lightMatrix = matricesTable;
@@ -1531,7 +1526,7 @@ int32 Renderer::renderAnimatedModel(uint8 *bodyPtr) {
 
 		numOfPrimitives = numOfElements;
 
-		tmpElemPtr = pri2Ptr3 = elementsPtr2 + 18;
+		const uint8 *tmpElemPtr = pri2Ptr3 = elementsPtr2 + 18;
 
 		do { // for each element
 			numOfShades = *((const uint16 *)tmpElemPtr);
@@ -1552,23 +1547,17 @@ int32 Renderer::renderAnimatedModel(uint8 *bodyPtr) {
 				shadeMatrix[8] = (*(lightMatrix + 8)) * lightZ;
 
 				do { // for each normal
-					int16 col1;
-					int16 col2;
-					int16 col3;
+					const int16 *colPtr = (const int16 *)shadePtr;
 
-					const int16 *colPtr;
-
-					colPtr = (const int16 *)shadePtr;
-
-					col1 = *((const int16 *)colPtr++);
-					col2 = *((const int16 *)colPtr++);
-					col3 = *((const int16 *)colPtr++);
+					int16 col1 = *((const int16 *)colPtr++);
+					int16 col2 = *((const int16 *)colPtr++);
+					int16 col3 = *((const int16 *)colPtr++);
 
 					color = shadeMatrix[0] * col1 + shadeMatrix[1] * col2 + shadeMatrix[2] * col3;
 					color += shadeMatrix[3] * col1 + shadeMatrix[4] * col2 + shadeMatrix[5] * col3;
 					color += shadeMatrix[6] * col1 + shadeMatrix[7] * col2 + shadeMatrix[8] * col3;
 
-					shade = 0;
+					int32 shade = 0;
 
 					if (color > 0) {
 						color >>= 14;


Commit: a372f14cf8b6f9c595012380a6cd2b3cfdba70c3
    https://github.com/scummvm/scummvm/commit/a372f14cf8b6f9c595012380a6cd2b3cfdba70c3
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-06T16:52:45+01:00

Commit Message:
TWINE: reduced scope and members

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


diff --git a/engines/twine/renderer.cpp b/engines/twine/renderer.cpp
index 0e95ed8c89..d4a76cf6a5 100644
--- a/engines/twine/renderer.cpp
+++ b/engines/twine/renderer.cpp
@@ -259,7 +259,7 @@ void Renderer::applyPointsRotation(const uint8 *firstPointsPtr, int32 numPoints,
 	} while (--numOfPoints2);
 }
 
-void Renderer::processRotatedElement(int32 rotZ, int32 rotY, int32 rotX, const elementEntry *elemPtr) { // unsigned char * elemPtr) // loadPart
+void Renderer::processRotatedElement(const uint8 *pointsPtr, int32 rotZ, int32 rotY, int32 rotX, const elementEntry *elemPtr) { // unsigned char * elemPtr) // loadPart
 	int32 firstPoint = elemPtr->firstPoint;
 	int32 numOfPoints2 = elemPtr->numOfPoints;
 
@@ -320,7 +320,7 @@ void Renderer::applyPointsTranslation(const uint8 *firstPointsPtr, int32 numPoin
 	} while (--numOfPoints2);
 }
 
-void Renderer::processTranslatedElement(int32 rotX, int32 rotY, int32 rotZ, const elementEntry *elemPtr) {
+void Renderer::processTranslatedElement(const uint8 *pointsPtr, int32 rotX, int32 rotY, int32 rotZ, const elementEntry *elemPtr) {
 	renderAngleX = rotX;
 	renderAngleY = rotY;
 	renderAngleZ = rotZ;
@@ -412,7 +412,6 @@ FORCEINLINE int16 clamp(int16 x, int16 a, int16 b) {
 
 int32 Renderer::computePolygons() {
 	pRenderV1 = vertexCoordinates;
-	pRenderV2 = pRenderV3;
 
 	vertexData *vertices = (vertexData *)vertexCoordinates;
 
@@ -627,7 +626,7 @@ void Renderer::renderPolygons(int32 renderType, int32 color) {
 		unsigned short int dx;
 		unsigned short int temp;
 		bx = (unsigned short)color << 0x10;
-		renderLoop = vsize;
+		int32 renderLoop = vsize;
 		do {
 			while (1) {
 				start = ptr1[0];
@@ -767,7 +766,7 @@ void Renderer::renderPolygons(int32 renderType, int32 color) {
 		break;
 	}
 	case POLYGONTYPE_GOURAUD: {
-		renderLoop = vsize;
+		int32 renderLoop = vsize;
 		currentLine = vtop;
 		do {
 			if (currentLine >= 0 && currentLine < 480) {
@@ -848,7 +847,7 @@ void Renderer::renderPolygons(int32 renderType, int32 color) {
 		break;
 	}
 	case POLYGONTYPE_DITHER: { // dithering
-		renderLoop = vsize;
+		int32 renderLoop = vsize;
 
 		currentLine = vtop;
 		do {
@@ -992,7 +991,7 @@ void Renderer::circleFill(int32 x, int32 y, int32 radius, int8 color) {
 	}
 }
 
-int32 Renderer::renderModelElements(uint8 *pointer) {
+int32 Renderer::renderModelElements(int32 numOfPrimitives, uint8 *pointer) {
 	int16 counter;
 	int16 type;
 	int16 color;
@@ -1021,7 +1020,7 @@ int32 Renderer::renderModelElements(uint8 *pointer) {
 	pointer += 2;
 
 	if (temp) {
-		primitiveCounter = temp; // the number of primitives = the number of polygons
+		int16 primitiveCounter = temp; // the number of primitives = the number of polygons
 
 		do { // loop that load all the polygons
 			render23 = edi;
@@ -1251,7 +1250,7 @@ int32 Renderer::renderModelElements(uint8 *pointer) {
 		} while (--temp);
 	}
 
-	renderTabEntryPtr2 = renderTab;
+	const renderTabEntry *renderTabEntryPtr2 = renderTab;
 
 	renderTabSortedPtr = renderTabSorted;
 	for (int32 i = 0; i < numOfPrimitives; i++) { // then we sort the polygones | WARNING: very slow | TODO: improve this
@@ -1275,7 +1274,7 @@ int32 Renderer::renderModelElements(uint8 *pointer) {
 	// prepare to render elements
 
 	if (numOfPrimitives) {
-		primitiveCounter = numOfPrimitives;
+		int16 primitiveCounter = numOfPrimitives;
 		renderV19 = pointer;
 
 		do {
@@ -1374,30 +1373,28 @@ int32 Renderer::renderModelElements(uint8 *pointer) {
 }
 
 int32 Renderer::renderAnimatedModel(uint8 *bodyPtr) {
-	elementEntry *elemEntryPtr;
-	const pointTab *pointPtr;
-	pointTab *pointPtrDest;
 	//	int32 *tmpLightMatrix;
-	const uint8 *tmpShadePtr;
-	int32 numOfShades;
-
-	numOfPoints = *((const uint16 *)bodyPtr);
+	int32 numOfPoints = *((const uint16 *)bodyPtr);
 	bodyPtr += 2;
-	pointsPtr = bodyPtr;
+	const uint8 *pointsPtr = bodyPtr;
 
 	bodyPtr += numOfPoints * 6;
 
-	numOfElements = *((const uint16 *)bodyPtr);
+	int32 numOfElements = *((const uint16 *)bodyPtr);
 	bodyPtr += 2;
-	elementsPtr = elementsPtr2 = bodyPtr;
+
+	uint8 *elementsPtr = bodyPtr;
+	uint8 *elementsPtr2 = elementsPtr;
 
 	currentMatrixTableEntry = (uint8 *)matricesTable;
 
-	processRotatedElement(renderAngleX, renderAngleY, renderAngleZ, (const elementEntry *)elementsPtr);
+	processRotatedElement(pointsPtr, renderAngleX, renderAngleY, renderAngleZ, (const elementEntry *)elementsPtr);
 
 	elementsPtr += 38;
 
-	elemEntryPtr = (elementEntry *)elementsPtr;
+	elementEntry *elemEntryPtr = (elementEntry *)elementsPtr;
+
+	int32 numOfPrimitives = 0;
 
 	if (numOfElements - 1 != 0) {
 		numOfPrimitives = numOfElements - 1;
@@ -1407,9 +1404,9 @@ int32 Renderer::renderAnimatedModel(uint8 *bodyPtr) {
 			int16 boneType = elemEntryPtr->flag;
 
 			if (boneType == 0) {
-				processRotatedElement(elemEntryPtr->rotateX, elemEntryPtr->rotateY, elemEntryPtr->rotateZ, elemEntryPtr); // rotation
+				processRotatedElement(pointsPtr, elemEntryPtr->rotateX, elemEntryPtr->rotateY, elemEntryPtr->rotateZ, elemEntryPtr); // rotation
 			} else if (boneType == 1) {
-				processTranslatedElement(elemEntryPtr->rotateX, elemEntryPtr->rotateY, elemEntryPtr->rotateZ, elemEntryPtr); // translation
+				processTranslatedElement(pointsPtr, elemEntryPtr->rotateX, elemEntryPtr->rotateY, elemEntryPtr->rotateZ, elemEntryPtr); // translation
 			}
 
 			currentMatrixTableEntry += 36;
@@ -1420,8 +1417,8 @@ int32 Renderer::renderAnimatedModel(uint8 *bodyPtr) {
 
 	numOfPrimitives = numOfPoints;
 
-	pointPtr = (pointTab *)computedPoints;
-	pointPtrDest = (pointTab *)flattenPoints;
+	const pointTab *pointPtr = (pointTab *)computedPoints;
+	pointTab *pointPtrDest = (pointTab *)flattenPoints;
 
 	if (isUsingOrhoProjection != 0) { // use standard projection
 		do {
@@ -1513,7 +1510,7 @@ int32 Renderer::renderAnimatedModel(uint8 *bodyPtr) {
 
 	shadePtr = (int32 *)elementsPtr;
 
-	numOfShades = *((const uint16 *)shadePtr);
+	int32 numOfShades = *((const uint16 *)shadePtr);
 
 	shadePtr = (int32 *)(((uint8 *)shadePtr) + 2);
 
@@ -1561,7 +1558,7 @@ int32 Renderer::renderAnimatedModel(uint8 *bodyPtr) {
 
 					if (color > 0) {
 						color >>= 14;
-						tmpShadePtr = (const uint8 *)shadePtr;
+						const uint8 *tmpShadePtr = (const uint8 *)shadePtr;
 						color /= *((const uint16 *)(tmpShadePtr + 6));
 						shade = (uint16)color;
 					}
@@ -1578,7 +1575,7 @@ int32 Renderer::renderAnimatedModel(uint8 *bodyPtr) {
 		} while (--numOfPrimitives);
 	}
 
-	return renderModelElements((uint8 *)shadePtr);
+	return renderModelElements(numOfPrimitives, (uint8 *)shadePtr);
 }
 
 void Renderer::prepareIsoModel(uint8 *bodyPtr) { // loadGfxSub
@@ -1649,9 +1646,6 @@ int32 Renderer::renderIsoModel(int32 X, int32 Y, int32 Z, int32 angleX, int32 an
 		renderZ = Z;
 	}
 
-	// reset the number of primitives in the model
-	numOfPrimitives = 0;
-
 	// restart at the beginning of the renderTable
 	renderTabEntryPtr = renderTab;
 
diff --git a/engines/twine/renderer.h b/engines/twine/renderer.h
index 30fefbce17..c732373a96 100644
--- a/engines/twine/renderer.h
+++ b/engines/twine/renderer.h
@@ -120,14 +120,14 @@ private:
 
 	int32 renderAnimatedModel(uint8 *bodyPtr);
 	void circleFill(int32 x, int32 y, int32 radius, int8 color);
-	int32 renderModelElements(uint8 *pointer);
+	int32 renderModelElements(int32 numOfPrimitives, uint8 *pointer);
 	void getBaseRotationPosition(int32 x, int32 y, int32 z);
 	void getCameraAnglePositions(int32 x, int32 y, int32 z);
 	void applyRotation(int32 *tempMatrix, const int32 *currentMatrix);
 	void applyPointsRotation(const uint8 *firstPointsPtr, int32 numPoints, pointTab *destPoints, const int32 *rotationMatrix);
-	void processRotatedElement(int32 rotZ, int32 rotY, int32 rotX, const elementEntry *elemPtr);
+	void processRotatedElement(const uint8 *pointsPtr, int32 rotZ, int32 rotY, int32 rotX, const elementEntry *elemPtr);
 	void applyPointsTranslation(const uint8 *firstPointsPtr, int32 numPoints, pointTab *destPoints, const int32 *translationMatrix);
-	void processTranslatedElement(int32 rotX, int32 rotY, int32 rotZ, const elementEntry *elemPtr);
+	void processTranslatedElement(const uint8 *pointsPtr, int32 rotX, int32 rotY, int32 rotZ, const elementEntry *elemPtr);
 	void translateGroup(int16 ax, int16 bx, int16 cx);
 
 	// ---- variables ----
@@ -162,16 +162,6 @@ private:
 
 	int32 baseMatrix[3 * 3] {0};
 
-	int32 numOfPrimitives = 0;
-
-	int32 numOfPoints = 0;
-	int32 numOfElements = 0;
-	const uint8 *pointsPtr = nullptr;
-	uint8 *elementsPtr = nullptr;
-	uint8 *elementsPtr2 = nullptr;
-
-	const uint8 *pri2Ptr2 = nullptr;
-
 	int32 matricesTable[271] {0};
 	uint8 *currentMatrixTableEntry = nullptr;
 
@@ -185,9 +175,7 @@ private:
 	pointTab flattenPoints[800];  // _flattenPointTable
 	int16 shadeTable[500] {0};
 
-	int16 primitiveCounter = 0;
 	renderTabEntry *renderTabEntryPtr = nullptr;
-	const renderTabEntry *renderTabEntryPtr2 = nullptr;
 	renderTabEntry *renderTabSortedPtr = nullptr;
 
 	renderTabEntry renderTab[1000];
@@ -196,10 +184,6 @@ private:
 
 	uint8 *renderV19 = nullptr; // RECHECK THIS
 
-	// render polygon vars
-	int16 pRenderV3[96] {0};
-	const int16 *pRenderV2 = 0;
-
 	int16 vleft = 0;
 	int16 vtop = 0;
 	int16 vright = 0;
@@ -211,7 +195,6 @@ private:
 
 	int16 polyTab[960] {0};
 	int16 polyTab2[960] {0};
-	int32 renderLoop = 0;
 	// end render polygon vars
 
 	int32 isUsingOrhoProjection = 0;


Commit: 471823b7d497f23e042c918ba30cd64535f5b633
    https://github.com/scummvm/scummvm/commit/471823b7d497f23e042c918ba30cd64535f5b633
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-06T16:52:45+01:00

Commit Message:
TWINE: replaced magic numbers

Changed paths:
    engines/twine/renderer.cpp


diff --git a/engines/twine/renderer.cpp b/engines/twine/renderer.cpp
index d4a76cf6a5..1434e3dab1 100644
--- a/engines/twine/renderer.cpp
+++ b/engines/twine/renderer.cpp
@@ -422,17 +422,21 @@ int32 Renderer::computePolygons() {
 		vertices[i].x = clamp(vertices[i].x, 0, SCREEN_WIDTH - 1);
 		int16 vertexX = vertices[i].x;
 
-		if (vertexX < vleft)
+		if (vertexX < vleft) {
 			vleft = vertexX;
-		if (vertexX > vright)
+		}
+		if (vertexX > vright) {
 			vright = vertexX;
+		}
 
 		vertices[i].y = clamp(vertices[i].y, 0, SCREEN_HEIGHT - 1);
 		int16 vertexY = vertices[i].y;
-		if (vertexY < vtop)
+		if (vertexY < vtop) {
 			vtop = vertexY;
-		if (vertexY > vbottom)
+		}
+		if (vertexY > vbottom) {
 			vbottom = vertexY;
+		}
 	}
 
 	vertexParam1 = vertexParam2 = vertices[numOfVertex - 1].param;
@@ -476,7 +480,7 @@ int32 Renderer::computePolygons() {
 			cvalue = (oldVertexParam << 8) + ((vertexParam2 - oldVertexParam) << 8) % vsize;
 			cdelta = ((vertexParam2 - oldVertexParam) << 8) / vsize;
 		}
-		int16 *outPtr = &polyTab[ypos + (up ? 480 : 0)]; // outPtr is the output ptr in the renderTab
+		int16 *outPtr = &polyTab[ypos + (up ? SCREEN_HEIGHT : 0)]; // outPtr is the output ptr in the renderTab
 
 		int64 slope = (int64)hsize / (int64)vsize;
 		slope = up ? -slope : slope;
@@ -492,7 +496,7 @@ int32 Renderer::computePolygons() {
 		}
 
 		if (polyRenderType >= 7) { // we must compute the color progression
-			int16 *outPtr2 = &polyTab2[ypos + (up ? 480 : 0)];
+			int16 *outPtr2 = &polyTab2[ypos + (up ? SCREEN_HEIGHT : 0)];
 
 			for (int32 i = 0; i < vsize + 2; i++) {
 				if (outPtr2 - polyTab2 < 960) {
@@ -517,7 +521,7 @@ void Renderer::renderPolygons(int32 renderType, int32 color) {
 
 	int16 start, stop;
 
-	uint8 *out = (uint8*)_engine->frontVideoBuffer.getPixels() + 640 * vtop;
+	uint8 *out = (uint8*)_engine->frontVideoBuffer.getPixels() + SCREEN_WIDTH * vtop;
 
 	int16 *ptr1 = &polyTab[vtop];
 	int16 *ptr2 = &polyTab2[vtop];
@@ -529,8 +533,8 @@ void Renderer::renderPolygons(int32 renderType, int32 color) {
 	case POLYGONTYPE_FLAT: {
 		currentLine = vtop;
 		do {
-			if (currentLine >= 0 && currentLine < 480) {
-				stop = ptr1[480];
+			if (currentLine >= 0 && currentLine < SCREEN_HEIGHT) {
+				stop = ptr1[SCREEN_HEIGHT];
 				start = ptr1[0];
 
 				ptr1++;
@@ -541,12 +545,13 @@ void Renderer::renderPolygons(int32 renderType, int32 color) {
 					out2 = start + out;
 
 					for (j = start; j < hsize + start; j++) {
-						if (j >= 0 && j < 640)
+						if (j >= 0 && j < SCREEN_WIDTH) {
 							out[j] = color;
+						}
 					}
 				}
 			}
-			out += 640;
+			out += SCREEN_WIDTH;
 			currentLine++;
 		} while (--vsize);
 		break;
@@ -554,9 +559,9 @@ void Renderer::renderPolygons(int32 renderType, int32 color) {
 	case POLYGONTYPE_COPPER: {
 		currentLine = vtop;
 		do {
-			if (currentLine >= 0 && currentLine < 480) {
+			if (currentLine >= 0 && currentLine < SCREEN_HEIGHT) {
 				start = ptr1[0];
-				stop = ptr1[480];
+				stop = ptr1[SCREEN_HEIGHT];
 
 				ptr1++;
 				hsize = stop - start;
@@ -577,7 +582,7 @@ void Renderer::renderPolygons(int32 renderType, int32 color) {
 						start += mask;
 						start = (start & 0xFF00) | ((start & 0xFF) & (uint8)(dx >> 8));
 						start = (start & 0xFF00) | ((start & 0xFF) + (dx & 0xFF));
-						if (j >= 0 && j < 640) {
+						if (j >= 0 && j < SCREEN_WIDTH) {
 							out[j] = start & 0xFF;
 						}
 						mask = (mask << 2) | (mask >> 14);
@@ -585,7 +590,7 @@ void Renderer::renderPolygons(int32 renderType, int32 color) {
 					}
 				}
 			}
-			out += 640;
+			out += SCREEN_WIDTH;
 			currentLine++;
 		} while (--vsize);
 		break;
@@ -593,9 +598,9 @@ void Renderer::renderPolygons(int32 renderType, int32 color) {
 	case POLYGONTYPE_BOPPER: { // FIXME: buggy
 		currentLine = vtop;
 		do {
-			if (currentLine >= 0 && currentLine < 480) {
+			if (currentLine >= 0 && currentLine < SCREEN_HEIGHT) {
 				start = ptr1[0];
-				stop = ptr1[480];
+				stop = ptr1[SCREEN_HEIGHT];
 				ptr1++;
 				hsize = stop - start;
 
@@ -604,7 +609,7 @@ void Renderer::renderPolygons(int32 renderType, int32 color) {
 					out2 = start + out;
 					for (j = start; j < hsize + start; j++) {
 						if ((start + (vtop % 1)) & 1) {
-							if (j >= 0 && j < 640) {
+							if (j >= 0 && j < SCREEN_WIDTH) {
 								out[j] = color;
 							}
 						}
@@ -612,7 +617,7 @@ void Renderer::renderPolygons(int32 renderType, int32 color) {
 					}
 				}
 			}
-			out += 640;
+			out += SCREEN_WIDTH;
 			currentLine++;
 		} while (--vsize);
 		break;
@@ -630,7 +635,7 @@ void Renderer::renderPolygons(int32 renderType, int32 color) {
 		do {
 			while (1) {
 				start = ptr1[0];
-				stop = ptr1[480];
+				stop = ptr1[SCREEN_HEIGHT];
 				ptr1++;
 				hsize = stop - start;
 
@@ -642,7 +647,7 @@ void Renderer::renderPolygons(int32 renderType, int32 color) {
 
 				color = *(out2 + 1);
 
-				out += 640;
+				out += SCREEN_WIDTH;
 
 				--renderLoop;
 				if (!renderLoop)
@@ -692,7 +697,7 @@ void Renderer::renderPolygons(int32 renderType, int32 color) {
 				}
 			}
 
-			out += 640;
+			out += SCREEN_WIDTH;
 			--renderLoop;
 
 		} while (renderLoop);
@@ -703,7 +708,7 @@ void Renderer::renderPolygons(int32 renderType, int32 color) {
 			unsigned short int bx;
 
 			start = ptr1[0];
-			stop = ptr1[480];
+			stop = ptr1[SCREEN_HEIGHT];
 
 			ptr1++;
 			hsize = stop - start;
@@ -713,9 +718,9 @@ void Renderer::renderPolygons(int32 renderType, int32 color) {
 				out2 = start + out;
 
 				if ((hsize >> 1) < 0) {
-					bx = color & 0x0FF;
+					bx = color & 0xFF;
 					bx = bx << 8;
-					bx += color & 0x0FF;
+					bx += color & 0xFF;
 					for (j = 0; j < hsize; j++) {
 						*(out2) = (*(out2)&0x0F0F) | bx;
 					}
@@ -724,7 +729,7 @@ void Renderer::renderPolygons(int32 renderType, int32 color) {
 					out2++;
 				}
 			}
-			out += 640;
+			out += SCREEN_WIDTH;
 		} while (--vsize);
 		break;
 	}
@@ -733,9 +738,9 @@ void Renderer::renderPolygons(int32 renderType, int32 color) {
 
 		currentLine = vtop;
 		do {
-			if (currentLine >= 0 && currentLine < 480) {
+			if (currentLine >= 0 && currentLine < SCREEN_HEIGHT) {
 				start = ptr1[0];
-				stop = ptr1[480];
+				stop = ptr1[SCREEN_HEIGHT];
 				ptr1++;
 				hsize = stop - start;
 
@@ -760,7 +765,7 @@ void Renderer::renderPolygons(int32 renderType, int32 color) {
 					}
 				}
 			}
-			out += 640;
+			out += SCREEN_WIDTH;
 			currentLine++;
 		} while (--vsize);
 		break;
@@ -769,20 +774,20 @@ void Renderer::renderPolygons(int32 renderType, int32 color) {
 		int32 renderLoop = vsize;
 		currentLine = vtop;
 		do {
-			if (currentLine >= 0 && currentLine < 480) {
+			if (currentLine >= 0 && currentLine < SCREEN_HEIGHT) {
 				uint16 startColor = ptr2[0];
-				uint16 stopColor = ptr2[480];
+				uint16 stopColor = ptr2[SCREEN_HEIGHT];
 
 				int16 colorSize = stopColor - startColor;
 
-				stop = ptr1[480]; // stop
+				stop = ptr1[SCREEN_HEIGHT]; // stop
 				start = ptr1[0];  // start
 
 				ptr1++;
 				out2 = start + out;
 				hsize = stop - start;
 
-				//varf2 = ptr2[480];
+				//varf2 = ptr2[SCREEN_HEIGHT];
 				//varf3 = ptr2[0];
 
 				ptr2++;
@@ -790,24 +795,30 @@ void Renderer::renderPolygons(int32 renderType, int32 color) {
 				//varf4 = (int64)((int32)varf2 - (int32)varf3);
 
 				if (hsize == 0) {
-					if (start >= 0 && start < 640)
+					if (start >= 0 && start < SCREEN_WIDTH) {
 						*out2 = ((startColor + stopColor) / 2) >> 8; // moyenne des 2 couleurs
+					}
 				} else if (hsize > 0) {
 					if (hsize == 1) {
-						if (start >= -1 && start < 640 - 1)
+						if (start >= -1 && start < SCREEN_WIDTH - 1) {
 							*(out2 + 1) = stopColor >> 8;
+						}
 
-						if (start >= 0 && start < 640)
+						if (start >= 0 && start < SCREEN_WIDTH) {
 							*(out2) = startColor >> 8;
+						}
 					} else if (hsize == 2) {
-						if (start >= -2 && start < 640 - 2)
+						if (start >= -2 && start < SCREEN_WIDTH - 2) {
 							*(out2 + 2) = stopColor >> 8;
+						}
 
-						if (start >= -1 && start < 640 - 1)
+						if (start >= -1 && start < SCREEN_WIDTH - 1) {
 							*(out2 + 1) = ((startColor + stopColor) / 2) >> 8;
+						}
 
-						if (start >= 0 && start < 640)
+						if (start >= 0 && start < SCREEN_WIDTH) {
 							*(out2) = startColor >> 8;
+						}
 					} else {
 						int32 currentXPos = start;
 						colorSize /= hsize;
@@ -815,8 +826,9 @@ void Renderer::renderPolygons(int32 renderType, int32 color) {
 
 						if (hsize % 2) {
 							hsize /= 2;
-							if (currentXPos >= 0 && currentXPos < 640)
+							if (currentXPos >= 0 && currentXPos < SCREEN_WIDTH) {
 								*(out2) = startColor >> 8;
+							}
 							out2++;
 							currentXPos++;
 							startColor += colorSize;
@@ -825,14 +837,16 @@ void Renderer::renderPolygons(int32 renderType, int32 color) {
 						}
 
 						do {
-							if (currentXPos >= 0 && currentXPos < 640)
+							if (currentXPos >= 0 && currentXPos < SCREEN_WIDTH) {
 								*(out2) = startColor >> 8;
+							}
 
 							currentXPos++;
 							startColor += colorSize;
 
-							if (currentXPos >= 0 && currentXPos < 640)
+							if (currentXPos >= 0 && currentXPos < SCREEN_WIDTH) {
 								*(out2 + 1) = startColor >> 8;
+							}
 
 							currentXPos++;
 							out2 += 2;
@@ -841,7 +855,7 @@ void Renderer::renderPolygons(int32 renderType, int32 color) {
 					}
 				}
 			}
-			out += 640;
+			out += SCREEN_WIDTH;
 			currentLine++;
 		} while (--renderLoop);
 		break;
@@ -851,23 +865,24 @@ void Renderer::renderPolygons(int32 renderType, int32 color) {
 
 		currentLine = vtop;
 		do {
-			if (currentLine >= 0 && currentLine < 480) {
-				stop = ptr1[480]; // stop
+			if (currentLine >= 0 && currentLine < SCREEN_HEIGHT) {
+				stop = ptr1[SCREEN_HEIGHT]; // stop
 				start = ptr1[0];  // start
 				ptr1++;
 				hsize = stop - start;
 
 				if (hsize >= 0) {
 					uint16 startColor = ptr2[0];
-					uint16 stopColor = ptr2[480];
+					uint16 stopColor = ptr2[SCREEN_HEIGHT];
 					int32 currentXPos = start;
 
 					out2 = start + out;
 					ptr2++;
 
 					if (hsize == 0) {
-						if (currentXPos >= 0 && currentXPos < 640)
+						if (currentXPos >= 0 && currentXPos < SCREEN_WIDTH) {
 							*(out2) = (uint8)(((startColor + stopColor) / 2) >> 8);
+						}
 					} else {
 						int16 colorSize = stopColor - startColor;
 						if (hsize == 1) {
@@ -877,8 +892,9 @@ void Renderer::renderPolygons(int32 renderType, int32 color) {
 
 							currentColor &= 0xFF;
 							currentColor += startColor;
-							if (currentXPos >= 0 && currentXPos < 640)
+							if (currentXPos >= 0 && currentXPos < SCREEN_WIDTH) {
 								*(out2) = currentColor >> 8;
+							}
 
 							currentColor &= 0xFF;
 							startColor += colorSize;
@@ -886,8 +902,9 @@ void Renderer::renderPolygons(int32 renderType, int32 color) {
 							currentColor += startColor;
 
 							currentXPos++;
-							if (currentXPos >= 0 && currentXPos < 640)
+							if (currentXPos >= 0 && currentXPos < SCREEN_WIDTH) {
 								*(out2 + 1) = currentColor >> 8;
+							}
 						} else if (hsize == 2) {
 							uint16 currentColor = startColor;
 							hsize++;
@@ -897,8 +914,9 @@ void Renderer::renderPolygons(int32 renderType, int32 color) {
 							colorSize /= 2;
 							currentColor = ((currentColor & (0xFF00)) | ((((currentColor & 0xFF) << (hsize & 0xFF))) & 0xFF));
 							currentColor += startColor;
-							if (currentXPos >= 0 && currentXPos < 640)
+							if (currentXPos >= 0 && currentXPos < SCREEN_WIDTH) {
 								*(out2) = currentColor >> 8;
+							}
 
 							out2++;
 							currentXPos++;
@@ -907,8 +925,9 @@ void Renderer::renderPolygons(int32 renderType, int32 color) {
 							currentColor &= 0xFF;
 							currentColor += startColor;
 
-							if (currentXPos >= 0 && currentXPos < 640)
+							if (currentXPos >= 0 && currentXPos < SCREEN_WIDTH) {
 								*(out2) = currentColor >> 8;
+							}
 
 							currentColor &= 0xFF;
 							startColor += colorSize;
@@ -916,8 +935,9 @@ void Renderer::renderPolygons(int32 renderType, int32 color) {
 							currentColor += startColor;
 
 							currentXPos++;
-							if (currentXPos >= 0 && currentXPos < 640)
+							if (currentXPos >= 0 && currentXPos < SCREEN_WIDTH) {
 								*(out2 + 1) = currentColor >> 8;
+							}
 						} else {
 							uint16 currentColor = startColor;
 							colorSize /= hsize;
@@ -928,7 +948,7 @@ void Renderer::renderPolygons(int32 renderType, int32 color) {
 								currentColor &= 0xFF;
 								currentColor = ((currentColor & (0xFF00)) | ((((currentColor & 0xFF) << (hsize & 0xFF))) & 0xFF));
 								currentColor += startColor;
-								if (currentXPos >= 0 && currentXPos < 640)
+								if (currentXPos >= 0 && currentXPos < SCREEN_WIDTH)
 									*(out2) = currentColor >> 8;
 								out2++;
 								currentXPos++;
@@ -939,15 +959,17 @@ void Renderer::renderPolygons(int32 renderType, int32 color) {
 							do {
 								currentColor &= 0xFF;
 								currentColor += startColor;
-								if (currentXPos >= 0 && currentXPos < 640)
+								if (currentXPos >= 0 && currentXPos < SCREEN_WIDTH) {
 									*(out2) = currentColor >> 8;
+								}
 								currentXPos++;
 								currentColor &= 0xFF;
 								startColor += colorSize;
 								currentColor = ((currentColor & (0xFF00)) | ((((currentColor & 0xFF) << (hsize & 0xFF))) & 0xFF));
 								currentColor += startColor;
-								if (currentXPos >= 0 && currentXPos < 640)
+								if (currentXPos >= 0 && currentXPos < SCREEN_WIDTH) {
 									*(out2 + 1) = currentColor >> 8;
+								}
 								currentXPos++;
 								out2 += 2;
 								startColor += colorSize;
@@ -956,7 +978,7 @@ void Renderer::renderPolygons(int32 renderType, int32 color) {
 					}
 				}
 			}
-			out += 640;
+			out += SCREEN_WIDTH;
 			currentLine++;
 		} while (--renderLoop);
 		break;


Commit: a33c61fcaa140618ad7fe9d6ca62b3e5d2bbb22f
    https://github.com/scummvm/scummvm/commit/a33c61fcaa140618ad7fe9d6ca62b3e5d2bbb22f
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-06T16:52:45+01:00

Commit Message:
TWINE: converted to boolean

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


diff --git a/engines/twine/renderer.cpp b/engines/twine/renderer.cpp
index 1434e3dab1..ca333fd0a6 100644
--- a/engines/twine/renderer.cpp
+++ b/engines/twine/renderer.cpp
@@ -86,7 +86,7 @@ void Renderer::setCameraPosition(int32 x, int32 y, int32 cX, int32 cY, int32 cZ)
 	cameraPosY = cY;
 	cameraPosZ = cZ;
 
-	isUsingOrhoProjection = 0;
+	isUsingOrhoProjection = false;
 }
 
 void Renderer::setBaseTranslation(int32 x, int32 y, int32 z) {
@@ -100,7 +100,7 @@ void Renderer::setOrthoProjection(int32 X, int32 Y, int32 Z) {
 	orthoProjY = Y;
 	orthoProjZ = Z;
 
-	isUsingOrhoProjection = 1;
+	isUsingOrhoProjection = true;
 }
 
 void Renderer::getBaseRotationPosition(int32 x, int32 y, int32 z) {
@@ -1442,7 +1442,7 @@ int32 Renderer::renderAnimatedModel(uint8 *bodyPtr) {
 	const pointTab *pointPtr = (pointTab *)computedPoints;
 	pointTab *pointPtrDest = (pointTab *)flattenPoints;
 
-	if (isUsingOrhoProjection != 0) { // use standard projection
+	if (isUsingOrhoProjection) { // use standard projection
 		do {
 			const int32 coX = pointPtr->x + renderX;
 			const int32 coY = pointPtr->y + renderY;
@@ -1642,10 +1642,7 @@ void Renderer::prepareIsoModel(uint8 *bodyPtr) { // loadGfxSub
 	}
 }
 
-int32 Renderer::renderIsoModel(int32 X, int32 Y, int32 Z, int32 angleX, int32 angleY, int32 angleZ, uint8 *bodyPtr) { // AffObjetIso
-	uint8 *ptr;
-	int16 bodyHeader;
-
+int32 Renderer::renderIsoModel(int32 x, int32 y, int32 z, int32 angleX, int32 angleY, int32 angleZ, uint8 *bodyPtr) { // AffObjetIso
 	renderAngleX = angleX;
 	renderAngleY = angleY;
 	renderAngleZ = angleZ;
@@ -1656,25 +1653,25 @@ int32 Renderer::renderIsoModel(int32 X, int32 Y, int32 Z, int32 angleX, int32 an
 	_engine->_redraw->renderRight = -32767;
 	_engine->_redraw->renderBottom = -32767;
 
-	if (isUsingOrhoProjection == 0) {
-		getBaseRotationPosition(X, Y, Z);
+	if (isUsingOrhoProjection) {
+		renderX = x;
+		renderY = y;
+		renderZ = z;
+	} else {
+		getBaseRotationPosition(x, y, z);
 
 		renderX = destX - baseRotPosX;
 		renderY = destY - baseRotPosY; // RECHECK
 		renderZ = destZ - baseRotPosZ;
-	} else {
-		renderX = X;
-		renderY = Y;
-		renderZ = Z;
 	}
 
 	// restart at the beginning of the renderTable
 	renderTabEntryPtr = renderTab;
 
-	bodyHeader = *((uint16 *)bodyPtr);
+	int16 bodyHeader = *((uint16 *)bodyPtr);
 
 	// jump after the header
-	ptr = bodyPtr + 16 + *((uint16 *)(bodyPtr + 14));
+	uint8 *ptr = bodyPtr + 16 + *((uint16 *)(bodyPtr + 14));
 
 	if (bodyHeader & 2) { // if animated
 		// the mostly used renderer code
@@ -1686,11 +1683,13 @@ int32 Renderer::renderIsoModel(int32 X, int32 Y, int32 Z, int32 angleX, int32 an
 
 void Renderer::copyActorInternAnim(uint8 *bodyPtrSrc, uint8 *bodyPtrDest) {
 	// check if both characters allow animation
-	if (!(*((int16 *)bodyPtrSrc) & 2))
+	if (!(*((int16 *)bodyPtrSrc) & 2)) {
 		return;
+	}
 
-	if (!(*((int16 *)bodyPtrDest) & 2))
+	if (!(*((int16 *)bodyPtrDest) & 2)) {
 		return;
+	}
 
 	// skip header
 	bodyPtrSrc += 16;
@@ -1707,8 +1706,9 @@ void Renderer::copyActorInternAnim(uint8 *bodyPtrSrc, uint8 *bodyPtrDest) {
 	bodyPtrDest = bodyPtrDest + (*((int16 *)bodyPtrDest)) * 6 + 2;
 	int16 ax = *((int16 *)bodyPtrDest);
 
-	if (cx > ax)
+	if (cx > ax) {
 		cx = ax;
+	}
 
 	bodyPtrSrc += 10;
 	bodyPtrDest += 10;
@@ -1750,7 +1750,7 @@ void Renderer::renderBehaviourModel(int32 boxLeft, int32 boxTop, int32 boxRight,
 	}
 }
 
-void Renderer::renderInventoryItem(int32 X, int32 Y, uint8 *itemBodyPtr, int32 angle, int32 param) { // Draw3DObject
+void Renderer::renderInventoryItem(int32 X, int32 Y, uint8 *itemBodyPtr, int32 angle, int32 param) {
 	setCameraPosition(X, Y, 128, 200, 200);
 	setCameraAngle(0, 0, 0, 60, 0, 0, param);
 
diff --git a/engines/twine/renderer.h b/engines/twine/renderer.h
index c732373a96..84be6984f4 100644
--- a/engines/twine/renderer.h
+++ b/engines/twine/renderer.h
@@ -197,7 +197,7 @@ private:
 	int16 polyTab2[960] {0};
 	// end render polygon vars
 
-	int32 isUsingOrhoProjection = 0;
+	bool isUsingOrhoProjection = false;
 
 public:
 	Renderer(TwinEEngine *engine) : _engine(engine) {}


Commit: 51534d74ece0a515e79258fadc06ba06f8698353
    https://github.com/scummvm/scummvm/commit/51534d74ece0a515e79258fadc06ba06f8698353
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-06T16:52:45+01:00

Commit Message:
TWINE: removed unused members and reduced scope

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


diff --git a/engines/twine/renderer.cpp b/engines/twine/renderer.cpp
index ca333fd0a6..a9bc2d4fe3 100644
--- a/engines/twine/renderer.cpp
+++ b/engines/twine/renderer.cpp
@@ -112,10 +112,6 @@ void Renderer::getBaseRotationPosition(int32 x, int32 y, int32 z) {
 void Renderer::setBaseRotation(int32 x, int32 y, int32 z) {
 	shadeAngleTab3 = &shadeAngleTable[384];
 
-	baseMatrixRotationX = x & 0x3FF;
-	baseMatrixRotationY = y & 0x3FF;
-	baseMatrixRotationZ = z & 0x3FF;
-
 	double Xradians = (double)((256 - x) % 1024) * 2 * M_PI / 1024;
 	double Yradians = (double)((256 - y) % 1024) * 2 * M_PI / 1024;
 	double Zradians = (double)((256 - z) % 1024) * 2 * M_PI / 1024;
@@ -515,12 +511,8 @@ int32 Renderer::computePolygons() {
 
 void Renderer::renderPolygons(int32 renderType, int32 color) {
 	uint8 *out2;
-	int32 hsize;
-	int32 j;
 	int32 currentLine;
 
-	int16 start, stop;
-
 	uint8 *out = (uint8*)_engine->frontVideoBuffer.getPixels() + SCREEN_WIDTH * vtop;
 
 	int16 *ptr1 = &polyTab[vtop];
@@ -534,17 +526,17 @@ void Renderer::renderPolygons(int32 renderType, int32 color) {
 		currentLine = vtop;
 		do {
 			if (currentLine >= 0 && currentLine < SCREEN_HEIGHT) {
-				stop = ptr1[SCREEN_HEIGHT];
-				start = ptr1[0];
+				int16 stop = ptr1[SCREEN_HEIGHT];
+				int16 start = ptr1[0];
 
 				ptr1++;
-				hsize = stop - start;
+				int32 hsize = stop - start;
 
 				if (hsize >= 0) {
 					hsize++;
 					out2 = start + out;
 
-					for (j = start; j < hsize + start; j++) {
+					for (int32 j = start; j < hsize + start; j++) {
 						if (j >= 0 && j < SCREEN_WIDTH) {
 							out[j] = color;
 						}
@@ -560,11 +552,11 @@ void Renderer::renderPolygons(int32 renderType, int32 color) {
 		currentLine = vtop;
 		do {
 			if (currentLine >= 0 && currentLine < SCREEN_HEIGHT) {
-				start = ptr1[0];
-				stop = ptr1[SCREEN_HEIGHT];
+				int16 start = ptr1[0];
+				int16 stop = ptr1[SCREEN_HEIGHT];
 
 				ptr1++;
-				hsize = stop - start;
+				int32 hsize = stop - start;
 
 				if (hsize >= 0) {
 					uint16 mask = 0x43DB;
@@ -578,7 +570,7 @@ void Renderer::renderPolygons(int32 renderType, int32 color) {
 					out2 = start + out;
 					startCopy = start;
 
-					for (j = startCopy; j < hsize + startCopy; j++) {
+					for (int32 j = startCopy; j < hsize + startCopy; j++) {
 						start += mask;
 						start = (start & 0xFF00) | ((start & 0xFF) & (uint8)(dx >> 8));
 						start = (start & 0xFF00) | ((start & 0xFF) + (dx & 0xFF));
@@ -599,15 +591,15 @@ void Renderer::renderPolygons(int32 renderType, int32 color) {
 		currentLine = vtop;
 		do {
 			if (currentLine >= 0 && currentLine < SCREEN_HEIGHT) {
-				start = ptr1[0];
-				stop = ptr1[SCREEN_HEIGHT];
+				int16 start = ptr1[0];
+				int16 stop = ptr1[SCREEN_HEIGHT];
 				ptr1++;
-				hsize = stop - start;
+				int32 hsize = stop - start;
 
 				if (hsize >= 0) {
 					hsize++;
 					out2 = start + out;
-					for (j = start; j < hsize + start; j++) {
+					for (int32 j = start; j < hsize + start; j++) {
 						if ((start + (vtop % 1)) & 1) {
 							if (j >= 0 && j < SCREEN_WIDTH) {
 								out[j] = color;
@@ -633,14 +625,18 @@ void Renderer::renderPolygons(int32 renderType, int32 color) {
 		bx = (unsigned short)color << 0x10;
 		int32 renderLoop = vsize;
 		do {
+			int16 start;
+			int16 stop;
+			int32 hsize;
 			while (1) {
 				start = ptr1[0];
 				stop = ptr1[SCREEN_HEIGHT];
 				ptr1++;
 				hsize = stop - start;
 
-				if (hsize)
+				if (hsize) {
 					break;
+				}
 
 				out2 = start + out;
 				*out2 = ((unsigned short)(bx >> 0x18)) & 0x0F;
@@ -650,8 +646,9 @@ void Renderer::renderPolygons(int32 renderType, int32 color) {
 				out += SCREEN_WIDTH;
 
 				--renderLoop;
-				if (!renderLoop)
+				if (!renderLoop) {
 					return;
+				}
 			}
 
 			if (stop >= start) {
@@ -681,7 +678,7 @@ void Renderer::renderPolygons(int32 renderType, int32 color) {
 					ax = 0; // not sure about this
 				}
 
-				j = hsize >> 1;
+				int32 j = hsize >> 1;
 
 				while (1) {
 					*(out2++) = ax & 0x0F;
@@ -707,11 +704,11 @@ void Renderer::renderPolygons(int32 renderType, int32 color) {
 		do {
 			unsigned short int bx;
 
-			start = ptr1[0];
-			stop = ptr1[SCREEN_HEIGHT];
+			int16 start = ptr1[0];
+			int16 stop = ptr1[SCREEN_HEIGHT];
 
 			ptr1++;
-			hsize = stop - start;
+			int32 hsize = stop - start;
 
 			if (hsize >= 0) {
 				hsize++;
@@ -721,7 +718,7 @@ void Renderer::renderPolygons(int32 renderType, int32 color) {
 					bx = color & 0xFF;
 					bx = bx << 8;
 					bx += color & 0xFF;
-					for (j = 0; j < hsize; j++) {
+					for (int32 j = 0; j < hsize; j++) {
 						*(out2) = (*(out2)&0x0F0F) | bx;
 					}
 				} else {
@@ -739,10 +736,10 @@ void Renderer::renderPolygons(int32 renderType, int32 color) {
 		currentLine = vtop;
 		do {
 			if (currentLine >= 0 && currentLine < SCREEN_HEIGHT) {
-				start = ptr1[0];
-				stop = ptr1[SCREEN_HEIGHT];
+				int16 start = ptr1[0];
+				int16 stop = ptr1[SCREEN_HEIGHT];
 				ptr1++;
-				hsize = stop - start;
+				int32 hsize = stop - start;
 
 				if (hsize >= 0) {
 					hsize++;
@@ -758,7 +755,7 @@ void Renderer::renderPolygons(int32 renderType, int32 color) {
 							out2++;
 						}
 
-						for (j = 0; j < hsize; j++) {
+						for (int32 j = 0; j < hsize; j++) {
 							*(out2) = (uint8)color;
 							out2 += 2;
 						}
@@ -780,12 +777,12 @@ void Renderer::renderPolygons(int32 renderType, int32 color) {
 
 				int16 colorSize = stopColor - startColor;
 
-				stop = ptr1[SCREEN_HEIGHT]; // stop
-				start = ptr1[0];  // start
+				int16 stop = ptr1[SCREEN_HEIGHT]; // stop
+				int16 start = ptr1[0];  // start
 
 				ptr1++;
 				out2 = start + out;
-				hsize = stop - start;
+				int32 hsize = stop - start;
 
 				//varf2 = ptr2[SCREEN_HEIGHT];
 				//varf3 = ptr2[0];
@@ -866,10 +863,10 @@ void Renderer::renderPolygons(int32 renderType, int32 color) {
 		currentLine = vtop;
 		do {
 			if (currentLine >= 0 && currentLine < SCREEN_HEIGHT) {
-				stop = ptr1[SCREEN_HEIGHT]; // stop
-				start = ptr1[0];  // start
+				int16 stop = ptr1[SCREEN_HEIGHT]; // stop
+				int16 start = ptr1[0];  // start
 				ptr1++;
-				hsize = stop - start;
+				int32 hsize = stop - start;
 
 				if (hsize >= 0) {
 					uint16 startColor = ptr2[0];
@@ -948,8 +945,9 @@ void Renderer::renderPolygons(int32 renderType, int32 color) {
 								currentColor &= 0xFF;
 								currentColor = ((currentColor & (0xFF00)) | ((((currentColor & 0xFF) << (hsize & 0xFF))) & 0xFF));
 								currentColor += startColor;
-								if (currentXPos >= 0 && currentXPos < SCREEN_WIDTH)
+								if (currentXPos >= 0 && currentXPos < SCREEN_WIDTH) {
 									*(out2) = currentColor >> 8;
+								}
 								out2++;
 								currentXPos++;
 							} else {
diff --git a/engines/twine/renderer.h b/engines/twine/renderer.h
index 84be6984f4..aba2a47cbf 100644
--- a/engines/twine/renderer.h
+++ b/engines/twine/renderer.h
@@ -132,10 +132,6 @@ private:
 
 	// ---- variables ----
 
-	int32 baseMatrixRotationX = 0;
-	int32 baseMatrixRotationY = 0;
-	int32 baseMatrixRotationZ = 0;
-
 	int32 baseTransPosX = 0; // setSomething2Var1
 	int32 baseTransPosY = 0; // setSomething2Var2
 	int32 baseTransPosZ = 0; // setSomething2Var3


Commit: 1d2984678a7bc630999003512e0b3a9e3106d1eb
    https://github.com/scummvm/scummvm/commit/1d2984678a7bc630999003512e0b3a9e3106d1eb
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-06T16:52:45+01:00

Commit Message:
TWINE: reduced scope

Changed paths:
    engines/twine/renderer.cpp


diff --git a/engines/twine/renderer.cpp b/engines/twine/renderer.cpp
index a9bc2d4fe3..5e32f8467a 100644
--- a/engines/twine/renderer.cpp
+++ b/engines/twine/renderer.cpp
@@ -1004,8 +1004,9 @@ void Renderer::circleFill(int32 x, int32 y, int32 radius, int8 color) {
 
 		width *= radius;
 
-		if (width < 0)
+		if (width < 0) {
 			width = -width;
+		}
 
 		_engine->_interface->drawLine((int32)(x - width), currentLine + y, (int32)(x + width), currentLine + y, color);
 	}
@@ -1027,9 +1028,6 @@ int32 Renderer::renderModelElements(int32 numOfPrimitives, uint8 *pointer) {
 	int32 eax;
 	//	int32 ecx;
 
-	uint8 *render23;
-	uint8 *render24;
-
 	pointTab *currentVertex;
 	pointTab *destinationVertex;
 
@@ -1043,7 +1041,7 @@ int32 Renderer::renderModelElements(int32 numOfPrimitives, uint8 *pointer) {
 		int16 primitiveCounter = temp; // the number of primitives = the number of polygons
 
 		do { // loop that load all the polygons
-			render23 = edi;
+			uint8 *render23 = edi;
 			polyHeader *currentPolyHeader = (polyHeader *)pointer;
 			//ecx = *((int32*) pointer);
 			pointer += 2;
@@ -1163,7 +1161,7 @@ int32 Renderer::renderModelElements(int32 numOfPrimitives, uint8 *pointer) {
 				} while (--(counter));
 			}
 
-			render24 = edi;
+			uint8 *render24 = edi;
 			edi = renderV19;
 
 			render25 = bestDepth;


Commit: e08b7d64558c8bc4af3080b9c2825da9aabc1664
    https://github.com/scummvm/scummvm/commit/e08b7d64558c8bc4af3080b9c2825da9aabc1664
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-06T16:52:45+01:00

Commit Message:
TWINE: reduced scope

Changed paths:
    engines/twine/renderer.cpp


diff --git a/engines/twine/renderer.cpp b/engines/twine/renderer.cpp
index 5e32f8467a..de186fbbe3 100644
--- a/engines/twine/renderer.cpp
+++ b/engines/twine/renderer.cpp
@@ -1020,11 +1020,9 @@ int32 Renderer::renderModelElements(int32 numOfPrimitives, uint8 *pointer) {
 	int16 shadeEntry;
 	int16 shadeValue;
 
-	int32 depth;
 	int32 bestDepth;
 	int32 currentDepth;
 	int32 bestPoly = 0;
-	int32 render25;
 	int32 eax;
 	//	int32 ecx;
 
@@ -1164,7 +1162,7 @@ int32 Renderer::renderModelElements(int32 numOfPrimitives, uint8 *pointer) {
 			uint8 *render24 = edi;
 			edi = renderV19;
 
-			render25 = bestDepth;
+			int32 render25 = bestDepth;
 
 			int16 ax = *((int16 *)(edi + 4));
 			int16 bx = *((int16 *)(edi + 8));
@@ -1226,7 +1224,7 @@ int32 Renderer::renderModelElements(int32 numOfPrimitives, uint8 *pointer) {
 			*((int16 *)&lineCoordinatesPtr->x2) = flattenPoints[point2].x;
 			*((int16 *)&lineCoordinatesPtr->y2) = flattenPoints[point2].y;
 			bestDepth = flattenPoints[point1].z;
-			depth = flattenPoints[point2].z;
+			int32 depth = flattenPoints[point2].z;
 
 			if (depth >= bestDepth) {
 				bestDepth = depth;


Commit: ee0e586f7bd26563bcee1915d3f95255fdd6fb4f
    https://github.com/scummvm/scummvm/commit/ee0e586f7bd26563bcee1915d3f95255fdd6fb4f
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-06T16:52:45+01:00

Commit Message:
TWINE: reduced cyclic complexity

Changed paths:
    engines/twine/renderer.cpp


diff --git a/engines/twine/renderer.cpp b/engines/twine/renderer.cpp
index de186fbbe3..8a8ce8eb0a 100644
--- a/engines/twine/renderer.cpp
+++ b/engines/twine/renderer.cpp
@@ -1017,8 +1017,6 @@ int32 Renderer::renderModelElements(int32 numOfPrimitives, uint8 *pointer) {
 	int16 type;
 	int16 color;
 	int16 bestZ;
-	int16 shadeEntry;
-	int16 shadeValue;
 
 	int32 bestDepth;
 	int32 currentDepth;
@@ -1027,7 +1025,6 @@ int32 Renderer::renderModelElements(int32 numOfPrimitives, uint8 *pointer) {
 	//	int32 ecx;
 
 	pointTab *currentVertex;
-	pointTab *destinationVertex;
 
 	// prepare polygons
 
@@ -1064,14 +1061,14 @@ int32 Renderer::renderModelElements(int32 numOfPrimitives, uint8 *pointer) {
 				do {
 					polyVertexHeader *currentPolyVertex = (polyVertexHeader *)pointer;
 
-					shadeValue = currentPolyHeader->colorIndex + shadeTable[currentPolyVertex->shadeEntry];
+					int16 shadeValue = currentPolyHeader->colorIndex + shadeTable[currentPolyVertex->shadeEntry];
 
 					computedVertex *currentComputedVertex = (computedVertex *)edi;
 
 					currentComputedVertex->shadeValue = shadeValue;
 
 					currentVertex = &flattenPoints[currentPolyVertex->dataOffset / 6];
-					destinationVertex = (pointTab *)(edi + 2);
+					pointTab *destinationVertex = (pointTab *)(edi + 2);
 
 					destinationVertex->x = currentVertex->x;
 					destinationVertex->y = currentVertex->y;
@@ -1093,7 +1090,7 @@ int32 Renderer::renderModelElements(int32 numOfPrimitives, uint8 *pointer) {
 
 				color = currentPolyHeader->colorIndex;
 
-				shadeEntry = *((int16 *)(pointer + 2));
+				int16 shadeEntry = *((int16 *)(pointer + 2));
 
 				pointer += 4;
 
@@ -1110,7 +1107,7 @@ int32 Renderer::renderModelElements(int32 numOfPrimitives, uint8 *pointer) {
 
 					currentVertex = &flattenPoints[eax / 6];
 
-					destinationVertex = (pointTab *)(edi + 2);
+					pointTab *destinationVertex = (pointTab *)(edi + 2);
 
 					destinationVertex->x = currentVertex->x;
 					destinationVertex->y = currentVertex->y;
@@ -1144,7 +1141,7 @@ int32 Renderer::renderModelElements(int32 numOfPrimitives, uint8 *pointer) {
 
 					currentVertex = &flattenPoints[eax / 6];
 
-					destinationVertex = (pointTab *)(edi + 2);
+					pointTab *destinationVertex = (pointTab *)(edi + 2);
 
 					destinationVertex->x = currentVertex->x;
 					destinationVertex->y = currentVertex->y;
@@ -1289,102 +1286,101 @@ int32 Renderer::renderModelElements(int32 numOfPrimitives, uint8 *pointer) {
 
 	// prepare to render elements
 
-	if (numOfPrimitives) {
-		int16 primitiveCounter = numOfPrimitives;
-		renderV19 = pointer;
-
-		do {
-			type = renderTabEntryPtr2->renderType;
-			pointer = renderTabEntryPtr2->dataPtr;
-			renderV19 += 8;
-
-			switch (type) {
-			case RENDERTYPE_DRAWLINE: { // draw a line
-				lineCoordinates *lineCoordinatesPtr = (lineCoordinates *)pointer;
-				color = (*((int32 *)&lineCoordinatesPtr->data) & 0xFF00) >> 8;
-
-				const int32 x1 = *((const int16 *)&lineCoordinatesPtr->x1);
-				const int32 y1 = *((const int16 *)&lineCoordinatesPtr->y1);
-				const int32 x2 = *((const int16 *)&lineCoordinatesPtr->x2);
-				const int32 y2 = *((const int16 *)&lineCoordinatesPtr->y2);
-
-				_engine->_interface->drawLine(x1, y1, x2, y2, color);
-				break;
-			}
-			case RENDERTYPE_DRAWPOLYGON: { // draw a polygon
-				eax = *((const int *)pointer);
-				pointer += 4;
+	if (numOfPrimitives == 0) {
+		_engine->_redraw->renderRight = -1;
+		_engine->_redraw->renderBottom = -1;
+		_engine->_redraw->renderLeft = -1;
+		_engine->_redraw->renderTop = -1;
+		return -1;
+	}
 
-				polyRenderType = eax & 0xFF;
-				numOfVertex = (eax & 0xFF00) >> 8;
-				color = (eax & 0xFF0000) >> 16;
+	int16 primitiveCounter = numOfPrimitives;
+	renderV19 = pointer;
 
-				uint8 *destPtr = (uint8 *)vertexCoordinates;
+	do {
+		type = renderTabEntryPtr2->renderType;
+		pointer = renderTabEntryPtr2->dataPtr;
+		renderV19 += 8;
+
+		switch (type) {
+		case RENDERTYPE_DRAWLINE: { // draw a line
+			lineCoordinates *lineCoordinatesPtr = (lineCoordinates *)pointer;
+			color = (*((int32 *)&lineCoordinatesPtr->data) & 0xFF00) >> 8;
+
+			const int32 x1 = *((const int16 *)&lineCoordinatesPtr->x1);
+			const int32 y1 = *((const int16 *)&lineCoordinatesPtr->y1);
+			const int32 x2 = *((const int16 *)&lineCoordinatesPtr->x2);
+			const int32 y2 = *((const int16 *)&lineCoordinatesPtr->y2);
+
+			_engine->_interface->drawLine(x1, y1, x2, y2, color);
+			break;
+		}
+		case RENDERTYPE_DRAWPOLYGON: { // draw a polygon
+			eax = *((const int *)pointer);
+			pointer += 4;
 
-				for (int32 i = 0; i < (numOfVertex * 3); i++) {
-					*((int16 *)destPtr) = *((const int16 *)pointer);
-					destPtr += 2;
-					pointer += 2;
-				}
+			polyRenderType = eax & 0xFF;
+			numOfVertex = (eax & 0xFF00) >> 8;
+			color = (eax & 0xFF0000) >> 16;
 
-				if (computePolygons() != ERROR_OUT_OF_SCREEN) {
-					renderPolygons(polyRenderType, color);
-				}
+			uint8 *destPtr = (uint8 *)vertexCoordinates;
 
-				break;
+			for (int32 i = 0; i < (numOfVertex * 3); i++) {
+				*((int16 *)destPtr) = *((const int16 *)pointer);
+				destPtr += 2;
+				pointer += 2;
 			}
-			case RENDERTYPE_DRAWSPHERE: { // draw a sphere
-				eax = *(const int *)pointer;
 
-				const int32 circleParam1 = *(const uint8 *)pointer;
-				const int32 circleParam4 = *((const int16 *)(pointer + 1));
-				const int32 circleParam5 = *((const int16 *)(pointer + 3));
-				int32 circleParam3 = *((const int16 *)(pointer + 5));
-
-				if (!isUsingOrhoProjection) {
-					circleParam3 = (circleParam3 * cameraPosY) / (cameraPosX + *(const int16 *)pointer);
-				} else {
-					circleParam3 = (circleParam3 * 34) >> 9;
-				}
+			if (computePolygons() != ERROR_OUT_OF_SCREEN) {
+				renderPolygons(polyRenderType, color);
+			}
 
-				circleParam3 += 3;
+			break;
+		}
+		case RENDERTYPE_DRAWSPHERE: { // draw a sphere
+			eax = *(const int *)pointer;
 
-				if (circleParam4 + circleParam3 > _engine->_redraw->renderRight) {
-					_engine->_redraw->renderRight = circleParam4 + circleParam3;
-				}
+			const int32 circleParam1 = *(const uint8 *)pointer;
+			const int32 circleParam4 = *((const int16 *)(pointer + 1));
+			const int32 circleParam5 = *((const int16 *)(pointer + 3));
+			int32 circleParam3 = *((const int16 *)(pointer + 5));
 
-				if (circleParam4 - circleParam3 < _engine->_redraw->renderLeft) {
-					_engine->_redraw->renderLeft = circleParam4 - circleParam3;
-				}
+			if (!isUsingOrhoProjection) {
+				circleParam3 = (circleParam3 * cameraPosY) / (cameraPosX + *(const int16 *)pointer);
+			} else {
+				circleParam3 = (circleParam3 * 34) >> 9;
+			}
 
-				if (circleParam5 + circleParam3 > _engine->_redraw->renderBottom) {
-					_engine->_redraw->renderBottom = circleParam5 + circleParam3;
-				}
+			circleParam3 += 3;
 
-				if (circleParam5 - circleParam3 < _engine->_redraw->renderTop) {
-					_engine->_redraw->renderTop = circleParam5 - circleParam3;
-				}
+			if (circleParam4 + circleParam3 > _engine->_redraw->renderRight) {
+				_engine->_redraw->renderRight = circleParam4 + circleParam3;
+			}
 
-				circleParam3 -= 3;
+			if (circleParam4 - circleParam3 < _engine->_redraw->renderLeft) {
+				_engine->_redraw->renderLeft = circleParam4 - circleParam3;
+			}
 
-				circleFill(circleParam4, circleParam5, circleParam3, circleParam1);
-				break;
+			if (circleParam5 + circleParam3 > _engine->_redraw->renderBottom) {
+				_engine->_redraw->renderBottom = circleParam5 + circleParam3;
 			}
-			default:
-				break;
+
+			if (circleParam5 - circleParam3 < _engine->_redraw->renderTop) {
+				_engine->_redraw->renderTop = circleParam5 - circleParam3;
 			}
 
-			pointer = renderV19;
-			renderTabEntryPtr2++;
-		} while (--primitiveCounter);
-	} else {
-		_engine->_redraw->renderRight = -1;
-		_engine->_redraw->renderBottom = -1;
-		_engine->_redraw->renderLeft = -1;
-		_engine->_redraw->renderTop = -1;
-		return -1;
-	}
+			circleParam3 -= 3;
+
+			circleFill(circleParam4, circleParam5, circleParam3, circleParam1);
+			break;
+		}
+		default:
+			break;
+		}
 
+		pointer = renderV19;
+		renderTabEntryPtr2++;
+	} while (--primitiveCounter);
 	return 0;
 }
 


Commit: 89a9b97ae018f19fc6d9a611d28a2d89cda6ebf5
    https://github.com/scummvm/scummvm/commit/89a9b97ae018f19fc6d9a611d28a2d89cda6ebf5
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-06T16:52:45+01:00

Commit Message:
TWINE: reduced scope

Changed paths:
    engines/twine/renderer.cpp


diff --git a/engines/twine/renderer.cpp b/engines/twine/renderer.cpp
index 8a8ce8eb0a..71db4e913b 100644
--- a/engines/twine/renderer.cpp
+++ b/engines/twine/renderer.cpp
@@ -1015,8 +1015,6 @@ void Renderer::circleFill(int32 x, int32 y, int32 radius, int8 color) {
 int32 Renderer::renderModelElements(int32 numOfPrimitives, uint8 *pointer) {
 	int16 counter;
 	int16 type;
-	int16 color;
-	int16 bestZ;
 
 	int32 bestDepth;
 	int32 currentDepth;
@@ -1088,7 +1086,7 @@ int32 Renderer::renderModelElements(int32 numOfPrimitives, uint8 *pointer) {
 				destinationHeader->renderType = currentPolyHeader->renderType - 7;
 				destinationHeader->numOfVertex = currentPolyHeader->numOfVertex;
 
-				color = currentPolyHeader->colorIndex;
+				int16 color = currentPolyHeader->colorIndex;
 
 				int16 shadeEntry = *((int16 *)(pointer + 2));
 
@@ -1268,7 +1266,7 @@ int32 Renderer::renderModelElements(int32 numOfPrimitives, uint8 *pointer) {
 	renderTabSortedPtr = renderTabSorted;
 	for (int32 i = 0; i < numOfPrimitives; i++) { // then we sort the polygones | WARNING: very slow | TODO: improve this
 		renderTabEntryPtr2 = renderTab;
-		bestZ = -0x7FFF;
+		int16 bestZ = -0x7FFF;
 		for (int32 j = 0; j < numOfPrimitives; j++) {
 			if (renderTabEntryPtr2->depth > bestZ) {
 				bestZ = renderTabEntryPtr2->depth;
@@ -1305,7 +1303,7 @@ int32 Renderer::renderModelElements(int32 numOfPrimitives, uint8 *pointer) {
 		switch (type) {
 		case RENDERTYPE_DRAWLINE: { // draw a line
 			lineCoordinates *lineCoordinatesPtr = (lineCoordinates *)pointer;
-			color = (*((int32 *)&lineCoordinatesPtr->data) & 0xFF00) >> 8;
+			int16 color = (*((int32 *)&lineCoordinatesPtr->data) & 0xFF00) >> 8;
 
 			const int32 x1 = *((const int16 *)&lineCoordinatesPtr->x1);
 			const int32 y1 = *((const int16 *)&lineCoordinatesPtr->y1);
@@ -1321,7 +1319,7 @@ int32 Renderer::renderModelElements(int32 numOfPrimitives, uint8 *pointer) {
 
 			polyRenderType = eax & 0xFF;
 			numOfVertex = (eax & 0xFF00) >> 8;
-			color = (eax & 0xFF0000) >> 16;
+			int16 color = (eax & 0xFF0000) >> 16;
 
 			uint8 *destPtr = (uint8 *)vertexCoordinates;
 


Commit: 5c423ecd2f1d8ca11788915bc7351b148965df00
    https://github.com/scummvm/scummvm/commit/5c423ecd2f1d8ca11788915bc7351b148965df00
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-06T16:52:45+01:00

Commit Message:
TWINE: reduced scope

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


diff --git a/engines/twine/renderer.cpp b/engines/twine/renderer.cpp
index 71db4e913b..028300c106 100644
--- a/engines/twine/renderer.cpp
+++ b/engines/twine/renderer.cpp
@@ -1038,7 +1038,7 @@ int32 Renderer::renderModelElements(int32 numOfPrimitives, uint8 *pointer) {
 			polyHeader *currentPolyHeader = (polyHeader *)pointer;
 			//ecx = *((int32*) pointer);
 			pointer += 2;
-			polyRenderType = currentPolyHeader->renderType;
+			int16 polyRenderType = currentPolyHeader->renderType;
 
 			// TODO: RECHECK coordinates axis
 			if (polyRenderType >= 9) {
@@ -1317,7 +1317,7 @@ int32 Renderer::renderModelElements(int32 numOfPrimitives, uint8 *pointer) {
 			eax = *((const int *)pointer);
 			pointer += 4;
 
-			polyRenderType = eax & 0xFF;
+			int16 polyRenderType = eax & 0xFF;
 			numOfVertex = (eax & 0xFF00) >> 8;
 			int16 color = (eax & 0xFF0000) >> 16;
 
diff --git a/engines/twine/renderer.h b/engines/twine/renderer.h
index aba2a47cbf..6dfc3bd222 100644
--- a/engines/twine/renderer.h
+++ b/engines/twine/renderer.h
@@ -215,7 +215,6 @@ public:
 
 	const int16 *shadeAngleTab3 = nullptr; // tab3
 
-	int16 polyRenderType = 0; //FillVertic_AType;
 	int32 numOfVertex = 0;
 	int16 vertexCoordinates[193] {0};
 	int16 *pRenderV1 = nullptr;


Commit: 2ede9b688b6ebc5604f50d4b76bacea359f8315c
    https://github.com/scummvm/scummvm/commit/2ede9b688b6ebc5604f50d4b76bacea359f8315c
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-06T16:52:45+01:00

Commit Message:
TWINE: reduced scope and removed unused member

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


diff --git a/engines/twine/renderer.cpp b/engines/twine/renderer.cpp
index 028300c106..5dfe6f784d 100644
--- a/engines/twine/renderer.cpp
+++ b/engines/twine/renderer.cpp
@@ -406,9 +406,7 @@ FORCEINLINE int16 clamp(int16 x, int16 a, int16 b) {
 	return x < a ? a : (x > b ? b : x);
 }
 
-int32 Renderer::computePolygons() {
-	pRenderV1 = vertexCoordinates;
-
+int32 Renderer::computePolygons(int16 polyRenderType) {
 	vertexData *vertices = (vertexData *)vertexCoordinates;
 
 	vleft = vtop = 32767;
@@ -1019,7 +1017,6 @@ int32 Renderer::renderModelElements(int32 numOfPrimitives, uint8 *pointer) {
 	int32 bestDepth;
 	int32 currentDepth;
 	int32 bestPoly = 0;
-	int32 eax;
 	//	int32 ecx;
 
 	pointTab *currentVertex;
@@ -1100,7 +1097,7 @@ int32 Renderer::renderModelElements(int32 numOfPrimitives, uint8 *pointer) {
 				counter = destinationHeader->numOfVertex;
 
 				do {
-					eax = *((int16 *)pointer);
+					int32 eax = *((int16 *)pointer);
 					pointer += 2;
 
 					currentVertex = &flattenPoints[eax / 6];
@@ -1130,7 +1127,7 @@ int32 Renderer::renderModelElements(int32 numOfPrimitives, uint8 *pointer) {
 
 				bestDepth = -32000;
 				renderV19 = edi;
-				eax = 0;
+				int32 eax = 0;
 				counter = currentPolyHeader->numOfVertex;
 
 				do {
@@ -1314,7 +1311,7 @@ int32 Renderer::renderModelElements(int32 numOfPrimitives, uint8 *pointer) {
 			break;
 		}
 		case RENDERTYPE_DRAWPOLYGON: { // draw a polygon
-			eax = *((const int *)pointer);
+			int32 eax = *((const int *)pointer);
 			pointer += 4;
 
 			int16 polyRenderType = eax & 0xFF;
@@ -1329,15 +1326,13 @@ int32 Renderer::renderModelElements(int32 numOfPrimitives, uint8 *pointer) {
 				pointer += 2;
 			}
 
-			if (computePolygons() != ERROR_OUT_OF_SCREEN) {
+			if (computePolygons(polyRenderType) != ERROR_OUT_OF_SCREEN) {
 				renderPolygons(polyRenderType, color);
 			}
 
 			break;
 		}
 		case RENDERTYPE_DRAWSPHERE: { // draw a sphere
-			eax = *(const int *)pointer;
-
 			const int32 circleParam1 = *(const uint8 *)pointer;
 			const int32 circleParam4 = *((const int16 *)(pointer + 1));
 			const int32 circleParam5 = *((const int16 *)(pointer + 3));
diff --git a/engines/twine/renderer.h b/engines/twine/renderer.h
index 6dfc3bd222..3de5614e70 100644
--- a/engines/twine/renderer.h
+++ b/engines/twine/renderer.h
@@ -217,11 +217,10 @@ public:
 
 	int32 numOfVertex = 0;
 	int16 vertexCoordinates[193] {0};
-	int16 *pRenderV1 = nullptr;
 
 	void setLightVector(int32 angleX, int32 angleY, int32 angleZ);
 
-	int32 computePolygons();
+	int32 computePolygons(int16 polyRenderType);
 	void renderPolygons(int32 ecx, int32 edi);
 
 	void prepareIsoModel(uint8 *bodyPtr); // loadGfxSub
diff --git a/engines/twine/text.cpp b/engines/twine/text.cpp
index 488b0733ee..fc474f1159 100644
--- a/engines/twine/text.cpp
+++ b/engines/twine/text.cpp
@@ -462,11 +462,11 @@ void Text::printText10Sub() {
 	_engine->_renderer->vertexCoordinates[7] = _engine->_renderer->vertexCoordinates[1];
 	_engine->_renderer->vertexCoordinates[8] = _engine->_renderer->vertexCoordinates[5];
 
-	_engine->_renderer->polyRenderType = 0; // POLYGONTYPE_FLAT
 	_engine->_renderer->numOfVertex = 3;
 
-	if (_engine->_renderer->computePolygons()) {
-		_engine->_renderer->renderPolygons(_engine->_renderer->polyRenderType, dialTextStopColor);
+	int32 polyRenderType = 0; // POLYGONTYPE_FLAT
+	if (_engine->_renderer->computePolygons(polyRenderType)) {
+		_engine->_renderer->renderPolygons(polyRenderType, dialTextStopColor);
 	}
 
 	_engine->copyBlockPhys(dialTextBoxRight - 24, dialTextBoxBottom - 24, dialTextBoxRight - 3, dialTextBoxBottom - 3);


Commit: 85ce25f67163d1cf65202de3df677f6254d768c4
    https://github.com/scummvm/scummvm/commit/85ce25f67163d1cf65202de3df677f6254d768c4
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-06T16:52:45+01:00

Commit Message:
TWINE: endian safe text and font parsing

Changed paths:
    engines/twine/resources.cpp
    engines/twine/resources.h
    engines/twine/text.cpp
    engines/twine/text.h


diff --git a/engines/twine/resources.cpp b/engines/twine/resources.cpp
index 1c2f93ca97..f3af058c4a 100644
--- a/engines/twine/resources.cpp
+++ b/engines/twine/resources.cpp
@@ -119,7 +119,8 @@ void Resources::initResources() {
 	// Menu and in-game palette
 	initPalettes();
 
-	if (HQR::getAllocEntry(&fontPtr, Resources::HQR_RESS_FILE, RESSHQR_LBAFONT) == 0) {
+	fontBufSize = HQR::getAllocEntry(&fontPtr, Resources::HQR_RESS_FILE, RESSHQR_LBAFONT);
+	if (fontBufSize == 0) {
 		error("Failed to load font");
 	}
 
diff --git a/engines/twine/resources.h b/engines/twine/resources.h
index ccfd4f13d8..3c205709d7 100644
--- a/engines/twine/resources.h
+++ b/engines/twine/resources.h
@@ -140,6 +140,7 @@ public:
 	uint32 samplesSizeTable[NUM_SAMPLES]{0};
 
 	/** Font buffer pointer */
+	int32 fontBufSize = 0;
 	uint8 *fontPtr = nullptr;
 
 	uint32 spriteShadowSize = 0;
diff --git a/engines/twine/text.cpp b/engines/twine/text.cpp
index fc474f1159..4aae06589f 100644
--- a/engines/twine/text.cpp
+++ b/engines/twine/text.cpp
@@ -21,6 +21,7 @@
  */
 
 #include "twine/text.h"
+#include "common/memstream.h"
 #include "common/scummsys.h"
 #include "common/str.h"
 #include "common/system.h"
@@ -72,24 +73,20 @@ void Text::initVoxBank(int32 bankIdx) {
 }
 
 bool Text::initVoxToPlay(int32 index) { // setVoxFileAtDigit
-	int32 currIdx = 0;
-
-	const int16 *localOrderBuf = (const int16 *)dialOrderPtr;
-
+	currDialTextEntry = 0;
 	voxHiddenIndex = 0;
 	hasHiddenVox = false;
 
+	Common::MemoryReadStream stream((const byte*)dialOrderPtr, dialOrderSize);
 	// choose right text from order index
 	for (int32 i = 0; i < numDialTextEntries; i++) {
-		int32 orderIdx = *(localOrderBuf++);
+		int32 orderIdx = stream.readSint16LE();
 		if (orderIdx == index) {
-			currIdx = i;
+			currDialTextEntry = i;
 			break;
 		}
 	}
 
-	currDialTextEntry = currIdx;
-
 	_engine->_sound->playVoxSample(currDialTextEntry);
 
 	return true;
@@ -137,13 +134,13 @@ void Text::initTextBank(int32 bankIdx) {
 	// the text banks indices are split into index and dialogs - each entry thus consists of two entries in the hqr
 	// every 28 entries starts a new language
 	const int32 languageIndex = _engine->cfgfile.LanguageId * size + (int)bankIdx * 2;
-	const int32 hqrSize = HQR::getAllocEntry((uint8 **)&dialOrderPtr, Resources::HQR_TEXT_FILE, languageIndex + INDEXOFFSET);
-	if (hqrSize == 0) {
+	dialOrderSize = HQR::getAllocEntry((uint8 **)&dialOrderPtr, Resources::HQR_TEXT_FILE, languageIndex + INDEXOFFSET);
+	if (dialOrderSize == 0) {
 		warning("Failed to initialize text bank %i from file %s", languageIndex, Resources::HQR_TEXT_FILE);
 		return;
 	}
 
-	numDialTextEntries = hqrSize / 2;
+	numDialTextEntries = dialOrderSize / 2;
 
 	if (HQR::getAllocEntry((uint8 **)&dialTextPtr, Resources::HQR_TEXT_FILE, languageIndex + DIALOGSOFFSET) == 0) {
 		warning("Failed to initialize additional text bank %i from file %s", languageIndex + 1, Resources::HQR_TEXT_FILE);
@@ -155,10 +152,12 @@ void Text::initTextBank(int32 bankIdx) {
 void Text::drawCharacter(int32 x, int32 y, uint8 character) { // drawCharacter
 	const uint8 sizeX = getCharWidth(character);
 	uint8 sizeY = getCharHeight(character);
-	uint8 *data = _engine->_resources->fontPtr + *((const int16 *)(_engine->_resources->fontPtr + character * 4));
-	data += 2;
-	x += *(data++);
-	y += *(data++);
+	Common::MemoryReadStream stream(_engine->_resources->fontPtr, _engine->_resources->fontBufSize);
+	stream.seek(character * 4);
+	stream.seek(stream.readSint16LE());
+	stream.skip(2);
+	x += stream.readByte();
+	y += stream.readByte();
 
 	const uint8 usedColor = dialTextColor;
 
@@ -170,9 +169,9 @@ void Text::drawCharacter(int32 x, int32 y, uint8 character) { // drawCharacter
 	const int32 toNextLine = SCREEN_WIDTH - sizeX;
 
 	do {
-		uint8 index = *(data++);
+		uint8 index = stream.readByte();
 		do {
-			const uint8 jump = *(data++);
+			const uint8 jump = stream.readByte();
 			screen2 += jump;
 			tempX += jump;
 			if (--index == 0) {
@@ -185,7 +184,7 @@ void Text::drawCharacter(int32 x, int32 y, uint8 character) { // drawCharacter
 				}
 				break;
 			}
-			uint8 number = *(data++);
+			uint8 number = stream.readByte();
 			for (uint8 i = 0; i < number; i++) {
 				if (tempX >= SCREEN_TEXTLIMIT_LEFT && tempX < SCREEN_TEXTLIMIT_RIGHT && tempY >= SCREEN_TEXTLIMIT_TOP && tempY < SCREEN_TEXTLIMIT_BOTTOM) {
 					*((uint8 *)_engine->frontVideoBuffer.getBasePtr(tempX, tempY)) = usedColor;
@@ -493,11 +492,17 @@ void Text::printText10Sub2() {
 }
 
 int32 Text::getCharWidth(uint8 chr) const {
-	return *(_engine->_resources->fontPtr + *((const int16 *)(_engine->_resources->fontPtr + chr * 4)));
+	Common::MemoryReadStream stream(_engine->_resources->fontPtr, _engine->_resources->fontBufSize);
+	stream.seek(chr * 4);
+	stream.seek(stream.readSint16LE());
+	return stream.readByte();
 }
 
 int32 Text::getCharHeight(uint8 chr) const {
-	return *(_engine->_resources->fontPtr + 1 + *((const int16 *)(_engine->_resources->fontPtr + chr * 4)));
+	Common::MemoryReadStream stream(_engine->_resources->fontPtr, _engine->_resources->fontBufSize);
+	stream.seek(chr * 4);
+	stream.seek(stream.readSint16LE() + 1);
+	return stream.readByte();
 }
 
 // TODO: refactor this code
diff --git a/engines/twine/text.h b/engines/twine/text.h
index 5d21081852..1e65fb5f3b 100644
--- a/engines/twine/text.h
+++ b/engines/twine/text.h
@@ -146,6 +146,7 @@ private:
 	/** Dialogue text pointer */
 	char *dialTextPtr = nullptr; // bufText
 	/** Dialogue entry order pointer */
+	int32 dialOrderSize = 0;
 	char *dialOrderPtr = nullptr; // bufOrder
 	/** Number of dialogues text entries */
 	int16 numDialTextEntries = 0;


Commit: 73e2f2af8e08190d013210bd231cd26d935e529b
    https://github.com/scummvm/scummvm/commit/73e2f2af8e08190d013210bd231cd26d935e529b
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-06T16:52:45+01:00

Commit Message:
TWINE: converted to bool

Changed paths:
    engines/twine/script_life_v1.cpp
    engines/twine/text.h


diff --git a/engines/twine/script_life_v1.cpp b/engines/twine/script_life_v1.cpp
index 70e22becdd..7900b3cf9f 100644
--- a/engines/twine/script_life_v1.cpp
+++ b/engines/twine/script_life_v1.cpp
@@ -1292,13 +1292,13 @@ static int32 lEXPLODE_OBJ(TwinEEngine *engine, LifeScriptContext &ctx) {
 
 /*0x59*/
 static int32 lBUBBLE_ON(TwinEEngine *engine, LifeScriptContext &ctx) {
-	engine->_text->showDialogueBubble = 1;
+	engine->_text->showDialogueBubble = true;
 	return 0;
 }
 
 /*0x5A*/
 static int32 lBUBBLE_OFF(TwinEEngine *engine, LifeScriptContext &ctx) {
-	engine->_text->showDialogueBubble = 1;
+	engine->_text->showDialogueBubble = true; // TODO: this looks wrong - why true and not false?
 	return 0;
 }
 
diff --git a/engines/twine/text.h b/engines/twine/text.h
index 1e65fb5f3b..d2601bd4c2 100644
--- a/engines/twine/text.h
+++ b/engines/twine/text.h
@@ -217,7 +217,7 @@ public:
 	int32 nextDialTextEntry = 0; // ordered entry
 	Common::String currentVoxBankFile;
 
-	int32 showDialogueBubble = 1;
+	bool showDialogueBubble = true;
 
 	/**
 	 * Initialize dialogue


Commit: b13c10f0b4818686c1c6976a24a96848944f7e92
    https://github.com/scummvm/scummvm/commit/b13c10f0b4818686c1c6976a24a96848944f7e92
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-06T16:56:43+01:00

Commit Message:
TWINE: re-added detection entry from pull request 2557

looks like they were removed in 98df1b2

Changed paths:
    engines/twine/detection.cpp


diff --git a/engines/twine/detection.cpp b/engines/twine/detection.cpp
index 69b9c0a04c..9eb0d438a1 100644
--- a/engines/twine/detection.cpp
+++ b/engines/twine/detection.cpp
@@ -374,6 +374,33 @@ static const ADGameDescription twineGameDescriptions[] = {
 		ADGF_TESTING,
 		GUIO1(GUIO_NONE)
 	},
+	{
+		"lba",
+		"",
+		AD_ENTRY1s("text.hqr", "31d880f658cc6cc6d6cf70df732aec4f", 248829),
+		Common::EN_GRB,
+		Common::kPlatformDOS,
+		ADGF_TESTING,
+		GUIO1(GUIO_NONE)
+	},
+	{
+		"lba",
+		"",
+		AD_ENTRY1s("text.hqr", "31d880f658cc6cc6d6cf70df732aec4f", 248829),
+		Common::FR_FRA,
+		Common::kPlatformDOS,
+		ADGF_TESTING,
+		GUIO1(GUIO_NONE)
+	},
+	{
+		"lba",
+		"",
+		AD_ENTRY1s("text.hqr", "31d880f658cc6cc6d6cf70df732aec4f", 248829),
+		Common::DE_DEU,
+		Common::kPlatformDOS,
+		ADGF_TESTING,
+		GUIO1(GUIO_NONE)
+	},
 
 	// FAN Translations - http://lba.fishos.net/bit/index.html
 




More information about the Scummvm-git-logs mailing list