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

mgerhardy noreply at scummvm.org
Sat Jan 21 20:30:36 UTC 2023


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

Summary:
a658b349d8 TWINE: renamed variables and updated doxygen
1b8252df0b TWINE: renamed variables and ActorMoveStruct functions
2e53c0fa3f TWINE: unified movement stuff with original sources
c53ce8923a TWINE: more renaming
72b4bfb052 TWINE: continue with renaming
de50ee3e4a TWINE: removed vtop and vbottom from renderPolygons


Commit: a658b349d8ce04f3e73c9625cc4ef65934490669
    https://github.com/scummvm/scummvm/commit/a658b349d8ce04f3e73c9625cc4ef65934490669
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2023-01-21T18:10:01+01:00

Commit Message:
TWINE: renamed variables and updated doxygen

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


diff --git a/engines/twine/scene/movements.cpp b/engines/twine/scene/movements.cpp
index 908ed116ba8..412de674bc8 100644
--- a/engines/twine/scene/movements.cpp
+++ b/engines/twine/scene/movements.cpp
@@ -140,14 +140,14 @@ int32 Movements::getAngleAndSetTargetActorDistance(int32 x1, int32 z1, int32 x2,
 	return ClampAngle(finalAngle);
 }
 
-IVec3 Movements::rotate(int32 x, int32 z, int32 angle) {
+IVec3 Movements::rotate(int32 side, int32 forward, int32 angle) {
 	if (angle) {
 		const double radians = AngleToRadians(angle);
-		const int32 vx = (int32)(x * cos(radians) + z * sin(radians));
-		const int32 vz = (int32)(z * cos(radians) - x * sin(radians));
+		const int32 vx = (int32)((side * cos(radians) + forward * sin(radians)));
+		const int32 vz = (int32)((forward * cos(radians) - side * sin(radians)));
 		return IVec3(vx, 0, vz);
 	}
-	return IVec3(x, 0, z);
+	return IVec3(side, 0, forward);
 }
 
 void Movements::initRealAngleConst(int32 start, int32 end, int32 duration, ActorMoveStruct *movePtr) const { // ManualRealAngle
diff --git a/engines/twine/scene/movements.h b/engines/twine/scene/movements.h
index 84e2454c576..e9ed84350c2 100644
--- a/engines/twine/scene/movements.h
+++ b/engines/twine/scene/movements.h
@@ -176,12 +176,12 @@ public:
 	}
 
 	/**
-	 * Rotate actor with a given angle
-	 * @param x Actor current X coordinate
-	 * @param z Actor current Z coordinate
+	 * Calculate offset for the side and forward distances by the given angle of an actor
+	 * @param side Actor current X coordinate
+	 * @param forward Actor current Z coordinate
 	 * @param angle Actor angle to rotate
 	 */
-	IVec3 rotate(int32 x, int32 z, int32 angle);
+	IVec3 rotate(int32 side, int32 forward, int32 angle);
 
 	/**
 	 * Move actor around the scene
diff --git a/engines/twine/twine.cpp b/engines/twine/twine.cpp
index 8accc3897d9..d9c26fbbfab 100644
--- a/engines/twine/twine.cpp
+++ b/engines/twine/twine.cpp
@@ -751,7 +751,7 @@ void TwinEEngine::processInventoryAction() {
 
 		const IVec3 &destPos = _movements->rotate(0, 800, _scene->_sceneHero->_beta);
 
-		penguin->_pos = _scene->_sceneHero->_pos;
+		penguin->_pos = _scene->_sceneHero->posObj();
 		penguin->_pos.x += destPos.x;
 		penguin->_pos.z += destPos.z;
 


Commit: 1b8252df0bfd0ba959d24b4d69cfb51356918bab
    https://github.com/scummvm/scummvm/commit/1b8252df0bfd0ba959d24b4d69cfb51356918bab
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2023-01-21T18:10:01+01:00

Commit Message:
TWINE: renamed variables and ActorMoveStruct functions

Changed paths:
    engines/twine/holomap.cpp
    engines/twine/menu/menu.cpp
    engines/twine/renderer/redraw.cpp
    engines/twine/renderer/renderer.cpp
    engines/twine/renderer/renderer.h
    engines/twine/scene/actor.cpp
    engines/twine/scene/actor.h
    engines/twine/scene/animations.cpp
    engines/twine/scene/extra.cpp
    engines/twine/scene/gamestate.cpp
    engines/twine/scene/movements.cpp
    engines/twine/scene/scene.cpp
    engines/twine/script/script_life.cpp
    engines/twine/script/script_move.cpp
    engines/twine/script/script_move_v2.cpp
    engines/twine/twine.cpp
    engines/twine/twine.h


diff --git a/engines/twine/holomap.cpp b/engines/twine/holomap.cpp
index 3c0fdd56281..fad80d18db9 100644
--- a/engines/twine/holomap.cpp
+++ b/engines/twine/holomap.cpp
@@ -299,8 +299,8 @@ void Holomap::drawHoloObj(const IVec3 &angle, int32 alpha, int32 beta) {
 }
 
 void Holomap::renderHolomapVehicle(uint &frameNumber, ActorMoveStruct &move, AnimTimerDataStruct &animTimerData, BodyData &bodyData, AnimData &animData) {
-	const int16 newAngle = move.getRealAngle(_engine->_lbaTime);
-	if (move.numOfStep == 0) {
+	const int16 newAngle = move.getRealAngle(_engine->timerRef);
+	if (move.timeValue == 0) {
 		_engine->_movements->initRealAngle(LBAAngles::ANGLE_0, -LBAAngles::ANGLE_90, 500, &move);
 	}
 
@@ -364,7 +364,7 @@ void Holomap::drawHolomapTrajectory(int32 trajectoryIndex) {
 	BodyData bodyData;
 	bodyData.loadFromHQR(Resources::HQR_RESS_FILE, data->getModel(), _engine->isLBA1());
 	uint frameNumber = 0;
-	int32 frameTime = _engine->_lbaTime;
+	int32 frameTime = _engine->timerRef;
 	int16 trajAnimFrameIdx = 0;
 
 	int32 waterPaletteChangeTimer = 0;
@@ -377,13 +377,13 @@ void Holomap::drawHolomapTrajectory(int32 trajectoryIndex) {
 			break;
 		}
 
-		if (!fadeInPalette && waterPaletteChangeTimer < _engine->_lbaTime) {
+		if (!fadeInPalette && waterPaletteChangeTimer < _engine->timerRef) {
 			// animate the water surface
 			_engine->setPalette(HOLOMAP_PALETTE_INDEX, NUM_HOLOMAPCOLORS, &_paletteHolomap[3 * _holomapPaletteIndex++]);
 			if (_holomapPaletteIndex == NUM_HOLOMAPCOLORS) {
 				_holomapPaletteIndex = 0;
 			}
-			waterPaletteChangeTimer = _engine->_lbaTime + 3;
+			waterPaletteChangeTimer = _engine->timerRef + 3;
 		}
 
 		renderHolomapVehicle(frameNumber, move, animTimerData, bodyData, animData);
@@ -395,8 +395,8 @@ void Holomap::drawHolomapTrajectory(int32 trajectoryIndex) {
 
 		// animate the path from point 1 to point 2 by rendering a point model on each position
 		// on the globe every 40 timeunits
-		if (frameTime + 40 <= _engine->_lbaTime) {
-			frameTime = _engine->_lbaTime;
+		if (frameTime + 40 <= _engine->timerRef) {
+			frameTime = _engine->timerRef;
 			int32 modelX;
 			int32 modelY;
 			if (trajAnimFrameIdx < data->numAnimFrames) {
@@ -417,7 +417,7 @@ void Holomap::drawHolomapTrajectory(int32 trajectoryIndex) {
 			fadeInPalette = false;
 			//_engine->_screens->fadeToPal(_engine->_screens->_paletteRGBACustom);
 		}
-		++_engine->_lbaTime;
+		++_engine->timerRef;
 	}
 
 	_engine->_screens->clearScreen();
@@ -540,7 +540,7 @@ void Holomap::holoMap() {
 	int32 currentLocation = _engine->_scene->_currentSceneIdx;
 	_engine->_text->drawHolomapLocation(_locations[currentLocation].textIndex);
 
-	int32 time = _engine->_lbaTime;
+	int32 time = _engine->timerRef;
 	int32 xRot = _locations[currentLocation].angleX;
 	int32 yRot = _locations[currentLocation].angleY;
 	bool automove = false;
@@ -560,7 +560,7 @@ void Holomap::holoMap() {
 			if (nextLocation != -1 && currentLocation != nextLocation) {
 				currentLocation = nextLocation;
 				_engine->_text->drawHolomapLocation(_locations[currentLocation].textIndex);
-				time = _engine->_lbaTime;
+				time = _engine->timerRef;
 				automove = true;
 			}
 		} else if (_engine->_input->toggleActionIfActive(TwinEActionType::HolomapNext)) {
@@ -568,7 +568,7 @@ void Holomap::holoMap() {
 			if (nextLocation != -1 && currentLocation != nextLocation) {
 				currentLocation = nextLocation;
 				_engine->_text->drawHolomapLocation(_locations[currentLocation].textIndex);
-				time = _engine->_lbaTime;
+				time = _engine->timerRef;
 				automove = true;
 			}
 		}
@@ -576,37 +576,37 @@ void Holomap::holoMap() {
 		if (_engine->_input->isActionActive(TwinEActionType::HolomapDown)) {
 			xRot += LBAAngles::ANGLE_2;
 			automove = true;
-			time = _engine->_lbaTime;
+			time = _engine->timerRef;
 		} else if (_engine->_input->isActionActive(TwinEActionType::HolomapUp)) {
 			xRot -= LBAAngles::ANGLE_2;
 			automove = true;
-			time = _engine->_lbaTime;
+			time = _engine->timerRef;
 		}
 
 		if (_engine->_input->isActionActive(TwinEActionType::HolomapRight)) {
 			yRot += LBAAngles::ANGLE_2;
 			automove = true;
-			time = _engine->_lbaTime;
+			time = _engine->timerRef;
 		} else if (_engine->_input->isActionActive(TwinEActionType::HolomapLeft)) {
 			yRot -= LBAAngles::ANGLE_2;
 			automove = true;
-			time = _engine->_lbaTime;
+			time = _engine->timerRef;
 		}
 
 		if (automove) {
-			const int32 dt = _engine->_lbaTime - time;
+			const int32 dt = _engine->timerRef - time;
 			xRot = _engine->_collision->clampedLerp(ClampAngle(xRot), _locations[currentLocation].angleX, 75, dt);
 			yRot = _engine->_collision->clampedLerp(ClampAngle(yRot), _locations[currentLocation].angleY, 75, dt);
 			redraw = true;
 		}
 
-		if (!fadeInPalette && waterPaletteChangeTimer < _engine->_lbaTime) {
+		if (!fadeInPalette && waterPaletteChangeTimer < _engine->timerRef) {
 			// animate the water surface
 			_engine->setPalette(HOLOMAP_PALETTE_INDEX, NUM_HOLOMAPCOLORS, &_paletteHolomap[3 * _holomapPaletteIndex++]);
 			if (_holomapPaletteIndex == NUM_HOLOMAPCOLORS) {
 				_holomapPaletteIndex = 0;
 			}
-			waterPaletteChangeTimer = _engine->_lbaTime + 3;
+			waterPaletteChangeTimer = _engine->timerRef + 3;
 			redraw = true;
 		}
 
@@ -638,7 +638,7 @@ void Holomap::holoMap() {
 			automove = false;
 		}
 
-		++_engine->_lbaTime;
+		++_engine->timerRef;
 
 		if (fadeInPalette) {
 			fadeInPalette = false;
diff --git a/engines/twine/menu/menu.cpp b/engines/twine/menu/menu.cpp
index fc84a885318..96b5b7ba15f 100644
--- a/engines/twine/menu/menu.cpp
+++ b/engines/twine/menu/menu.cpp
@@ -1065,7 +1065,7 @@ void Menu::drawBehaviour(int32 left, int32 top, HeroBehaviourType behaviour, int
 		_engine->_interface->drawFilledRect(boxRect, COLOR_BLACK);
 	}
 
-	_engine->_renderer->renderBehaviourModel(boxRect, -600, angle, *_behaviourEntity, _moveMenu);
+	_engine->_renderer->drawObj3D(boxRect, -600, angle, *_behaviourEntity, _moveMenu);
 
 	_engine->_interface->restoreClip();
 }
@@ -1137,7 +1137,7 @@ void Menu::processBehaviourMenu(bool behaviourMenu) {
 		const int animIdx = _engine->_actor->_heroAnimIdx[(byte)_engine->_actor->_heroBehaviour];
 		_engine->_animations->setAnimObjet(_behaviourAnimState[(byte)_engine->_actor->_heroBehaviour], _engine->_resources->_animData[animIdx], *_behaviourEntity, &_behaviourAnimData[(byte)_engine->_actor->_heroBehaviour]);
 
-		int32 tmpTime = _engine->_lbaTime;
+		int32 tmpTime = _engine->timerRef;
 
 #if 0
 		ScopedCursor scopedCursor(_engine);
@@ -1187,10 +1187,10 @@ void Menu::processBehaviourMenu(bool behaviourMenu) {
 
 			drawBehaviour(left, top, _engine->_actor->_heroBehaviour, -1, true);
 
-			_engine->_lbaTime++;
+			_engine->timerRef++;
 		}
 
-		_engine->_lbaTime = tmpTime;
+		_engine->timerRef = tmpTime;
 
 		_engine->_gameState->init3DGame();
 	}
diff --git a/engines/twine/renderer/redraw.cpp b/engines/twine/renderer/redraw.cpp
index 3fc0f7546e1..fb8c3e015fa 100644
--- a/engines/twine/renderer/redraw.cpp
+++ b/engines/twine/renderer/redraw.cpp
@@ -179,7 +179,7 @@ void Redraw::addOverlay(OverlayType type, int16 info0, int16 x, int16 y, int16 i
 			overlay->y = y;
 			overlay->info1 = info1;
 			overlay->posType = posType;
-			overlay->lifeTime = _engine->_lbaTime + _engine->toSeconds(lifeTime);
+			overlay->lifeTime = _engine->timerRef + _engine->toSeconds(lifeTime);
 			break;
 		}
 	}
@@ -285,16 +285,16 @@ int32 Redraw::fillExtraDrawingList(DrawListStruct *drawList, int32 drawListPos)
 			continue;
 		}
 		if (extra->type & ExtraType::TIME_IN) {
-			if (_engine->_lbaTime - extra->spawnTime > 35) {
-				extra->spawnTime = _engine->_lbaTime;
+			if (_engine->timerRef - extra->spawnTime > 35) {
+				extra->spawnTime = _engine->timerRef;
 				extra->type &= ~ExtraType::TIME_IN;
 				_engine->_sound->playSample(Samples::ItemPopup, 1, extra->pos);
 			}
 			continue;
 		}
 		if ((extra->type & ExtraType::TIME_OUT) && (extra->type & ExtraType::FLASH)) {
-			if (_engine->_lbaTime >= extra->spawnTime + extra->payload.lifeTime - _engine->toSeconds(3)) {
-				if ((_engine->_lbaTime + extra->spawnTime) & 8) {
+			if (_engine->timerRef >= extra->spawnTime + extra->payload.lifeTime - _engine->toSeconds(3)) {
+				if ((_engine->timerRef + extra->spawnTime) & 8) {
 					continue;
 				}
 			}
@@ -641,7 +641,7 @@ void Redraw::renderOverlays() {
 			// process position overlay
 			switch (overlay->posType) {
 			case OverlayPosType::koNormal:
-				if (_engine->_lbaTime >= overlay->lifeTime) {
+				if (_engine->timerRef >= overlay->lifeTime) {
 					overlay->info0 = -1;
 					continue;
 				}
@@ -654,7 +654,7 @@ void Redraw::renderOverlays() {
 				overlay->x = projPos.x;
 				overlay->y = projPos.y;
 
-				if (_engine->_lbaTime >= overlay->lifeTime) {
+				if (_engine->timerRef >= overlay->lifeTime) {
 					overlay->info0 = -1;
 					continue;
 				}
@@ -706,7 +706,7 @@ void Redraw::renderOverlays() {
 				break;
 			}
 			case OverlayType::koNumberRange: {
-				const int32 range = _engine->_collision->clampedLerp(overlay->info1, overlay->info0, 100, overlay->lifeTime - _engine->_lbaTime - 50);
+				const int32 range = _engine->_collision->clampedLerp(overlay->info1, overlay->info0, 100, overlay->lifeTime - _engine->timerRef - 50);
 
 				char text[10];
 				Common::sprintf_s(text, "%d", range);
@@ -781,12 +781,12 @@ void Redraw::setRenderText(const Common::String &text) {
 	if (_text.empty()) {
 		_textDisappearTime = -1;
 	} else {
-		_textDisappearTime = _engine->_lbaTime + _engine->toSeconds(1);
+		_textDisappearTime = _engine->timerRef + _engine->toSeconds(1);
 	}
 }
 
 void Redraw::renderText() {
-	if (_textDisappearTime <= _engine->_lbaTime) {
+	if (_textDisappearTime <= _engine->timerRef) {
 		return;
 	}
 	if (_text.empty()) {
diff --git a/engines/twine/renderer/renderer.cpp b/engines/twine/renderer/renderer.cpp
index 2876a82047c..4a7abc1e259 100644
--- a/engines/twine/renderer/renderer.cpp
+++ b/engines/twine/renderer/renderer.cpp
@@ -1739,7 +1739,7 @@ bool Renderer::affObjetIso(int32 x, int32 y, int32 z, int32 angleX, int32 angleY
 	return true;
 }
 
-void Renderer::renderBehaviourModel(const Common::Rect &rect, int32 y, int32 angle, const BodyData &bodyData, ActorMoveStruct &move) {
+void Renderer::drawObj3D(const Common::Rect &rect, int32 y, int32 angle, const BodyData &bodyData, ActorMoveStruct &move) {
 	int32 boxLeft = rect.left;
 	int32 boxTop = rect.top;
 	int32 boxRight = rect.right;
@@ -1752,15 +1752,12 @@ void Renderer::renderBehaviourModel(const Common::Rect &rect, int32 y, int32 ang
 
 	Common::Rect dummy;
 	if (angle == -1) {
-		const int16 newAngle = move.getRealAngle(_engine->_lbaTime);
-		if (move.numOfStep == 0) {
-			_engine->_movements->initRealAngle(newAngle, newAngle - LBAAngles::ANGLE_90, LBAAngles::ANGLE_17, &move);
+		angle = move.getRealAngle(_engine->timerRef);
+		if (move.timeValue == 0) {
+			_engine->_movements->initRealAngle(angle, angle - LBAAngles::ANGLE_90, LBAAngles::ANGLE_17, &move);
 		}
-		affObjetIso(0, y, 0, LBAAngles::ANGLE_0, newAngle, LBAAngles::ANGLE_0, bodyData, dummy);
-	} else {
-		affObjetIso(0, y, 0, LBAAngles::ANGLE_0, angle, LBAAngles::ANGLE_0, bodyData, dummy);
 	}
-	_engine->_interface->unsetClip();
+	affObjetIso(0, y, 0, LBAAngles::ANGLE_0, angle, LBAAngles::ANGLE_0, bodyData, dummy);
 }
 
 void Renderer::draw3dObject(int32 x, int32 y, const BodyData &bodyData, int32 angle, int32 cameraZoom) {
diff --git a/engines/twine/renderer/renderer.h b/engines/twine/renderer/renderer.h
index 9b251078d2f..8bf9dc00aab 100644
--- a/engines/twine/renderer/renderer.h
+++ b/engines/twine/renderer/renderer.h
@@ -276,7 +276,7 @@ public:
 	/**
 	 * @param angle A value of @c -1 means that the model is automatically rotated
 	 */
-	void renderBehaviourModel(const Common::Rect &rect, int32 y, int32 angle, const BodyData &bodyData, ActorMoveStruct &move);
+	void drawObj3D(const Common::Rect &rect, int32 y, int32 angle, const BodyData &bodyData, ActorMoveStruct &move);
 
 	/**
 	 * @brief Render an inventory item
diff --git a/engines/twine/scene/actor.cpp b/engines/twine/scene/actor.cpp
index ab931325a36..85096de602d 100644
--- a/engines/twine/scene/actor.cpp
+++ b/engines/twine/scene/actor.cpp
@@ -369,41 +369,38 @@ void ActorStruct::loadModel(int32 modelIndex, bool lba1) {
 	}
 }
 
-int32 ActorMoveStruct::getRealAngle(int32 time) {
-	if (numOfStep) {
-		const int32 timePassed = time - timeOfChange;
+int16 ActorMoveStruct::getRealValueFromTime(int32 time) {
+	if (timeValue) {
+		const int32 delta = time - memoTicks;
 
-		if (timePassed >= numOfStep) { // rotation is finished
-			numOfStep = 0;
-			return to;
+		if (delta >= timeValue) { // rotation is finished
+			timeValue = 0;
+			return endValue;
 		}
 
-		int32 remainingAngle = NormalizeAngle(to - from);
-		remainingAngle *= timePassed;
-		remainingAngle /= numOfStep;
-		remainingAngle += from;
+		int32 t = ((endValue - startValue) * delta) / timeValue;
+		t += startValue;
 
-		return remainingAngle;
+		return (int16)t;
 	}
 
-	return to;
+	return endValue;
 }
 
-int32 ActorMoveStruct::getRealValue(int32 time) {
-	if (!numOfStep) {
-		return to;
-	}
+int16 ActorMoveStruct::getRealAngle(int32 time) {
+	if (timeValue) {
+		int32 delta = time - memoTicks;
+		if (delta < timeValue) {
+			int32 t = NormalizeAngle(endValue - startValue);
+			t = (t * delta) / timeValue;
+			t += startValue;
+			return (int16)t;
+		}
 
-	if (time - timeOfChange >= numOfStep) {
-		numOfStep = 0;
-		return to;
+		timeValue = 0;
 	}
 
-	int32 tempStep = to - from;
-	tempStep *= time - timeOfChange;
-	tempStep /= numOfStep;
-
-	return tempStep + from;
+	return endValue;
 }
 
 bool ActorStruct::isAttackAnimationActive() const {
diff --git a/engines/twine/scene/actor.h b/engines/twine/scene/actor.h
index a49f3d6f1cc..e5fdd175dd4 100644
--- a/engines/twine/scene/actor.h
+++ b/engines/twine/scene/actor.h
@@ -37,22 +37,17 @@ namespace TwinE {
 
 /** Actors move structure */
 struct ActorMoveStruct {
-	int16 from = 0;
-	int16 to = 0;
-	int16 numOfStep = 0;
-	int32 timeOfChange = 0;
+	int16 startValue = 0;
+	int16 endValue = 0;
+	int16 timeValue = 0;
+	int32 memoTicks = 0;
 
 	/**
 	 * Get actor real angle
 	 * @param time engine time used for interpolation
 	 */
-	int32 getRealAngle(int32 time);
-
-	/**
-	 * Get actor step
-	 * @param time engine time used for interpolation
-	 */
-	int32 getRealValue(int32 time);
+	int16 getRealValueFromTime(int32 time);
+	int16 getRealAngle(int32 time);
 };
 
 /** Actors animation timer structure */
diff --git a/engines/twine/scene/animations.cpp b/engines/twine/scene/animations.cpp
index 468eb9f2877..cae65c03211 100644
--- a/engines/twine/scene/animations.cpp
+++ b/engines/twine/scene/animations.cpp
@@ -122,11 +122,11 @@ bool Animations::setModelAnimation(int32 keyframeIdx, const AnimData &animData,
 		lastKeyFramePtr = keyFrame;
 		remainingFrameTime = keyFrameLength;
 	}
-	const int32 deltaTime = _engine->_lbaTime - remainingFrameTime;
+	const int32 deltaTime = _engine->timerRef - remainingFrameTime;
 	if (deltaTime >= keyFrameLength) {
 		copyKeyFrameToState(keyFrame, bodyData, numOfBonesInAnim);
 		animTimerDataPtr->ptr = keyFrame;
-		animTimerDataPtr->time = _engine->_lbaTime;
+		animTimerDataPtr->time = _engine->timerRef;
 		return true;
 	}
 
@@ -186,7 +186,7 @@ void Animations::setAnimObjet(int32 keyframeIdx, const AnimData &animData, BodyD
 	_processLastRotationAngle = ToAngle(keyFrame->boneframes[0].y);
 
 	animTimerDataPtr->ptr = animData.getKeyframe(keyframeIdx);
-	animTimerDataPtr->time = _engine->_lbaTime;
+	animTimerDataPtr->time = _engine->timerRef;
 
 	const int16 numBones = bodyData.getNumBones();
 
@@ -206,7 +206,7 @@ void Animations::stockInterAnim(const BodyData &bodyData, AnimTimerDataStruct *a
 	if (_animKeyframeBufIdx >= ARRAYSIZE(_animKeyframeBuf)) {
 		_animKeyframeBufIdx = 0;
 	}
-	animTimerDataPtr->time = _engine->_lbaTime;
+	animTimerDataPtr->time = _engine->timerRef;
 	KeyFrame *keyframe = &_animKeyframeBuf[_animKeyframeBufIdx++];
 	animTimerDataPtr->ptr = keyframe;
 	copyStateToKeyFrame(keyframe, bodyData);
@@ -238,7 +238,7 @@ bool Animations::verifyAnimAtKeyframe(int32 keyframeIdx, const AnimData &animDat
 		remainingFrameTime = keyFrameLength;
 	}
 
-	const int32 deltaTime = _engine->_lbaTime - remainingFrameTime;
+	const int32 deltaTime = _engine->timerRef - remainingFrameTime;
 
 	_currentStep.x = keyFrame->x;
 	_currentStep.y = keyFrame->y;
@@ -250,7 +250,7 @@ bool Animations::verifyAnimAtKeyframe(int32 keyframeIdx, const AnimData &animDat
 
 	if (deltaTime >= keyFrameLength) {
 		animTimerDataPtr->ptr = animData.getKeyframe(keyframeIdx);
-		animTimerDataPtr->time = _engine->_lbaTime;
+		animTimerDataPtr->time = _engine->timerRef;
 		return true;
 	}
 
@@ -483,9 +483,9 @@ void Animations::doAnim(int32 actorIdx) {
 
 		if (!actor->_dynamicFlags.bIsFalling) {
 			if (actor->_speed) {
-				int32 xAxisRotation = actor->_moveAngle.getRealValue(_engine->_lbaTime);
+				int32 xAxisRotation = actor->_moveAngle.getRealValueFromTime(_engine->timerRef);
 				if (!xAxisRotation) {
-					if (actor->_moveAngle.to > 0) {
+					if (actor->_moveAngle.endValue > 0) {
 						xAxisRotation = 1;
 					} else {
 						xAxisRotation = -1;
diff --git a/engines/twine/scene/extra.cpp b/engines/twine/scene/extra.cpp
index 974a5fb94a3..e200d409e5f 100644
--- a/engines/twine/scene/extra.cpp
+++ b/engines/twine/scene/extra.cpp
@@ -115,7 +115,7 @@ int32 Extra::addExtraExplode(int32 x, int32 y, int32 z) {
 		extra->pos.y = y;
 		extra->pos.z = z;
 		extra->payload.lifeTime = 40;
-		extra->spawnTime = _engine->_lbaTime;
+		extra->spawnTime = _engine->timerRef;
 		extra->strengthOfHit = 0;
 		return i;
 	}
@@ -145,7 +145,7 @@ void Extra::initFly(ExtraListStruct *extra, int32 xAngle, int32 yAngle, int32 x,
 	extra->destPos.z = destPos.z;
 
 	extra->angle = extraAngle;
-	extra->spawnTime = _engine->_lbaTime;
+	extra->spawnTime = _engine->timerRef;
 }
 
 int32 Extra::initSpecial(int32 x, int32 y, int32 z, ExtraSpecialType type) {
@@ -178,7 +178,7 @@ int32 Extra::initSpecial(int32 x, int32 y, int32 z, ExtraSpecialType type) {
 			extra->pos.z = z;
 
 			extra->strengthOfHit = 0;
-			extra->spawnTime = _engine->_lbaTime;
+			extra->spawnTime = _engine->timerRef;
 			extra->payload.lifeTime = 5;
 		}
 		return i;
@@ -264,7 +264,7 @@ int32 Extra::throwExtra(int32 actorIdx, int32 x, int32 y, int32 z, int32 spriteI
 		initFly(extra, xAngle, yAngle, xRotPoint, extraAngle);
 
 		extra->strengthOfHit = strengthOfHit;
-		extra->spawnTime = _engine->_lbaTime;
+		extra->spawnTime = _engine->timerRef;
 		extra->payload.actorIdx = actorIdx;
 		extra->info1 = 0;
 
@@ -438,10 +438,10 @@ void Extra::affSpecial(int32 extraIdx, int32 x, int32 y, Common::Rect &renderRec
 
 	switch (specialType) {
 	case ExtraSpecialType::kHitStars:
-		aff2DShape(hitStarsShape, x, y, COLOR_WHITE, (_engine->_lbaTime * 32) & LBAAngles::ANGLE_270, 4, renderRect);
+		aff2DShape(hitStarsShape, x, y, COLOR_WHITE, (_engine->timerRef * 32) & LBAAngles::ANGLE_270, 4, renderRect);
 		break;
 	case ExtraSpecialType::kExplodeCloud: {
-		int32 zoom = 1 + _engine->_lbaTime - extra->spawnTime;
+		int32 zoom = 1 + _engine->timerRef - extra->spawnTime;
 
 		if (zoom > 32) {
 			zoom = 32;
@@ -473,7 +473,7 @@ void Extra::bounceExtra(ExtraListStruct *extra, int32 x, int32 y, int32 z) {
 	extra->pos.z = z;
 	extra->lastPos.z = z;
 
-	extra->spawnTime = _engine->_lbaTime;
+	extra->spawnTime = _engine->timerRef;
 }
 
 void Extra::gereExtras() {
@@ -488,7 +488,7 @@ void Extra::gereExtras() {
 		}
 		// process extra life time
 		if (extra->type & ExtraType::TIME_OUT) {
-			if (extra->payload.lifeTime + extra->spawnTime <= _engine->_lbaTime) {
+			if (extra->payload.lifeTime + extra->spawnTime <= _engine->timerRef) {
 				extra->sprite = -1;
 				continue;
 			}
@@ -498,7 +498,7 @@ void Extra::gereExtras() {
 			extra->sprite = -1;
 			continue;
 		}
-		const int32 deltaT = _engine->_lbaTime - extra->spawnTime;
+		const int32 deltaT = _engine->timerRef - extra->spawnTime;
 
 		if (extra->type & ExtraType::EXPLOSION) {
 			extra->sprite = _engine->_collision->clampedLerp(SPRITEHQR_EXPLOSION_FIRST_FRAME, 100, 30, deltaT);
@@ -547,7 +547,7 @@ void Extra::gereExtras() {
 		}
 
 		if (extra->type & ExtraType::WAIT_SOME_TIME) {
-			if (_engine->_lbaTime - extra->spawnTime > 40) {
+			if (_engine->timerRef - extra->spawnTime > 40) {
 				extra->type &= ~ExtraType::WAIT_SOME_TIME;
 			}
 			continue;
@@ -579,7 +579,7 @@ void Extra::gereExtras() {
 			}
 
 			const int32 angle2 = _engine->_movements->getAngleAndSetTargetActorDistance(extra->pos.y, 0, currentExtraY, _engine->_movements->_targetActorDistance);
-			int32 pos = extra->trackActorMove.getRealAngle(_engine->_lbaTime);
+			int32 pos = extra->trackActorMove.getRealValueFromTime(_engine->timerRef);
 			if (!pos) {
 				pos = 1;
 			}
@@ -628,7 +628,7 @@ void Extra::gereExtras() {
 				continue;
 			}
 			const int32 angle2 = _engine->_movements->getAngleAndSetTargetActorDistance(extra->pos.y, 0, extraKey->pos.y, _engine->_movements->_targetActorDistance);
-			int32 pos = extra->trackActorMove.getRealAngle(_engine->_lbaTime);
+			int32 pos = extra->trackActorMove.getRealValueFromTime(_engine->timerRef);
 
 			if (!pos) {
 				pos = 1;
diff --git a/engines/twine/scene/gamestate.cpp b/engines/twine/scene/gamestate.cpp
index f4b1c976e86..9fae01faa43 100644
--- a/engines/twine/scene/gamestate.cpp
+++ b/engines/twine/scene/gamestate.cpp
@@ -429,7 +429,7 @@ void GameState::doFoundObj(InventoryItems item) {
 
 		_engine->_text->playVoxSimple(_engine->_text->_currDialTextEntry);
 
-		_engine->_lbaTime++;
+		_engine->timerRef++;
 	}
 
 	while (_engine->_text->playVoxSimple(_engine->_text->_currDialTextEntry)) {
@@ -481,7 +481,7 @@ void GameState::processGameChoices(TextId choiceIdx) {
 }
 
 void GameState::processGameoverAnimation() {
-	const int32 tmpLbaTime = _engine->_lbaTime;
+	const int32 tmpLbaTime = _engine->timerRef;
 
 	_engine->exitSceneryView();
 	// workaround to fix hero redraw after drowning
@@ -500,27 +500,27 @@ void GameState::processGameoverAnimation() {
 	_engine->_sound->stopSamples();
 	_engine->_music->stopMidiMusic(); // stop fade music
 	_engine->_renderer->setProjection(_engine->width() / 2, _engine->height() / 2, 128, 200, 200);
-	int32 startLbaTime = _engine->_lbaTime;
+	int32 startLbaTime = _engine->timerRef;
 	const Common::Rect &rect = _engine->centerOnScreen(_engine->width() / 2, _engine->height() / 2);
 	_engine->_interface->setClip(rect);
 
 	int32 zoom = 50000;
 	Common::Rect dummy;
-	while (!_engine->_input->toggleAbortAction() && (_engine->_lbaTime - startLbaTime) <= _engine->toSeconds(10)) {
+	while (!_engine->_input->toggleAbortAction() && (_engine->timerRef - startLbaTime) <= _engine->toSeconds(10)) {
 		FrameMarker frame(_engine, 66);
 		_engine->readKeys();
 		if (_engine->shouldQuit()) {
 			return;
 		}
 
-		zoom = _engine->_collision->clampedLerp(40000, 3200, _engine->toSeconds(10), _engine->_lbaTime - startLbaTime);
-		const int32 angle = _engine->_screens->lerp(1, LBAAngles::ANGLE_360, _engine->toSeconds(2), (_engine->_lbaTime - startLbaTime) % _engine->toSeconds(2));
+		zoom = _engine->_collision->clampedLerp(40000, 3200, _engine->toSeconds(10), _engine->timerRef - startLbaTime);
+		const int32 angle = _engine->_screens->lerp(1, LBAAngles::ANGLE_360, _engine->toSeconds(2), (_engine->timerRef - startLbaTime) % _engine->toSeconds(2));
 
 		_engine->blitWorkToFront(rect);
 		_engine->_renderer->setFollowCamera(0, 0, 0, 0, -angle, 0, zoom);
 		_engine->_renderer->affObjetIso(0, 0, 0, LBAAngles::ANGLE_0, LBAAngles::ANGLE_0, LBAAngles::ANGLE_0, gameOverPtr, dummy);
 
-		_engine->_lbaTime++;
+		_engine->timerRef++;
 	}
 
 	_engine->_sound->playSample(Samples::Explode);
@@ -534,7 +534,7 @@ void GameState::processGameoverAnimation() {
 	_engine->restoreFrontBuffer();
 	init3DGame();
 
-	_engine->_lbaTime = tmpLbaTime;
+	_engine->timerRef = tmpLbaTime;
 }
 
 void GameState::giveUp() {
diff --git a/engines/twine/scene/movements.cpp b/engines/twine/scene/movements.cpp
index 412de674bc8..b7f1ee9e852 100644
--- a/engines/twine/scene/movements.cpp
+++ b/engines/twine/scene/movements.cpp
@@ -57,10 +57,10 @@ IVec3 Movements::getShadow(const IVec3 &pos) { // GetShadow
 }
 
 void Movements::initRealAngle(int16 startAngle, int16 endAngle, int16 stepAngle, ActorMoveStruct *movePtr) {
-	movePtr->from = ClampAngle(startAngle);
-	movePtr->to = ClampAngle(endAngle);
-	movePtr->numOfStep = ClampAngle(stepAngle);
-	movePtr->timeOfChange = _engine->_lbaTime;
+	movePtr->startValue = ClampAngle(startAngle);
+	movePtr->endValue = ClampAngle(endAngle);
+	movePtr->timeValue = ClampAngle(stepAngle);
+	movePtr->memoTicks = _engine->timerRef;
 }
 
 void Movements::clearRealAngle(ActorStruct *actorPtr) {
@@ -68,10 +68,10 @@ void Movements::clearRealAngle(ActorStruct *actorPtr) {
 }
 
 void Movements::setActorAngle(int16 startAngle, int16 endAngle, int16 stepAngle, ActorMoveStruct *movePtr) {
-	movePtr->from = startAngle;
-	movePtr->to = endAngle;
-	movePtr->numOfStep = stepAngle;
-	movePtr->timeOfChange = _engine->_lbaTime;
+	movePtr->startValue = startAngle;
+	movePtr->endValue = endAngle;
+	movePtr->timeValue = stepAngle;
+	movePtr->memoTicks = _engine->timerRef;
 }
 
 int32 Movements::getAngleAndSetTargetActorDistance(int32 x1, int32 z1, int32 x2, int32 z2) {
@@ -154,18 +154,18 @@ void Movements::initRealAngleConst(int32 start, int32 end, int32 duration, Actor
 	const int16 cstart = ClampAngle(start);
 	const int16 cend = ClampAngle(end);
 
-	movePtr->from = cstart;
-	movePtr->to = cend;
+	movePtr->startValue = cstart;
+	movePtr->endValue = cend;
 
 	const int16 numOfStep = (cstart - cend) * 64;
-	int32 numOfStepInt = ABS(numOfStep);
-	numOfStepInt /= 64;
+	int32 t = ABS(numOfStep);
+	t /= 64;
 
-	numOfStepInt *= duration;
-	numOfStepInt /= 256;
+	t *= duration;
+	t /= 256;
 
-	movePtr->numOfStep = (int16)numOfStepInt;
-	movePtr->timeOfChange = _engine->_lbaTime;
+	movePtr->timeValue = (int16)t;
+	movePtr->memoTicks = _engine->timerRef;
 }
 
 void Movements::ChangedCursorKeys::update(TwinEEngine *engine) {
@@ -226,7 +226,7 @@ bool Movements::processBehaviourExecution(int actorIdx) {
 		if (_engine->_actor->_combatAuto) {
 			ActorStruct *actor = _engine->_scene->getActor(actorIdx);
 			_lastJoyFlag = true;
-			actor->_beta = actor->_moveAngle.getRealAngle(_engine->_lbaTime);
+			actor->_beta = actor->_moveAngle.getRealAngle(_engine->timerRef);
 			// TODO: previousLoopActionKey must be handled properly
 			if (!_previousLoopActionKey || actor->_genAnim == AnimationTypes::kStanding) {
 				const int32 aggresiveMode = _engine->getRandomNumber(3);
@@ -274,7 +274,7 @@ bool Movements::processAttackExecution(int actorIdx) {
 				_engine->_animations->initAnim(AnimationTypes::kThrowBall, AnimType::kAnimationThen, AnimationTypes::kStanding, actorIdx);
 			}
 
-			actor->_beta = actor->_moveAngle.getRealAngle(_engine->_lbaTime);
+			actor->_beta = actor->_moveAngle.getRealAngle(_engine->timerRef);
 			return true;
 		}
 	} else if (_engine->_gameState->hasItem(InventoryItems::kiUseSabre)) {
@@ -284,7 +284,7 @@ bool Movements::processAttackExecution(int actorIdx) {
 
 		_engine->_animations->initAnim(AnimationTypes::kSabreAttack, AnimType::kAnimationThen, AnimationTypes::kStanding, actorIdx);
 
-		actor->_beta = actor->_moveAngle.getRealAngle(_engine->_lbaTime);
+		actor->_beta = actor->_moveAngle.getRealAngle(_engine->timerRef);
 		return true;
 	}
 	return false;
@@ -326,7 +326,7 @@ void Movements::processManualMovementExecution(int actorIdx) {
 				_engine->_animations->initAnim(AnimationTypes::kTurnLeft, AnimType::kAnimationTypeLoop, AnimationTypes::kAnimInvalid, actorIdx);
 			} else {
 				if (!actor->_dynamicFlags.bIsRotationByAnim) {
-					actor->_beta = actor->_moveAngle.getRealAngle(_engine->_lbaTime);
+					actor->_beta = actor->_moveAngle.getRealAngle(_engine->timerRef);
 				}
 			}
 			_lastJoyFlag = true;
@@ -335,7 +335,7 @@ void Movements::processManualMovementExecution(int actorIdx) {
 				_engine->_animations->initAnim(AnimationTypes::kTurnRight, AnimType::kAnimationTypeLoop, AnimationTypes::kAnimInvalid, actorIdx);
 			} else {
 				if (!actor->_dynamicFlags.bIsRotationByAnim) {
-					actor->_beta = actor->_moveAngle.getRealAngle(_engine->_lbaTime);
+					actor->_beta = actor->_moveAngle.getRealAngle(_engine->timerRef);
 				}
 			}
 			_lastJoyFlag = true;
@@ -402,16 +402,16 @@ void Movements::processRandomAction(int actorIdx) {
 	if (actor->brickCausesDamage()) {
 		const int32 angle = ClampAngle(actor->_beta + (_engine->getRandomNumber() & (LBAAngles::ANGLE_180 - 1)) - LBAAngles::ANGLE_90 + LBAAngles::ANGLE_180);
 		initRealAngleConst(actor->_beta, angle, actor->_speed, &actor->_moveAngle);
-		actor->_delayInMillis = _engine->getRandomNumber(300) + _engine->_lbaTime + 300;
+		actor->_delayInMillis = _engine->getRandomNumber(300) + _engine->timerRef + 300;
 		_engine->_animations->initAnim(AnimationTypes::kStanding, AnimType::kAnimationTypeLoop, AnimationTypes::kAnimInvalid, actorIdx);
 	}
 
-	if (!actor->_moveAngle.numOfStep) {
+	if (!actor->_moveAngle.timeValue) {
 		_engine->_animations->initAnim(AnimationTypes::kForward, AnimType::kAnimationTypeLoop, AnimationTypes::kAnimInvalid, actorIdx);
-		if (_engine->_lbaTime > actor->_delayInMillis) {
+		if (_engine->timerRef > actor->_delayInMillis) {
 			const int32 angle = ClampAngle(actor->_beta + (_engine->getRandomNumber() & (LBAAngles::ANGLE_180 - 1)) - LBAAngles::ANGLE_90);
 			initRealAngleConst(actor->_beta, angle, actor->_speed, &actor->_moveAngle);
-			actor->_delayInMillis = _engine->getRandomNumber(300) + _engine->_lbaTime + 300;
+			actor->_delayInMillis = _engine->getRandomNumber(300) + _engine->timerRef + 300;
 		}
 	}
 }
@@ -453,7 +453,7 @@ void Movements::doDir(int32 actorIdx) {
 	}
 	if (!actor->_staticFlags.bIsSpriteActor) {
 		if (actor->_controlMode != ControlMode::kManual) {
-			actor->_beta = actor->_moveAngle.getRealAngle(_engine->_lbaTime);
+			actor->_beta = actor->_moveAngle.getRealAngle(_engine->timerRef);
 		}
 	}
 
diff --git a/engines/twine/scene/scene.cpp b/engines/twine/scene/scene.cpp
index fbfd52703ca..dede6daca6b 100644
--- a/engines/twine/scene/scene.cpp
+++ b/engines/twine/scene/scene.cpp
@@ -648,7 +648,7 @@ void Scene::playSceneMusic() {
 }
 
 void Scene::processEnvironmentSound() {
-	if (_engine->_lbaTime < _sampleAmbienceTime) {
+	if (_engine->timerRef < _sampleAmbienceTime) {
 		return;
 	}
 	int16 currentAmb = _engine->getRandomNumber(4); // random ambiance
@@ -676,7 +676,7 @@ void Scene::processEnvironmentSound() {
 	}
 
 	// compute next ambiance timer
-	_sampleAmbienceTime = _engine->_lbaTime + _engine->toSeconds(_engine->getRandomNumber(_sampleMinDelayRnd) + _sampleMinDelay);
+	_sampleAmbienceTime = _engine->timerRef + _engine->toSeconds(_engine->getRandomNumber(_sampleMinDelayRnd) + _sampleMinDelay);
 }
 
 void Scene::processZoneExtraBonus(ZoneStruct *zone) {
diff --git a/engines/twine/script/script_life.cpp b/engines/twine/script/script_life.cpp
index 762602f7562..b9a88c57542 100644
--- a/engines/twine/script/script_life.cpp
+++ b/engines/twine/script/script_life.cpp
@@ -1141,9 +1141,9 @@ int32 ScriptLife::lGIVE_GOLD_PIECES(TwinEEngine *engine, LifeScriptContext &ctx)
 	for (int16 i = 0; i < OVERLAY_MAX_ENTRIES; i++) {
 		OverlayListStruct *overlay = &engine->_redraw->overlayList[i];
 		if (overlay->info0 != -1 && overlay->type == OverlayType::koNumberRange) {
-			overlay->info0 = engine->_collision->clampedLerp(overlay->info1, overlay->info0, engine->toSeconds(2), overlay->lifeTime - engine->_lbaTime - engine->toSeconds(1));
+			overlay->info0 = engine->_collision->clampedLerp(overlay->info1, overlay->info0, engine->toSeconds(2), overlay->lifeTime - engine->timerRef - engine->toSeconds(1));
 			overlay->info1 = engine->_gameState->_goldPieces;
-			overlay->lifeTime = engine->_lbaTime + engine->toSeconds(3);
+			overlay->lifeTime = engine->timerRef + engine->toSeconds(3);
 			hideRange = true;
 			break;
 		}
diff --git a/engines/twine/script/script_move.cpp b/engines/twine/script/script_move.cpp
index 1745f7e4aa4..5d911db8659 100644
--- a/engines/twine/script/script_move.cpp
+++ b/engines/twine/script/script_move.cpp
@@ -148,7 +148,7 @@ int32 ScriptMove::mANGLE(TwinEEngine *engine, MoveScriptContext &ctx) {
 		return 0;
 	}
 	engine->_scene->_currentScriptValue = angle;
-	if (ctx.actor->_moveAngle.numOfStep == 0) {
+	if (ctx.actor->_moveAngle.timeValue == 0) {
 		engine->_movements->initRealAngleConst(ctx.actor->_beta, angle, ctx.actor->_speed, &ctx.actor->_moveAngle);
 	}
 	if (ctx.actor->_beta == angle) {
@@ -361,12 +361,12 @@ int32 ScriptMove::mWAIT_NUM_SECOND(TwinEEngine *engine, MoveScriptContext &ctx)
 	debugC(3, kDebugLevels::kDebugScripts, "MOVE::WAIT_NUM_SECOND(%i, %i)", (int)numSeconds, currentTime);
 
 	if (currentTime == 0) {
-		currentTime = engine->_lbaTime + engine->toSeconds(numSeconds);
+		currentTime = engine->timerRef + engine->toSeconds(numSeconds);
 		ctx.stream.rewind(4);
 		ctx.stream.writeSint32LE(currentTime);
 	}
 
-	if (engine->_lbaTime < currentTime) {
+	if (engine->timerRef < currentTime) {
 		ctx.undo(5);
 		return 1;
 	}
@@ -577,7 +577,7 @@ int32 ScriptMove::mFACE_HERO(TwinEEngine *engine, MoveScriptContext &ctx) {
 		return 0;
 	}
 	engine->_scene->_currentScriptValue = angle;
-	if (engine->_scene->_currentScriptValue == -1 && ctx.actor->_moveAngle.numOfStep == 0) {
+	if (engine->_scene->_currentScriptValue == -1 && ctx.actor->_moveAngle.timeValue == 0) {
 		engine->_scene->_currentScriptValue = engine->_movements->getAngleAndSetTargetActorDistance(ctx.actor->posObj(), engine->_scene->_sceneHero->posObj());
 		engine->_movements->initRealAngleConst(ctx.actor->_beta, engine->_scene->_currentScriptValue, ctx.actor->_speed, &ctx.actor->_moveAngle);
 		ctx.stream.rewind(2);
@@ -608,7 +608,7 @@ int32 ScriptMove::mANGLE_RND(TwinEEngine *engine, MoveScriptContext &ctx) {
 
 	engine->_scene->_currentScriptValue = val2;
 
-	if (engine->_scene->_currentScriptValue == -1 && ctx.actor->_moveAngle.numOfStep == 0) {
+	if (engine->_scene->_currentScriptValue == -1 && ctx.actor->_moveAngle.timeValue == 0) {
 		if (engine->getRandomNumber() & 1) {
 			const int32 newAngle = ctx.actor->_beta + LBAAngles::ANGLE_90 + (ABS(val1) >> 1);
 			engine->_scene->_currentScriptValue = ClampAngle(newAngle - engine->getRandomNumber(val1));
diff --git a/engines/twine/script/script_move_v2.cpp b/engines/twine/script/script_move_v2.cpp
index 1751d8f5df1..cdc7cf23e69 100644
--- a/engines/twine/script/script_move_v2.cpp
+++ b/engines/twine/script/script_move_v2.cpp
@@ -86,12 +86,12 @@ int32 ScriptMoveV2::mWAIT_NB_DIZIEME(TwinEEngine *engine, MoveScriptContext &ctx
 	debugC(3, kDebugLevels::kDebugScripts, "MOVE::WAIT_NB_DIZIEME(%i, %i)", (int)numSeconds, currentTime);
 
 	if (currentTime == 0) {
-		currentTime = engine->_lbaTime + engine->toSeconds(numSeconds) / 10;
+		currentTime = engine->timerRef + engine->toSeconds(numSeconds) / 10;
 		ctx.stream.rewind(4);
 		ctx.stream.writeSint32LE(currentTime);
 	}
 
-	if (engine->_lbaTime < currentTime) {
+	if (engine->timerRef < currentTime) {
 		ctx.undo(5);
 		return 1;
 	}
@@ -108,12 +108,12 @@ int32 ScriptMoveV2::mWAIT_NB_DIZIEME_RND(TwinEEngine *engine, MoveScriptContext
 	debugC(3, kDebugLevels::kDebugScripts, "MOVE::WAIT_NB_DIZIEME(%i, %i)", (int)numSeconds, currentTime);
 
 	if (currentTime == 0) {
-		currentTime = engine->_lbaTime + engine->toSeconds(numSeconds) / 10;
+		currentTime = engine->timerRef + engine->toSeconds(numSeconds) / 10;
 		ctx.stream.rewind(4);
 		ctx.stream.writeSint32LE(currentTime);
 	}
 
-	if (engine->_lbaTime < currentTime) {
+	if (engine->timerRef < currentTime) {
 		ctx.undo(5);
 		return 1;
 	}
@@ -130,12 +130,12 @@ int32 ScriptMoveV2::mWAIT_NB_SECOND_RND(TwinEEngine *engine, MoveScriptContext &
 	debugC(3, kDebugLevels::kDebugScripts, "MOVE::WAIT_NB_SECOND_RND(%i, %i)", (int)numSeconds, currentTime);
 
 	if (currentTime == 0) {
-		currentTime = engine->_lbaTime + engine->toSeconds(numSeconds);
+		currentTime = engine->timerRef + engine->toSeconds(numSeconds);
 		ctx.stream.rewind(4);
 		ctx.stream.writeSint32LE(currentTime);
 	}
 
-	if (engine->_lbaTime < currentTime) {
+	if (engine->timerRef < currentTime) {
 		ctx.undo(5);
 		return 1;
 	}
diff --git a/engines/twine/twine.cpp b/engines/twine/twine.cpp
index d9c26fbbfab..5a11fde68be 100644
--- a/engines/twine/twine.cpp
+++ b/engines/twine/twine.cpp
@@ -646,7 +646,7 @@ int TwinEEngine::getRandomNumber(uint max) {
 
 void TwinEEngine::freezeTime(bool pause) {
 	if (_isTimeFreezed == 0) {
-		_saveFreezedTime = _lbaTime;
+		_saveFreezedTime = timerRef;
 		if (pause)
 			_pauseToken = pauseEngine();
 	}
@@ -656,7 +656,7 @@ void TwinEEngine::freezeTime(bool pause) {
 void TwinEEngine::unfreezeTime() {
 	--_isTimeFreezed;
 	if (_isTimeFreezed == 0) {
-		_lbaTime = _saveFreezedTime;
+		timerRef = _saveFreezedTime;
 		if (_pauseToken.isActive()) {
 			_pauseToken.clear();
 		}
@@ -756,6 +756,7 @@ void TwinEEngine::processInventoryAction() {
 		penguin->_pos.z += destPos.z;
 
 		penguin->_beta = _scene->_sceneHero->_beta;
+		debug("penguin angle: %i", penguin->_beta);
 
 		if (_collision->checkValidObjPos(_scene->_mecaPenguinIdx)) {
 			penguin->setLife(kActorMaxLife);
@@ -765,7 +766,7 @@ void TwinEEngine::processInventoryAction() {
 			penguin->setBrickShape(ShapeType::kNone);
 			_movements->initRealAngleConst(penguin->_beta, penguin->_beta, penguin->_speed, &penguin->_moveAngle);
 			_gameState->removeItem(InventoryItems::kiPenguin);
-			penguin->_delayInMillis = _lbaTime + toSeconds(30);
+			penguin->_delayInMillis = timerRef + toSeconds(30);
 		}
 		break;
 	}
@@ -953,7 +954,7 @@ bool TwinEEngine::runGameEngine() { // mainLoopInteration
 		}
 	}
 
-	_loopActorStep = _loopMovePtr.getRealValue(_lbaTime);
+	_loopActorStep = _loopMovePtr.getRealValueFromTime(timerRef);
 	if (!_loopActorStep) {
 		_loopActorStep = 1;
 	}
@@ -1126,7 +1127,7 @@ bool TwinEEngine::gameEngineLoop() {
 		if (runGameEngine()) {
 			return true;
 		}
-		_lbaTime++;
+		timerRef++;
 		if (shouldQuit()) {
 			break;
 		}
diff --git a/engines/twine/twine.h b/engines/twine/twine.h
index 230176a0c53..3093159e713 100644
--- a/engines/twine/twine.h
+++ b/engines/twine/twine.h
@@ -296,7 +296,7 @@ public:
 
 	int32 _frameCounter = 0;
 	SceneLoopState _sceneLoopState = SceneLoopState::ReturnToMenu;
-	int32 _lbaTime = 0;
+	int32 timerRef = 0;
 
 	int32 _loopInventoryItem = 0;
 	int32 _loopActorStep = 0;


Commit: 2e53c0fa3fb5d9c52fd396ff3ba5c63fda72da5d
    https://github.com/scummvm/scummvm/commit/2e53c0fa3fb5d9c52fd396ff3ba5c63fda72da5d
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2023-01-21T18:10:02+01:00

Commit Message:
TWINE: unified movement stuff with original sources

Changed paths:
    engines/twine/renderer/renderer.cpp
    engines/twine/renderer/shadeangletab.h
    engines/twine/scene/actor.cpp
    engines/twine/scene/actor.h
    engines/twine/scene/animations.cpp
    engines/twine/scene/collision.cpp
    engines/twine/scene/extra.cpp
    engines/twine/scene/movements.cpp
    engines/twine/scene/movements.h
    engines/twine/scene/scene.cpp
    engines/twine/script/script_life.cpp
    engines/twine/script/script_move.cpp
    engines/twine/twine.cpp


diff --git a/engines/twine/renderer/renderer.cpp b/engines/twine/renderer/renderer.cpp
index 4a7abc1e259..72f0afdd473 100644
--- a/engines/twine/renderer/renderer.cpp
+++ b/engines/twine/renderer/renderer.cpp
@@ -211,8 +211,8 @@ void Renderer::setFollowCamera(int32 transPosX, int32 transPosY, int32 transPosZ
 
 IVec3 Renderer::getHolomapRotation(const int32 x, const int32 y, const int32 angle) const {
 	if (angle) {
-		const int32 nSin = lba1ShadeAngleTable[ClampAngle(angle)];
-		const int32 nCos = lba1ShadeAngleTable[ClampAngle((angle + LBAAngles::ANGLE_90))];
+		const int32 nSin = sinTab[ClampAngle(angle)];
+		const int32 nCos = sinTab[ClampAngle((angle + LBAAngles::ANGLE_90))];
 
 		const int32 x0 = ((x * nCos) + (y * nSin)) >> 14;
 		const int32 y0 = ((y * nCos) - (x * nSin)) >> 14;
@@ -227,9 +227,9 @@ void Renderer::rotMatIndex2(IMatrix3x3 *targetMatrix, const IMatrix3x3 *currentM
 
 	if (angleVec.x) {
 		int32 angle = angleVec.x;
-		int32 angleVar2 = lba1ShadeAngleTable[ClampAngle(angle)];
+		int32 angleVar2 = sinTab[ClampAngle(angle)];
 		angle += LBAAngles::ANGLE_90;
-		int32 angleVar1 = lba1ShadeAngleTable[ClampAngle(angle)];
+		int32 angleVar1 = sinTab[ClampAngle(angle)];
 
 		matrix1.row1.x = currentMatrix->row1.x;
 		matrix1.row2.x = currentMatrix->row2.x;
@@ -247,9 +247,9 @@ void Renderer::rotMatIndex2(IMatrix3x3 *targetMatrix, const IMatrix3x3 *currentM
 
 	if (angleVec.z) {
 		int32 angle = angleVec.z;
-		int32 angleVar2 = lba1ShadeAngleTable[ClampAngle(angle)];
+		int32 angleVar2 = sinTab[ClampAngle(angle)];
 		angle += LBAAngles::ANGLE_90;
-		int32 angleVar1 = lba1ShadeAngleTable[ClampAngle(angle)];
+		int32 angleVar1 = sinTab[ClampAngle(angle)];
 
 		matrix2.row1.z = matrix1.row1.z;
 		matrix2.row2.z = matrix1.row2.z;
@@ -267,9 +267,9 @@ void Renderer::rotMatIndex2(IMatrix3x3 *targetMatrix, const IMatrix3x3 *currentM
 
 	if (angleVec.y) {
 		int32 angle = angleVec.y;
-		int32 angleVar2 = lba1ShadeAngleTable[ClampAngle(angle)];
+		int32 angleVar2 = sinTab[ClampAngle(angle)];
 		angle += LBAAngles::ANGLE_90;
-		int32 angleVar1 = lba1ShadeAngleTable[ClampAngle(angle)];
+		int32 angleVar1 = sinTab[ClampAngle(angle)];
 
 		targetMatrix->row1.y = matrix2.row1.y;
 		targetMatrix->row2.y = matrix2.row2.y;
diff --git a/engines/twine/renderer/shadeangletab.h b/engines/twine/renderer/shadeangletab.h
index 411c8270833..baadeef7697 100644
--- a/engines/twine/renderer/shadeangletab.h
+++ b/engines/twine/renderer/shadeangletab.h
@@ -31,7 +31,7 @@ namespace TwinE {
  * @brief Caches sin cos table for all possible angles (0-1024 = 0-360 degree)
  * @todo this is for lba1 - lba2 is missing
  */
-const int16 lba1ShadeAngleTable[] = {
+const int16 sinTab[] = {
 	0, // tab1
 	101,
 	201,
diff --git a/engines/twine/scene/actor.cpp b/engines/twine/scene/actor.cpp
index 85096de602d..a06d6e208f6 100644
--- a/engines/twine/scene/actor.cpp
+++ b/engines/twine/scene/actor.cpp
@@ -63,7 +63,7 @@ void Actor::restartHeroScene() {
 	sceneHero->_zone = -1;
 	sceneHero->_beta = _previousHeroAngle;
 
-	_engine->_movements->initRealAngle(sceneHero->_beta, sceneHero->_beta, LBAAngles::ANGLE_0, &sceneHero->_moveAngle);
+	_engine->_movements->initRealAngle(sceneHero->_beta, sceneHero->_beta, LBAAngles::ANGLE_0, &sceneHero->realAngle);
 	setBehaviour(_previousHeroBehaviour);
 
 	_cropBottomScreen = 0;
@@ -236,7 +236,7 @@ void Actor::initActor(int16 actorIdx) {
 
 		initSpriteActor(actorIdx);
 
-		_engine->_movements->initRealAngle(LBAAngles::ANGLE_0, LBAAngles::ANGLE_0, LBAAngles::ANGLE_0, &actor->_moveAngle);
+		_engine->_movements->initRealAngle(LBAAngles::ANGLE_0, LBAAngles::ANGLE_0, LBAAngles::ANGLE_0, &actor->realAngle);
 
 		if (actor->_staticFlags.bUsesClipping) {
 			actor->_animStep = actor->posObj();
@@ -254,7 +254,7 @@ void Actor::initActor(int16 actorIdx) {
 			_engine->_animations->initAnim(actor->_genAnim, AnimType::kAnimationTypeLoop, AnimationTypes::kAnimInvalid, actorIdx);
 		}
 
-		_engine->_movements->initRealAngle(actor->_beta, actor->_beta, LBAAngles::ANGLE_0, &actor->_moveAngle);
+		_engine->_movements->initRealAngle(actor->_beta, actor->_beta, LBAAngles::ANGLE_0, &actor->realAngle);
 	}
 
 	actor->_offsetTrack = -1;
@@ -274,7 +274,7 @@ void Actor::resetActor(int16 actorIdx) {
 	memset(&actor->_dynamicFlags, 0, sizeof(DynamicFlagsStruct));
 	memset(&actor->_bonusParameter, 0, sizeof(BonusParameter));
 
-	_engine->_movements->initRealAngle(LBAAngles::ANGLE_0, LBAAngles::ANGLE_0, LBAAngles::ANGLE_0, &actor->_moveAngle);
+	_engine->_movements->initRealAngle(LBAAngles::ANGLE_0, LBAAngles::ANGLE_0, LBAAngles::ANGLE_0, &actor->realAngle);
 }
 
 void Actor::hitObj(int32 actorIdx, int32 actorIdxAttacked, int32 hitforce, int32 angle) {
@@ -300,7 +300,7 @@ void Actor::hitObj(int32 actorIdx, int32 actorIdxAttacked, int32 hitforce, int32
 
 		} else {
 			if (angle != -1) {
-				_engine->_movements->initRealAngle(angle, angle, LBAAngles::ANGLE_0, &actor->_moveAngle);
+				_engine->_movements->initRealAngle(angle, angle, LBAAngles::ANGLE_0, &actor->realAngle);
 			}
 
 			if (_engine->getRandomNumber() & 1) {
@@ -349,7 +349,7 @@ void Actor::giveExtraBonus(int32 actorIdx) {
 		_engine->_sound->playSample(Samples::ItemPopup, 1, actor->posObj(), actorIdx);
 	} else {
 		const ActorStruct *sceneHero = _engine->_scene->_sceneHero;
-		const int32 angle = _engine->_movements->getAngleAndSetTargetActorDistance(actor->posObj(), sceneHero->posObj());
+		const int32 angle = _engine->_movements->getAngle(actor->posObj(), sceneHero->posObj());
 		const IVec3 pos(actor->_pos.x, actor->_pos.y + actor->_boundingBox.maxs.y, actor->_pos.z);
 		_engine->_extra->addExtraBonus(pos, LBAAngles::ANGLE_70, angle, bonusSprite, actor->_bonusAmount);
 		_engine->_sound->playSample(Samples::ItemPopup, 1, pos, actorIdx);
diff --git a/engines/twine/scene/actor.h b/engines/twine/scene/actor.h
index e5fdd175dd4..d4d06a8ddaa 100644
--- a/engines/twine/scene/actor.h
+++ b/engines/twine/scene/actor.h
@@ -135,7 +135,7 @@ struct BonusParameter {
  */
 class ActorStruct {
 private:
-	ShapeType _brickShape = ShapeType::kNone; // field_3
+	ShapeType _col = ShapeType::kNone; // collision
 	bool _brickCausesDamage = false; // TODO: this is a bitmask with multiple values in the original source
 
 	EntityData _entityData;
@@ -143,9 +143,9 @@ public:
 	StaticFlagsStruct _staticFlags;
 	DynamicFlagsStruct _dynamicFlags;
 
-	inline ShapeType brickShape() const { return _brickShape; }
-	inline void setBrickShape(ShapeType shapeType) {
-		_brickShape = shapeType;
+	inline ShapeType brickShape() const { return _col; }
+	inline void setCollision(ShapeType shapeType) {
+		_col = shapeType;
 		_brickCausesDamage = false;
 	}
 	inline void setBrickCausesDamage() { _brickCausesDamage = true; }
@@ -227,7 +227,7 @@ public:
 	uint8 _brickSound = 0U; // CodeJeu
 
 	BoundingBox _boundingBox; // Xmin, YMin, Zmin, Xmax, Ymax, Zmax
-	ActorMoveStruct _moveAngle;
+	ActorMoveStruct realAngle;
 	AnimTimerDataStruct _animTimerData;
 };
 
diff --git a/engines/twine/scene/animations.cpp b/engines/twine/scene/animations.cpp
index cae65c03211..f68de79e7c6 100644
--- a/engines/twine/scene/animations.cpp
+++ b/engines/twine/scene/animations.cpp
@@ -349,7 +349,7 @@ void Animations::processAnimActions(int32 actorIdx) { // GereAnimAction
 		case ActionType::ACTION_THROW_3D_ALPHA:
 			if (action.animFrame == actor->_frame) {
 				const int32 distance = getDistance2D(actor->posObj(), _engine->_scene->_sceneHero->posObj());
-				const int32 newAngle = _engine->_movements->getAngleAndSetTargetActorDistance(actor->_pos.y, 0, _engine->_scene->_sceneHero->_pos.y, distance);
+				const int32 newAngle = _engine->_movements->getAngle(actor->_pos.y, 0, _engine->_scene->_sceneHero->_pos.y, distance);
 
 				const IVec3 &destPos = _engine->_movements->rotate(action.distanceX, action.distanceZ, actor->_beta);
 
@@ -483,9 +483,9 @@ void Animations::doAnim(int32 actorIdx) {
 
 		if (!actor->_dynamicFlags.bIsFalling) {
 			if (actor->_speed) {
-				int32 xAxisRotation = actor->_moveAngle.getRealValueFromTime(_engine->timerRef);
+				int32 xAxisRotation = actor->realAngle.getRealValueFromTime(_engine->timerRef);
 				if (!xAxisRotation) {
-					if (actor->_moveAngle.endValue > 0) {
+					if (actor->realAngle.endValue > 0) {
 						xAxisRotation = 1;
 					} else {
 						xAxisRotation = -1;
@@ -501,7 +501,7 @@ void Animations::doAnim(int32 actorIdx) {
 				processActor.x = actor->_pos.x + destPos.x;
 				processActor.z = actor->_pos.z + destPos.z;
 
-				_engine->_movements->setActorAngle(LBAAngles::LBAAngles::ANGLE_0, actor->_speed, LBAAngles::LBAAngles::ANGLE_17, &actor->_moveAngle);
+				_engine->_movements->setActorAngle(LBAAngles::LBAAngles::ANGLE_0, actor->_speed, LBAAngles::LBAAngles::ANGLE_17, &actor->realAngle);
 
 				if (actor->_dynamicFlags.bIsSpriteMoving) {
 					if (actor->_doorWidth) { // open door
@@ -717,7 +717,7 @@ void Animations::doAnim(int32 actorIdx) {
 		}
 
 		brickShape = _engine->_grid->worldColBrick(processActor);
-		actor->setBrickShape(brickShape);
+		actor->setCollision(brickShape);
 
 		if (brickShape != ShapeType::kNone) {
 			if (brickShape == ShapeType::kSolid) {
diff --git a/engines/twine/scene/collision.cpp b/engines/twine/scene/collision.cpp
index 380a0d892ab..f428919e8a3 100644
--- a/engines/twine/scene/collision.cpp
+++ b/engines/twine/scene/collision.cpp
@@ -187,7 +187,7 @@ void Collision::handlePushing(const IVec3 &minsTest, const IVec3 &maxsTest, Acto
 	IVec3 &processActor = actor->_processActor;
 	const IVec3 &previousActor = actor->_previousActor;
 
-	const int32 newAngle = _engine->_movements->getAngleAndSetTargetActorDistance(processActor, actorTest->posObj());
+	const int32 newAngle = _engine->_movements->getAngle(processActor, actorTest->posObj());
 
 	// protect against chain reactions
 	if (actorTest->_staticFlags.bCanBePushed && !actor->_staticFlags.bCanBePushed) {
diff --git a/engines/twine/scene/extra.cpp b/engines/twine/scene/extra.cpp
index e200d409e5f..bc847ac786a 100644
--- a/engines/twine/scene/extra.cpp
+++ b/engines/twine/scene/extra.cpp
@@ -96,7 +96,7 @@ int32 Extra::extraSearch(int32 actorIdx, int32 x, int32 y, int32 z, int32 sprite
 
 		_engine->_movements->setActorAngle(LBAAngles::ANGLE_0, maxSpeed, LBAAngles::ANGLE_17, &extra->trackActorMove);
 		const ActorStruct *actor = _engine->_scene->getActor(targetActor);
-		extra->angle = _engine->_movements->getAngleAndSetTargetActorDistance(extra->pos, actor->posObj());
+		extra->angle = _engine->_movements->getAngle(extra->pos, actor->posObj());
 		return i;
 	}
 	return -1;
@@ -292,7 +292,7 @@ int32 Extra::addExtraAiming(int32 actorIdx, int32 x, int32 y, int32 z, int32 spr
 		extra->strengthOfHit = strengthOfHit;
 		_engine->_movements->setActorAngle(LBAAngles::ANGLE_0, finalAngle, LBAAngles::ANGLE_17, &extra->trackActorMove);
 		const ActorStruct *actor = _engine->_scene->getActor(targetActorIdx);
-		extra->angle = _engine->_movements->getAngleAndSetTargetActorDistance(extra->pos, actor->posObj());
+		extra->angle = _engine->_movements->getAngle(extra->pos, actor->posObj());
 
 		return i;
 	}
@@ -327,7 +327,7 @@ int32 Extra::extraSearchKey(int32 actorIdx, int32 x, int32 y, int32 z, int32 spr
 		extra->destPos.z = 4000;
 		extra->strengthOfHit = 0;
 		_engine->_movements->setActorAngle(LBAAngles::ANGLE_0, 4000, LBAAngles::ANGLE_17, &extra->trackActorMove);
-		extra->angle = _engine->_movements->getAngleAndSetTargetActorDistance(extra->pos, _extraList[extraIdx].pos);
+		extra->angle = _engine->_movements->getAngle(extra->pos, _extraList[extraIdx].pos);
 
 		return i;
 	}
@@ -562,7 +562,7 @@ void Extra::gereExtras() {
 			currentExtraY = actor->_pos.y + 1000;
 			currentExtraZ = actor->_pos.z;
 
-			const int32 tmpAngle = _engine->_movements->getAngleAndSetTargetActorDistance(extra->pos, actor->posObj());
+			const int32 tmpAngle = _engine->_movements->getAngle(extra->pos, actor->posObj());
 			const int32 angle = ClampAngle(tmpAngle - extra->angle);
 
 			if (angle > LBAAngles::ANGLE_140 && angle < LBAAngles::ANGLE_210) {
@@ -578,7 +578,7 @@ void Extra::gereExtras() {
 				continue;
 			}
 
-			const int32 angle2 = _engine->_movements->getAngleAndSetTargetActorDistance(extra->pos.y, 0, currentExtraY, _engine->_movements->_targetActorDistance);
+			const int32 angle2 = _engine->_movements->getAngle(extra->pos.y, 0, currentExtraY, _engine->_movements->_targetActorDistance);
 			int32 pos = extra->trackActorMove.getRealValueFromTime(_engine->timerRef);
 			if (!pos) {
 				pos = 1;
@@ -607,7 +607,7 @@ void Extra::gereExtras() {
 			ExtraListStruct *extraKey = &_extraList[extra->payload.extraIdx];
 			const int32 extraIdx = extra->payload.extraIdx;
 
-			const int32 tmpAngle = _engine->_movements->getAngleAndSetTargetActorDistance(extra->pos, extraKey->pos);
+			const int32 tmpAngle = _engine->_movements->getAngle(extra->pos, extraKey->pos);
 			const int32 angle = ClampAngle(tmpAngle - extra->angle);
 
 			if (angle > LBAAngles::ANGLE_140 && angle < LBAAngles::ANGLE_210) {
@@ -627,7 +627,7 @@ void Extra::gereExtras() {
 				_engine->_gameState->_magicBall = extraSearch(-1, extra->pos.x, extra->pos.y, extra->pos.z, SPRITEHQR_KEY, 0, 8000, 0);
 				continue;
 			}
-			const int32 angle2 = _engine->_movements->getAngleAndSetTargetActorDistance(extra->pos.y, 0, extraKey->pos.y, _engine->_movements->_targetActorDistance);
+			const int32 angle2 = _engine->_movements->getAngle(extra->pos.y, 0, extraKey->pos.y, _engine->_movements->_targetActorDistance);
 			int32 pos = extra->trackActorMove.getRealValueFromTime(_engine->timerRef);
 
 			if (!pos) {
diff --git a/engines/twine/scene/movements.cpp b/engines/twine/scene/movements.cpp
index b7f1ee9e852..26214740514 100644
--- a/engines/twine/scene/movements.cpp
+++ b/engines/twine/scene/movements.cpp
@@ -64,7 +64,7 @@ void Movements::initRealAngle(int16 startAngle, int16 endAngle, int16 stepAngle,
 }
 
 void Movements::clearRealAngle(ActorStruct *actorPtr) {
-	initRealAngle(actorPtr->_beta, actorPtr->_beta, LBAAngles::ANGLE_0, &actorPtr->_moveAngle);
+	initRealAngle(actorPtr->_beta, actorPtr->_beta, LBAAngles::ANGLE_0, &actorPtr->realAngle);
 }
 
 void Movements::setActorAngle(int16 startAngle, int16 endAngle, int16 stepAngle, ActorMoveStruct *movePtr) {
@@ -74,70 +74,59 @@ void Movements::setActorAngle(int16 startAngle, int16 endAngle, int16 stepAngle,
 	movePtr->memoTicks = _engine->timerRef;
 }
 
-int32 Movements::getAngleAndSetTargetActorDistance(int32 x1, int32 z1, int32 x2, int32 z2) {
-	/*
-	//Pythagoras
-	targetActorDistance = (int32)sqrt((float)(((z2 - z1)*(z2 - z1) + (x2 - x1)*(x2 - x1))));
+int32 Movements::getAngle(int32 x0, int32 z0, int32 x1, int32 z1) {
+	z1 -= z0;
+	x1 -= x0;
+	const int32 x2 = x1 * x1;
+	const int32 z2 = z1 * z1;
 
-	if (targetActorDistance == 0)
+	_targetActorDistance = (int32)sqrt((float)(x2 + z2));
+	if (!_targetActorDistance) {
 		return 0;
+	}
 
-	//given two points, we calculate its arc-tangent in radians
-	//Then we convert from radians (360 degrees == 2*M_PI) to a 10bit value (360 degrees == 1024) and invert the rotation direction
-	//Then we add an offset of 90 degrees (256) and limit it to the 10bit value range.
-	return (256 + ((int32)floor((-1024 * atan2((float)(z2-z1), (int32)(x2-x1))) / (2*M_PI)))) % 1024;
-	*/
-
-	int32 difZ = z2 - z1;
-	const int32 newZ = difZ * difZ;
-
-	int32 difX = x2 - x1;
-	const int32 newX = difX * difX;
-
-	bool flag;
-	// Exchange X and Z
-	if (newX < newZ) {
-		const int32 tmpEx = difX;
-		difX = difZ;
-		difZ = tmpEx;
-
-		flag = true;
+	if (z2 > x2) {
+		const int32 tmpEx = z1;
+		x1 = z1 | 1; // flag = 1
+		z1 = tmpEx;
 	} else {
-		flag = false;
+		x1 &= -2; // flag = 0
 	}
 
-	_targetActorDistance = (int32)sqrt((float)(newX + newZ));
-
-	if (!_targetActorDistance) {
-		return 0;
-	}
+	const int32 tmp = (z1 * SCENE_SIZE_HALF) / _targetActorDistance;
 
-	const int32 destAngle = (difZ * SCENE_SIZE_HALF) / _targetActorDistance;
+	int32 start = LBAAngles::ANGLE_135;
+	int32 end = LBAAngles::ANGLE_135 + LBAAngles::ANGLE_90;
+	int32 diff = 0;
 
-	int32 startAngle = LBAAngles::ANGLE_0;
-	//	stopAngle  = LBAAngles::ANGLE_90;
-	const int16 *shadeAngleTab3(&lba1ShadeAngleTable[LBAAngles::ANGLE_135]);
-	while (shadeAngleTab3[startAngle] > destAngle) {
-		startAngle++;
+	while (start < (end - 1)) {
+		int32 angle = (start + end) >> 1;
+		diff = tmp - sinTab[angle];
+		if (diff > 0) {
+			end = angle;
+		} else {
+			start = angle;
+			if (diff == 0) {
+				break;
+			}
+		}
 	}
-
-	if (shadeAngleTab3[startAngle] != destAngle) {
-		if ((shadeAngleTab3[startAngle - 1] + shadeAngleTab3[startAngle]) / 2 <= destAngle) {
-			startAngle--;
+	if (diff) {
+		if (tmp <= ((sinTab[start] + sinTab[end]) >> 1)) {
+			start = end;
 		}
 	}
 
-	int32 finalAngle = LBAAngles::ANGLE_45 + startAngle;
-
-	if (difX <= 0) {
-		finalAngle = -finalAngle;
+	int32 angle = start - LBAAngles::ANGLE_90;
+	if (x1 < 0) {
+		angle = -angle;
 	}
 
-	if (flag) {
-		finalAngle = -finalAngle + LBAAngles::ANGLE_90;
+	if (x1 & 1) {
+		angle = LBAAngles::ANGLE_90 - angle;
 	}
 
-	return ClampAngle(finalAngle);
+	return ClampAngle(angle);
 }
 
 IVec3 Movements::rotate(int32 side, int32 forward, int32 angle) {
@@ -226,7 +215,7 @@ bool Movements::processBehaviourExecution(int actorIdx) {
 		if (_engine->_actor->_combatAuto) {
 			ActorStruct *actor = _engine->_scene->getActor(actorIdx);
 			_lastJoyFlag = true;
-			actor->_beta = actor->_moveAngle.getRealAngle(_engine->timerRef);
+			actor->_beta = actor->realAngle.getRealAngle(_engine->timerRef);
 			// TODO: previousLoopActionKey must be handled properly
 			if (!_previousLoopActionKey || actor->_genAnim == AnimationTypes::kStanding) {
 				const int32 aggresiveMode = _engine->getRandomNumber(3);
@@ -274,7 +263,7 @@ bool Movements::processAttackExecution(int actorIdx) {
 				_engine->_animations->initAnim(AnimationTypes::kThrowBall, AnimType::kAnimationThen, AnimationTypes::kStanding, actorIdx);
 			}
 
-			actor->_beta = actor->_moveAngle.getRealAngle(_engine->timerRef);
+			actor->_beta = actor->realAngle.getRealAngle(_engine->timerRef);
 			return true;
 		}
 	} else if (_engine->_gameState->hasItem(InventoryItems::kiUseSabre)) {
@@ -284,7 +273,7 @@ bool Movements::processAttackExecution(int actorIdx) {
 
 		_engine->_animations->initAnim(AnimationTypes::kSabreAttack, AnimType::kAnimationThen, AnimationTypes::kStanding, actorIdx);
 
-		actor->_beta = actor->_moveAngle.getRealAngle(_engine->timerRef);
+		actor->_beta = actor->realAngle.getRealAngle(_engine->timerRef);
 		return true;
 	}
 	return false;
@@ -326,7 +315,7 @@ void Movements::processManualMovementExecution(int actorIdx) {
 				_engine->_animations->initAnim(AnimationTypes::kTurnLeft, AnimType::kAnimationTypeLoop, AnimationTypes::kAnimInvalid, actorIdx);
 			} else {
 				if (!actor->_dynamicFlags.bIsRotationByAnim) {
-					actor->_beta = actor->_moveAngle.getRealAngle(_engine->timerRef);
+					actor->_beta = actor->realAngle.getRealAngle(_engine->timerRef);
 				}
 			}
 			_lastJoyFlag = true;
@@ -335,7 +324,7 @@ void Movements::processManualMovementExecution(int actorIdx) {
 				_engine->_animations->initAnim(AnimationTypes::kTurnRight, AnimType::kAnimationTypeLoop, AnimationTypes::kAnimInvalid, actorIdx);
 			} else {
 				if (!actor->_dynamicFlags.bIsRotationByAnim) {
-					actor->_beta = actor->_moveAngle.getRealAngle(_engine->timerRef);
+					actor->_beta = actor->realAngle.getRealAngle(_engine->timerRef);
 				}
 			}
 			_lastJoyFlag = true;
@@ -361,7 +350,7 @@ void Movements::processManualRotationExecution(int actorIdx) {
 		tempAngle = LBAAngles::ANGLE_0;
 	}
 
-	initRealAngleConst(actor->_beta, actor->_beta + tempAngle, actor->_speed, &actor->_moveAngle);
+	initRealAngleConst(actor->_beta, actor->_beta + tempAngle, actor->_speed, &actor->realAngle);
 }
 
 void Movements::processManualAction(int actorIdx) {
@@ -385,11 +374,11 @@ void Movements::processManualAction(int actorIdx) {
 void Movements::processFollowAction(int actorIdx) {
 	ActorStruct *actor = _engine->_scene->getActor(actorIdx);
 	const ActorStruct *followedActor = _engine->_scene->getActor(actor->_followedActor);
-	int32 newAngle = getAngleAndSetTargetActorDistance(actor->posObj(), followedActor->posObj());
+	int32 newAngle = getAngle(actor->posObj(), followedActor->posObj());
 	if (actor->_staticFlags.bIsSpriteActor) {
 		actor->_beta = newAngle;
 	} else {
-		initRealAngleConst(actor->_beta, newAngle, actor->_speed, &actor->_moveAngle);
+		initRealAngleConst(actor->_beta, newAngle, actor->_speed, &actor->realAngle);
 	}
 }
 
@@ -401,16 +390,16 @@ void Movements::processRandomAction(int actorIdx) {
 
 	if (actor->brickCausesDamage()) {
 		const int32 angle = ClampAngle(actor->_beta + (_engine->getRandomNumber() & (LBAAngles::ANGLE_180 - 1)) - LBAAngles::ANGLE_90 + LBAAngles::ANGLE_180);
-		initRealAngleConst(actor->_beta, angle, actor->_speed, &actor->_moveAngle);
+		initRealAngleConst(actor->_beta, angle, actor->_speed, &actor->realAngle);
 		actor->_delayInMillis = _engine->getRandomNumber(300) + _engine->timerRef + 300;
 		_engine->_animations->initAnim(AnimationTypes::kStanding, AnimType::kAnimationTypeLoop, AnimationTypes::kAnimInvalid, actorIdx);
 	}
 
-	if (!actor->_moveAngle.timeValue) {
+	if (!actor->realAngle.timeValue) {
 		_engine->_animations->initAnim(AnimationTypes::kForward, AnimType::kAnimationTypeLoop, AnimationTypes::kAnimInvalid, actorIdx);
 		if (_engine->timerRef > actor->_delayInMillis) {
 			const int32 angle = ClampAngle(actor->_beta + (_engine->getRandomNumber() & (LBAAngles::ANGLE_180 - 1)) - LBAAngles::ANGLE_90);
-			initRealAngleConst(actor->_beta, angle, actor->_speed, &actor->_moveAngle);
+			initRealAngleConst(actor->_beta, angle, actor->_speed, &actor->realAngle);
 			actor->_delayInMillis = _engine->getRandomNumber(300) + _engine->timerRef + 300;
 		}
 	}
@@ -430,6 +419,17 @@ void Movements::processSameXZAction(int actorIdx) {
 	actor->_pos.z = followedActor->_pos.z;
 }
 
+void Movements::manualRealAngle(ActorStruct *actor) {
+	int16 tempAngle = LBAAngles::ANGLE_0;
+	if (_engine->_input->isActionActive(TwinEActionType::TurnLeft)) {
+		tempAngle = LBAAngles::ANGLE_90;
+	} else if (_engine->_input->isActionActive(TwinEActionType::TurnRight)) {
+		tempAngle = -LBAAngles::ANGLE_90;
+	}
+
+	initRealAngleConst(actor->_beta, actor->_beta + tempAngle, actor->_speed, &actor->realAngle);
+}
+
 void Movements::doDir(int32 actorIdx) {
 	ActorStruct *actor = _engine->_scene->getActor(actorIdx);
 	if (actor->_body == -1) {
@@ -437,43 +437,25 @@ void Movements::doDir(int32 actorIdx) {
 	}
 
 	if (actor->_dynamicFlags.bIsFalling) {
-		if (actor->_controlMode != ControlMode::kManual) {
-			return;
-		}
-
-		int16 tempAngle = LBAAngles::ANGLE_0;
-		if (_engine->_input->isActionActive(TwinEActionType::TurnLeft)) {
-			tempAngle = LBAAngles::ANGLE_90;
-		} else if (_engine->_input->isActionActive(TwinEActionType::TurnRight)) {
-			tempAngle = -LBAAngles::ANGLE_90;
+		if (actor->_controlMode == ControlMode::kManual) {
+			manualRealAngle(actor);
 		}
-
-		initRealAngleConst(actor->_beta, actor->_beta + tempAngle, actor->_speed, &actor->_moveAngle);
 		return;
 	}
-	if (!actor->_staticFlags.bIsSpriteActor) {
-		if (actor->_controlMode != ControlMode::kManual) {
-			actor->_beta = actor->_moveAngle.getRealAngle(_engine->timerRef);
-		}
+	if (!actor->_staticFlags.bIsSpriteActor && actor->_controlMode != ControlMode::kManual) {
+		actor->_beta = actor->realAngle.getRealAngle(_engine->timerRef);
 	}
 
 	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 ControlMode::kNoMove:
-	case ControlMode::kFollow2:     // unused
-	case ControlMode::kTrackAttack: // unused
-		break;
 	case ControlMode::kManual:
 		processManualAction(actorIdx);
 		break;
 	case ControlMode::kFollow:
 		processFollowAction(actorIdx);
 		break;
+	case ControlMode::kRandom:
+		processRandomAction(actorIdx);
+		break;
 	case ControlMode::kTrack:
 		processTrackAction(actorIdx);
 		break;
@@ -481,8 +463,15 @@ void Movements::doDir(int32 actorIdx) {
 		// TODO: see lSET_DIRMODE and lSET_DIRMODE_OBJ opcodes
 		processSameXZAction(actorIdx);
 		break;
-	case ControlMode::kRandom:
-		processRandomAction(actorIdx);
+	/**
+	 * 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 ControlMode::kNoMove:
+	case ControlMode::kFollow2:     // unused
+	case ControlMode::kTrackAttack: // unused
 		break;
 	default:
 		warning("Unknown control mode %d", (int)actor->_controlMode);
diff --git a/engines/twine/scene/movements.h b/engines/twine/scene/movements.h
index e9ed84350c2..88364390098 100644
--- a/engines/twine/scene/movements.h
+++ b/engines/twine/scene/movements.h
@@ -117,6 +117,7 @@ private:
 	 * This is true if the player hits the action button. E.g. in the second prison scene when you hide in the waste.
 	 */
 	bool _actionNormal = false;
+	void manualRealAngle(ActorStruct *actor);
 
 public:
 	Movements(TwinEEngine *engine);
@@ -169,10 +170,10 @@ public:
 	 * @param x2 Actor 2 X
 	 * @param z2 Actor 2 Z
 	 */
-	int32 getAngleAndSetTargetActorDistance(int32 x1, int32 z1, int32 x2, int32 z2);
+	int32 getAngle(int32 x1, int32 z1, int32 x2, int32 z2);
 
-	inline int32 getAngleAndSetTargetActorDistance(const IVec3& v1, const IVec3 &v2) {
-		return getAngleAndSetTargetActorDistance(v1.x, v1.z, v2.x, v2.z);
+	inline int32 getAngle(const IVec3& v1, const IVec3 &v2) {
+		return getAngle(v1.x, v1.z, v2.x, v2.z);
 	}
 
 	/**
diff --git a/engines/twine/scene/scene.cpp b/engines/twine/scene/scene.cpp
index dede6daca6b..323e197edca 100644
--- a/engines/twine/scene/scene.cpp
+++ b/engines/twine/scene/scene.cpp
@@ -692,7 +692,7 @@ void Scene::processZoneExtraBonus(ZoneStruct *zone) {
 	const int32 amount = zone->infoData.Bonus.amount;
 	const int32 x = (zone->maxs.x + zone->mins.x) / 2;
 	const int32 z = (zone->maxs.z + zone->mins.z) / 2;
-	const int32 angle = _engine->_movements->getAngleAndSetTargetActorDistance(x, z, _sceneHero->_pos.x, _sceneHero->_pos.z);
+	const int32 angle = _engine->_movements->getAngle(x, z, _sceneHero->_pos.x, _sceneHero->_pos.z);
 	const int32 index = _engine->_extra->addExtraBonus(x, zone->maxs.y, z, LBAAngles::ANGLE_63, angle, bonusSprite, amount);
 
 	if (index != -1) {
diff --git a/engines/twine/script/script_life.cpp b/engines/twine/script/script_life.cpp
index b9a88c57542..d988f135909 100644
--- a/engines/twine/script/script_life.cpp
+++ b/engines/twine/script/script_life.cpp
@@ -223,7 +223,7 @@ static ReturnType processLifeConditions(TwinEEngine *engine, LifeScriptContext &
 		}
 
 		if (ABS(targetActor->_pos.y - ctx.actor->_pos.y) < 1500) {
-			newAngle = engine->_movements->getAngleAndSetTargetActorDistance(ctx.actor->posObj(), targetActor->posObj());
+			newAngle = engine->_movements->getAngle(ctx.actor->posObj(), targetActor->posObj());
 			if (ABS(engine->_movements->_targetActorDistance) > MAX_TARGET_ACTOR_DISTANCE) {
 				engine->_movements->_targetActorDistance = MAX_TARGET_ACTOR_DISTANCE;
 			}
@@ -435,7 +435,7 @@ static ReturnType processLifeConditions(TwinEEngine *engine, LifeScriptContext &
 			engine->_scene->_currentScriptValue = MAX_TARGET_ACTOR_DISTANCE;
 			break;
 		}
-		int32 angle = engine->_movements->getAngleAndSetTargetActorDistance(ctx.actor->posObj(), otherActor->posObj());
+		int32 angle = engine->_movements->getAngle(ctx.actor->posObj(), otherActor->posObj());
 		engine->_scene->_currentScriptValue = ClampAngle(ctx.actor->_beta - angle);
 		if (engine->_scene->_currentScriptValue > LBAAngles::ANGLE_180) {
 			engine->_scene->_currentScriptValue = LBAAngles::ANGLE_360 - engine->_scene->_currentScriptValue;
@@ -450,7 +450,7 @@ static ReturnType processLifeConditions(TwinEEngine *engine, LifeScriptContext &
 			engine->_scene->_currentScriptValue = MAX_TARGET_ACTOR_DISTANCE;
 			break;
 		}
-		int32 angle = engine->_movements->getAngleAndSetTargetActorDistance(otherActor->posObj(), ctx.actor->posObj());
+		int32 angle = engine->_movements->getAngle(otherActor->posObj(), ctx.actor->posObj());
 		engine->_scene->_currentScriptValue = ClampAngle(otherActor->_beta - angle);
 		if (engine->_scene->_currentScriptValue > LBAAngles::ANGLE_180) {
 			engine->_scene->_currentScriptValue = LBAAngles::ANGLE_360 - engine->_scene->_currentScriptValue;
@@ -465,7 +465,7 @@ static ReturnType processLifeConditions(TwinEEngine *engine, LifeScriptContext &
 			engine->_scene->_currentScriptValue = MAX_TARGET_ACTOR_DISTANCE;
 			break;
 		}
-		int32 angle = engine->_movements->getAngleAndSetTargetActorDistance(ctx.actor->posObj(), otherActor->posObj());
+		int32 angle = engine->_movements->getAngle(ctx.actor->posObj(), otherActor->posObj());
 		engine->_scene->_currentScriptValue = ClampAngle(ctx.actor->_beta - angle);
 		if (engine->_scene->_currentScriptValue > LBAAngles::ANGLE_180) {
 			engine->_scene->_currentScriptValue = LBAAngles::ANGLE_360 - engine->_scene->_currentScriptValue;
@@ -530,7 +530,7 @@ static ReturnType processLifeConditions(TwinEEngine *engine, LifeScriptContext &
 		}
 
 		if (ABS(otherActor->posObj().y - ctx.actor->posObj().y) < 1500) {
-			int32 angle = engine->_movements->getAngleAndSetTargetActorDistance(ctx.actor->posObj(),
+			int32 angle = engine->_movements->getAngle(ctx.actor->posObj(),
 																				otherActor->posObj());
 			angle = ClampAngle(ctx.actor->_beta - angle + LBAAngles::ANGLE_90);
 
diff --git a/engines/twine/script/script_move.cpp b/engines/twine/script/script_move.cpp
index 5d911db8659..e9b5f716ea6 100644
--- a/engines/twine/script/script_move.cpp
+++ b/engines/twine/script/script_move.cpp
@@ -96,12 +96,12 @@ int32 ScriptMove::mGOTO_POINT(TwinEEngine *engine, MoveScriptContext &ctx) {
 	debugC(3, kDebugLevels::kDebugScripts, "MOVE::GOTO_POINT(%i)", (int)engine->_scene->_currentScriptValue);
 
 	const IVec3 &sp = engine->_scene->_sceneTracks[engine->_scene->_currentScriptValue];
-	const int32 newAngle = engine->_movements->getAngleAndSetTargetActorDistance(ctx.actor->_pos.x, ctx.actor->_pos.z, sp.x, sp.z);
+	const int32 newAngle = engine->_movements->getAngle(ctx.actor->_pos.x, ctx.actor->_pos.z, sp.x, sp.z);
 
 	if (ctx.actor->_staticFlags.bIsSpriteActor) {
 		ctx.actor->_beta = newAngle;
 	} else {
-		engine->_movements->initRealAngleConst(ctx.actor->_beta, newAngle, ctx.actor->_speed, &ctx.actor->_moveAngle);
+		engine->_movements->initRealAngleConst(ctx.actor->_beta, newAngle, ctx.actor->_speed, &ctx.actor->realAngle);
 	}
 
 	if (engine->_movements->_targetActorDistance > 500) {
@@ -148,8 +148,8 @@ int32 ScriptMove::mANGLE(TwinEEngine *engine, MoveScriptContext &ctx) {
 		return 0;
 	}
 	engine->_scene->_currentScriptValue = angle;
-	if (ctx.actor->_moveAngle.timeValue == 0) {
-		engine->_movements->initRealAngleConst(ctx.actor->_beta, angle, ctx.actor->_speed, &ctx.actor->_moveAngle);
+	if (ctx.actor->realAngle.timeValue == 0) {
+		engine->_movements->initRealAngleConst(ctx.actor->_beta, angle, ctx.actor->_speed, &ctx.actor->realAngle);
 	}
 	if (ctx.actor->_beta == angle) {
 		engine->_movements->clearRealAngle(ctx.actor);
@@ -226,12 +226,12 @@ int32 ScriptMove::mGOTO_SYM_POINT(TwinEEngine *engine, MoveScriptContext &ctx) {
 	debugC(3, kDebugLevels::kDebugScripts, "MOVE::GOTO_SYM_POINT(%i)", (int)engine->_scene->_currentScriptValue);
 
 	const IVec3 &sp = engine->_scene->_sceneTracks[engine->_scene->_currentScriptValue];
-	const int32 newAngle = LBAAngles::ANGLE_180 + engine->_movements->getAngleAndSetTargetActorDistance(ctx.actor->_pos, sp);
+	const int32 newAngle = LBAAngles::ANGLE_180 + engine->_movements->getAngle(ctx.actor->_pos, sp);
 
 	if (ctx.actor->_staticFlags.bIsSpriteActor) {
 		ctx.actor->_beta = newAngle;
 	} else {
-		engine->_movements->initRealAngleConst(ctx.actor->_beta, newAngle, ctx.actor->_speed, &ctx.actor->_moveAngle);
+		engine->_movements->initRealAngleConst(ctx.actor->_beta, newAngle, ctx.actor->_speed, &ctx.actor->realAngle);
 	}
 
 	if (engine->_movements->_targetActorDistance > 500) {
@@ -298,8 +298,8 @@ int32 ScriptMove::mGOTO_POINT_3D(TwinEEngine *engine, MoveScriptContext &ctx) {
 	engine->_scene->_currentScriptValue = trackId;
 
 	const IVec3 &sp = engine->_scene->_sceneTracks[engine->_scene->_currentScriptValue];
-	ctx.actor->_beta = engine->_movements->getAngleAndSetTargetActorDistance(ctx.actor->_pos.x, ctx.actor->_pos.z, sp.x, sp.z);
-	ctx.actor->_spriteActorRotation = engine->_movements->getAngleAndSetTargetActorDistance(ctx.actor->_pos.y, 0, sp.y, engine->_movements->_targetActorDistance);
+	ctx.actor->_beta = engine->_movements->getAngle(ctx.actor->_pos.x, ctx.actor->_pos.z, sp.x, sp.z);
+	ctx.actor->_spriteActorRotation = engine->_movements->getAngle(ctx.actor->_pos.y, 0, sp.y, engine->_movements->_targetActorDistance);
 
 	if (engine->_movements->_targetActorDistance > 100) {
 		ctx.undo(1);
@@ -319,7 +319,7 @@ int32 ScriptMove::mSPEED(TwinEEngine *engine, MoveScriptContext &ctx) {
 	debugC(3, kDebugLevels::kDebugScripts, "MOVE::SPEED(%i)", (int)ctx.actor->_speed);
 
 	if (ctx.actor->_staticFlags.bIsSpriteActor) {
-		engine->_movements->setActorAngle(LBAAngles::ANGLE_0, ctx.actor->_speed, LBAAngles::ANGLE_17, &ctx.actor->_moveAngle);
+		engine->_movements->setActorAngle(LBAAngles::ANGLE_0, ctx.actor->_speed, LBAAngles::ANGLE_17, &ctx.actor->realAngle);
 	}
 
 	return 0;
@@ -412,7 +412,7 @@ int32 ScriptMove::mOPEN_GENERIC(TwinEEngine *engine, MoveScriptContext &ctx, int
 		ctx.actor->_doorWidth = doorStatus;
 		ctx.actor->_dynamicFlags.bIsSpriteMoving = 1;
 		ctx.actor->_speed = 1000;
-		engine->_movements->setActorAngle(LBAAngles::ANGLE_0, LBAAngles::ANGLE_351, LBAAngles::ANGLE_17, &ctx.actor->_moveAngle);
+		engine->_movements->setActorAngle(LBAAngles::ANGLE_0, LBAAngles::ANGLE_351, LBAAngles::ANGLE_17, &ctx.actor->realAngle);
 	}
 	if (engine->_scene->_currentSceneIdx == LBA1SceneId::Proxima_Island_Museum && ctx.actor->_actorIdx == 16) {
 		engine->unlockAchievement("LBA_ACH_009");
@@ -464,7 +464,7 @@ int32 ScriptMove::mCLOSE(TwinEEngine *engine, MoveScriptContext &ctx) {
 		ctx.actor->_doorWidth = 0;
 		ctx.actor->_dynamicFlags.bIsSpriteMoving = 1;
 		ctx.actor->_speed = -1000;
-		engine->_movements->setActorAngle(LBAAngles::ANGLE_0, -LBAAngles::ANGLE_351, LBAAngles::ANGLE_17, &ctx.actor->_moveAngle);
+		engine->_movements->setActorAngle(LBAAngles::ANGLE_0, -LBAAngles::ANGLE_351, LBAAngles::ANGLE_17, &ctx.actor->realAngle);
 	}
 	return 0;
 }
@@ -577,9 +577,9 @@ int32 ScriptMove::mFACE_HERO(TwinEEngine *engine, MoveScriptContext &ctx) {
 		return 0;
 	}
 	engine->_scene->_currentScriptValue = angle;
-	if (engine->_scene->_currentScriptValue == -1 && ctx.actor->_moveAngle.timeValue == 0) {
-		engine->_scene->_currentScriptValue = engine->_movements->getAngleAndSetTargetActorDistance(ctx.actor->posObj(), engine->_scene->_sceneHero->posObj());
-		engine->_movements->initRealAngleConst(ctx.actor->_beta, engine->_scene->_currentScriptValue, ctx.actor->_speed, &ctx.actor->_moveAngle);
+	if (engine->_scene->_currentScriptValue == -1 && ctx.actor->realAngle.timeValue == 0) {
+		engine->_scene->_currentScriptValue = engine->_movements->getAngle(ctx.actor->posObj(), engine->_scene->_sceneHero->posObj());
+		engine->_movements->initRealAngleConst(ctx.actor->_beta, engine->_scene->_currentScriptValue, ctx.actor->_speed, &ctx.actor->realAngle);
 		ctx.stream.rewind(2);
 		ctx.stream.writeSint16LE(engine->_scene->_currentScriptValue);
 	}
@@ -608,7 +608,7 @@ int32 ScriptMove::mANGLE_RND(TwinEEngine *engine, MoveScriptContext &ctx) {
 
 	engine->_scene->_currentScriptValue = val2;
 
-	if (engine->_scene->_currentScriptValue == -1 && ctx.actor->_moveAngle.timeValue == 0) {
+	if (engine->_scene->_currentScriptValue == -1 && ctx.actor->realAngle.timeValue == 0) {
 		if (engine->getRandomNumber() & 1) {
 			const int32 newAngle = ctx.actor->_beta + LBAAngles::ANGLE_90 + (ABS(val1) >> 1);
 			engine->_scene->_currentScriptValue = ClampAngle(newAngle - engine->getRandomNumber(val1));
@@ -617,7 +617,7 @@ int32 ScriptMove::mANGLE_RND(TwinEEngine *engine, MoveScriptContext &ctx) {
 			engine->_scene->_currentScriptValue = ClampAngle(newAngle - engine->getRandomNumber(val1));
 		}
 
-		engine->_movements->initRealAngleConst(ctx.actor->_beta, engine->_scene->_currentScriptValue, ctx.actor->_speed, &ctx.actor->_moveAngle);
+		engine->_movements->initRealAngleConst(ctx.actor->_beta, engine->_scene->_currentScriptValue, ctx.actor->_speed, &ctx.actor->realAngle);
 		ctx.stream.rewind(2);
 		ctx.stream.writeSint16LE(engine->_scene->_currentScriptValue);
 	}
diff --git a/engines/twine/twine.cpp b/engines/twine/twine.cpp
index 5a11fde68be..83a0bb6a23e 100644
--- a/engines/twine/twine.cpp
+++ b/engines/twine/twine.cpp
@@ -763,8 +763,8 @@ void TwinEEngine::processInventoryAction() {
 			penguin->_genBody = BodyType::btNone;
 			_actor->initBody(BodyType::btNormal, _scene->_mecaPenguinIdx);
 			penguin->_dynamicFlags.bIsDead = 0;
-			penguin->setBrickShape(ShapeType::kNone);
-			_movements->initRealAngleConst(penguin->_beta, penguin->_beta, penguin->_speed, &penguin->_moveAngle);
+			penguin->setCollision(ShapeType::kNone);
+			_movements->initRealAngleConst(penguin->_beta, penguin->_beta, penguin->_speed, &penguin->realAngle);
 			_gameState->removeItem(InventoryItems::kiPenguin);
 			penguin->_delayInMillis = timerRef + toSeconds(30);
 		}


Commit: c53ce8923ac8793acf8bf636b87a605eed20db9b
    https://github.com/scummvm/scummvm/commit/c53ce8923ac8793acf8bf636b87a605eed20db9b
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2023-01-21T18:10:02+01:00

Commit Message:
TWINE: more renaming

Changed paths:
    engines/twine/debugger/debug_grid.cpp
    engines/twine/scene/actor.cpp
    engines/twine/scene/actor.h
    engines/twine/scene/animations.cpp
    engines/twine/scene/collision.cpp
    engines/twine/scene/grid.cpp
    engines/twine/scene/grid.h
    engines/twine/scene/movements.cpp
    engines/twine/scene/scene.cpp
    engines/twine/scene/scene.h
    engines/twine/script/script_life.cpp
    engines/twine/script/script_move.cpp
    engines/twine/shared.h


diff --git a/engines/twine/debugger/debug_grid.cpp b/engines/twine/debugger/debug_grid.cpp
index 8f0de45c9af..58390c5c6ef 100644
--- a/engines/twine/debugger/debug_grid.cpp
+++ b/engines/twine/debugger/debug_grid.cpp
@@ -110,7 +110,7 @@ void DebugGrid::applyCellingGrid() {
 			_engine->_scene->_needChangeScene = SCENE_CEILING_GRID_FADE_2; // tricky to make the fade
 		} else if (grid->_useCellingGrid == 1) {
 			grid->_useCellingGrid = -1;
-			grid->createGridMap();
+			grid->copyMapToCube();
 			_engine->_redraw->_firstTime = true;
 			debug("Disable Celling Grid index: %d", grid->_cellingGridIdx);
 			_engine->_scene->_needChangeScene = SCENE_CEILING_GRID_FADE_2; // tricky to make the fade
diff --git a/engines/twine/scene/actor.cpp b/engines/twine/scene/actor.cpp
index a06d6e208f6..1f3a49b5b55 100644
--- a/engines/twine/scene/actor.cpp
+++ b/engines/twine/scene/actor.cpp
@@ -126,9 +126,9 @@ void Actor::setBehaviour(HeroBehaviourType behaviour) {
 	initBody(bodyIdx, OWN_ACTOR_SCENE_INDEX);
 
 	sceneHero->_genAnim = AnimationTypes::kAnimNone;
-	sceneHero->_flagAnim = AnimType::kAnimationTypeLoop;
+	sceneHero->_flagAnim = AnimType::kAnimationTypeRepeat;
 
-	_engine->_animations->initAnim(AnimationTypes::kStanding, AnimType::kAnimationTypeLoop, AnimationTypes::kAnimInvalid, OWN_ACTOR_SCENE_INDEX);
+	_engine->_animations->initAnim(AnimationTypes::kStanding, AnimType::kAnimationTypeRepeat, AnimationTypes::kAnimInvalid, OWN_ACTOR_SCENE_INDEX);
 }
 
 void Actor::initSpriteActor(int32 actorIdx) {
@@ -248,10 +248,10 @@ void Actor::initActor(int16 actorIdx) {
 		initBody(actor->_genBody, actorIdx);
 
 		actor->_anim = -1;
-		actor->_flagAnim = AnimType::kAnimationTypeLoop;
+		actor->_flagAnim = AnimType::kAnimationTypeRepeat;
 
 		if (actor->_body != -1) {
-			_engine->_animations->initAnim(actor->_genAnim, AnimType::kAnimationTypeLoop, AnimationTypes::kAnimInvalid, actorIdx);
+			_engine->_animations->initAnim(actor->_genAnim, AnimType::kAnimationTypeRepeat, AnimationTypes::kAnimInvalid, actorIdx);
 		}
 
 		_engine->_movements->initRealAngle(actor->_beta, actor->_beta, LBAAngles::ANGLE_0, &actor->realAngle);
diff --git a/engines/twine/scene/actor.h b/engines/twine/scene/actor.h
index d4d06a8ddaa..e60bac539d6 100644
--- a/engines/twine/scene/actor.h
+++ b/engines/twine/scene/actor.h
@@ -222,7 +222,7 @@ public:
 	int32 _anim = -1;
 	int32 _doorWidth = 0;
 	int32 _frame = 0;
-	AnimType _flagAnim = AnimType::kAnimationTypeLoop;
+	AnimType _flagAnim = AnimType::kAnimationTypeRepeat;
 	int32 _spriteActorRotation = 0;
 	uint8 _brickSound = 0U; // CodeJeu
 
diff --git a/engines/twine/scene/animations.cpp b/engines/twine/scene/animations.cpp
index f68de79e7c6..2b3eaa825a9 100644
--- a/engines/twine/scene/animations.cpp
+++ b/engines/twine/scene/animations.cpp
@@ -602,7 +602,7 @@ void Animations::doAnim(int32 actorIdx) {
 				if (numKeyframe == (int16)animData.getNumKeyframes()) {
 					actor->_dynamicFlags.bIsHitting = 0;
 
-					if (actor->_flagAnim == AnimType::kAnimationTypeLoop) {
+					if (actor->_flagAnim == AnimType::kAnimationTypeRepeat) {
 						actor->_frame = animData.getLoopFrame();
 					} else {
 						actor->_genAnim = actor->_nextGenAnim;
@@ -615,7 +615,7 @@ void Animations::doAnim(int32 actorIdx) {
 
 						actor->_ptrAnimAction = _currentActorAnimExtraPtr;
 
-						actor->_flagAnim = AnimType::kAnimationTypeLoop;
+						actor->_flagAnim = AnimType::kAnimationTypeRepeat;
 						actor->_frame = 0;
 						actor->_strengthOfHit = 0;
 					}
@@ -779,10 +779,10 @@ void Animations::doAnim(int32 actorIdx) {
 							if (fallHeight <= (2 * SIZE_BRICK_Y) && actor->_genAnim == AnimationTypes::kForward) {
 								actor->_dynamicFlags.bWasWalkingBeforeFalling = 1;
 							} else {
-								initAnim(AnimationTypes::kFall, AnimType::kAnimationTypeLoop, AnimationTypes::kAnimInvalid, actorIdx);
+								initAnim(AnimationTypes::kFall, AnimType::kAnimationTypeRepeat, AnimationTypes::kAnimInvalid, actorIdx);
 							}
 						} else {
-							initAnim(AnimationTypes::kFall, AnimType::kAnimationTypeLoop, AnimationTypes::kAnimInvalid, actorIdx);
+							initAnim(AnimationTypes::kFall, AnimType::kAnimationTypeRepeat, AnimationTypes::kAnimInvalid, actorIdx);
 						}
 					}
 				}
diff --git a/engines/twine/scene/collision.cpp b/engines/twine/scene/collision.cpp
index f428919e8a3..75a68e3c5e4 100644
--- a/engines/twine/scene/collision.cpp
+++ b/engines/twine/scene/collision.cpp
@@ -427,9 +427,9 @@ void Collision::receptionObj(int actorIdx) {
 		} else {
 			if (_engine->_actor->_processActorPtr->_dynamicFlags.bWasWalkingBeforeFalling) {
 				// try to not interrupt walk animation if Twinsen falls down from small height
-				_engine->_animations->initAnim(AnimationTypes::kForward, AnimType::kAnimationTypeLoop, AnimationTypes::kStanding, actorIdx);
+				_engine->_animations->initAnim(AnimationTypes::kForward, AnimType::kAnimationTypeRepeat, AnimationTypes::kStanding, actorIdx);
 			} else {
-				_engine->_animations->initAnim(AnimationTypes::kStanding, AnimType::kAnimationTypeLoop, AnimationTypes::kStanding, actorIdx);
+				_engine->_animations->initAnim(AnimationTypes::kStanding, AnimType::kAnimationTypeRepeat, AnimationTypes::kStanding, actorIdx);
 			}
 		}
 
diff --git a/engines/twine/scene/grid.cpp b/engines/twine/scene/grid.cpp
index 7c3356bdc87..a6d3a08e7ba 100644
--- a/engines/twine/scene/grid.cpp
+++ b/engines/twine/scene/grid.cpp
@@ -336,7 +336,7 @@ void Grid::loadGridBricks() {
 	}
 }
 
-void Grid::createGridColumn(const uint8 *gridEntry, uint32 gridEntrySize, uint8 *dest, uint32 destSize) {
+void Grid::decompColumn(const uint8 *gridEntry, uint32 gridEntrySize, uint8 *dest, uint32 destSize) { // DecompColonne
 	Common::MemoryReadStream stream(gridEntry, gridEntrySize);
 	Common::MemoryWriteStream outstream(dest, destSize);
 	int32 brickCount = stream.readByte();
@@ -393,7 +393,7 @@ void Grid::createCellingGridColumn(const uint8 *gridEntry, uint32 gridEntrySize,
 	} while (--brickCount);
 }
 
-void Grid::createGridMap() {
+void Grid::copyMapToCube() {
 	int32 blockOffset = 0;
 
 	for (int32 z = 0; z < SIZE_CUBE_Z; z++) {
@@ -401,13 +401,13 @@ void Grid::createGridMap() {
 
 		for (int32 x = 0; x < SIZE_CUBE_X; x++) {
 			const int32 gridOffset = READ_LE_UINT16(_currentGrid + 2 * (x + gridIdx));
-			createGridColumn(_currentGrid + gridOffset, _currentGridSize - gridOffset, _bufCube + blockOffset, _blockBufferSize - blockOffset);
+			decompColumn(_currentGrid + gridOffset, _currentGridSize - gridOffset, _bufCube + blockOffset, _blockBufferSize - blockOffset);
 			blockOffset += 2 * SIZE_CUBE_Y;
 		}
 	}
 }
 
-void Grid::createCellingGridMap(const uint8 *gridPtr, int32 gridPtrSize) {
+void Grid::createCellingGridMap(const uint8 *gridPtr, int32 gridPtrSize) { // MixteMapToCube
 	int32 currGridOffset = 0;
 	int32 blockOffset = 0;
 
@@ -442,12 +442,12 @@ bool Grid::initGrid(int32 index) {
 
 	createGridMask();
 
-	createGridMap();
+	copyMapToCube();
 
 	return true;
 }
 
-bool Grid::initCellingGrid(int32 index) {
+bool Grid::initCellingGrid(int32 index) { // IncrustGrm
 	uint8 *gridPtr = nullptr;
 
 	// load grids from file
diff --git a/engines/twine/scene/grid.h b/engines/twine/scene/grid.h
index 6600528fad4..5c86354088f 100644
--- a/engines/twine/scene/grid.h
+++ b/engines/twine/scene/grid.h
@@ -128,7 +128,7 @@ private:
 	 * @param gridEntry current grid index
 	 * @param dest destination block buffer
 	 */
-	void createGridColumn(const uint8 *gridEntry, uint32 gridEntrySize, uint8 *dest, uint32 destSize);
+	void decompColumn(const uint8 *gridEntry, uint32 gridEntrySize, uint8 *dest, uint32 destSize);
 	/**
 	 * Load grid bricks according with block librarie usage
 	 */
@@ -270,7 +270,7 @@ public:
 	const BlockDataEntry* getBlockPointer(int32 blockIdx, int32 tmpBrickIdx) const;
 
 	/** Create grid map from current grid to block library buffer */
-	void createGridMap();
+	void copyMapToCube();
 
 	/**
 	 * Initialize grid (background scenearios)
diff --git a/engines/twine/scene/movements.cpp b/engines/twine/scene/movements.cpp
index 26214740514..7fa76aa8e57 100644
--- a/engines/twine/scene/movements.cpp
+++ b/engines/twine/scene/movements.cpp
@@ -246,7 +246,7 @@ bool Movements::processBehaviourExecution(int actorIdx) {
 		}
 		break;
 	case HeroBehaviourType::kDiscrete:
-		_engine->_animations->initAnim(AnimationTypes::kHide, AnimType::kAnimationTypeLoop, AnimationTypes::kAnimInvalid, actorIdx);
+		_engine->_animations->initAnim(AnimationTypes::kHide, AnimType::kAnimationTypeRepeat, AnimationTypes::kAnimInvalid, actorIdx);
 		break;
 	case HeroBehaviourType::kProtoPack:
 		break;
@@ -294,25 +294,25 @@ void Movements::processManualMovementExecution(int actorIdx) {
 		// if walking should get stopped
 		if (!_engine->_input->isActionActive(TwinEActionType::MoveForward) && !_engine->_input->isActionActive(TwinEActionType::MoveBackward)) {
 			if (_lastJoyFlag && (_heroActionKey != _previousLoopActionKey || _changedCursorKeys != _previousChangedCursorKeys)) {
-				_engine->_animations->initAnim(AnimationTypes::kStanding, AnimType::kAnimationTypeLoop, AnimationTypes::kAnimInvalid, actorIdx);
+				_engine->_animations->initAnim(AnimationTypes::kStanding, AnimType::kAnimationTypeRepeat, AnimationTypes::kAnimInvalid, actorIdx);
 			}
 		}
 
 		_lastJoyFlag = false;
 
 		if (_engine->_input->isActionActive(TwinEActionType::MoveForward)) {
-			if (!_engine->_scene->_currentActorInZone) {
-				_engine->_animations->initAnim(AnimationTypes::kForward, AnimType::kAnimationTypeLoop, AnimationTypes::kAnimInvalid, actorIdx);
+			if (!_engine->_scene->_flagClimbing) {
+				_engine->_animations->initAnim(AnimationTypes::kForward, AnimType::kAnimationTypeRepeat, AnimationTypes::kAnimInvalid, actorIdx);
 			}
 			_lastJoyFlag = true;
 		} else if (_engine->_input->isActionActive(TwinEActionType::MoveBackward)) {
-			_engine->_animations->initAnim(AnimationTypes::kBackward, AnimType::kAnimationTypeLoop, AnimationTypes::kAnimInvalid, actorIdx);
+			_engine->_animations->initAnim(AnimationTypes::kBackward, AnimType::kAnimationTypeRepeat, AnimationTypes::kAnimInvalid, actorIdx);
 			_lastJoyFlag = true;
 		}
 
 		if (_engine->_input->isActionActive(TwinEActionType::TurnLeft)) {
 			if (actor->_genAnim == AnimationTypes::kStanding) {
-				_engine->_animations->initAnim(AnimationTypes::kTurnLeft, AnimType::kAnimationTypeLoop, AnimationTypes::kAnimInvalid, actorIdx);
+				_engine->_animations->initAnim(AnimationTypes::kTurnLeft, AnimType::kAnimationTypeRepeat, AnimationTypes::kAnimInvalid, actorIdx);
 			} else {
 				if (!actor->_dynamicFlags.bIsRotationByAnim) {
 					actor->_beta = actor->realAngle.getRealAngle(_engine->timerRef);
@@ -321,7 +321,7 @@ void Movements::processManualMovementExecution(int actorIdx) {
 			_lastJoyFlag = true;
 		} else if (_engine->_input->isActionActive(TwinEActionType::TurnRight)) {
 			if (actor->_genAnim == AnimationTypes::kStanding) {
-				_engine->_animations->initAnim(AnimationTypes::kTurnRight, AnimType::kAnimationTypeLoop, AnimationTypes::kAnimInvalid, actorIdx);
+				_engine->_animations->initAnim(AnimationTypes::kTurnRight, AnimType::kAnimationTypeRepeat, AnimationTypes::kAnimInvalid, actorIdx);
 			} else {
 				if (!actor->_dynamicFlags.bIsRotationByAnim) {
 					actor->_beta = actor->realAngle.getRealAngle(_engine->timerRef);
@@ -392,11 +392,11 @@ void Movements::processRandomAction(int actorIdx) {
 		const int32 angle = ClampAngle(actor->_beta + (_engine->getRandomNumber() & (LBAAngles::ANGLE_180 - 1)) - LBAAngles::ANGLE_90 + LBAAngles::ANGLE_180);
 		initRealAngleConst(actor->_beta, angle, actor->_speed, &actor->realAngle);
 		actor->_delayInMillis = _engine->getRandomNumber(300) + _engine->timerRef + 300;
-		_engine->_animations->initAnim(AnimationTypes::kStanding, AnimType::kAnimationTypeLoop, AnimationTypes::kAnimInvalid, actorIdx);
+		_engine->_animations->initAnim(AnimationTypes::kStanding, AnimType::kAnimationTypeRepeat, AnimationTypes::kAnimInvalid, actorIdx);
 	}
 
 	if (!actor->realAngle.timeValue) {
-		_engine->_animations->initAnim(AnimationTypes::kForward, AnimType::kAnimationTypeLoop, AnimationTypes::kAnimInvalid, actorIdx);
+		_engine->_animations->initAnim(AnimationTypes::kForward, AnimType::kAnimationTypeRepeat, AnimationTypes::kAnimInvalid, actorIdx);
 		if (_engine->timerRef > actor->_delayInMillis) {
 			const int32 angle = ClampAngle(actor->_beta + (_engine->getRandomNumber() & (LBAAngles::ANGLE_180 - 1)) - LBAAngles::ANGLE_90);
 			initRealAngleConst(actor->_beta, angle, actor->_speed, &actor->realAngle);
@@ -439,6 +439,7 @@ void Movements::doDir(int32 actorIdx) {
 	if (actor->_dynamicFlags.bIsFalling) {
 		if (actor->_controlMode == ControlMode::kManual) {
 			manualRealAngle(actor);
+			// TODO: _lastJoyFlag = _joyFlag;
 		}
 		return;
 	}
diff --git a/engines/twine/scene/scene.cpp b/engines/twine/scene/scene.cpp
index 323e197edca..ff1d30090c1 100644
--- a/engines/twine/scene/scene.cpp
+++ b/engines/twine/scene/scene.cpp
@@ -712,7 +712,7 @@ void Scene::checkZoneSce(int32 actorIdx) {
 	bool tmpCellingGrid = false;
 
 	if (IS_HERO(actorIdx)) {
-		_currentActorInZone = false;
+		_flagClimbing = false;
 	}
 
 	for (int32 z = 0; z < _sceneNumZones; z++) {
@@ -753,7 +753,7 @@ void Scene::checkZoneSce(int32 actorIdx) {
 					tmpCellingGrid = true;
 					if (_engine->_grid->_useCellingGrid != zone->num) {
 						if (zone->num != -1) {
-							_engine->_grid->createGridMap();
+							_engine->_grid->copyMapToCube();
 						}
 
 						_engine->_grid->_useCellingGrid = zone->num;
@@ -787,11 +787,11 @@ void Scene::checkZoneSce(int32 actorIdx) {
 
 					if (destPos.x >= 0 && destPos.z >= 0 && destPos.x <= SCENE_SIZE_MAX && destPos.z <= SCENE_SIZE_MAX) {
 						if (_engine->_grid->worldColBrick(destPos.x, actor->_pos.y + SIZE_BRICK_Y, destPos.z) != ShapeType::kNone) {
-							_currentActorInZone = true;
-							if (actor->_pos.y >= ABS(zone->mins.y + zone->maxs.y) / 2) {
+							_flagClimbing = true;
+							if (actor->_pos.y >= (zone->mins.y + zone->maxs.y) / 2) {
 								_engine->_animations->initAnim(AnimationTypes::kTopLadder, AnimType::kAnimationAllThen, AnimationTypes::kStanding, actorIdx); // reached end of ladder
 							} else {
-								_engine->_animations->initAnim(AnimationTypes::kClimbLadder, AnimType::kAnimationTypeLoop, AnimationTypes::kAnimInvalid, actorIdx); // go up in ladder
+								_engine->_animations->initAnim(AnimationTypes::kClimbLadder, AnimType::kAnimationTypeRepeat, AnimationTypes::kAnimInvalid, actorIdx); // go up in ladder
 							}
 						}
 					}
@@ -804,7 +804,7 @@ void Scene::checkZoneSce(int32 actorIdx) {
 	if (!tmpCellingGrid && actorIdx == _currentlyFollowedActor && _engine->_grid->_useCellingGrid != -1) {
 		_engine->_grid->_useCellingGrid = -1;
 		_engine->_grid->_cellingGridIdx = -1;
-		_engine->_grid->createGridMap();
+		_engine->_grid->copyMapToCube();
 		_engine->_redraw->_firstTime = true;
 	}
 }
diff --git a/engines/twine/scene/scene.h b/engines/twine/scene/scene.h
index 8d787b80eeb..f5fd72726bb 100644
--- a/engines/twine/scene/scene.h
+++ b/engines/twine/scene/scene.h
@@ -185,7 +185,7 @@ public:
 	/** Current followed actor in scene */
 	int16 _currentlyFollowedActor = OWN_ACTOR_SCENE_INDEX;
 	/** Current actor in zone - climbing a ladder */
-	bool _currentActorInZone = false;
+	bool _flagClimbing = false;
 	bool _enableEnhancements = false;
 	/** Current actor manipulated in scripts */
 	int16 _currentScriptValue = 0;
diff --git a/engines/twine/script/script_life.cpp b/engines/twine/script/script_life.cpp
index d988f135909..1f07e2d6f23 100644
--- a/engines/twine/script/script_life.cpp
+++ b/engines/twine/script/script_life.cpp
@@ -839,7 +839,7 @@ int32 ScriptLife::lBODY_OBJ(TwinEEngine *engine, LifeScriptContext &ctx) {
 int32 ScriptLife::lANIM(TwinEEngine *engine, LifeScriptContext &ctx) {
 	const AnimationTypes animIdx = (AnimationTypes)ctx.stream.readByte();
 	debugC(3, kDebugLevels::kDebugScripts, "LIFE::ANIM(%i)", (int)animIdx);
-	engine->_animations->initAnim(animIdx, AnimType::kAnimationTypeLoop, AnimationTypes::kStanding, ctx.actorIdx);
+	engine->_animations->initAnim(animIdx, AnimType::kAnimationTypeRepeat, AnimationTypes::kStanding, ctx.actorIdx);
 	return 0;
 }
 
@@ -851,7 +851,7 @@ int32 ScriptLife::lANIM_OBJ(TwinEEngine *engine, LifeScriptContext &ctx) {
 	const int32 otherActorIdx = ctx.stream.readByte();
 	const AnimationTypes otherAnimIdx = (AnimationTypes)ctx.stream.readByte();
 	debugC(3, kDebugLevels::kDebugScripts, "LIFE::ANIM_OBJ(%i, %i)", (int)otherActorIdx, (int)otherAnimIdx);
-	engine->_animations->initAnim(otherAnimIdx, AnimType::kAnimationTypeLoop, AnimationTypes::kStanding, otherActorIdx);
+	engine->_animations->initAnim(otherAnimIdx, AnimType::kAnimationTypeRepeat, AnimationTypes::kStanding, otherActorIdx);
 	return 0;
 }
 
@@ -919,7 +919,7 @@ int32 ScriptLife::lMESSAGE(TwinEEngine *engine, LifeScriptContext &ctx) {
 	// if we are in sporty mode, we might have triggered a jump with the special action binding
 	// see https://bugs.scummvm.org/ticket/13676 for more details.
 	if (ctx.actor->isJumpAnimationActive()) {
-		engine->_animations->initAnim(AnimationTypes::kStanding, AnimType::kAnimationTypeLoop, AnimationTypes::kAnimInvalid, OWN_ACTOR_SCENE_INDEX);
+		engine->_animations->initAnim(AnimationTypes::kStanding, AnimType::kAnimationTypeRepeat, AnimationTypes::kAnimInvalid, OWN_ACTOR_SCENE_INDEX);
 	}
 
 	engine->_text->drawTextProgressive(textIdx);
@@ -1005,7 +1005,7 @@ int32 ScriptLife::lSET_BEHAVIOUR(TwinEEngine *engine, LifeScriptContext &ctx) {
 	const HeroBehaviourType behavior = (HeroBehaviourType)ctx.stream.readByte();
 	debugC(3, kDebugLevels::kDebugScripts, "LIFE::SET_BEHAVIOUR(%i)", (int)behavior);
 
-	engine->_animations->initAnim(AnimationTypes::kStanding, AnimType::kAnimationTypeLoop, AnimationTypes::kAnimInvalid, OWN_ACTOR_SCENE_INDEX);
+	engine->_animations->initAnim(AnimationTypes::kStanding, AnimType::kAnimationTypeRepeat, AnimationTypes::kAnimInvalid, OWN_ACTOR_SCENE_INDEX);
 	engine->_actor->setBehaviour(behavior);
 
 	return 0;
@@ -1752,7 +1752,7 @@ int32 ScriptLife::lGRM_OFF(TwinEEngine *engine, LifeScriptContext &ctx) {
 	if (engine->_grid->_cellingGridIdx != -1) {
 		engine->_grid->_useCellingGrid = -1;
 		engine->_grid->_cellingGridIdx = -1;
-		engine->_grid->createGridMap();
+		engine->_grid->copyMapToCube();
 		engine->_redraw->redrawEngineActions(true);
 	}
 
@@ -1952,7 +1952,7 @@ int32 ScriptLife::lANIM_SET(TwinEEngine *engine, LifeScriptContext &ctx) {
 
 	ctx.actor->_genAnim = AnimationTypes::kAnimNone;
 	ctx.actor->_anim = -1;
-	engine->_animations->initAnim(animIdx, AnimType::kAnimationTypeLoop, AnimationTypes::kStanding, ctx.actorIdx);
+	engine->_animations->initAnim(animIdx, AnimType::kAnimationTypeRepeat, AnimationTypes::kStanding, ctx.actorIdx);
 
 	return 0;
 }
diff --git a/engines/twine/script/script_move.cpp b/engines/twine/script/script_move.cpp
index e9b5f716ea6..ac048bf16da 100644
--- a/engines/twine/script/script_move.cpp
+++ b/engines/twine/script/script_move.cpp
@@ -80,7 +80,7 @@ int32 ScriptMove::mBODY(TwinEEngine *engine, MoveScriptContext &ctx) {
 int32 ScriptMove::mANIM(TwinEEngine *engine, MoveScriptContext &ctx) {
 	AnimationTypes animIdx = (AnimationTypes)ctx.stream.readByte();
 	debugC(3, kDebugLevels::kDebugScripts, "MOVE::ANIM(%i)", (int)animIdx);
-	if (engine->_animations->initAnim(animIdx, AnimType::kAnimationTypeLoop, AnimationTypes::kStanding, ctx.actorIdx)) {
+	if (engine->_animations->initAnim(animIdx, AnimType::kAnimationTypeRepeat, AnimationTypes::kStanding, ctx.actorIdx)) {
 		return 0;
 	}
 	ctx.undo(1);
diff --git a/engines/twine/shared.h b/engines/twine/shared.h
index 8e50781391e..a4d3ace45ff 100644
--- a/engines/twine/shared.h
+++ b/engines/twine/shared.h
@@ -288,7 +288,7 @@ enum class AnimationTypes {
 };
 
 enum class AnimType {
-	kAnimationTypeLoop = 0,
+	kAnimationTypeRepeat = 0,
 	kAnimationThen = 1,
 	// play animation and let animExtra follow as next animation
 	// if there is already a next animation set - replace the value


Commit: 72b4bfb05298aa804408ce0971a6fe3338b909d7
    https://github.com/scummvm/scummvm/commit/72b4bfb05298aa804408ce0971a6fe3338b909d7
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2023-01-21T18:33:26+01:00

Commit Message:
TWINE: continue with renaming

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


diff --git a/engines/twine/holomap.cpp b/engines/twine/holomap.cpp
index fad80d18db9..7ece1e2eed7 100644
--- a/engines/twine/holomap.cpp
+++ b/engines/twine/holomap.cpp
@@ -51,9 +51,8 @@ namespace TwinE {
 #define HOLOMAP_UNK4		(1 << 3)
 #define HOLOMAP_UNK5		(1 << 4)
 #define HOLOMAP_UNK6		(1 << 5)
-#define HOLOMAP_UNK7		(1 << 6)
+#define HOLOMAP_CUBE_DONE	(1 << 6)
 #define HOLOMAP_CAN_FOCUS	(1 << 7)
-#define HOLOMAP_RESET		(HOLOMAP_VISITED | HOLOMAP_UNK3 | HOLOMAP_UNK4 | HOLOMAP_UNK5 | HOLOMAP_UNK6 | HOLOMAP_UNK7)
 #define HOLOMAP_ACTIVE		(HOLOMAP_CAN_FOCUS | HOLOMAP_ARROW)
 
 static const float ZOOM_BIG_HOLO = 9500.0f;
@@ -93,10 +92,10 @@ bool Holomap::loadLocations() {
 
 	_engine->_text->initDial(TextBankId::Inventory_Intro_and_Holomap);
 	for (int32 i = 0; i < _numLocations; i++) {
-		_locations[i].angleX = (int16)ClampAngle(stream.readSint16LE());
-		_locations[i].angleY = (int16)ClampAngle(stream.readSint16LE());
+		_locations[i].angleX = stream.readSint16LE();
+		_locations[i].angleY = stream.readSint16LE();
 		_locations[i].size = stream.readSint16LE();
-		_locations[i].textIndex = (TextId)stream.readUint16LE();
+		_locations[i].textIndex = (TextId)stream.readSint16LE();
 
 		if (_engine->_text->getMenuText(_locations[i].textIndex, _locations[i].name, sizeof(_locations[i].name))) {
 			debug(2, "Scene %i: %s", i, _locations[i].name);
@@ -107,7 +106,7 @@ bool Holomap::loadLocations() {
 	return true;
 }
 
-void Holomap::setHolomapPosition(int32 locationIdx) {
+void Holomap::setHolomapPosition(int32 locationIdx) { // SetHoloPos
 	assert(locationIdx >= 0 && locationIdx <= ARRAYSIZE(_engine->_gameState->_holomapFlags));
 	_engine->_gameState->_holomapFlags[locationIdx] = HOLOMAP_ACTIVE;
 	if (_engine->_gameState->hasItem(InventoryItems::kiHolomap)) {
@@ -115,10 +114,10 @@ void Holomap::setHolomapPosition(int32 locationIdx) {
 	}
 }
 
-void Holomap::clearHolomapPosition(int32 locationIdx) {
+void Holomap::clearHolomapPosition(int32 locationIdx) { // ClrHoloPos
 	assert(locationIdx >= 0 && locationIdx <= ARRAYSIZE(_engine->_gameState->_holomapFlags));
-	_engine->_gameState->_holomapFlags[locationIdx] &= HOLOMAP_RESET;
-	_engine->_gameState->_holomapFlags[locationIdx] |= HOLOMAP_UNK7;
+	_engine->_gameState->_holomapFlags[locationIdx] &= ~HOLOMAP_ACTIVE;
+	_engine->_gameState->_holomapFlags[locationIdx] |= HOLOMAP_CUBE_DONE;
 }
 
 void Holomap::initHoloDatas() {
@@ -439,7 +438,7 @@ int32 Holomap::searchNextArrow(int32 currentLocation, int32 dir) const {
 		} else {
 			i %= NUM_LOCATIONS;
 		}
-		if (i == _engine->_scene->_currentSceneIdx || (_engine->_gameState->_holomapFlags[i] & HOLOMAP_ACTIVE) != 0u) {
+		if ((_engine->_gameState->_holomapFlags[i] & HOLOMAP_ACTIVE) != 0u) {
 			return i;
 		}
 	}
@@ -472,9 +471,9 @@ void Holomap::drawListPos(int xRot, int yRot, int zRot, bool pos) {
 				continue;
 			}
 		}
-		uint8 flags = _engine->_gameState->_holomapFlags[locationIdx] & HOLOMAP_ARROW;
+		uint32 flags = _engine->_gameState->_holomapFlags[locationIdx] & HOLOMAP_ARROW;
 		if (locationIdx == _engine->_scene->_currentSceneIdx) {
-			flags |= 2u; // model type
+			flags |= HOLOMAP_VISITED; // model type
 		}
 		DrawListStruct &drawList = drawListArray[n];
 		drawList.posValue = destPos3.z;
@@ -488,13 +487,13 @@ void Holomap::drawListPos(int xRot, int yRot, int zRot, bool pos) {
 	_engine->_redraw->sortDrawingList(drawListArray, n);
 	for (int i = 0; i < n; ++i) {
 		const DrawListStruct &drawList = drawListArray[i];
-		const uint16 flags = drawList.type;
+		const uint32 flags = drawList.type;
 		const BodyData *bodyData = nullptr;
-		if (flags == 1u) {
+		if (flags == HOLOMAP_ARROW) {
 			bodyData = &_engine->_resources->_holomapArrowPtr;
-		} else if (flags == 2u) {
+		} else if (flags == HOLOMAP_VISITED) {
 			bodyData = &_engine->_resources->_holomapTwinsenModelPtr;
-		} else if (flags == 3u) {
+		} else if (flags == (HOLOMAP_ARROW | HOLOMAP_VISITED)) {
 			bodyData = &_engine->_resources->_holomapTwinsenArrowPtr;
 		}
 		if (bodyData != nullptr) {
diff --git a/engines/twine/renderer/renderer.cpp b/engines/twine/renderer/renderer.cpp
index 72f0afdd473..9a59ed313a9 100644
--- a/engines/twine/renderer/renderer.cpp
+++ b/engines/twine/renderer/renderer.cpp
@@ -296,7 +296,7 @@ bool isPolygonVisible(const ComputedVertex *vertices) { // TestVuePoly
 	return true;
 }
 
-void Renderer::applyPointsRotation(const Common::Array<BodyVertex> &vertices, int32 firstPoint, int32 numPoints, I16Vec3 *destPoints, const IMatrix3x3 *rotationMatrix, const IVec3 &destPos) {
+void Renderer::rotList(const Common::Array<BodyVertex> &vertices, int32 firstPoint, int32 numPoints, I16Vec3 *destPoints, const IMatrix3x3 *rotationMatrix, const IVec3 &destPos) {
 	for (int32 i = 0; i < numPoints; ++i) {
 		const BodyVertex &vertex = vertices[i + firstPoint];
 		destPoints->x = (int16)((rotationMatrix->row1.x * vertex.x + rotationMatrix->row1.y * vertex.y + rotationMatrix->row1.z * vertex.z) / SCENE_SIZE_HALF) + destPos.x;
@@ -332,7 +332,7 @@ void Renderer::processRotatedElement(IMatrix3x3 *targetMatrix, const Common::Arr
 		warning("RENDER WARNING: No points in this model!");
 	}
 
-	applyPointsRotation(vertices, firstPoint, numOfPoints, &modelData->computedPoints[firstPoint], targetMatrix, destPos);
+	rotList(vertices, firstPoint, numOfPoints, &modelData->computedPoints[firstPoint], targetMatrix, destPos);
 }
 
 void Renderer::applyPointsTranslation(const Common::Array<BodyVertex> &vertices, int32 firstPoint, int32 numPoints, I16Vec3 *destPoints, const IMatrix3x3 *translationMatrix, const IVec3 &angleVec, const IVec3 &destPos) {
diff --git a/engines/twine/renderer/renderer.h b/engines/twine/renderer/renderer.h
index 8bf9dc00aab..44a10ff7c5f 100644
--- a/engines/twine/renderer/renderer.h
+++ b/engines/twine/renderer/renderer.h
@@ -160,7 +160,7 @@ private:
 		return longInverseRot(vec.x, vec.y, vec.z);
 	}
 	void rotMatIndex2(IMatrix3x3 *targetMatrix, const IMatrix3x3 *currentMatrix, const IVec3 &angleVec);
-	void applyPointsRotation(const Common::Array<BodyVertex>& vertices, int32 firstPoint, int32 numPoints, I16Vec3 *destPoints, const IMatrix3x3 *rotationMatrix, const IVec3 &destPos);
+	void rotList(const Common::Array<BodyVertex>& vertices, int32 firstPoint, int32 numPoints, I16Vec3 *destPoints, const IMatrix3x3 *rotationMatrix, const IVec3 &destPos);
 	void processRotatedElement(IMatrix3x3 *targetMatrix, const Common::Array<BodyVertex>& vertices, int32 rotX, int32 rotY, int32 rotZ, const BodyBone &bone, ModelData *modelData);
 	void applyPointsTranslation(const Common::Array<BodyVertex>& vertices, int32 firstPoint, int32 numPoints, I16Vec3 *destPoints, const IMatrix3x3 *translationMatrix, const IVec3 &angleVec, const IVec3 &destPos);
 	void processTranslatedElement(IMatrix3x3 *targetMatrix, const Common::Array<BodyVertex>& vertices, int32 rotX, int32 rotY, int32 rotZ, const BodyBone &bone, ModelData *modelData);
diff --git a/engines/twine/scene/scene.h b/engines/twine/scene/scene.h
index f5fd72726bb..55e97fc74e2 100644
--- a/engines/twine/scene/scene.h
+++ b/engines/twine/scene/scene.h
@@ -156,7 +156,7 @@ public:
 	~Scene();
 
 	int32 _needChangeScene = LBA1SceneId::Citadel_Island_Prison;
-	int32 _currentSceneIdx = LBA1SceneId::Citadel_Island_Prison;
+	int32 _currentSceneIdx = LBA1SceneId::Citadel_Island_Prison; // NumCube
 	int32 _previousSceneIdx = LBA1SceneId::Citadel_Island_Prison;
 
 	int32 _planet = -1;


Commit: de50ee3e4a4af97f37df2bcd6abd183933edab5e
    https://github.com/scummvm/scummvm/commit/de50ee3e4a4af97f37df2bcd6abd183933edab5e
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2023-01-21T21:29:40+01:00

Commit Message:
TWINE: removed vtop and vbottom from renderPolygons

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


diff --git a/engines/twine/renderer/renderer.cpp b/engines/twine/renderer/renderer.cpp
index 9a59ed313a9..2d101c694a9 100644
--- a/engines/twine/renderer/renderer.cpp
+++ b/engines/twine/renderer/renderer.cpp
@@ -380,10 +380,6 @@ void Renderer::setLightVector(int32 angleX, int32 angleY, int32 angleZ) {
 	_normalLight = rot(matrix, 0, 0, normalUnit - 5);
 }
 
-static FORCEINLINE int16 clamp(int16 x, int16 a, int16 b) {
-	return x < a ? a : (x > b ? b : x);
-}
-
 int16 Renderer::leftClip(int16 polyRenderType, ComputedVertex** offTabPoly, int32 numVertices) {
 	const Common::Rect &clip = _engine->_interface->_clip;
 	ComputedVertex *pTabPolyClip = offTabPoly[1];
@@ -624,36 +620,33 @@ int16 Renderer::bottomClip(int16 polyRenderType, ComputedVertex** offTabPoly, in
 	return newNbPoints;
 }
 
-int32 Renderer::computePolyMinMax(int16 polyRenderType, ComputedVertex **offTabPoly, int32 numVertices, int &vtop, int &vbottom) {
-	const Common::Rect &clip = _engine->_interface->_clip;
-	if (clip.isEmpty()) {
-		return numVertices;
-	}
+int32 Renderer::computePolyMinMax(int16 polyRenderType, ComputedVertex **offTabPoly, int32 numVertices, int16 &ymin, int16 &ymax) {
+	int16 xmin = SCENE_SIZE_MAX;
+	int16 xmax = SCENE_SIZE_MIN;
 
-	int32 minsx = SCENE_SIZE_MAX;
-	int32 maxsx = SCENE_SIZE_MIN;
-	int32 minsy = SCENE_SIZE_MAX;
-	int32 maxsy = SCENE_SIZE_MIN;
+	ymin = SCENE_SIZE_MAX;
+	ymax = SCENE_SIZE_MIN;
 
 	ComputedVertex* pTabPoly = offTabPoly[0];
 	for (int32 i = 0; i < numVertices; i++) {
-		if (pTabPoly[i].x < minsx) {
-			minsx = pTabPoly[i].x;
+		if (pTabPoly[i].x < xmin) {
+			xmin = pTabPoly[i].x;
 		}
-		if (pTabPoly[i].x > maxsx) {
-			maxsx = pTabPoly[i].x;
+		if (pTabPoly[i].x > xmax) {
+			xmax = pTabPoly[i].x;
 		}
-		if (pTabPoly[i].y < minsy) {
-			minsy = pTabPoly[i].y;
+		if (pTabPoly[i].y < ymin) {
+			ymin = pTabPoly[i].y;
 		}
-		if (pTabPoly[i].y > maxsy) {
-			maxsy = pTabPoly[i].y;
+		if (pTabPoly[i].y > ymax) {
+			ymax = pTabPoly[i].y;
 		}
 	}
 
+	const Common::Rect &clip = _engine->_interface->_clip;
 	// no vertices
-	if (minsy > maxsy || maxsx < clip.left || minsx > clip.right || maxsy < clip.top || minsy > clip.bottom) {
-		debug(10, "Clipped %i:%i:%i:%i, clip rect(%i:%i:%i:%i)", minsx, minsy, maxsx, maxsy, clip.left, clip.top, clip.right, clip.bottom);
+	if (ymin > ymax || xmax < clip.left || xmin > clip.right || ymax < clip.top || ymin > clip.bottom) {
+		debug(10, "Clipped %i:%i:%i:%i, clip rect(%i:%i:%i:%i)", xmin, ymin, xmax, ymax, clip.left, clip.top, clip.right, clip.bottom);
 		return 0;
 	}
 
@@ -662,7 +655,7 @@ int32 Renderer::computePolyMinMax(int16 polyRenderType, ComputedVertex **offTabP
 	bool hasBeenClipped = false;
 
 	int32 clippedNumVertices = numVertices;
-	if (minsx < clip.left) {
+	if (xmin < clip.left) {
 		clippedNumVertices = leftClip(polyRenderType, offTabPoly, clippedNumVertices);
 		if (!clippedNumVertices) {
 			return 0;
@@ -671,7 +664,7 @@ int32 Renderer::computePolyMinMax(int16 polyRenderType, ComputedVertex **offTabP
 		hasBeenClipped = true;
 	}
 
-	if (maxsx > clip.right) {
+	if (xmax > clip.right) {
 		clippedNumVertices = rightClip(polyRenderType, offTabPoly, clippedNumVertices);
 		if (!clippedNumVertices) {
 			return 0;
@@ -680,7 +673,7 @@ int32 Renderer::computePolyMinMax(int16 polyRenderType, ComputedVertex **offTabP
 		hasBeenClipped = true;
 	}
 
-	if (minsy < clip.top) {
+	if (ymin < clip.top) {
 		clippedNumVertices = topClip(polyRenderType, offTabPoly, clippedNumVertices);
 		if (!clippedNumVertices) {
 			return 0;
@@ -689,7 +682,7 @@ int32 Renderer::computePolyMinMax(int16 polyRenderType, ComputedVertex **offTabP
 		hasBeenClipped = true;
 	}
 
-	if (maxsy > clip.bottom) {
+	if (ymax > clip.bottom) {
 		clippedNumVertices = bottomClip(polyRenderType, offTabPoly, clippedNumVertices);
 		if (!clippedNumVertices) {
 			return 0;
@@ -699,31 +692,28 @@ int32 Renderer::computePolyMinMax(int16 polyRenderType, ComputedVertex **offTabP
 	}
 
 	if (hasBeenClipped) {
-		minsy = 32767;
-		maxsy = -32768;
+		ymin = 32767;
+		ymax = -32768;
 
 		for (int32 i = 0; i < clippedNumVertices; i++) {
-			if (offTabPoly[0][i].y < minsy) {
-				minsy = offTabPoly[0][i].y;
+			if (offTabPoly[0][i].y < ymin) {
+				ymin = offTabPoly[0][i].y;
 			}
 
-			if (offTabPoly[0][i].y > maxsy) {
-				maxsy = offTabPoly[0][i].y;
+			if (offTabPoly[0][i].y > ymax) {
+				ymax = offTabPoly[0][i].y;
 			}
 		}
 
-		if (minsy >= maxsy) {
+		if (ymin >= ymax) {
 			return 0;
 		}
 	}
 
-	vtop = minsy;
-	vbottom = maxsy;
-
 	return clippedNumVertices;
 }
 
-bool Renderer::computePoly(int16 polyRenderType, const ComputedVertex *vertices, int32 numVertices, int &vtop, int &vbottom) {
+bool Renderer::computePoly(int16 polyRenderType, const ComputedVertex *vertices, int32 numVertices, int16 &vtop, int16 &vbottom) {
 	assert(numVertices < ARRAYSIZE(_clippedPolygonVertices1));
 	for (int i = 0; i < numVertices; ++i) {
 		_clippedPolygonVertices1[i] = vertices[i];
@@ -1181,7 +1171,8 @@ void Renderer::svgaPolyTriche(int16 vtop, int16 Ymax, uint16 color) const {
 	}
 }
 
-void Renderer::renderPolygons(const CmdRenderPolygon &polygon, ComputedVertex *vertices, int vtop, int vbottom) {
+void Renderer::renderPolygons(const CmdRenderPolygon &polygon, ComputedVertex *vertices) {
+	int16 vtop, vbottom;
 	if (computePoly(polygon.renderType, vertices, polygon.numVertices, vtop, vbottom)) {
 		fillVertices(vtop, vbottom, polygon.renderType, polygon.colorIndex);
 	}
@@ -1385,8 +1376,6 @@ uint8 *Renderer::preparePolygons(const Common::Array<BodyPolygon> &polygons, int
 
 		CmdRenderPolygon *destinationPolygon = (CmdRenderPolygon *)(void*)renderBufferPtr;
 		destinationPolygon->numVertices = numVertices;
-		destinationPolygon->top = SCENE_SIZE_MAX;
-		destinationPolygon->bottom = SCENE_SIZE_MIN;
 
 		renderBufferPtr += sizeof(CmdRenderPolygon);
 
@@ -1396,7 +1385,7 @@ uint8 *Renderer::preparePolygons(const Common::Array<BodyPolygon> &polygons, int
 		ComputedVertex *vertex = vertices;
 
 		if (materialType >= MAT_GOURAUD) {
-			destinationPolygon->renderType = polygon.materialType - (MAT_GOURAUD - POLYGONTYPE_GOURAUD);
+			destinationPolygon->renderType = polygon.materialType - (MAT_GOURAUD - MAT_FLAT);
 			destinationPolygon->colorIndex = polygon.intensity;
 
 			for (int16 idx = 0; idx < numVertices; ++idx) {
@@ -1408,8 +1397,6 @@ uint8 *Renderer::preparePolygons(const Common::Array<BodyPolygon> &polygons, int
 				vertex->intensity = shadeValue;
 				vertex->x = point->x;
 				vertex->y = point->y;
-				destinationPolygon->top = MIN<int16>(destinationPolygon->top, vertex->y);
-				destinationPolygon->bottom = MAX<int16>(destinationPolygon->bottom, vertex->y);
 				zMax = MAX(zMax, point->z);
 				++vertex;
 			}
@@ -1433,8 +1420,6 @@ uint8 *Renderer::preparePolygons(const Common::Array<BodyPolygon> &polygons, int
 				vertex->intensity = destinationPolygon->colorIndex;
 				vertex->x = point->x;
 				vertex->y = point->y;
-				destinationPolygon->top = MIN<int16>(destinationPolygon->top, vertex->y);
-				destinationPolygon->bottom = MAX<int16>(destinationPolygon->bottom, vertex->y);
 				zMax = MAX<int16>(zMax, point->z);
 				++vertex;
 			}
@@ -1492,7 +1477,7 @@ bool Renderer::renderObjectIso(const BodyData &bodyData, RenderCommand **renderC
 		case RENDERTYPE_DRAWPOLYGON: {
 			const CmdRenderPolygon *header = (const CmdRenderPolygon *)(const void*)pointer;
 			ComputedVertex *vertices = (ComputedVertex *)(void*)(pointer + sizeof(CmdRenderPolygon));
-			renderPolygons(*header, vertices, header->top, header->bottom);
+			renderPolygons(*header, vertices);
 			break;
 		}
 		case RENDERTYPE_DRAWSPHERE: {
diff --git a/engines/twine/renderer/renderer.h b/engines/twine/renderer/renderer.h
index 44a10ff7c5f..e07f3954071 100644
--- a/engines/twine/renderer/renderer.h
+++ b/engines/twine/renderer/renderer.h
@@ -69,8 +69,6 @@ struct CmdRenderPolygon {
 	uint8 renderType = 0;
 	uint8 numVertices = 0;
 	int16 colorIndex = 0; // intensity
-	int16 top = 0;
-	int16 bottom = 0;
 	// followed by Vertex array
 };
 
@@ -208,7 +206,7 @@ private:
 	void svgaPolyDith(int16 vtop, int16 vbottom) const;
 	void svgaPolyMarbre(int16 vtop, int16 vbottom, uint16 color) const;
 	void svgaPolyTriche(int16 vtop, int16 vbottom, uint16 color) const;
-	bool computePoly(int16 polyRenderType, const ComputedVertex *vertices, int32 numVertices, int &vtop, int &vbottom);
+	bool computePoly(int16 polyRenderType, const ComputedVertex *vertices, int32 numVertices, int16 &vtop, int16 &vbottom);
 
 	const RenderCommand *depthSortRenderCommands(int32 numOfPrimitives);
 	uint8 *preparePolygons(const Common::Array<BodyPolygon>& polygons, int32 &numOfPrimitives, RenderCommand **renderCmds, uint8 *renderBufferPtr, ModelData *modelData);
@@ -225,7 +223,7 @@ private:
 	int16 rightClip(int16 polyRenderType, ComputedVertex** offTabPoly, int32 numVertices);
 	int16 topClip(int16 polyRenderType, ComputedVertex** offTabPoly, int32 numVertices);
 	int16 bottomClip(int16 polyRenderType, ComputedVertex** offTabPoly, int32 numVertices);
-	int32 computePolyMinMax(int16 polyRenderType, ComputedVertex **offTabPoly, int32 numVertices, int &vtop, int &vbottom);
+	int32 computePolyMinMax(int16 polyRenderType, ComputedVertex **offTabPoly, int32 numVertices, int16 &vtop, int16 &vbottom);
 public:
 	Renderer(TwinEEngine *engine);
 	~Renderer();
@@ -241,7 +239,7 @@ public:
 	IVec3 worldRotatePoint(const IVec3& vec);
 
 	void fillVertices(int16 vtop, int16 vbottom, uint8 renderType, uint16 color);
-	void renderPolygons(const CmdRenderPolygon &polygon, ComputedVertex *vertices, int vtop, int vbottom);
+	void renderPolygons(const CmdRenderPolygon &polygon, ComputedVertex *vertices);
 
 	inline IVec3 projectPoint(const IVec3& pos) { // ProjettePoint
 		return projectPoint(pos.x, pos.y, pos.z);
diff --git a/engines/twine/text.cpp b/engines/twine/text.cpp
index 25bc297ff68..6ec91ac80a1 100644
--- a/engines/twine/text.cpp
+++ b/engines/twine/text.cpp
@@ -458,7 +458,7 @@ void Text::processTextLine() {
 	_progressiveTextBufferPtr = _progressiveTextBuffer;
 }
 
-void Text::renderContinueReadingTriangle() {
+void Text::renderContinueReadingTriangle() { // AffFleche
 	const int32 border = 3;
 	const int32 size = 21;
 	const int16 color = 136;
@@ -485,7 +485,7 @@ void Text::renderContinueReadingTriangle() {
 	polygon.numVertices = ARRAYSIZE(vertices);
 	polygon.colorIndex = _dialTextStopColor;
 	polygon.renderType = POLYGONTYPE_FLAT;
-	_engine->_renderer->renderPolygons(polygon, vertices, top, bottom);
+	_engine->_renderer->renderPolygons(polygon, vertices);
 
 	_engine->copyBlockPhys(left, top, right, bottom);
 }
@@ -529,7 +529,7 @@ void Text::fadeInRemainingChars() {
 	--_fadeInCharactersPos;
 }
 
-ProgressiveTextState Text::updateProgressiveText() {
+ProgressiveTextState Text::updateProgressiveText() { // NextDialCar
 	if (!_hasValidTextHandle) {
 		return ProgressiveTextState::End;
 	}
@@ -672,7 +672,7 @@ void Text::setFontParameters(int32 spaceBetween, int32 charSpace) {
 	_dialCharSpace = charSpace;
 }
 
-void Text::setFontCrossColor(int32 color) {
+void Text::setFontCrossColor(int32 color) { // TestCoulDial
 	_dialTextStepSize = -1;
 	_dialTextBufferSize = 14;
 	_dialTextStartColor = color * 16;
@@ -683,7 +683,7 @@ void Text::setFontColor(int32 color) {
 	_dialTextColor = color;
 }
 
-void Text::setTextCrossColor(int32 stopColor, int32 startColor, int32 stepSize) {
+void Text::setTextCrossColor(int32 stopColor, int32 startColor, int32 stepSize) { // CoulDial
 	_dialTextStartColor = startColor;
 	_dialTextStopColor = stopColor;
 	_dialTextStepSize = stepSize;




More information about the Scummvm-git-logs mailing list