[Scummvm-git-logs] scummvm master -> 6fd22e78ad8a9607c27536119bed59a554d64a61

mgerhardy noreply at scummvm.org
Fri Oct 18 18:23:14 UTC 2024


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

Summary:
5a3fdf415b TWINE: further renaming and comments about original names
6fd22e78ad TWINE: activated some lba2 code snippets


Commit: 5a3fdf415bef61f45ff567f4bbbae5ddcc757752
    https://github.com/scummvm/scummvm/commit/5a3fdf415bef61f45ff567f4bbbae5ddcc757752
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2024-10-18T20:22:15+02:00

Commit Message:
TWINE: further renaming and comments about original names

Changed paths:
    engines/twine/scene/actor.h
    engines/twine/scene/movements.h
    engines/twine/scene/scene.cpp
    engines/twine/script/script_life.cpp
    engines/twine/shared.h


diff --git a/engines/twine/scene/actor.h b/engines/twine/scene/actor.h
index 016b4aedcfb..8299ba6c742 100644
--- a/engines/twine/scene/actor.h
+++ b/engines/twine/scene/actor.h
@@ -98,10 +98,10 @@ struct DynamicFlagsStruct {
 	uint32 bIsTargetable : 1;            // 0x0200 IS_TARGETABLE (lba1) OK_SUPER_HIT (lba2)
 	uint32 bIsBlinking : 1;              // 0x0400 IS_BLINKING (lba1) FRAME_SHIELD (lba2)
 	uint32 bWasWalkingBeforeFalling : 1; // 0x0800 DRAW_SHADOW (lba2) - bWasWalkingBeforeFalling in lba1
-	uint32 bUnk1000 : 1;                 // 0x1000 ANIM_MASTER_GRAVITY (lba2)
-	uint32 bUnk2000 : 1;                 // 0x2000 SKATING (lba2) Ouch! I slip in a forbidden collision
-	uint32 bUnk4000 : 1;                 // 0x4000 OK_RENVOIE (lba2) ready to send back a projectile
-	uint32 bUnk8000 : 1;                 // 0x8000 LEFT_JUMP (lba2) ready to jump from the left foot
+	uint32 bANIM_MASTER_GRAVITY : 1;     // 0x1000 ANIM_MASTER_GRAVITY (lba2)
+	uint32 bSKATING : 1;                 // 0x2000 SKATING (lba2) Ouch! I slip in a forbidden collision
+	uint32 bOK_RENVOIE : 1;              // 0x4000 OK_RENVOIE (lba2) ready to send back a projectile
+	uint32 bLEFT_JUMP : 1;               // 0x8000 LEFT_JUMP (lba2) ready to jump from the left foot
 	uint32 bRIGHT_JUMP : 1;              // RIGHT_JUMP          (1<<16) // (lba2) ready to jump from the right foot
 	uint32 bWAIT_SUPER_HIT : 1;          // WAIT_SUPER_HIT      (1<<17) // (lba2) waiting for the end of the animation before giving another super hit
 	uint32 bTRACK_MASTER_ROT : 1;        // TRACK_MASTER_ROT    (1<<18) // (lba2) it's the track that manages the direction
diff --git a/engines/twine/scene/movements.h b/engines/twine/scene/movements.h
index d25d20ea54e..48cdf038f38 100644
--- a/engines/twine/scene/movements.h
+++ b/engines/twine/scene/movements.h
@@ -129,7 +129,7 @@ public:
 	/**
 	 * Hero executes the current action of the trigger zone
 	 */
-	bool shouldExecuteAction() const;
+	bool actionNormal() const;
 
 	bool _lastJoyFlag = false;
 
@@ -194,7 +194,7 @@ inline void Movements::setActionNormal(bool actionNormal) {
 	_actionNormal = actionNormal;
 }
 
-inline bool Movements::shouldExecuteAction() const {
+inline bool Movements::actionNormal() const {
 	return _actionNormal;
 }
 
diff --git a/engines/twine/scene/scene.cpp b/engines/twine/scene/scene.cpp
index 7f50e4280ed..018888eccc9 100644
--- a/engines/twine/scene/scene.cpp
+++ b/engines/twine/scene/scene.cpp
@@ -838,13 +838,13 @@ void Scene::checkZoneSce(int32 actorIdx) {
 				}
 				break;
 			case ZoneType::kObject:
-				if (IS_HERO(actorIdx) && _engine->_movements->shouldExecuteAction()) {
+				if (IS_HERO(actorIdx) && _engine->_movements->actionNormal()) {
 					_engine->_animations->initAnim(AnimationTypes::kAction, AnimType::kAnimationThen, AnimationTypes::kStanding, OWN_ACTOR_SCENE_INDEX);
 					processZoneExtraBonus(zone);
 				}
 				break;
 			case ZoneType::kText:
-				if (IS_HERO(actorIdx) && _engine->_movements->shouldExecuteAction()) {
+				if (IS_HERO(actorIdx) && _engine->_movements->actionNormal()) {
 					_engine->saveTimer(false);
 					_engine->testRestoreModeSVGA(true);
 					_engine->_text->setFontCrossColor(zone->infoData.DisplayText.textColor);
diff --git a/engines/twine/script/script_life.cpp b/engines/twine/script/script_life.cpp
index 69d073095cb..f32db9c7a0a 100644
--- a/engines/twine/script/script_life.cpp
+++ b/engines/twine/script/script_life.cpp
@@ -284,7 +284,7 @@ static ReturnType processLifeConditions(TwinEEngine *engine, LifeScriptContext &
 	}
 	case kcACTION:
 		debugCN(3, kDebugLevels::kDebugScriptsLife, "action(");
-		engine->_scene->_currentScriptValue = engine->_movements->shouldExecuteAction() ? 1 : 0;
+		engine->_scene->_currentScriptValue = engine->_movements->actionNormal() ? 1 : 0;
 		break;
 	case kcFLAG_GAME: {
 		int32 flagIdx = ctx.stream.readByte();
diff --git a/engines/twine/shared.h b/engines/twine/shared.h
index 7a9d46ac150..e6d5fa9402e 100644
--- a/engines/twine/shared.h
+++ b/engines/twine/shared.h
@@ -323,15 +323,15 @@ enum class AnimationTypes {
 
 enum class AnimType {
 	kAnimationTypeRepeat = 0, // ANIM_REPEAT
-	kAnimationThen = 1,
+	kAnimationThen = 1, // ANIM_THEN
 	// play animation and let animExtra follow as next animation
 	// if there is already a next animation set - replace the value
-	kAnimationAllThen = 2,
+	kAnimationAllThen = 2, // ANIM_ALL_THEN
 	// replace animation and let the current animation follow
-	kAnimationInsert = 3,
+	kAnimationInsert = 3, // ANIM_TEMPO
 	// play animation and let animExtra follow as next animation
 	// but don't take the current state in account
-	kAnimationSet = 4
+	kAnimationSet = 4 // ANIM_FINAL
 };
 
 /** Hero behaviour


Commit: 6fd22e78ad8a9607c27536119bed59a554d64a61
    https://github.com/scummvm/scummvm/commit/6fd22e78ad8a9607c27536119bed59a554d64a61
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2024-10-18T20:22:15+02:00

Commit Message:
TWINE: activated some lba2 code snippets

Changed paths:
    engines/twine/parser/anim.h
    engines/twine/parser/body.cpp
    engines/twine/scene/actor.h
    engines/twine/scene/buggy.cpp
    engines/twine/scene/dart.cpp


diff --git a/engines/twine/parser/anim.h b/engines/twine/parser/anim.h
index 0682f7eccee..1212be24abd 100644
--- a/engines/twine/parser/anim.h
+++ b/engines/twine/parser/anim.h
@@ -35,12 +35,13 @@ enum BoneType : uint16 {
 	TYPE_ZOOM = 2,
 };
 
-struct BoneFrame {
+struct BoneFrame { // T_GROUP_INFO
 	BoneType type = BoneType::TYPE_ROTATE;
 	int16 x = 0; // alpha
 	int16 y = 0; // beta
 	int16 z = 0; // gamma
 };
+using T_GROUP_INFO = BoneFrame; // (lba2)
 
 struct KeyFrame {
 	uint16 length = 0;
diff --git a/engines/twine/parser/body.cpp b/engines/twine/parser/body.cpp
index 0443f0834f5..c4d54dc3a66 100644
--- a/engines/twine/parser/body.cpp
+++ b/engines/twine/parser/body.cpp
@@ -201,9 +201,10 @@ bool BodyData::loadFromStream(Common::SeekableReadStream &stream, bool lba1) {
 		loadLines(stream);
 		loadSpheres(stream);
 	} else {
+		// T_BODY_HEADER (lba2)
 		const uint32 flags = stream.readUint32LE();
 		animated = (flags & 2) != 0;
-		stream.skip(4);
+		stream.skip(4); // int16 size of header and int16 dummy
 		bbox.mins.x = stream.readSint32LE();
 		bbox.maxs.x = stream.readSint32LE();
 		bbox.mins.y = stream.readSint32LE();
diff --git a/engines/twine/scene/actor.h b/engines/twine/scene/actor.h
index 8299ba6c742..a806b4819e8 100644
--- a/engines/twine/scene/actor.h
+++ b/engines/twine/scene/actor.h
@@ -246,6 +246,9 @@ public:
 	// SizeSHit contains the number of the brick under the wagon - hack
 	int16 SizeSHit; // lba2 - always square
 
+	// T_OBJ_3D Obj; // lba2
+	// T_GROUP_INFO CurrentFrame[30]; // lba2
+
 	BoundingBox _boundingBox; // Xmin, YMin, Zmin, Xmax, Ymax, Zmax
 	RealValue realAngle;
 	AnimTimerDataStruct _animTimerData;
diff --git a/engines/twine/scene/buggy.cpp b/engines/twine/scene/buggy.cpp
index 7cbe727ed3c..74d24519618 100644
--- a/engines/twine/scene/buggy.cpp
+++ b/engines/twine/scene/buggy.cpp
@@ -113,31 +113,30 @@ void Buggy::resetBuggy() {
 }
 
 void Buggy::takeBuggy() {
-#if 0
 	int32 sample;
 	ActorStruct *ptrobj = _engine->_scene->getActor(OWN_ACTOR_SCENE_INDEX);
 	S_BUGGY *ptb = &ListBuggy[0];
 
 	ptb->SpeedRot = 1024;
-	ptb->LastTimer = TimerRefHR;
+	// TODO: ptb->LastTimer = TimerRefHR;
 
 	// TODO: ObjectClear(&ptrobj);
 
 	// Shielding in case the Buggy moved (being pushed, for example).
-	ptb->X = _engine->_scene->getActor(NUM_BUGGY)->_pos.x;
-	ptb->Y = _engine->_scene->getActor(NUM_BUGGY)->_pos.y;
-	ptb->Z = _engine->_scene->getActor(NUM_BUGGY)->_pos.z;
+	ptb->X = _engine->_scene->getActor(NUM_BUGGY)->_posObj.x;
+	ptb->Y = _engine->_scene->getActor(NUM_BUGGY)->_posObj.y;
+	ptb->Z = _engine->_scene->getActor(NUM_BUGGY)->_posObj.z;
 
-	ptrobj->_pos.x = ptb->X;
-	ptrobj->_pos.y = ptb->Y;
-	ptrobj->_pos.z = ptb->Z;
+	ptrobj->_posObj.x = ptb->X;
+	ptrobj->_posObj.y = ptb->Y;
+	ptrobj->_posObj.z = ptb->Z;
 	ptrobj->_beta = ptb->Beta;
 	_engine->_movements->clearRealAngle(ptrobj); // To avoid crushing the beta.
 
 	ptrobj->_workFlags.bMANUAL_INTER_FRAME = true;
 	ptrobj->_flags.bHasZBuffer = true;
 
-	_engine->_actor->setBehaviour(HeroBehaviourType::kBUGGY);
+	// TODO: _engine->_actor->setBehaviour(HeroBehaviourType::kBUGGY);
 
 	// Switch Buggy Scenario to NoBody.
 	_engine->_actor->initBody(BodyType::btNone, NUM_BUGGY);
@@ -155,14 +154,13 @@ void Buggy::takeBuggy() {
 
 	ptrobj->SampleVolume = 20;
 
-	ParmSampleVolume = ptrobj->SampleVolume;
+	// TODO: ParmSampleVolume = ptrobj->SampleVolume;
 
 	Gear = 0;
 	TimerGear = 0;
 
-	ptrobj->SampleAlways = _engine->_sound->playSample(SAMPLE_BUGGY, 4096, 0, 0,
-										   ptrobj->_pos.x, ptrobj->_pos.y, ptrobj->_pos.z);
-#endif
+	// TODO: ptrobj->SampleAlways = _engine->_sound->playSample(SAMPLE_BUGGY, 4096, 0, 0,
+	//    ptrobj->_posObj.x, ptrobj->_posObj.y, ptrobj->_posObj.z);
 }
 
 #if 0
@@ -222,6 +220,105 @@ void Buggy::leaveBuggy(HeroBehaviourType behaviour) {
 	_engine->_actor->posObjectAroundAnother(NUM_BUGGY, OWN_ACTOR_SCENE_INDEX);
 }
 
+#if 0
+
+struct T_HALF_POLY {
+	uint32 Bank : 4;       // coul bank poly
+	uint32 TexFlag : 2;    // flag texture 00 rien 01 triste 10 flat 11 gouraud
+	uint32 PolyFlag : 2;   // flag poly 00 rien 01 flat 10 gouraud 11 dither
+	uint32 SampleStep : 4; // sample pas twinsen
+	uint32 CodeJeu : 4;    // code jeu
+	uint32 Sens : 1;       // sens diagonale
+	uint32 Col : 1;
+	uint32 Dummy : 1;
+	uint32 IndexTex : 13; // index texture 8192
+}; // 1 long
+
+struct T_HALF_TEX {
+	uint16 Tx0;
+	uint16 Ty0;
+	uint16 Tx1;
+	uint16 Ty1;
+	uint16 Tx2;
+	uint16 Ty2;
+}; // 2 Longs
+
+int32 CalculAltitudeObjet(int32 x, int32 z, int32 cj) {
+	int32 y0, y1, y2, y3;
+	int32 dx, dz;
+	int32 dz0, dz1;
+
+	dx = x >> 9; // div512
+	dz = z >> 9; // div512
+
+	if ((dx < 0) || (dx > 63))
+		return -1;
+	if ((dz < 0) || (dz > 63))
+		return -1;
+
+	x &= 511;
+	z &= 511;
+
+	dz0 = dz * 65;
+	dz1 = dz0 + 65;
+
+	//---------------------------------------------------------------
+	if (cj == -1) {
+		T_HALF_POLY *mappoly = &MapPolyGround[dz * 64 * 2 + dx * 2];
+
+		if (mappoly->Sens == 0) // poly séparé par ligne reliant point 0 et 2
+		{
+			if (x >= z) // poly de droite
+			{
+				mappoly++;
+			}
+		} else // poly séparé par ligne reliant point 1 et 3
+		{
+			if (511 - x <= z) // poly de droite
+			{
+				mappoly++;
+			}
+		}
+
+		cj = (uint8)mappoly->CodeJeu;
+	}
+	//--------------------------------------------------------------
+
+	y0 = MapSommetY[dz0 + dx];
+	y1 = MapSommetY[dz1 + dx];
+	y2 = MapSommetY[dz1 + (dx + 1)];
+	y3 = MapSommetY[dz0 + (dx + 1)];
+
+	if (cj == CJ_FOOT_WATER OR cj == CJ_WATER) {
+		uint8 *i = &MapIntensity[dz0 + dx];
+
+		y0 += (i[0] >> 4) * -200;
+		y1 += (i[65] >> 4) * -200;
+		y2 += (i[65 + 1] >> 4) * -200;
+		y3 += (i[1] >> 4) * -200;
+	}
+	if (MapPolyGround[dz * 64 * 2 + dx * 2].Sens == 0) // poly séparé par ligne reliant point 0 et 2
+	{
+		if (x < z) // poly de gauche
+		{
+			return (y0 + ((y1 - y0) * z + (y2 - y1) * x) / 512);
+		} else // poly de droite
+		{
+			return (y0 + ((y3 - y0) * x + (y2 - y3) * z) / 512);
+		}
+	} else // poly séparé par ligne reliant point 1 et 3
+	{
+		if (511 - x > z) // poly de gauche
+		{
+			return (y0 + ((y3 - y0) * x + (y1 - y0) * z) / 512);
+		} else // poly de droite
+		{
+			return (y1 + ((y2 - y1) * x + (y3 - y2) * (511 - z)) / 512);
+		}
+	}
+}
+#endif
+
 void Buggy::doAnimBuggy(ActorStruct *ptrobj) {
 #if 0
 	int32 x1, y1, z1, yw;
@@ -236,16 +333,16 @@ void Buggy::doAnimBuggy(ActorStruct *ptrobj) {
 	// Trick to avoid crushing the groups in AffOneObject().
 	ObjectSetInterFrame(ptb3d);
 
-	if (ptrobj->_workFlags.bIsFalling || ptrobj->_workFlags.bUnk1000) {
+	if (ptrobj->_workFlags.bIsFalling || ptrobj->_workFlags.bANIM_MASTER_GRAVITY) {
 		return;
 	}
 
 	LongRotate(0, ptb->SpeedInc * 1024, ptb3d->Beta);
-	Nxw = ptb3d->X + X0 / 1024;
-	Nzw = ptb3d->Z + Z0 / 1024;
+	ptrobj->_processActor.x = ptb3d->X + X0 / 1024;
+	ptrobj->_processActor.z = ptb3d->Z + Z0 / 1024;
 
 	// Ideal altitude
-	yw = CalculAltitudeObjet(Nxw, Nzw, -1); // Ground Y for XZ
+	yw = CalculAltitudeObjet(ptrobj->_processActor.x, ptrobj->_processActor.z, -1); // Ground Y for XZ
 
 	// test altitude #2: Forbidden triangles
 
@@ -259,8 +356,8 @@ void Buggy::doAnimBuggy(ActorStruct *ptrobj) {
 	// front right wheel
 
 	LongRotate(-400, 400, ptb3d->Beta);
-	x = Nxw + X0;
-	z = Nzw + Z0;
+	x = ptrobj->_processActor.x + X0;
+	z = ptrobj->_processActor.z + Z0;
 	y = yw;
 
 	if (x >= 0 && x < 32768 && z >= 0 && z < 32768) {
@@ -283,8 +380,8 @@ void Buggy::doAnimBuggy(ActorStruct *ptrobj) {
 	// front left wheel
 
 	LongRotate(400, 400, ptb3d->Beta);
-	x = Nxw + X0;
-	z = Nzw + Z0;
+	x = ptrobj->_processActor.x + X0;
+	z = ptrobj->_processActor.z + Z0;
 	y = yw;
 
 	if (x >= 0 && x < 32768 && z >= 0 && z < 32768) {
@@ -307,8 +404,8 @@ void Buggy::doAnimBuggy(ActorStruct *ptrobj) {
 	// back left wheel
 
 	LongRotate(400, -350, ptb3d->Beta);
-	x = Nxw + X0;
-	z = Nzw + Z0;
+	x = ptrobj->_processActor.x + X0;
+	z = ptrobj->_processActor.z + Z0;
 	y = yw;
 
 	if (x >= 0 && x < 32768 && z >= 0 && z < 32768) {
@@ -331,8 +428,8 @@ void Buggy::doAnimBuggy(ActorStruct *ptrobj) {
 	// back right wheel
 
 	LongRotate(-400, -350, ptb3d->Beta);
-	x = Nxw + X0;
-	z = Nzw + Z0;
+	x = ptrobj->_processActor.x + X0;
+	z = ptrobj->_processActor.z + Z0;
 	y = yw;
 
 	if (x >= 0 && x < 32768 && z >= 0 && z < 32768) {
@@ -455,7 +552,7 @@ void Buggy::moveBuggy(ActorStruct *ptrobj) {
 		}
 	}
 
-	if (!flagattack && !ptrobj->_workFlags.bIsFalling && !ptrobj->_workFlags.bUnk1000) {
+	if (!flagattack && !ptrobj->_workFlags.bIsFalling && !ptrobj->_workFlags.bANIM_MASTER_GRAVITY) {
 		_engine->_movements->clearRealAngle(ptrobj);
 
 		if (_engine->_movements->_lastJoyFlag && (((Input & I_JOY) != LastMyJoy) || ((Input & I_FIRE) != LastMyFire))) {
@@ -487,7 +584,7 @@ void Buggy::moveBuggy(ActorStruct *ptrobj) {
 		}
 	}
 
-	if (!ptrobj->_workFlags.bIsFalling && !ptrobj->_workFlags.bUnk1000) {
+	if (!ptrobj->_workFlags.bIsFalling && !ptrobj->_workFlags.bANIM_MASTER_GRAVITY) {
 		// check speed command
 		if ((Input & I_UP) // accelerating
 			&& !flagattack) {
@@ -559,7 +656,7 @@ void Buggy::moveBuggy(ActorStruct *ptrobj) {
 			rotlevel = 0;
 		}
 
-		if (ptrobj->_staticFlags & SKATING) {
+		if (ptrobj->_staticFlags.bSKATING) {
 			ptb->Speed = 3000;
 			speedinc = ptb->Speed * deltatimer / 1000;
 		} else {
diff --git a/engines/twine/scene/dart.cpp b/engines/twine/scene/dart.cpp
index eb4866bc51a..b9f22a21fb3 100644
--- a/engines/twine/scene/dart.cpp
+++ b/engines/twine/scene/dart.cpp
@@ -28,12 +28,9 @@
 namespace TwinE {
 
 void Dart::InitDarts() {
+	int32 x0, x1, y0, y1, z0, z1;
 #if 0
-	T_DART *ptrd;
 	uint8 *ptrbody;
-	uint32 t;
-	int32 x0, x1, y0, y1, z0, z1;
-	int32 size;
 	T_BODY_HEADER *ptr;
 
 	ptrbody = (uint8 *)GivePtrObjFix(BODY_3D_DART);
@@ -51,13 +48,16 @@ void Dart::InitDarts() {
 	y1 = ptr->YMax;
 	z0 = ptr->ZMin;
 	z1 = ptr->ZMax;
+#else
+	x0 = x1 = y0 = y1 = z0 = z1 = 0;
+#endif
 
 	// Average
-	size = ((x1 - x0) + (z1 - z0)) / 4;
+	int32 size = ((x1 - x0) + (z1 - z0)) / 4;
 
-	ptrd = ListDart;
+	T_DART *ptrd = ListDart;
 
-	for (t = 0; t < MAX_DARTS; t++, ptrd++) {
+	for (uint32 t = 0; t < MAX_DARTS; t++, ptrd++) {
 		ptrd->Body = BODY_3D_DART;
 
 		ptrd->XMin = -size;
@@ -70,7 +70,6 @@ void Dart::InitDarts() {
 		ptrd->Flags = 0;
 		ptrd->NumCube = -1;
 	}
-#endif
 }
 
 int32 Dart::GetDart() {




More information about the Scummvm-git-logs mailing list