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

mgerhardy martin.gerhardy at gmail.com
Mon Dec 7 16:34:19 UTC 2020


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

Summary:
fbd8358d90 TWINE: cleanup in animation code
574b1b4d28 TWINE: renamed constants to match lba2remake findings
5cdad22b31 TWINE: reduced code duplication
b957500474 TWINE: renamed constants to match lba2remake findings


Commit: fbd8358d9087cdf03176263db9b8c91e44a72d53
    https://github.com/scummvm/scummvm/commit/fbd8358d9087cdf03176263db9b8c91e44a72d53
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-12-07T17:34:08+01:00

Commit Message:
TWINE: cleanup in animation code

Changed paths:
    engines/twine/animations.cpp


diff --git a/engines/twine/animations.cpp b/engines/twine/animations.cpp
index 78936dbf2d..b85ecc6f3d 100644
--- a/engines/twine/animations.cpp
+++ b/engines/twine/animations.cpp
@@ -199,19 +199,13 @@ int32 Animations::getAnimMode(uint8 **ptr, const uint8 **keyFramePtr, const uint
 }
 
 bool Animations::setModelAnimation(int32 animState, const uint8 *animPtr, uint8 *bodyPtr, AnimTimerDataStruct *animTimerDataPtr) {
+	if (!Model::isAnimated(bodyPtr)) {
+		return false;
+	}
 	int32 numOfPointInAnim = READ_LE_INT16(animPtr + 2);
-
 	const uint8* keyFramePtr = ((numOfPointInAnim * 8 + 8) * animState) + animPtr + 8;
-
 	const int32 keyFrameLength = READ_LE_INT16(keyFramePtr);
 
-	const Model *bodyHeader = (Model *)bodyPtr;
-	if (!bodyHeader->bodyFlag.animated) {
-		return false;
-	}
-
-	uint8 *edi = bodyPtr + 16;
-
 	const uint8 *lastKeyFramePtr = animTimerDataPtr->ptr;
 	int32 remainingFrameTime = animTimerDataPtr->time;
 
@@ -220,20 +214,22 @@ bool Animations::setModelAnimation(int32 animState, const uint8 *animPtr, uint8
 		remainingFrameTime = keyFrameLength;
 	}
 
-	edi += bodyHeader->offsetToData;
+	uint8 *verticesBase = bodyPtr + 0x1A;
 
-	int16 eax = READ_LE_INT16(edi);
-	eax = eax + eax * 2;
-	edi = edi + eax * 2 + 12;
+	const int16 numVertices = READ_LE_INT16(verticesBase);
+	verticesBase += 2;
+	uint8* bonesBase = verticesBase + numVertices * 6;
 
-	const int32 numOfPointInBody = READ_LE_INT16(edi - 10);
+	const int32 numBones = READ_LE_INT16(bonesBase);
+	bonesBase += 2;
 
-	if (numOfPointInAnim > numOfPointInBody) {
-		numOfPointInAnim = numOfPointInBody;
+	if (numOfPointInAnim > numBones) {
+		numOfPointInAnim = numBones;
 	}
 
 	const int32 deltaTime = _engine->lbaTime - remainingFrameTime;
 
+	uint8* edi = bonesBase + 8;
 	if (deltaTime >= keyFrameLength) {
 		const int32 *sourcePtr = (const int32 *)(keyFramePtr + 8);
 		int32 *destPtr = (int32 *)edi; // keyframe


Commit: 574b1b4d286e19921941eb0df1f74606e48920da
    https://github.com/scummvm/scummvm/commit/574b1b4d286e19921941eb0df1f74606e48920da
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-12-07T17:34:08+01:00

Commit Message:
TWINE: renamed constants to match lba2remake findings

Changed paths:
    engines/twine/animations.cpp


diff --git a/engines/twine/animations.cpp b/engines/twine/animations.cpp
index b85ecc6f3d..b6f64ddb06 100644
--- a/engines/twine/animations.cpp
+++ b/engines/twine/animations.cpp
@@ -55,16 +55,16 @@ enum ActionType {
 	ACTION_THROW_EXTRA_BONUS = 3,
 	ACTION_THROW_MAGIC_BALL = 4,
 	ACTION_SAMPLE_REPEAT = 5,
-	ACTION_UNKNOWN_6 = 6,
-	ACTION_UNKNOWN_7 = 7,
+	ACTION_THROW_SEARCH = 6,
+	ACTION_THROW_ALPHA = 7,
 	ACTION_SAMPLE_STOP = 8,
-	ACTION_UNKNOWN_9 = 9, // unused
+	ACTION_ZV = 9, // unused
 	ACTION_SAMPLE_BRICK_1 = 10,
 	ACTION_SAMPLE_BRICK_2 = 11,
 	ACTION_HERO_HITTING = 12,
-	ACTION_UNKNOWN_13 = 13,
-	ACTION_UNKNOWN_14 = 14,
-	ACTION_UNKNOWN_15 = 15,
+	ACTION_THROW_3D = 13,
+	ACTION_THROW_3D_ALPHA = 14,
+	ACTION_THROW_3D_SEARCH = 15,
 	ACTION_LAST
 };
 
@@ -441,36 +441,36 @@ void Animations::processAnimActions(int32 actorIdx) {
 
 		switch (actionType) {
 		case ACTION_HITTING: {
-			const int32 animPos = stream.readByte() - 1;
+			const int32 animFrame = stream.readByte() - 1;
 			const int32 strength = stream.readByte();
 
-			if (animPos == actor->animPosition) {
+			if (animFrame == actor->animPosition) {
 				actor->strengthOfHit = strength;
 				actor->dynamicFlags.bIsHitting = 1;
 			}
 			break;
 		}
 		case ACTION_SAMPLE: {
-			const int32 animPos = stream.readByte();
+			const int32 animFrame = stream.readByte();
 			const int16 sampleIdx = stream.readSint16LE();
 
-			if (animPos == actor->animPosition) {
+			if (animFrame == actor->animPosition) {
 				_engine->_sound->playSample(sampleIdx, 1, actor->x, actor->y, actor->z, actorIdx);
 			}
 			break;
 		}
 		case ACTION_SAMPLE_FREQ: {
-			const int32 animPos = stream.readByte();
+			const int32 animFrame = stream.readByte();
 			const int16 sampleIdx = stream.readSint16LE();
 			/*int16 frequency = */stream.readSint16LE();
 
-			if (animPos == actor->animPosition) {
+			if (animFrame == actor->animPosition) {
 				_engine->_sound->playSample(sampleIdx, 1, actor->x, actor->y, actor->z, actorIdx);
 			}
 			break;
 		}
 		case ACTION_THROW_EXTRA_BONUS: {
-			const int32 animPos = stream.readByte();
+			const int32 animFrame = stream.readByte();
 			const int32 yHeight = stream.readSint16LE();
 			const int32 sprite = stream.readByte();
 			const int32 xAngle = ToAngle(stream.readSint16LE());
@@ -479,52 +479,47 @@ void Animations::processAnimActions(int32 actorIdx) {
 			const int32 extraAngle = ToAngle(stream.readByte());
 			const int32 strengthOfHit = stream.readByte();
 
-			if (animPos == actor->animPosition) {
+			if (animFrame == actor->animPosition) {
 				_engine->_extra->addExtraThrow(actorIdx, actor->x, actor->y + yHeight, actor->z, sprite, xAngle, yAngle, xRotPoint, extraAngle, strengthOfHit);
 			}
 			break;
 		}
 		case ACTION_THROW_MAGIC_BALL: {
-			const int32 animPos = stream.readByte();
+			const int32 animFrame = stream.readByte();
 			const int32 yOffset = stream.readSint16LE();
 			const int32 xAngle = ToAngle(stream.readSint16LE());
 			const int32 xRotPoint = stream.readSint16LE();
 			const int32 extraAngle = stream.readByte();
 
-			if (_engine->_gameState->magicBallIdx == -1 && animPos == actor->animPosition) {
+			if (_engine->_gameState->magicBallIdx == -1 && animFrame == actor->animPosition) {
 				_engine->_extra->addExtraThrowMagicball(actor->x, actor->y + yOffset, actor->z, xAngle, actor->angle, xRotPoint, extraAngle);
 			}
 			break;
 		}
 		case ACTION_SAMPLE_REPEAT: {
-			const int32 animPos = stream.readByte();
+			const int32 animFrame = stream.readByte();
 			const int16 sampleIdx = stream.readSint16LE();
 			const int16 repeat = stream.readSint16LE();
 
-			if (animPos == actor->animPosition) {
+			if (animFrame == actor->animPosition) {
 				_engine->_sound->playSample(sampleIdx, repeat, actor->x, actor->y, actor->z, actorIdx);
 			}
 			break;
 		}
-		case ACTION_UNKNOWN_6: {
-			const int32 animPos = stream.readByte();
-			if (animPos == actor->animPosition) {
-				// TODO: The folowing fetches 7 bytes, but the else block skips only 6 bytes.
-				// Please check if that's correct.
-				const int32 yOffset = stream.readSint16LE();
-				const int32 spriteIdx = stream.readByte();
-				const int32 targetActorIdx = stream.readByte();
-				const int32 finalAngle = stream.readSint16LE();
-				const int32 strengthOfHit = stream.readByte();
-
+		case ACTION_THROW_SEARCH: {
+			const int32 animFrame = stream.readByte();
+			const int32 yOffset = stream.readSint16LE();
+			const int32 spriteIdx = stream.readByte();
+			const int32 targetActorIdx = stream.readByte();
+			const int32 finalAngle = stream.readSint16LE();
+			const int32 strengthOfHit = stream.readByte();
+			if (animFrame == actor->animPosition) {
 				_engine->_extra->addExtraAiming(actorIdx, actor->x, actor->y + yOffset, actor->z, spriteIdx, targetActorIdx, finalAngle, strengthOfHit);
-			} else {
-				stream.skip(6);
 			}
 			break;
 		}
-		case ACTION_UNKNOWN_7: {
-			const int32 animPos = stream.readByte();
+		case ACTION_THROW_ALPHA: {
+			const int32 animFrame = stream.readByte();
 			const int32 yHeight = stream.readSint16LE();
 			const int32 spriteIdx = stream.readByte();
 			const int32 xAngle = ToAngle(stream.readSint16LE());
@@ -533,47 +528,47 @@ void Animations::processAnimActions(int32 actorIdx) {
 			const int32 extraAngle = ToAngle(stream.readByte());
 			const int32 strengthOfHit = stream.readByte();
 
-			if (animPos == actor->animPosition) {
+			if (animFrame == actor->animPosition) {
 				_engine->_extra->addExtraThrow(actorIdx, actor->x, actor->y + yHeight, actor->z, spriteIdx, xAngle, yAngle, xRotPoint, extraAngle, strengthOfHit);
 			}
 			break;
 		}
 		case ACTION_SAMPLE_STOP: {
-			const int32 animPos = stream.readByte();
+			const int32 animFrame = stream.readByte();
 			const int32 sampleIdx = stream.readByte(); //why is it reading a byte but saving it in a 32bit variable?
 			stream.skip(1);               // TODO what is the meaning of this extra byte?
 
-			if (animPos == actor->animPosition) {
+			if (animFrame == actor->animPosition) {
 				_engine->_sound->stopSample(sampleIdx);
 			}
 			break;
 		}
 		case ACTION_SAMPLE_BRICK_1: {
-			const int32 animPos = stream.readByte();
-			if (animPos == actor->animPosition && (actor->brickSound & 0x0F0) != 0x0F0) {
+			const int32 animFrame = stream.readByte();
+			if (animFrame == actor->animPosition && (actor->brickSound & 0x0F0) != 0x0F0) {
 				const int16 sampleIdx = (actor->brickSound & 0x0F) + Samples::WalkFloorBegin;
 				_engine->_sound->playSample(sampleIdx, 1, actor->x, actor->y, actor->z, actorIdx);
 			}
 			break;
 		}
 		case ACTION_SAMPLE_BRICK_2: {
-			const int32 animPos = stream.readByte();
-			if (animPos == actor->animPosition && (actor->brickSound & 0x0F0) != 0x0F0) {
+			const int32 animFrame = stream.readByte();
+			if (animFrame == actor->animPosition && (actor->brickSound & 0x0F0) != 0x0F0) {
 				const int16 sampleIdx = (actor->brickSound & 0x0F) + Samples::WalkFloorBegin;
 				_engine->_sound->playSample(sampleIdx, 1, actor->x, actor->y, actor->z, actorIdx);
 			}
 			break;
 		}
 		case ACTION_HERO_HITTING: {
-			const int32 animPos = stream.readByte() - 1;
-			if (animPos == actor->animPosition) {
+			const int32 animFrame = stream.readByte() - 1;
+			if (animFrame == actor->animPosition) {
 				actor->strengthOfHit = magicLevelStrengthOfHit[_engine->_gameState->magicLevelIdx];
 				actor->dynamicFlags.bIsHitting = 1;
 			}
 			break;
 		}
-		case ACTION_UNKNOWN_13: {
-			const int32 animPos = stream.readByte();
+		case ACTION_THROW_3D: {
+			const int32 animFrame = stream.readByte();
 			const int32 distanceX = stream.readSint16LE();
 			const int32 distanceY = stream.readSint16LE();
 			const int32 distanceZ = stream.readSint16LE();
@@ -584,7 +579,7 @@ void Animations::processAnimActions(int32 actorIdx) {
 			const int32 extraAngle = ToAngle(stream.readByte());
 			const int32 strength = stream.readByte();
 
-			if (animPos == actor->animPosition) {
+			if (animFrame == actor->animPosition) {
 				_engine->_movements->rotateActor(distanceX, distanceZ, actor->angle);
 
 				const int32 throwX = _engine->_renderer->destX + actor->x;
@@ -596,8 +591,8 @@ void Animations::processAnimActions(int32 actorIdx) {
 			}
 			break;
 		}
-		case ACTION_UNKNOWN_14: {
-			const int32 animPos = stream.readByte();
+		case ACTION_THROW_3D_ALPHA: {
+			const int32 animFrame = stream.readByte();
 			const int32 distanceX = stream.readSint16LE();
 			const int32 distanceY = stream.readSint16LE();
 			const int32 distanceZ = stream.readSint16LE();
@@ -608,7 +603,7 @@ void Animations::processAnimActions(int32 actorIdx) {
 			const int32 extraAngle = ToAngle(stream.readByte());
 			const int32 strength = stream.readByte();
 
-			if (animPos == actor->animPosition) {
+			if (animFrame == actor->animPosition) {
 				const int32 newAngle = _engine->_movements->getAngleAndSetTargetActorDistance(actor->y, 0, _engine->_scene->sceneHero->y, _engine->_movements->getDistance2D(actor->x, actor->z, _engine->_scene->sceneHero->x, _engine->_scene->sceneHero->z));
 
 				_engine->_movements->rotateActor(distanceX, distanceZ, actor->angle);
@@ -622,8 +617,8 @@ void Animations::processAnimActions(int32 actorIdx) {
 			}
 			break;
 		}
-		case ACTION_UNKNOWN_15: {
-			const int32 animPos = stream.readByte();
+		case ACTION_THROW_3D_SEARCH: {
+			const int32 animFrame = stream.readByte();
 			const int32 distanceX = stream.readSint16LE();
 			const int32 distanceY = stream.readSint16LE();
 			const int32 distanceZ = stream.readSint16LE();
@@ -632,14 +627,14 @@ void Animations::processAnimActions(int32 actorIdx) {
 			const int32 finalAngle = ToAngle(stream.readSint16LE());
 			const int32 strengthOfHit = stream.readByte();
 
-			if (animPos == actor->animPosition) {
+			if (animFrame == actor->animPosition) {
 				_engine->_movements->rotateActor(distanceX, distanceZ, actor->angle);
 				_engine->_extra->addExtraAiming(actorIdx, actor->x + _engine->_renderer->destX, actor->y + distanceY, actor->z + distanceZ, spriteIdx,
 				                                targetActor, finalAngle, strengthOfHit);
 			}
 			break;
 		}
-		case ACTION_UNKNOWN_9:
+		case ACTION_ZV:
 			break;
 		default:
 			break;


Commit: 5cdad22b3195b4349b3d6c98689595b4874f01c6
    https://github.com/scummvm/scummvm/commit/5cdad22b3195b4349b3d6c98689595b4874f01c6
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-12-07T17:34:08+01:00

Commit Message:
TWINE: reduced code duplication

Changed paths:
    engines/twine/animations.cpp


diff --git a/engines/twine/animations.cpp b/engines/twine/animations.cpp
index b6f64ddb06..304d3134da 100644
--- a/engines/twine/animations.cpp
+++ b/engines/twine/animations.cpp
@@ -543,14 +543,7 @@ void Animations::processAnimActions(int32 actorIdx) {
 			}
 			break;
 		}
-		case ACTION_SAMPLE_BRICK_1: {
-			const int32 animFrame = stream.readByte();
-			if (animFrame == actor->animPosition && (actor->brickSound & 0x0F0) != 0x0F0) {
-				const int16 sampleIdx = (actor->brickSound & 0x0F) + Samples::WalkFloorBegin;
-				_engine->_sound->playSample(sampleIdx, 1, actor->x, actor->y, actor->z, actorIdx);
-			}
-			break;
-		}
+		case ACTION_SAMPLE_BRICK_1:
 		case ACTION_SAMPLE_BRICK_2: {
 			const int32 animFrame = stream.readByte();
 			if (animFrame == actor->animPosition && (actor->brickSound & 0x0F0) != 0x0F0) {


Commit: b957500474cf1ba38bc9d966dbb648aed15335e2
    https://github.com/scummvm/scummvm/commit/b957500474cf1ba38bc9d966dbb648aed15335e2
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-12-07T17:34:08+01:00

Commit Message:
TWINE: renamed constants to match lba2remake findings

Changed paths:
    engines/twine/animations.cpp


diff --git a/engines/twine/animations.cpp b/engines/twine/animations.cpp
index 304d3134da..7f7eeebce3 100644
--- a/engines/twine/animations.cpp
+++ b/engines/twine/animations.cpp
@@ -49,22 +49,27 @@ static const int32 magicLevelStrengthOfHit[] = {
 };
 
 enum ActionType {
-	ACTION_HITTING = 0,
-	ACTION_SAMPLE = 1,
-	ACTION_SAMPLE_FREQ = 2,
-	ACTION_THROW_EXTRA_BONUS = 3,
-	ACTION_THROW_MAGIC_BALL = 4,
-	ACTION_SAMPLE_REPEAT = 5,
-	ACTION_THROW_SEARCH = 6,
-	ACTION_THROW_ALPHA = 7,
-	ACTION_SAMPLE_STOP = 8,
-	ACTION_ZV = 9, // unused
-	ACTION_SAMPLE_BRICK_1 = 10,
-	ACTION_SAMPLE_BRICK_2 = 11,
-	ACTION_HERO_HITTING = 12,
-	ACTION_THROW_3D = 13,
-	ACTION_THROW_3D_ALPHA = 14,
-	ACTION_THROW_3D_SEARCH = 15,
+	ACTION_NOP = 0,
+	ACTION_BODY = 1,
+	ACTION_BODP = 2,
+	ACTION_ANIM = 3,
+	ACTION_ANIP = 4,
+	ACTION_HITTING = 5,
+	ACTION_SAMPLE = 6,
+	ACTION_SAMPLE_FREQ = 7,
+	ACTION_THROW_EXTRA_BONUS = 8,
+	ACTION_THROW_MAGIC_BALL = 9,
+	ACTION_SAMPLE_REPEAT = 10,
+	ACTION_THROW_SEARCH = 11,
+	ACTION_THROW_ALPHA = 12,
+	ACTION_SAMPLE_STOP = 13,
+	ACTION_ZV = 14, // unused
+	ACTION_LEFT_STEP = 15,
+	ACTION_RIGHT_STEP = 16,
+	ACTION_HERO_HITTING = 17,
+	ACTION_THROW_3D = 18,
+	ACTION_THROW_3D_ALPHA = 19,
+	ACTION_THROW_3D_SEARCH = 20,
 	ACTION_LAST
 };
 
@@ -434,7 +439,7 @@ void Animations::processAnimActions(int32 actorIdx) {
 	int32 index = 0;
 	const int32 endAnimEntityIdx = stream.readByte();
 	while (index++ < endAnimEntityIdx) {
-		const int32 actionType = stream.readByte() - 5;
+		const int32 actionType = stream.readByte();
 		if (actionType >= ACTION_LAST) {
 			return;
 		}
@@ -543,8 +548,8 @@ void Animations::processAnimActions(int32 actorIdx) {
 			}
 			break;
 		}
-		case ACTION_SAMPLE_BRICK_1:
-		case ACTION_SAMPLE_BRICK_2: {
+		case ACTION_LEFT_STEP:
+		case ACTION_RIGHT_STEP: {
 			const int32 animFrame = stream.readByte();
 			if (animFrame == actor->animPosition && (actor->brickSound & 0x0F0) != 0x0F0) {
 				const int16 sampleIdx = (actor->brickSound & 0x0F) + Samples::WalkFloorBegin;
@@ -628,7 +633,6 @@ void Animations::processAnimActions(int32 actorIdx) {
 			break;
 		}
 		case ACTION_ZV:
-			break;
 		default:
 			break;
 		}




More information about the Scummvm-git-logs mailing list