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

mgerhardy martin.gerhardy at gmail.com
Fri Nov 20 17:37:32 UTC 2020


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

Summary:
d6c879cbe7 TWINE: doxygen for scripts
b30a195e97 TWINE: introduced ClampAngle
699c8225c6 TWINE: replaced magic numbers with constants
6fefa0d9b5 TWINE: give_all_items enables the inventory


Commit: d6c879cbe72dcb7f7a440fe94e98093e0d2ab53f
    https://github.com/scummvm/scummvm/commit/d6c879cbe72dcb7f7a440fe94e98093e0d2ab53f
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-20T18:26:35+01:00

Commit Message:
TWINE: doxygen for scripts

http://moonbase.kazekr.net/index.php\?page\=d_dok

Changed paths:
    engines/twine/actor.h
    engines/twine/scene.h
    engines/twine/script_life_v1.cpp
    engines/twine/script_move_v1.cpp


diff --git a/engines/twine/actor.h b/engines/twine/actor.h
index 86d7730755..afe9bd8589 100644
--- a/engines/twine/actor.h
+++ b/engines/twine/actor.h
@@ -125,7 +125,11 @@ struct BonusParameter {
 	uint16 unused : 7;
 };
 
-/** Actors structure */
+/**
+ * Actors structure
+ *
+ * Such as characters, doors, moving plataforms, invisible actors, ...
+ */
 class ActorStruct {
 private:
 	ShapeType _brickShape = ShapeType::kNone; // field_3
diff --git a/engines/twine/scene.h b/engines/twine/scene.h
index 28d65c855d..30b4a9a0f3 100644
--- a/engines/twine/scene.h
+++ b/engines/twine/scene.h
@@ -51,6 +51,9 @@ struct ScenePoint {
 	int16 z = 0;
 };
 
+/**
+ * Special actions, like change scene, climbing a ladder, ...
+ */
 struct ZoneStruct {
 	ScenePoint bottomLeft;
 	ScenePoint topRight;
@@ -74,9 +77,11 @@ struct ZoneStruct {
 		struct {
 			int16 newGrid;
 		} CeillingGrid;
+
+		/** show a text (e.g. when reading a sign) */
 		struct {
-			int16 textIdx;
-			int16 textColor;
+			int16 textIdx;		/*!< text index in the current active text bank */
+			int16 textColor;	/*!< text color (see @c ActorStruct::talkColor) */
 		} DisplayText;
 		struct {
 			int16 info0;
@@ -335,7 +340,7 @@ public:
 
 	int16 talkingActor = 0;
 
-	// TRACKS
+	// TRACKS Tell the actor where to go
 
 	int32 sceneNumTracks = 0;
 	ScenePoint sceneTracks[NUM_MAX_TRACKS];
diff --git a/engines/twine/script_life_v1.cpp b/engines/twine/script_life_v1.cpp
index c315673fc4..99413b2aca 100644
--- a/engines/twine/script_life_v1.cpp
+++ b/engines/twine/script_life_v1.cpp
@@ -46,8 +46,9 @@
 
 namespace TwinE {
 
+// TODO: validate that lTEXTCLEAR is called before lTEXT - if that is the case
+// move this into the LifeScriptContext
 static int32 drawVar1;
-static char textStr[256]; // string
 
 struct LifeScriptContext {
 	int32 actorIdx;
@@ -70,10 +71,9 @@ struct LifeScriptContext {
 	}
 };
 
-/** Returns:
-	   -1 - Need implementation
-		0 - Completed
-		1 - Break script */
+/**
+ * Returns @c -1 Need implementation, @c 0 Condition false, @c 1 - Condition true
+ */
 typedef int32 ScriptLifeFunc(TwinEEngine *engine, LifeScriptContext &ctx);
 
 struct ScriptLifeFunction {
@@ -96,42 +96,41 @@ enum LifeScriptOperators {
 
 /** Script condition command opcodes */
 enum LifeScriptConditions {
-	/*0x00*/ kcCOL = 0,
-	/*0x01*/ kcCOL_OBJ = 1,
-	/*0x02*/ kcDISTANCE = 2,
-	/*0x03*/ kcZONE = 3,
-	/*0x04*/ kcZONE_OBJ = 4,
-	/*0x05*/ kcBODY = 5,
-	/*0x06*/ kcBODY_OBJ = 6,
-	/*0x07*/ kcANIM = 7,
-	/*0x08*/ kcANIM_OBJ = 8,
-	/*0x09*/ kcL_TRACK = 9,
-	/*0x0A*/ kcL_TRACK_OBJ = 10,
-	/*0x0B*/ kcFLAG_CUBE = 11,
-	/*0x0C*/ kcCONE_VIEW = 12,
-	/*0x0D*/ kcHIT_BY = 13,
-	/*0x0E*/ kcACTION = 14,
-	/*0x0F*/ kcFLAG_GAME = 15,
-	/*0x10*/ kcLIFE_POINT = 16,
-	/*0x11*/ kcLIFE_POINT_OBJ = 17,
-	/*0x12*/ kcNUM_LITTLE_KEYS = 18,
-	/*0x13*/ kcNUM_GOLD_PIECES = 19,
-	/*0x14*/ kcBEHAVIOUR = 20,
-	/*0x15*/ kcCHAPTER = 21,
-	/*0x16*/ kcDISTANCE_3D = 22,
+	/*0x00*/ kcCOL = 0,					/*<! Current actor collision with another actor. (Parameter = Actor Index) */
+	/*0x01*/ kcCOL_OBJ = 1,				/*<! Actor collision with the actor passed as parameter. (Parameter = Actor Index, Parameter = Actor Index) */
+	/*0x02*/ kcDISTANCE = 2,			/*<! Distance between the current actor and the actor passed as parameter. (Parameter = Actor Index, Parameter = Distance between) */
+	/*0x03*/ kcZONE = 3,				/*<! Current actor tread on zone passed as parameter. (Parameter = Zone Index) */
+	/*0x04*/ kcZONE_OBJ = 4,			/*<! The actor passed as parameter will tread on zone passed as parameter. (Parameter = Actor Index, Parameter = Zone Index) */
+	/*0x05*/ kcBODY = 5,				/*<! Body of the current actor. (Parameter = Body Index) */
+	/*0x06*/ kcBODY_OBJ = 6,			/*<! Body of the actor passed as parameter. (Parameter = Body Index) */
+	/*0x07*/ kcANIM = 7,				/*<! Body Animation of the current actor. (Parameter = Animation Index) */
+	/*0x08*/ kcANIM_OBJ = 8,			/*<! Body Animation of the actor passed as parameter. (Parameter = Animation Index) */
+	/*0x09*/ kcL_TRACK = 9,				/*<! Current actor track. (Parameter = Track Index) */
+	/*0x0A*/ kcL_TRACK_OBJ = 10,		/*<! Track of the actor passed as parameter. (Parameter = Track Index) */
+	/*0x0B*/ kcFLAG_CUBE = 11,			/*<! Game Cube Flags. (Parameter = Cube Flag Index, Parameter = 0 (not set), = 1 (set))k */
+	/*0x0C*/ kcCONE_VIEW = 12,			/*<! The actor passed as parameter have a "vision in circle". (Parameter = Actor Index, Parameter = Distance) */
+	/*0x0D*/ kcHIT_BY = 13,				/*<! Current actor hited by the actor passed as parameter. (Parameter = Actor Index) */
+	/*0x0E*/ kcACTION = 14,				/*<! Hero action behavior. (Parameter = Behaviour Index) */
+	/*0x0F*/ kcFLAG_GAME = 15,			/*<! Game Flags (See further list). (Parameter = Flag Index, Parameter = 0 (not set), = 1 (set)) */
+	/*0x10*/ kcLIFE_POINT = 16,			/*<! Current actor life points. (Parameter = Life points) */
+	/*0x11*/ kcLIFE_POINT_OBJ = 17,		/*<! Life points of the current actor passed as parameter. (Parameter = Life points) */
+	/*0x12*/ kcNUM_LITTLE_KEYS = 18,	/*<! Number of keys. (Parameter = Number of keys) */
+	/*0x13*/ kcNUM_GOLD_PIECES = 19,	/*<! Coins/Gold Amount. (Parameter = Coins/Gold amount) */
+	/*0x14*/ kcBEHAVIOUR = 20,			/*<! Hero behaviour. (Parameter = Behaviour Index) */
+	/*0x15*/ kcCHAPTER = 21,			/*<! Story Chapters. (Parameter = Chapter Index) */
+	/*0x16*/ kcDISTANCE_3D = 22,		/*<! Distance between the actor passed as parameter and the current actor. (Parameter = Actor Index, Parameter = Distance) */
 	/*0x17 - 23 unused */
 	/*0x18 - 24 unused */
-	/*0x19*/ kcUSE_INVENTORY = 25,
-	/*0x1A*/ kcCHOICE = 26,
-	/*0x1B*/ kcFUEL = 27,
-	/*0x1C*/ kcCARRIED_BY = 28,
-	/*0x1D*/ kcCDROM = 29
+	/*0x19*/ kcUSE_INVENTORY = 25,		/*<! Use inventory object. (Parameter = Object Index in the inventory, Paramenter = 0 (Not in Inventory), = 1 (In the Inventory)) */
+	/*0x1A*/ kcCHOICE = 26,				/*<! Menu choice. (Parameter = Text Index in the current Text Bank) */
+	/*0x1B*/ kcFUEL = 27,				/*<! Amount of fuel gas the Hero have in his inventory. (Parameter = Gas amount) */
+	/*0x1C*/ kcCARRIED_BY = 28,			/*<! The current is carried by the actor passed as paramenter. (Parameter = Actor Index) */
+	/*0x1D*/ kcCDROM = 29				/*<! CDROM audio tracks. (Parameter = Audio Tracks Index) */
 };
 
-/** Returns:
-	   -1 - Need implementation
-		1 - Condition value size (1 byte)
-		2 - Condition value size (2 byes) */
+/**
+ * Returns @c 1 Condition value size (1 byte), @c 2 Condition value size (2 byes)
+ */
 static int32 processLifeConditions(TwinEEngine *engine, LifeScriptContext &ctx) {
 	int32 conditionValueSize = 1;
 	int32 conditionOpcode = ctx.stream.readByte();
@@ -365,10 +364,9 @@ static int32 processLifeConditions(TwinEEngine *engine, LifeScriptContext &ctx)
 	return conditionValueSize;
 }
 
-/** Returns:
-	   -1 - Need implementation
-		0 - Condition false
-		1 - Condition true */
+/**
+ * Returns @c -1 Need implementation, @c 0 Condition false, @c 1 Condition true
+ */
 static int32 processLifeOperators(TwinEEngine *engine, LifeScriptContext &ctx, int32 valueSize) {
 	const int32 operatorCode = ctx.stream.readByte();
 
@@ -422,24 +420,35 @@ static int32 processLifeOperators(TwinEEngine *engine, LifeScriptContext &ctx, i
 
 /** Life script command definitions */
 
-/* For unused opcodes */
+/**
+ * For unused opcodes
+ */
 static int32 lEMPTY(TwinEEngine *engine, LifeScriptContext &ctx) {
 	return 0;
 }
 
-/*0x00*/
+/**
+ * End of Actor Life Script
+ * @note Opcode @c 0x00
+ */
 static int32 lEND(TwinEEngine *engine, LifeScriptContext &ctx) {
 	ctx.actor->positionInLifeScript = -1;
 	return 1; // break script
 }
 
-/*0x01*/
+/**
+ * No Operation
+ * @note Opcode @c 0x01
+ */
 static int32 lNOP(TwinEEngine *engine, LifeScriptContext &ctx) {
 	ctx.stream.skip(1);
 	return 0;
 }
 
-/*0x02*/
+/**
+ * To execute a switch no if. It's used to toggle the switch.
+ * @note Opcode @c 0x02
+ */
 static int32 lSNIF(TwinEEngine *engine, LifeScriptContext &ctx) {
 	const int32 valueSize = processLifeConditions(engine, ctx);
 	if (!processLifeOperators(engine, ctx, valueSize)) {
@@ -449,13 +458,19 @@ static int32 lSNIF(TwinEEngine *engine, LifeScriptContext &ctx) {
 	return 0;
 }
 
-/*0x03*/
+/**
+ * To jump to another offset in the current script. (Parameter = Offset)
+ * @note Opcode @c 0x03
+ */
 static int32 lOFFSET(TwinEEngine *engine, LifeScriptContext &ctx) {
 	ctx.stream.seek(ctx.stream.readSint16LE()); // offset
 	return 0;
 }
 
-/*0x04*/
+/**
+ * Will never execute that condition.
+ * @note Opcode @c 0x04
+ */
 static int32 lNEVERIF(TwinEEngine *engine, LifeScriptContext &ctx) {
 	int32 valueSize = processLifeConditions(engine, ctx);
 	processLifeOperators(engine, ctx, valueSize);
@@ -463,23 +478,35 @@ static int32 lNEVERIF(TwinEEngine *engine, LifeScriptContext &ctx) {
 	return 0;
 }
 
-/*0x06*/
+/**
+ * Will not execute the condition.
+ * @note Opcode @c 0x06
+ */
 static int32 lNO_IF(TwinEEngine *engine, LifeScriptContext &ctx) {
 	return 0;
 }
 
-/*0x0A*/
+/**
+ * Specify a new label
+ * @note Opcode @c 0x0A
+ */
 static int32 lLABEL(TwinEEngine *engine, LifeScriptContext &ctx) {
-	ctx.stream.skip(1); // label id
+	ctx.stream.skip(1); // label id - script offset
 	return 0;
 }
 
-/*0x0B*/
+/**
+ * To stop running the current script
+ * @note Opcode @c 0x0B
+ */
 static int32 lRETURN(TwinEEngine *engine, LifeScriptContext &ctx) {
 	return 1; // break script
 }
 
-/*0x0C*/
+/**
+ * Do a certain statement according the condition.
+ * @note Opcode @c 0x0C
+ */
 static int32 lIF(TwinEEngine *engine, LifeScriptContext &ctx) {
 	int32 valueSize = processLifeConditions(engine, ctx);
 	if (!processLifeOperators(engine, ctx, valueSize)) {
@@ -491,7 +518,10 @@ static int32 lIF(TwinEEngine *engine, LifeScriptContext &ctx) {
 	return 0;
 }
 
-/*0x0D*/
+/**
+ * To execute a switch if.
+ * @note Opcode @c 0x0D
+ */
 static int32 lSWIF(TwinEEngine *engine, LifeScriptContext &ctx) {
 	int32 valueSize = processLifeConditions(engine, ctx);
 	if (!processLifeOperators(engine, ctx, valueSize)) {
@@ -504,7 +534,10 @@ static int32 lSWIF(TwinEEngine *engine, LifeScriptContext &ctx) {
 	return 0;
 }
 
-/*0x0E*/
+/**
+ * Will only execute that condition one time.
+ * @note Opcode @c 0x0E
+ */
 static int32 lONEIF(TwinEEngine *engine, LifeScriptContext &ctx) {
 	int32 valueSize = processLifeConditions(engine, ctx);
 	if (!processLifeOperators(engine, ctx, valueSize)) {
@@ -517,20 +550,29 @@ static int32 lONEIF(TwinEEngine *engine, LifeScriptContext &ctx) {
 	return 0;
 }
 
-/*0x0F*/
+/**
+ * Else statement for an IF condition.
+ * @note Opcode @c 0x0F
+ */
 static int32 lELSE(TwinEEngine *engine, LifeScriptContext &ctx) {
 	ctx.stream.seek(ctx.stream.readSint16LE()); // offset
 	return 0;
 }
 
-/*0x11*/
+/**
+ * Choose new body for the current actor (Parameter = File3D Body Instance)
+ * @note Opcode @c 0x11
+ */
 static int32 lBODY(TwinEEngine *engine, LifeScriptContext &ctx) {
 	int32 bodyIdx = ctx.stream.readByte();
 	engine->_actor->initModelActor(bodyIdx, ctx.actorIdx);
 	return 0;
 }
 
-/*0x12*/
+/**
+ * Choose new body for the actor passed as parameter (Parameter = Actor Index, Parameter = File3D Body Instance)
+ * @note Opcode @c 0x12
+ */
 static int32 lBODY_OBJ(TwinEEngine *engine, LifeScriptContext &ctx) {
 	int32 otherActorIdx = ctx.stream.readByte();
 	int32 otherBodyIdx = ctx.stream.readByte();
@@ -538,14 +580,20 @@ static int32 lBODY_OBJ(TwinEEngine *engine, LifeScriptContext &ctx) {
 	return 0;
 }
 
-/*0x13*/
+/**
+ * Choose new animation for the current actor (Parameter = File3D Animation Instance)
+ * @note Opcode @c 0x13
+ */
 static int32 lANIM(TwinEEngine *engine, LifeScriptContext &ctx) {
 	AnimationTypes animIdx = (AnimationTypes)ctx.stream.readByte();
 	engine->_animations->initAnim(animIdx, 0, AnimationTypes::kStanding, ctx.actorIdx);
 	return 0;
 }
 
-/*0x14*/
+/**
+ * Choose new animation for the actor passed as parameter (Parameter = Actor Index, Parameter = File3D Animation Instance)
+ * @note Opcode @c 0x14
+ */
 static int32 lANIM_OBJ(TwinEEngine *engine, LifeScriptContext &ctx) {
 	int32 otherActorIdx = ctx.stream.readByte();
 	AnimationTypes otherAnimIdx = (AnimationTypes)ctx.stream.readByte();
@@ -553,33 +601,48 @@ static int32 lANIM_OBJ(TwinEEngine *engine, LifeScriptContext &ctx) {
 	return 0;
 }
 
-/*0x15*/
+/**
+ * Same as SET_COMPORTAMENT
+ * @note Opcode @c 0x15
+ */
 static int32 lSET_LIFE(TwinEEngine *engine, LifeScriptContext &ctx) {
 	ctx.actor->positionInLifeScript = ctx.stream.readSint16LE(); // offset
 	return 0;
 }
 
-/*0x16*/
+/**
+ * Same as SET_COMPORTAMENT_OBJ
+ * @note Opcode @c 0x16
+ */
 static int32 lSET_LIFE_OBJ(TwinEEngine *engine, LifeScriptContext &ctx) {
 	int32 otherActorIdx = ctx.stream.readByte();
 	engine->_scene->getActor(otherActorIdx)->positionInLifeScript = ctx.stream.readSint16LE(); // offset
 	return 0;
 }
 
-/*0x17*/
+/**
+ * Set a new track for the current actor. (Parameter = Track offset)
+ * @note Opcode @c 0x17
+ */
 static int32 lSET_TRACK(TwinEEngine *engine, LifeScriptContext &ctx) {
 	ctx.actor->positionInMoveScript = ctx.stream.readSint16LE(); // offset
 	return 0;
 }
 
-/*0x18*/
+/**
+ * Set a new track for tha actor passed as parameter (Parameter = Actor Index, Parameter = Track offset)
+ * @note Opcode @c 0x18
+ */
 static int32 lSET_TRACK_OBJ(TwinEEngine *engine, LifeScriptContext &ctx) {
 	int32 otherActorIdx = ctx.stream.readByte();
 	engine->_scene->getActor(otherActorIdx)->positionInMoveScript = ctx.stream.readSint16LE(); // offset
 	return 0;
 }
 
-/*0x19*/
+/**
+ * Choose a message to display. (Parameter = Text Index in the current Text Bank)
+ * @note Opcode @c 0x19
+ */
 static int32 lMESSAGE(TwinEEngine *engine, LifeScriptContext &ctx) {
 	const int32 textIdx = ctx.stream.readSint16LE();
 
@@ -596,14 +659,20 @@ static int32 lMESSAGE(TwinEEngine *engine, LifeScriptContext &ctx) {
 	return 0;
 }
 
-/*0x1A*/
+/**
+ * To set the current actor static flag fallable. (Parameter = value & 1)
+ * @note Opcode @c 0x1A
+ */
 static int32 lFALLABLE(TwinEEngine *engine, LifeScriptContext &ctx) {
 	const int32 flag = ctx.stream.readByte();
 	ctx.actor->staticFlags.bCanFall = flag & 1;
 	return 0;
 }
 
-/*0x1B*/
+/**
+ * To set direction for current actor.
+ * @note Opcode @c 0x1B
+ */
 static int32 lSET_DIRMODE(TwinEEngine *engine, LifeScriptContext &ctx) {
 	const int32 controlMode = ctx.stream.readByte();
 
@@ -615,7 +684,10 @@ static int32 lSET_DIRMODE(TwinEEngine *engine, LifeScriptContext &ctx) {
 	return 0;
 }
 
-/*0x1C*/
+/**
+ * To set direction
+ * @note Opcode @c 0x1C
+ */
 static int32 lSET_DIRMODE_OBJ(TwinEEngine *engine, LifeScriptContext &ctx) {
 	const int32 otherActorIdx = ctx.stream.readByte();
 	const int32 controlMode = ctx.stream.readByte();
@@ -629,7 +701,10 @@ static int32 lSET_DIRMODE_OBJ(TwinEEngine *engine, LifeScriptContext &ctx) {
 	return 0;
 }
 
-/*0x1D*/
+/**
+ * Camara follow the actor (Parameter = Actor to Follow)
+ * @note Opcode @c 0x1D
+ */
 static int32 lCAM_FOLLOW(TwinEEngine *engine, LifeScriptContext &ctx) {
 	const int32 followedActorIdx = ctx.stream.readByte();
 
@@ -646,7 +721,10 @@ static int32 lCAM_FOLLOW(TwinEEngine *engine, LifeScriptContext &ctx) {
 	return 0;
 }
 
-/*0x1E*/
+/**
+ * Set a new behavior for Twinsen (Paramenter = Behavior Index)
+ * @note Opcode @c 0x1E
+ */
 static int32 lSET_BEHAVIOUR(TwinEEngine *engine, LifeScriptContext &ctx) {
 	const HeroBehaviourType behavior = (HeroBehaviourType)ctx.stream.readByte();
 
@@ -656,7 +734,10 @@ static int32 lSET_BEHAVIOUR(TwinEEngine *engine, LifeScriptContext &ctx) {
 	return 0;
 }
 
-/*0x1F*/
+/**
+ * Set a new value for the cube flag (Paramter = Cube Flag Index, Parameter = Value)
+ * @note Opcode @c 0x1F
+ */
 static int32 lSET_FLAG_CUBE(TwinEEngine *engine, LifeScriptContext &ctx) {
 	const int32 flagIdx = ctx.stream.readByte();
 	const int32 flagValue = ctx.stream.readByte();
@@ -666,31 +747,46 @@ static int32 lSET_FLAG_CUBE(TwinEEngine *engine, LifeScriptContext &ctx) {
 	return 0;
 }
 
-/*0x20*/
+/**
+ * Set a new behaviour for the current actor. (Paramter = Comportament number)
+ * @note Opcode @c 0x20
+ */
 static int32 lCOMPORTEMENT(TwinEEngine *engine, LifeScriptContext &ctx) {
 	ctx.stream.skip(1);
 	return 0;
 }
 
-/*0x21*/
+/**
+ * Set a new comportament for the current actor. (Parameter = Comportament Offset)
+ * @note Opcode @c 0x21
+ */
 static int32 lSET_COMPORTEMENT(TwinEEngine *engine, LifeScriptContext &ctx) {
 	ctx.actor->positionInLifeScript = ctx.stream.readSint16LE();
 	return 0;
 }
 
-/*0x22*/
+/**
+ * Set a new comportament for the actor passed as parameter. (Paramter = Actor Index, Parameter = Comportament Offset)
+ * @note Opcode @c 0x22
+ */
 static int32 lSET_COMPORTEMENT_OBJ(TwinEEngine *engine, LifeScriptContext &ctx) {
 	const int32 otherActorIdx = ctx.stream.readByte();
 	engine->_scene->getActor(otherActorIdx)->positionInLifeScript = ctx.stream.readSint16LE();
 	return 0;
 }
 
-/*0x23*/
+/**
+ * End of comportament.
+ * @note Opcode @c 0x23
+ */
 static int32 lEND_COMPORTEMENT(TwinEEngine *engine, LifeScriptContext &ctx) {
 	return 1; // break
 }
 
-/*0x24*/
+/**
+ * Set a new value for the game flag (Paramter = Game Flag Index, Parameter = Value)
+ * @note Opcode @c 0x24
+ */
 static int32 lSET_FLAG_GAME(TwinEEngine *engine, LifeScriptContext &ctx) {
 	const int32 flagIdx = ctx.stream.readByte();
 	const int32 flagValue = ctx.stream.readByte();
@@ -700,7 +796,10 @@ static int32 lSET_FLAG_GAME(TwinEEngine *engine, LifeScriptContext &ctx) {
 	return 0;
 }
 
-/*0x25*/
+/**
+ * Kill the actor passed as paramenter (Parameter = Actor Index)
+ * @note Opcode @c 0x25
+ */
 static int32 lKILL_OBJ(TwinEEngine *engine, LifeScriptContext &ctx) {
 	const int32 otherActorIdx = ctx.stream.readByte();
 
@@ -714,7 +813,10 @@ static int32 lKILL_OBJ(TwinEEngine *engine, LifeScriptContext &ctx) {
 	return 0;
 }
 
-/*0x26*/
+/**
+ * Kill the current actor
+ * @note Opcode @c 0x26
+ */
 static int32 lSUICIDE(TwinEEngine *engine, LifeScriptContext &ctx) {
 	engine->_actor->processActorCarrier(ctx.actorIdx);
 	ctx.actor->dynamicFlags.bIsDead = 1;
@@ -725,7 +827,10 @@ static int32 lSUICIDE(TwinEEngine *engine, LifeScriptContext &ctx) {
 	return 0;
 }
 
-/*0x27*/
+/**
+ * Use one key collected in the behaviors menu.
+ * @note Opcode @c 0x27
+ */
 static int32 lUSE_ONE_LITTLE_KEY(TwinEEngine *engine, LifeScriptContext &ctx) {
 	engine->_gameState->inventoryNumKeys--;
 
@@ -738,7 +843,10 @@ static int32 lUSE_ONE_LITTLE_KEY(TwinEEngine *engine, LifeScriptContext &ctx) {
 	return 0;
 }
 
-/*0x28*/
+/**
+ * To give money. (Paramenter = Amount)
+ * @note Opcode @c 0x28
+ */
 static int32 lGIVE_GOLD_PIECES(TwinEEngine *engine, LifeScriptContext &ctx) {
 	int16 oldNumKashes = engine->_gameState->inventoryNumKashes;
 	bool hideRange = false;
@@ -769,26 +877,38 @@ static int32 lGIVE_GOLD_PIECES(TwinEEngine *engine, LifeScriptContext &ctx) {
 	return 0;
 }
 
-/*0x29*/
+/**
+ * The game will not play the current actor script anymore
+ * @note Opcode @c 0x29
+ */
 static int32 lEND_LIFE(TwinEEngine *engine, LifeScriptContext &ctx) {
 	ctx.actor->positionInLifeScript = -1;
 	return 1; // break;
 }
 
-/*0x2A*/
+/**
+ * The current actor will stop doing the track.
+ * @note Opcode @c 0x2A
+ */
 static int32 lSTOP_L_TRACK(TwinEEngine *engine, LifeScriptContext &ctx) {
 	ctx.actor->pausedTrackPtr = ctx.actor->currentLabelPtr;
 	ctx.actor->positionInMoveScript = -1;
 	return 0;
 }
 
-/*0x2B*/
+/**
+ * The current actor will resume the tracked started before.
+ * @note Opcode @c 0x2B
+ */
 static int32 lRESTORE_L_TRACK(TwinEEngine *engine, LifeScriptContext &ctx) {
 	ctx.actor->positionInMoveScript = ctx.actor->pausedTrackPtr;
 	return 0;
 }
 
-/*0x2C*/
+/**
+ * The actor passed as parameter will say that massage (Parameter = Actor Index, Parameter = Text Index in the current Text Bank)
+ * @note Opcode @c 0x2C
+ */
 static int32 lMESSAGE_OBJ(TwinEEngine *engine, LifeScriptContext &ctx) {
 	const int32 otherActorIdx = ctx.stream.readByte();
 	const int32 textIdx = ctx.stream.readSint16LE();
@@ -806,13 +926,19 @@ static int32 lMESSAGE_OBJ(TwinEEngine *engine, LifeScriptContext &ctx) {
 	return 0;
 }
 
-/*0x2D*/
+/**
+ * To increment the current chapter value
+ * @note Opcode @c 0x2D
+ */
 static int32 lINC_CHAPTER(TwinEEngine *engine, LifeScriptContext &ctx) {
 	engine->_gameState->gameChapter++;
 	return 0;
 }
 
-/*0x2E*/
+/**
+ * Found an object. (Parameter = Object Index)
+ * @note Opcode @c 0x2E
+ */
 static int32 lFOUND_OBJECT(TwinEEngine *engine, LifeScriptContext &ctx) {
 	const int32 item = ctx.stream.readByte();
 
@@ -824,7 +950,10 @@ static int32 lFOUND_OBJECT(TwinEEngine *engine, LifeScriptContext &ctx) {
 	return 0;
 }
 
-/*0x2F*/
+/**
+ * Set a new value to open the door (left way) (Parameter = distance to open).
+ * @note Opcode @c 0x2F
+ */
 static int32 lSET_DOOR_LEFT(TwinEEngine *engine, LifeScriptContext &ctx) {
 	int32 distance = ctx.stream.readSint16LE();
 
@@ -836,7 +965,10 @@ static int32 lSET_DOOR_LEFT(TwinEEngine *engine, LifeScriptContext &ctx) {
 	return 0;
 }
 
-/*0x30*/
+/**
+ * Set a new value to open the door (right way) (Parameter = distance to open).
+ * @note Opcode @c 0x30
+ */
 static int32 lSET_DOOR_RIGHT(TwinEEngine *engine, LifeScriptContext &ctx) {
 	int32 distance = ctx.stream.readSint16LE();
 
@@ -848,7 +980,10 @@ static int32 lSET_DOOR_RIGHT(TwinEEngine *engine, LifeScriptContext &ctx) {
 	return 0;
 }
 
-/*0x31*/
+/**
+ * Set a new value to open the door (up way) (Parameter = distance to open).
+ * @note Opcode @c 0x31
+ */
 static int32 lSET_DOOR_UP(TwinEEngine *engine, LifeScriptContext &ctx) {
 	int32 distance = ctx.stream.readSint16LE();
 
@@ -860,7 +995,10 @@ static int32 lSET_DOOR_UP(TwinEEngine *engine, LifeScriptContext &ctx) {
 	return 0;
 }
 
-/*0x32*/
+/**
+ * Set a new value to open the door (down way) (Parameter = distance to open).
+ * @note Opcode @c 0x32
+ */
 static int32 lSET_DOOR_DOWN(TwinEEngine *engine, LifeScriptContext &ctx) {
 	int32 distance = ctx.stream.readSint16LE();
 
@@ -872,7 +1010,10 @@ static int32 lSET_DOOR_DOWN(TwinEEngine *engine, LifeScriptContext &ctx) {
 	return 0;
 }
 
-/*0x33*/
+/**
+ * Give actor bonus. (Parameter = 0 (Don't change the actor bonus), > 0 (Change to another bonus))
+ * @note Opcode @c 0x33
+ */
 static int32 lGIVE_BONUS(TwinEEngine *engine, LifeScriptContext &ctx) {
 	int32 flag = ctx.stream.readByte();
 
@@ -887,7 +1028,10 @@ static int32 lGIVE_BONUS(TwinEEngine *engine, LifeScriptContext &ctx) {
 	return 0;
 }
 
-/*0x34*/
+/**
+ * Change to another room. (Parameter = Scene Index)
+ * @note Opcode @c 0x34
+ */
 static int32 lCHANGE_CUBE(TwinEEngine *engine, LifeScriptContext &ctx) {
 	int32 sceneIdx = ctx.stream.readByte();
 	engine->_scene->needChangeScene = sceneIdx;
@@ -895,7 +1039,10 @@ static int32 lCHANGE_CUBE(TwinEEngine *engine, LifeScriptContext &ctx) {
 	return 0;
 }
 
-/*0x35*/
+/**
+ * To set the current actor to collid with objects. (Parameter = 1(True) = other values(False))
+ * @note Opcode @c 0x35
+ */
 static int32 lOBJ_COL(TwinEEngine *engine, LifeScriptContext &ctx) {
 	int32 collision = ctx.stream.readByte();
 	if (collision != 0) {
@@ -906,7 +1053,10 @@ static int32 lOBJ_COL(TwinEEngine *engine, LifeScriptContext &ctx) {
 	return 0;
 }
 
-/*0x36*/
+/**
+ * To set the current actor to collid with bricks. (Parameter = 1(True), = 2(True and the actor is dead), = other values(False))
+ * @note Opcode @c 0x36
+ */
 static int32 lBRICK_COL(TwinEEngine *engine, LifeScriptContext &ctx) {
 	int32 collision = ctx.stream.readByte();
 
@@ -922,7 +1072,10 @@ static int32 lBRICK_COL(TwinEEngine *engine, LifeScriptContext &ctx) {
 	return 0;
 }
 
-/*0x37*/
+/**
+ * To use various conditions for the same IF statement. (Use above an IF condition)
+ * @note Opcode @c 0x37
+ */
 static int32 lOR_IF(TwinEEngine *engine, LifeScriptContext &ctx) {
 	int32 valueSize = processLifeConditions(engine, ctx);
 	if (processLifeOperators(engine, ctx, valueSize)) {
@@ -934,13 +1087,19 @@ static int32 lOR_IF(TwinEEngine *engine, LifeScriptContext &ctx) {
 	return 0;
 }
 
-/*0x38*/
+/**
+ * Put an actor invisible (Parameter = 1(True), = 0(False))
+ * @note Opcode @c 0x38
+ */
 static int32 lINVISIBLE(TwinEEngine *engine, LifeScriptContext &ctx) {
 	ctx.actor->staticFlags.bIsHidden = ctx.stream.readByte();
 	return 0;
 }
 
-/*0x39*/
+/**
+ * Camara zoom in and zoom out. (Parameter = 1(in) = 0(out))
+ * @note Opcode @c 0x39
+ */
 static int32 lZOOM(TwinEEngine *engine, LifeScriptContext &ctx) {
 	engine->zoomScreen = ctx.stream.readByte();
 
@@ -960,7 +1119,10 @@ static int32 lZOOM(TwinEEngine *engine, LifeScriptContext &ctx) {
 	return 0;
 }
 
-/*0x3A*/
+/**
+ * Set new postion for the current actor (Parameter = Track Index)
+ * @note Opcode @c 0x3A
+ */
 static int32 lPOS_POINT(TwinEEngine *engine, LifeScriptContext &ctx) {
 	int32 trackIdx = ctx.stream.readByte();
 
@@ -976,14 +1138,20 @@ static int32 lPOS_POINT(TwinEEngine *engine, LifeScriptContext &ctx) {
 	return 0;
 }
 
-/*0x3B*/
+/**
+ * To set the magic level. (Paramater = Magic Level)
+ * @note Opcode @c 0x3B
+ */
 static int32 lSET_MAGIC_LEVEL(TwinEEngine *engine, LifeScriptContext &ctx) {
 	engine->_gameState->magicLevelIdx = ctx.stream.readByte();
 	engine->_gameState->inventoryMagicPoints = engine->_gameState->magicLevelIdx * 20;
 	return 0;
 }
 
-/*0x3C*/
+/**
+ * Substract the magic points. (Parameter = Points Value)
+ * @note Opcode @c 0x3C
+ */
 static int32 lSUB_MAGIC_POINT(TwinEEngine *engine, LifeScriptContext &ctx) {
 	engine->_gameState->inventoryMagicPoints = ctx.stream.readByte();
 	if (engine->_gameState->inventoryMagicPoints < 0) {
@@ -992,7 +1160,10 @@ static int32 lSUB_MAGIC_POINT(TwinEEngine *engine, LifeScriptContext &ctx) {
 	return 0;
 }
 
-/*0x3D*/
+/**
+ * Set new a life point. (Parameter = Actor Index, Parameter = Points Value)
+ * @note Opcode @c 0x3D
+ */
 static int32 lSET_LIFE_POINT_OBJ(TwinEEngine *engine, LifeScriptContext &ctx) {
 	int32 otherActorIdx = ctx.stream.readByte();
 	static int32 lifeValue = ctx.stream.readByte();
@@ -1002,7 +1173,10 @@ static int32 lSET_LIFE_POINT_OBJ(TwinEEngine *engine, LifeScriptContext &ctx) {
 	return 0;
 }
 
-/*0x3E*/
+/**
+ * Substract the life points. (Parameter = Actor Index, Parameter = Points Value)
+ * @note Opcode @c 0x3E
+ */
 static int32 lSUB_LIFE_POINT_OBJ(TwinEEngine *engine, LifeScriptContext &ctx) {
 	int32 otherActorIdx = ctx.stream.readByte();
 	static int32 lifeValue = ctx.stream.readByte();
@@ -1017,7 +1191,10 @@ static int32 lSUB_LIFE_POINT_OBJ(TwinEEngine *engine, LifeScriptContext &ctx) {
 	return 0;
 }
 
-/*0x3F*/
+/**
+ * Hit an actor. (Parameter = Actor Index)
+ * @note Opcode @c 0x3F
+ */
 static int32 lHIT_OBJ(TwinEEngine *engine, LifeScriptContext &ctx) {
 	int32 otherActorIdx = ctx.stream.readByte();
 	int32 strengthOfHit = ctx.stream.readByte();
@@ -1025,7 +1202,10 @@ static int32 lHIT_OBJ(TwinEEngine *engine, LifeScriptContext &ctx) {
 	return 0;
 }
 
-/*0x40*/
+/**
+ * Play FLA cutscenes (Parameter = Cutscene Name)
+ * @note Opcode @c 0x40
+ */
 static int32 lPLAY_FLA(TwinEEngine *engine, LifeScriptContext &ctx) {
 	int strIdx = 0;
 	char movie[64];
@@ -1048,14 +1228,20 @@ static int32 lPLAY_FLA(TwinEEngine *engine, LifeScriptContext &ctx) {
 	return 0;
 }
 
-/*0x41*/
+/**
+ * Play Midis (Parameter = Midis Index)
+ * @note Opcode @c 0x41
+ */
 static int32 lPLAY_MIDI(TwinEEngine *engine, LifeScriptContext &ctx) {
 	int32 midiIdx = ctx.stream.readByte();
 	engine->_music->playMidiMusic(midiIdx); // TODO: improve this
 	return 0;
 }
 
-/*0x42*/
+/**
+ * To increment the clover box current value.
+ * @note Opcode @c 0x42
+ */
 static int32 lINC_CLOVER_BOX(TwinEEngine *engine, LifeScriptContext &ctx) {
 	if (engine->_gameState->inventoryNumLeafsBox < 10) {
 		engine->_gameState->inventoryNumLeafsBox++;
@@ -1063,7 +1249,10 @@ static int32 lINC_CLOVER_BOX(TwinEEngine *engine, LifeScriptContext &ctx) {
 	return 0;
 }
 
-/*0x43*/
+/**
+ * To set an inventory object as used (Parameter = Object Index)
+ * @note Opcode @c 0x43
+ */
 static int32 lSET_USED_INVENTORY(TwinEEngine *engine, LifeScriptContext &ctx) {
 	int32 item = ctx.stream.readByte();
 	if (item < InventoryItems::kKeypad) { // TODO: this looks wrong - why only up to keypad?
@@ -1072,14 +1261,20 @@ static int32 lSET_USED_INVENTORY(TwinEEngine *engine, LifeScriptContext &ctx) {
 	return 0;
 }
 
-/*0x44*/
+/**
+ * Add an option for the asked choice . (Parameter = Text Index in the current Text Bank)
+ * @note Opcode @c 0x44
+ */
 static int32 lADD_CHOICE(TwinEEngine *engine, LifeScriptContext &ctx) {
 	int32 choiceIdx = ctx.stream.readSint16LE();
 	engine->_gameState->gameChoices[engine->_gameState->numChoices++] = choiceIdx;
 	return 0;
 }
 
-/*0x45*/
+/**
+ * The current actor will ask something (parameter) with choices to choose. (Parameter = Text Index in the current Text Bank)
+ * @note Opcode @c 0x45
+ */
 static int32 lASK_CHOICE(TwinEEngine *engine, LifeScriptContext &ctx) {
 	int32 choiceIdx = ctx.stream.readSint16LE();
 
@@ -1096,7 +1291,10 @@ static int32 lASK_CHOICE(TwinEEngine *engine, LifeScriptContext &ctx) {
 	return 0;
 }
 
-/*0x46*/
+/**
+ * Show text in full screen. (Parameter = Text Index in the current Text Bank)
+ * @note Opcode @c 0x46
+ */
 static int32 lBIG_MESSAGE(TwinEEngine *engine, LifeScriptContext &ctx) {
 	int32 textIdx = ctx.stream.readSint16LE();
 
@@ -1115,7 +1313,10 @@ static int32 lBIG_MESSAGE(TwinEEngine *engine, LifeScriptContext &ctx) {
 	return 0;
 }
 
-/*0x47*/
+/**
+ * To initiate the hidden meca-pingouin in the current scene. (Parameter = Actor Index)
+ * @note Opcode @c 0x47
+ */
 static int32 lINIT_PINGOUIN(TwinEEngine *engine, LifeScriptContext &ctx) {
 	int32 pingouinActor = ctx.stream.readByte();
 	engine->_scene->mecaPinguinIdx = pingouinActor;
@@ -1126,7 +1327,10 @@ static int32 lINIT_PINGOUIN(TwinEEngine *engine, LifeScriptContext &ctx) {
 	return 0;
 }
 
-/*0x48*/
+/**
+ * To set an holomap position. (Parameter = Holomap/Scene Index)
+ * @note Opcode @c 0x48
+ */
 static int32 lSET_HOLO_POS(TwinEEngine *engine, LifeScriptContext &ctx) {
 	static int32 location = ctx.stream.readByte();
 	engine->_holomap->setHolomapPosition(location);
@@ -1137,14 +1341,20 @@ static int32 lSET_HOLO_POS(TwinEEngine *engine, LifeScriptContext &ctx) {
 	return 0;
 }
 
-/*0x49*/
+/**
+ * To clear an holomap position. (Parameter = Holomap/Scene Index)
+ * @note Opcode @c 0x49
+ */
 static int32 lCLR_HOLO_POS(TwinEEngine *engine, LifeScriptContext &ctx) {
 	static int32 location = ctx.stream.readByte();
 	engine->_holomap->clearHolomapPosition(location);
 	return 0;
 }
 
-/*0x4A*/
+/**
+ * Add to the current fuel value the passed parameter. (Parameter = Fuel Amount)
+ * @note Opcode @c 0x4A
+ */
 static int32 lADD_FUEL(TwinEEngine *engine, LifeScriptContext &ctx) {
 	engine->_gameState->inventoryNumGas += ctx.stream.readByte();
 	if (engine->_gameState->inventoryNumGas > 100) {
@@ -1153,7 +1363,10 @@ static int32 lADD_FUEL(TwinEEngine *engine, LifeScriptContext &ctx) {
 	return 0;
 }
 
-/*0x4B*/
+/**
+ * Substract the to fuel value the value passed as parameter. (Parameter = Fuel Amount)
+ * @note Opcode @c 0x4B
+ */
 static int32 lSUB_FUEL(TwinEEngine *engine, LifeScriptContext &ctx) {
 	engine->_gameState->inventoryNumGas -= ctx.stream.readByte();
 	if (engine->_gameState->inventoryNumGas < 0) {
@@ -1162,14 +1375,20 @@ static int32 lSUB_FUEL(TwinEEngine *engine, LifeScriptContext &ctx) {
 	return 0;
 }
 
-/*0x4C*/
+/**
+ * To set a GRID disappearing ceiling piece (Parameter = Disappearing ceiling piece Index)
+ * @note Opcode @c 0x4C
+ */
 static int32 lSET_GRM(TwinEEngine *engine, LifeScriptContext &ctx) {
 	engine->_grid->cellingGridIdx = ctx.stream.readByte();
 	engine->_grid->initCellingGrid(engine->_grid->cellingGridIdx);
 	return 0;
 }
 
-/*0x4D*/
+/**
+ * The current actor will say the message passed as paramenter. (Parameter = Actor Index)
+ * @note Opcode @c 0x4D
+ */
 static int32 lSAY_MESSAGE(TwinEEngine *engine, LifeScriptContext &ctx) {
 	int16 textEntry = ctx.stream.readSint16LE();
 
@@ -1181,7 +1400,10 @@ static int32 lSAY_MESSAGE(TwinEEngine *engine, LifeScriptContext &ctx) {
 	return 0;
 }
 
-/*04E*/
+/**
+ * The actor passed as parameter will say the message passed as paramenter. (Parameter = Actor Index, Parameter = Text Index in the current Text Bank)
+ * @note Opcode @c 0x4E
+ */
 static int32 lSAY_MESSAGE_OBJ(TwinEEngine *engine, LifeScriptContext &ctx) {
 	int32 otherActorIdx = ctx.stream.readByte();
 	int16 textEntry = ctx.stream.readSint16LE();
@@ -1194,14 +1416,20 @@ static int32 lSAY_MESSAGE_OBJ(TwinEEngine *engine, LifeScriptContext &ctx) {
 	return 0;
 }
 
-/*0x4F*/
+/**
+ * Set Twinsen life point as full.
+ * @note Opcode @c 0x4F
+ */
 static int32 lFULL_POINT(TwinEEngine *engine, LifeScriptContext &ctx) {
 	engine->_scene->sceneHero->life = 50;
 	engine->_gameState->inventoryMagicPoints = engine->_gameState->magicLevelIdx * 20;
 	return 0;
 }
 
-/*0x50*/
+/**
+ * Change actor orientation. (Parameter = New Angle)
+ * @note Opcode @c 0x50
+ */
 static int32 lBETA(TwinEEngine *engine, LifeScriptContext &ctx) {
 	int32 newAngle = ctx.stream.readSint16LE();
 	ctx.actor->angle = newAngle;
@@ -1209,7 +1437,10 @@ static int32 lBETA(TwinEEngine *engine, LifeScriptContext &ctx) {
 	return 0;
 }
 
-/*0x51*/
+/**
+ * To unset the GRID disappearing ceiling piece.
+ * @note Opcode @c 0x51
+ */
 static int32 lGRM_OFF(TwinEEngine *engine, LifeScriptContext &ctx) {
 	if (engine->_grid->cellingGridIdx != -1) {
 		engine->_grid->useCellingGrid = -1;
@@ -1221,7 +1452,10 @@ static int32 lGRM_OFF(TwinEEngine *engine, LifeScriptContext &ctx) {
 	return 0;
 }
 
-/*0x52*/
+/**
+ * Fade palette to red
+ * @note Opcode @c 0x52
+ */
 static int32 lFADE_PAL_RED(TwinEEngine *engine, LifeScriptContext &ctx) {
 	ScopedEngineFreeze scoped(engine);
 	engine->_screens->fadePalRed(engine->_screens->mainPaletteRGBA);
@@ -1229,7 +1463,10 @@ static int32 lFADE_PAL_RED(TwinEEngine *engine, LifeScriptContext &ctx) {
 	return 0;
 }
 
-/*0x53*/
+/**
+ * Fade alarm to red
+ * @note Opcode @c 0x53
+ */
 static int32 lFADE_ALARM_RED(TwinEEngine *engine, LifeScriptContext &ctx) {
 	ScopedEngineFreeze scoped(engine);
 	HQR::getEntry(engine->_screens->palette, Resources::HQR_RESS_FILE, RESSHQR_ALARMREDPAL);
@@ -1239,7 +1476,10 @@ static int32 lFADE_ALARM_RED(TwinEEngine *engine, LifeScriptContext &ctx) {
 	return 0;
 }
 
-/*0x54*/
+/**
+ * Fade alarm to palette
+ * @note Opcode @c 0x54
+ */
 static int32 lFADE_ALARM_PAL(TwinEEngine *engine, LifeScriptContext &ctx) {
 	ScopedEngineFreeze scoped(engine);
 	HQR::getEntry(engine->_screens->palette, Resources::HQR_RESS_FILE, RESSHQR_ALARMREDPAL);
@@ -1249,7 +1489,10 @@ static int32 lFADE_ALARM_PAL(TwinEEngine *engine, LifeScriptContext &ctx) {
 	return 0;
 }
 
-/*0x55*/
+/**
+ * Fade red to palette
+ * @note Opcode @c 0x55
+ */
 static int32 lFADE_RED_PAL(TwinEEngine *engine, LifeScriptContext &ctx) {
 	ScopedEngineFreeze scoped(engine);
 	engine->_screens->fadeRedPal(engine->_screens->mainPaletteRGBA);
@@ -1257,7 +1500,10 @@ static int32 lFADE_RED_PAL(TwinEEngine *engine, LifeScriptContext &ctx) {
 	return 0;
 }
 
-/*0x56*/
+/**
+ * Fade red to alarm
+ * @note Opcode @c 0x56
+ */
 static int32 lFADE_RED_ALARM(TwinEEngine *engine, LifeScriptContext &ctx) {
 	ScopedEngineFreeze scoped(engine);
 	HQR::getEntry(engine->_screens->palette, Resources::HQR_RESS_FILE, RESSHQR_ALARMREDPAL);
@@ -1267,7 +1513,10 @@ static int32 lFADE_RED_ALARM(TwinEEngine *engine, LifeScriptContext &ctx) {
 	return 0;
 }
 
-/*0x57*/
+/**
+ * Fade palette to alarm
+ * @note Opcode @c 0x57
+ */
 static int32 lFADE_PAL_ALARM(TwinEEngine *engine, LifeScriptContext &ctx) {
 	ScopedEngineFreeze scoped(engine);
 	HQR::getEntry(engine->_screens->palette, Resources::HQR_RESS_FILE, RESSHQR_ALARMREDPAL);
@@ -1277,7 +1526,10 @@ static int32 lFADE_PAL_ALARM(TwinEEngine *engine, LifeScriptContext &ctx) {
 	return 0;
 }
 
-/*0x58*/
+/**
+ * Explode an object. (Parameter = Object Index)
+ * @note Opcode @c 0x58
+ */
 static int32 lEXPLODE_OBJ(TwinEEngine *engine, LifeScriptContext &ctx) {
 	int32 otherActorIdx = ctx.stream.readByte();
 	ActorStruct *otherActor = engine->_scene->getActor(otherActorIdx);
@@ -1287,19 +1539,28 @@ static int32 lEXPLODE_OBJ(TwinEEngine *engine, LifeScriptContext &ctx) {
 	return 0;
 }
 
-/*0x59*/
+/**
+ * Turn on bubbles while actors talk.
+ * @note Opcode @c 0x59
+ */
 static int32 lBUBBLE_ON(TwinEEngine *engine, LifeScriptContext &ctx) {
 	engine->_text->showDialogueBubble = true;
 	return 0;
 }
 
-/*0x5A*/
+/**
+ * Turn off bubbles while actors talk.
+ * @note Opcode @c 0x5A
+ */
 static int32 lBUBBLE_OFF(TwinEEngine *engine, LifeScriptContext &ctx) {
 	engine->_text->showDialogueBubble = true; // TODO: this looks wrong - why true and not false?
 	return 0;
 }
 
-/*0x5B*/
+/**
+ * The actor will ask something with choices to choose. (Parameter = Actor Index, Parameter = Text Index in the current Text Bank)
+ * @note Opcode @c 0x5B
+ */
 static int32 lASK_CHOICE_OBJ(TwinEEngine *engine, LifeScriptContext &ctx) {
 	int32 otherActorIdx = ctx.stream.readByte();
 	int32 choiceIdx = ctx.stream.readSint16LE();
@@ -1317,7 +1578,10 @@ static int32 lASK_CHOICE_OBJ(TwinEEngine *engine, LifeScriptContext &ctx) {
 	return 0;
 }
 
-/*0x5C*/
+/**
+ * Set a dark palette.
+ * @note Opcode @c 0x5C
+ */
 static int32 lSET_DARK_PAL(TwinEEngine *engine, LifeScriptContext &ctx) {
 	ScopedEngineFreeze scoped(engine);
 	HQR::getEntry(engine->_screens->palette, Resources::HQR_RESS_FILE, RESSHQR_DARKPAL);
@@ -1329,7 +1593,10 @@ static int32 lSET_DARK_PAL(TwinEEngine *engine, LifeScriptContext &ctx) {
 	return 0;
 }
 
-/*0x5D*/
+/**
+ * Set main palette.
+ * @note Opcode @c 0x5D
+ */
 static int32 lSET_NORMAL_PAL(TwinEEngine *engine, LifeScriptContext &ctx) {
 	engine->_screens->useAlternatePalette = false;
 	if (!engine->_screens->lockPalette) {
@@ -1338,7 +1605,10 @@ static int32 lSET_NORMAL_PAL(TwinEEngine *engine, LifeScriptContext &ctx) {
 	return 0;
 }
 
-/*0x5E*/
+/**
+ * Show Sendell message.
+ * @note Opcode @c 0x5E
+ */
 static int32 lMESSAGE_SENDELL(TwinEEngine *engine, LifeScriptContext &ctx) {
 	ScopedEngineFreeze scoped(engine);
 	engine->_screens->fadeToBlack(engine->_screens->paletteRGBA);
@@ -1364,7 +1634,10 @@ static int32 lMESSAGE_SENDELL(TwinEEngine *engine, LifeScriptContext &ctx) {
 	return 0;
 }
 
-/*0x5F*/
+/**
+ * Set new animation for the current actor (Parameter = Animation Index)
+ * @note Opcode @c 0x5F
+ */
 static int32 lANIM_SET(TwinEEngine *engine, LifeScriptContext &ctx) {
 	AnimationTypes animIdx = (AnimationTypes)ctx.stream.readByte();
 
@@ -1375,14 +1648,19 @@ static int32 lANIM_SET(TwinEEngine *engine, LifeScriptContext &ctx) {
 	return 0;
 }
 
-/** Displays holomap travel animation */
-/*0x60*/
+/**
+ * Displays holomap travel animation. (Parameter = Trajectory)
+ * @note Opcode @c 0x60
+ */
 static int32 lHOLOMAP_TRAJ(TwinEEngine *engine, LifeScriptContext &ctx) {
 	ctx.stream.skip(1); // index of the holomap trajectory
 	return -1;
 }
 
-/*0x61*/
+/**
+ * Game over.
+ * @note Opcode @c 0x61
+ */
 static int32 lGAME_OVER(TwinEEngine *engine, LifeScriptContext &ctx) {
 	engine->_scene->sceneHero->dynamicFlags.bAnimEnded = 1;
 	engine->_scene->sceneHero->life = 0;
@@ -1390,7 +1668,10 @@ static int32 lGAME_OVER(TwinEEngine *engine, LifeScriptContext &ctx) {
 	return 1; // break
 }
 
-/*0x62*/
+/**
+ * End of the game.
+ * @note Opcode @c 0x62
+ */
 static int32 lTHE_END(TwinEEngine *engine, LifeScriptContext &ctx) {
 	engine->quitGame = 1;
 	engine->_gameState->inventoryNumLeafs = 0;
@@ -1404,20 +1685,29 @@ static int32 lTHE_END(TwinEEngine *engine, LifeScriptContext &ctx) {
 	return 1; // break;
 }
 
-/*0x63*/
+/**
+ * Stop the current played midi.
+ * @note Opcode @c 0x63
+ */
 static int32 lMIDI_OFF(TwinEEngine *engine, LifeScriptContext &ctx) {
 	engine->_music->stopMidiMusic();
 	return 0;
 }
 
-/*0x64*/
+/**
+ * Play a CD Track (Paramenter = CD Track).
+ * @note Opcode @c 0x64
+ */
 static int32 lPLAY_CD_TRACK(TwinEEngine *engine, LifeScriptContext &ctx) {
 	int32 track = ctx.stream.readByte();
 	engine->_music->playTrackMusic(track);
 	return 0;
 }
 
-/*0x65*/
+/**
+ * Set isometric projections
+ * @note Opcode @c 0x65
+ */
 static int32 lPROJ_ISO(TwinEEngine *engine, LifeScriptContext &ctx) {
 	engine->_renderer->setOrthoProjection(311, 240, 512);
 	engine->_renderer->setBaseTranslation(0, 0, 0);
@@ -1426,7 +1716,10 @@ static int32 lPROJ_ISO(TwinEEngine *engine, LifeScriptContext &ctx) {
 	return 0;
 }
 
-/*0x66*/
+/**
+ * Set 3D projections
+ * @note Opcode @c 0x66
+ */
 static int32 lPROJ_3D(TwinEEngine *engine, LifeScriptContext &ctx) {
 	engine->_screens->copyScreen(engine->frontVideoBuffer, engine->workVideoBuffer);
 	engine->flip();
@@ -1441,7 +1734,10 @@ static int32 lPROJ_3D(TwinEEngine *engine, LifeScriptContext &ctx) {
 	return 0;
 }
 
-/*0x67*/
+/**
+ * Only display the text. (e.g. like in the credit list) (Parameter = Text Index in the current Text Bank)
+ * @note Opcode @c 0x67
+ */
 static int32 lTEXT(TwinEEngine *engine, LifeScriptContext &ctx) {
 	int32 textIdx = ctx.stream.readSint16LE();
 
@@ -1452,6 +1748,7 @@ static int32 lTEXT(TwinEEngine *engine, LifeScriptContext &ctx) {
 			}
 		}
 
+		char textStr[256];
 		engine->_text->getMenuText(textIdx, textStr, sizeof(textStr));
 		int32 textSize = engine->_text->getTextSize(textStr);
 		int32 textBoxRight = textSize;
@@ -1462,13 +1759,17 @@ static int32 lTEXT(TwinEEngine *engine, LifeScriptContext &ctx) {
 		}
 
 		drawVar1 += 40;
+		// TODO: this looks wrong, top and bottom var are the same coordinates - the text height might be missing here
 		engine->copyBlockPhys(0, drawVar1, textBoxRight, drawVar1);
 	}
 
 	return 0;
 }
 
-/*0x68*/
+/**
+ * Clear displayed text in the screen.
+ * @note Opcode @c 0x68
+ */
 static int32 lCLEAR_TEXT(TwinEEngine *engine, LifeScriptContext &ctx) {
 	drawVar1 = 0;
 	engine->_interface->drawSplittedBox(0, 0, 639, 240, 0);
@@ -1476,7 +1777,10 @@ static int32 lCLEAR_TEXT(TwinEEngine *engine, LifeScriptContext &ctx) {
 	return 0;
 }
 
-/*0x69*/
+/**
+ * Exit the script execution.
+ * @note Opcode @c 0x69
+ */
 static int32 lBRUTAL_EXIT(TwinEEngine *engine, LifeScriptContext &ctx) {
 	engine->quitGame = 0;
 	return 1; // break
@@ -1499,7 +1803,7 @@ static const ScriptLifeFunction function_map[] = {
     /*0x0D*/ MAPFUNC("SWIF", lSWIF),
     /*0x0E*/ MAPFUNC("ONEIF", lONEIF),
     /*0x0F*/ MAPFUNC("ELSE", lELSE),
-    /*0x10*/ MAPFUNC("ENDIF", lEMPTY), // unused
+    /*0x10*/ MAPFUNC("ENDIF", lEMPTY), // End of a conditional statement (e.g. IF)
     /*0x11*/ MAPFUNC("BODY", lBODY),
     /*0x12*/ MAPFUNC("BODY_OBJ", lBODY_OBJ),
     /*0x13*/ MAPFUNC("ANIM", lANIM),
@@ -1592,7 +1896,6 @@ static const ScriptLifeFunction function_map[] = {
 
 ScriptLife::ScriptLife(TwinEEngine *engine) : _engine(engine) {
 	drawVar1 = 0;
-	textStr[0] = '\0';
 }
 
 void ScriptLife::processLifeScript(int32 actorIdx) {
diff --git a/engines/twine/script_move_v1.cpp b/engines/twine/script_move_v1.cpp
index 62e532debf..305728c91e 100644
--- a/engines/twine/script_move_v1.cpp
+++ b/engines/twine/script_move_v1.cpp
@@ -37,11 +37,11 @@
 
 namespace TwinE {
 
-static int32 numRepeatSample = 1;
-
 struct MoveScriptContext {
 	int32 actorIdx;
 	ActorStruct *actor;
+	int32 numRepeatSample = 1;
+
 	Common::MemorySeekableReadWriteStream stream;
 
 	MoveScriptContext(int32 _actorIdx, ActorStruct *_actor) : actorIdx(_actorIdx), actor(_actor), stream(actor->moveScript, actor->moveScriptSize) {
@@ -56,10 +56,9 @@ struct MoveScriptContext {
 	}
 };
 
-/** Returns:
-	   -1 - Need implementation
-		0 - Completed
-		1 - Break script */
+/**
+ * Returns @c -1 Need implementation, @c 0 Condition false, @c 1 - Condition true
+ */
 typedef int32 ScriptMoveFunc(TwinEEngine *engine, MoveScriptContext &ctx);
 
 struct ScriptMoveFunction {
@@ -70,25 +69,37 @@ struct ScriptMoveFunction {
 #define MAPFUNC(name, func) \
 	{ name, func }
 
-/*0x00*/
+/**
+ * End of Actor Move Script
+ * @note Opcode @c 0x00
+ */
 static int32 mEND(TwinEEngine *engine, MoveScriptContext &ctx) {
 	ctx.actor->positionInMoveScript = -1;
 	return 1;
 }
 
-/*0x01*/
+/**
+ * No Operation
+ * @note Opcode @c 0x01
+ */
 static int32 mNOP(TwinEEngine *engine, MoveScriptContext &ctx) {
 	return 0;
 }
 
-/*0x02*/
+/**
+ * Choose new body for the current actor (Parameter = File3D Body Instance)
+ * @note Opcode @c 0x02
+ */
 static int32 mBODY(TwinEEngine *engine, MoveScriptContext &ctx) {
 	int32 bodyIdx = ctx.stream.readByte();
 	engine->_actor->initModelActor(bodyIdx, ctx.actorIdx);
 	return 0;
 }
 
-/*0x03*/
+/**
+ * Choose new animation for the current actor (Parameter = File3D Animation Instance)
+ * @note Opcode @c 0x03
+ */
 static int32 mANIM(TwinEEngine *engine, MoveScriptContext &ctx) {
 	AnimationTypes animIdx = (AnimationTypes)ctx.stream.readByte();
 	if (engine->_animations->initAnim(animIdx, 0, AnimationTypes::kStanding, ctx.actorIdx)) {
@@ -98,7 +109,10 @@ static int32 mANIM(TwinEEngine *engine, MoveScriptContext &ctx) {
 	return 1;
 }
 
-/*0x04*/
+/**
+ * Tell the actor to go to a new position (Parameter = Track Index)
+ * @note Opcode @c 0x04
+ */
 static int32 mGOTO_POINT(TwinEEngine *engine, MoveScriptContext &ctx) {
 	engine->_scene->currentScriptValue = ctx.stream.readByte();
 
@@ -123,7 +137,10 @@ static int32 mGOTO_POINT(TwinEEngine *engine, MoveScriptContext &ctx) {
 	return 0;
 }
 
-/*0x05*/
+/**
+ * Wait the end of the current animation
+ * @note Opcode @c 0x05
+ */
 static int32 mWAIT_ANIM(TwinEEngine *engine, MoveScriptContext &ctx) {
 	if (!ctx.actor->dynamicFlags.bAnimEnded) {
 		ctx.undo(0);
@@ -133,13 +150,19 @@ static int32 mWAIT_ANIM(TwinEEngine *engine, MoveScriptContext &ctx) {
 	return 1;
 }
 
-/*0x06*/
+/**
+ * Loop a certain label (Parameter = Label Number)
+ * @note Opcode @c 0x06
+ */
 static int32 mLOOP(TwinEEngine *engine, MoveScriptContext &ctx) {
 	// TODO no params
 	return -1;
 }
 
-/*0x07*/
+/**
+ * Make the actor turn around
+ * @note Opcode @c 0x07
+ */
 static int32 mANGLE(TwinEEngine *engine, MoveScriptContext &ctx) {
 	const int16 angle = ctx.stream.readSint16LE();
 	if (ctx.actor->staticFlags.bIsSpriteActor) {
@@ -157,7 +180,10 @@ static int32 mANGLE(TwinEEngine *engine, MoveScriptContext &ctx) {
 	return 1;
 }
 
-/*0x08*/
+/**
+ * Set new postion for the current actor (Parameter = Track Index)
+ * @note Opcode @c 0x08
+ */
 static int32 mPOS_POINT(TwinEEngine *engine, MoveScriptContext &ctx) {
 	engine->_scene->currentScriptValue = ctx.stream.readByte();
 
@@ -177,14 +203,20 @@ static int32 mPOS_POINT(TwinEEngine *engine, MoveScriptContext &ctx) {
 	return 0;
 }
 
-/*0x09*/
+/**
+ * Specify a new label (Parameter = Label Number)
+ * @note Opcode @c 0x09
+ */
 static int32 mLABEL(TwinEEngine *engine, MoveScriptContext &ctx) {
 	ctx.actor->labelIdx = ctx.stream.readByte();
 	ctx.actor->currentLabelPtr = ctx.stream.pos() - 2;
 	return 0;
 }
 
-/*0x0A*/
+/**
+ * Go to a certain label (Parameter = Label Number)
+ * @note Opcode @c 0x0A
+ */
 static int32 mGOTO(TwinEEngine *engine, MoveScriptContext &ctx) {
 	const int16 pos = ctx.stream.readSint16LE();
 	if (pos == -1) {
@@ -195,13 +227,19 @@ static int32 mGOTO(TwinEEngine *engine, MoveScriptContext &ctx) {
 	return 0;
 }
 
-/*0x0B*/
+/**
+ * Tell the actor to stop the current animation
+ * @note Opcode @c 0x0B
+ */
 static int32 mSTOP(TwinEEngine *engine, MoveScriptContext &ctx) {
 	ctx.actor->positionInMoveScript = -1;
 	return 1;
 }
 
-/*0x0C*/
+/**
+ * Tell the actor to go to a symbolic point
+ * @note Opcode @c 0x0C
+ */
 static int32 mGOTO_SYM_POINT(TwinEEngine *engine, MoveScriptContext &ctx) {
 	engine->_scene->currentScriptValue = ctx.stream.readByte();
 
@@ -226,7 +264,10 @@ static int32 mGOTO_SYM_POINT(TwinEEngine *engine, MoveScriptContext &ctx) {
 	return 0;
 }
 
-/*0x0D*/
+/**
+ * Wait a certain number of frame update in the current animation
+ * @note Opcode @c 0x0D
+ */
 static int32 mWAIT_NUM_ANIM(TwinEEngine *engine, MoveScriptContext &ctx) {
 	bool abortMove = false;
 	const int32 animRepeats = ctx.stream.readByte();
@@ -253,14 +294,20 @@ static int32 mWAIT_NUM_ANIM(TwinEEngine *engine, MoveScriptContext &ctx) {
 	return abortMove ? 1 : 0;
 }
 
-/*0x0E*/
+/**
+ * Play a sample (Parameter = Sample index)
+ * @note Opcode @c 0x0E
+ */
 static int32 mSAMPLE(TwinEEngine *engine, MoveScriptContext &ctx) {
 	int32 sampleIdx = ctx.stream.readSint16LE();
 	engine->_sound->playSample(sampleIdx, 0x1000, 1, ctx.actor->x, ctx.actor->y, ctx.actor->z, ctx.actorIdx);
 	return 0;
 }
 
-/*0x0F*/
+/**
+ * Tell the actor to go to a new position (Parameter = Track Index)
+ * @note Opcode @c 0x0F
+ */
 static int32 mGOTO_POINT_3D(TwinEEngine *engine, MoveScriptContext &ctx) {
 	const int32 trackId = ctx.stream.readByte();
 	if (!ctx.actor->staticFlags.bIsSpriteActor) {
@@ -288,7 +335,10 @@ static int32 mGOTO_POINT_3D(TwinEEngine *engine, MoveScriptContext &ctx) {
 	return 0;
 }
 
-/*0x10*/
+/**
+ * Specify a new rotation speed for the current actor (Parameter = Rotation speed) [ 0 means fast, 32767 means slow ]
+ * @note Opcode @c 0x10
+ */
 static int32 mSPEED(TwinEEngine *engine, MoveScriptContext &ctx) {
 	ctx.actor->speed = ctx.stream.readSint16LE();
 
@@ -299,7 +349,10 @@ static int32 mSPEED(TwinEEngine *engine, MoveScriptContext &ctx) {
 	return 0;
 }
 
-/*0x11*/
+/**
+ * Set actor as background (Parameter = 1 (true); = 0 (false))
+ * @note Opcode @c 0x11
+ */
 static int32 mBACKGROUND(TwinEEngine *engine, MoveScriptContext &ctx) {
 	if (ctx.stream.readByte() != 0) {
 		if (!ctx.actor->staticFlags.bIsBackgrounded) {
@@ -320,7 +373,10 @@ static int32 mBACKGROUND(TwinEEngine *engine, MoveScriptContext &ctx) {
 	return 0;
 }
 
-/*0x12*/
+/**
+ * Number os seconds to wait.
+ * @note Opcode @c 0x12
+ */
 static int32 mWAIT_NUM_SECOND(TwinEEngine *engine, MoveScriptContext &ctx) {
 	const int32 numSeconds = ctx.stream.readByte();
 	int32 currentTime = ctx.stream.readSint32LE();
@@ -342,13 +398,19 @@ static int32 mWAIT_NUM_SECOND(TwinEEngine *engine, MoveScriptContext &ctx) {
 	return 0;
 }
 
-/*0x13*/
+/**
+ * To not use Bodies.
+ * @note Opcode @c 0x13
+ */
 static int32 mNO_BODY(TwinEEngine *engine, MoveScriptContext &ctx) {
 	engine->_actor->initModelActor(-1, ctx.actorIdx);
 	return 0;
 }
 
-/*0x14*/
+/**
+ * Change actor orientation. (Parameter = New Angle)
+ * @note Opcode @c 0x14
+ */
 static int32 mBETA(TwinEEngine *engine, MoveScriptContext &ctx) {
 	const int16 beta = ctx.stream.readSint16LE();
 
@@ -361,7 +423,10 @@ static int32 mBETA(TwinEEngine *engine, MoveScriptContext &ctx) {
 	return 0;
 }
 
-/*0x15*/
+/**
+ * Open the door (left way) (Parameter = distance to open).
+ * @note Opcode @c 0x15
+ */
 static int32 mOPEN_LEFT(TwinEEngine *engine, MoveScriptContext &ctx) {
 	const int16 doorStatus = ctx.stream.readSint16LE();
 	if (ctx.actor->staticFlags.bIsSpriteActor && ctx.actor->staticFlags.bUsesClipping) {
@@ -374,7 +439,10 @@ static int32 mOPEN_LEFT(TwinEEngine *engine, MoveScriptContext &ctx) {
 	return 0;
 }
 
-/*0x16*/
+/**
+ * Open the door (right way) (Parameter = distance to open).
+ * @note Opcode @c 0x16
+ */
 static int32 mOPEN_RIGHT(TwinEEngine *engine, MoveScriptContext &ctx) {
 	const int16 doorStatus = ctx.stream.readSint16LE();
 	if (ctx.actor->staticFlags.bIsSpriteActor && ctx.actor->staticFlags.bUsesClipping) {
@@ -387,7 +455,10 @@ static int32 mOPEN_RIGHT(TwinEEngine *engine, MoveScriptContext &ctx) {
 	return 0;
 }
 
-/*0x17*/
+/**
+ * Open the door (up way) (Parameter = distance to open).
+ * @note Opcode @c 0x17
+ */
 static int32 mOPEN_UP(TwinEEngine *engine, MoveScriptContext &ctx) {
 	const int16 doorStatus = ctx.stream.readSint16LE();
 	if (ctx.actor->staticFlags.bIsSpriteActor && ctx.actor->staticFlags.bUsesClipping) {
@@ -400,7 +471,10 @@ static int32 mOPEN_UP(TwinEEngine *engine, MoveScriptContext &ctx) {
 	return 0;
 }
 
-/*0x18*/
+/**
+ * Open the door (down way) (Parameter = distance to open).
+ * @note Opcode @c 0x18
+ */
 static int32 mOPEN_DOWN(TwinEEngine *engine, MoveScriptContext &ctx) {
 	const int16 doorStatus = ctx.stream.readSint16LE();
 	if (ctx.actor->staticFlags.bIsSpriteActor && ctx.actor->staticFlags.bUsesClipping) {
@@ -413,7 +487,10 @@ static int32 mOPEN_DOWN(TwinEEngine *engine, MoveScriptContext &ctx) {
 	return 0;
 }
 
-/*0x19*/
+/**
+ * Close the door.
+ * @note Opcode @c 0x19
+ */
 static int32 mCLOSE(TwinEEngine *engine, MoveScriptContext &ctx) {
 	if (ctx.actor->staticFlags.bIsSpriteActor && ctx.actor->staticFlags.bUsesClipping) {
 		ctx.actor->doorStatus = 0;
@@ -424,7 +501,10 @@ static int32 mCLOSE(TwinEEngine *engine, MoveScriptContext &ctx) {
 	return 0;
 }
 
-/*0x1A*/
+/**
+ * Wait till door close.
+ * @note Opcode @c 0x1A
+ */
 static int32 mWAIT_DOOR(TwinEEngine *engine, MoveScriptContext &ctx) {
 	if (ctx.actor->staticFlags.bIsSpriteActor && ctx.actor->staticFlags.bUsesClipping) {
 		if (ctx.actor->speed) {
@@ -435,7 +515,10 @@ static int32 mWAIT_DOOR(TwinEEngine *engine, MoveScriptContext &ctx) {
 	return 0;
 }
 
-/*0x1B*/
+/**
+ * Generate a random sample.
+ * @note Opcode @c 0x1B
+ */
 static int32 mSAMPLE_RND(TwinEEngine *engine, MoveScriptContext &ctx) {
 	int32 freq = engine->getRandomNumber(2048) + 2048;
 	int32 sampleIdx = ctx.stream.readSint16LE();
@@ -443,7 +526,10 @@ static int32 mSAMPLE_RND(TwinEEngine *engine, MoveScriptContext &ctx) {
 	return 0;
 }
 
-/*0x1C*/
+/**
+ * Play always the sample (Parameter = Sample index)
+ * @note Opcode @c 0x1C
+ */
 static int32 mSAMPLE_ALWAYS(TwinEEngine *engine, MoveScriptContext &ctx) {
 	int32 sampleIdx = ctx.stream.readSint16LE();
 	if (!engine->_sound->isSamplePlaying(sampleIdx)) { // if its not playing
@@ -452,14 +538,20 @@ static int32 mSAMPLE_ALWAYS(TwinEEngine *engine, MoveScriptContext &ctx) {
 	return 0;
 }
 
-/*0x1D*/
+/**
+ * Stop playing the sample
+ * @note Opcode @c 0x1D
+ */
 static int32 mSAMPLE_STOP(TwinEEngine *engine, MoveScriptContext &ctx) {
 	int32 sampleIdx = ctx.stream.readSint16LE();
 	engine->_sound->stopSample(sampleIdx);
 	return 0;
 }
 
-/*0x1E*/
+/**
+ * Play FLA cutscenes (Parameter = Cutscene Name)
+ * @note Opcode @c 0x1E
+ */
 static int32 mPLAY_FLA(TwinEEngine *engine, MoveScriptContext &ctx) {
 	int strIdx = 0;
 	char movie[64];
@@ -481,21 +573,30 @@ static int32 mPLAY_FLA(TwinEEngine *engine, MoveScriptContext &ctx) {
 	return 0;
 }
 
-/*0x1F*/
+/**
+ * Repeat sample (Parameter = Sample index).
+ * @note Opcode @c 0x1F
+ */
 static int32 mREPEAT_SAMPLE(TwinEEngine *engine, MoveScriptContext &ctx) {
-	numRepeatSample = ctx.stream.readSint16LE();
+	ctx.numRepeatSample = ctx.stream.readSint16LE();
 	return 0;
 }
 
-/*0x20*/
+/**
+ * Play a sample (Parameter = Sample index)
+ * @note Opcode @c 0x20
+ */
 static int32 mSIMPLE_SAMPLE(TwinEEngine *engine, MoveScriptContext &ctx) {
 	int32 sampleIdx = ctx.stream.readSint16LE();
-	engine->_sound->playSample(sampleIdx, 0x1000, numRepeatSample, ctx.actor->x, ctx.actor->y, ctx.actor->z, ctx.actorIdx);
-	numRepeatSample = 1;
+	engine->_sound->playSample(sampleIdx, 0x1000, ctx.numRepeatSample, ctx.actor->x, ctx.actor->y, ctx.actor->z, ctx.actorIdx);
+	ctx.numRepeatSample = 1;
 	return 0;
 }
 
-/*0x21*/
+/**
+ * The actor rotate to Twinsen direction (Parameter = -1 (near); = 0 (far))
+ * @note Opcode @c 0x21
+ */
 static int32 mFACE_HERO(TwinEEngine *engine, MoveScriptContext &ctx) {
 	const int16 angle = ctx.stream.readSint16LE();
 	if (ctx.actor->staticFlags.bIsSpriteActor) {
@@ -519,7 +620,10 @@ static int32 mFACE_HERO(TwinEEngine *engine, MoveScriptContext &ctx) {
 	return 0;
 }
 
-/*0x22*/
+/**
+ * Generate an random angle for the current actor
+ * @note Opcode @c 0x22
+ */
 static int32 mANGLE_RND(TwinEEngine *engine, MoveScriptContext &ctx) {
 	const int16 val1 = ctx.stream.readSint16LE();
 	const int16 val2 = ctx.stream.readSint16LE();
@@ -593,12 +697,10 @@ static const ScriptMoveFunction function_map[] = {
     /*0x22*/ MAPFUNC("ANGLE_RND", mANGLE_RND)};
 
 ScriptMove::ScriptMove(TwinEEngine *engine) : _engine(engine) {
-	numRepeatSample = 1;
 }
 
 void ScriptMove::processMoveScript(int32 actorIdx) {
 	ActorStruct *actor = _engine->_scene->getActor(actorIdx);
-	numRepeatSample = 1;
 
 	int32 end = -2;
 


Commit: b30a195e97748ba5341c9a7f698081d126588e83
    https://github.com/scummvm/scummvm/commit/b30a195e97748ba5341c9a7f698081d126588e83
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-20T18:26:35+01:00

Commit Message:
TWINE: introduced ClampAngle

Changed paths:
    engines/twine/animations.cpp
    engines/twine/extra.cpp
    engines/twine/movements.cpp
    engines/twine/renderer.cpp
    engines/twine/script_life_v1.cpp
    engines/twine/script_move_v1.cpp
    engines/twine/shared.h


diff --git a/engines/twine/animations.cpp b/engines/twine/animations.cpp
index 07807f9d17..3510f50391 100644
--- a/engines/twine/animations.cpp
+++ b/engines/twine/animations.cpp
@@ -143,15 +143,12 @@ int32 Animations::getStartKeyframe(const uint8 *animPtr) {
 }
 
 void Animations::applyAnimStepRotation(uint8 **ptr, int32 bp, int32 bx, const uint8 **keyFramePtr, const uint8 **lastKeyFramePtr) {
-	int16 lastAngle = READ_LE_INT16(*lastKeyFramePtr);
+	const int16 lastAngle = ClampAngle(READ_LE_INT16(*lastKeyFramePtr));
 	*lastKeyFramePtr += 2;
 
-	int16 newAngle = READ_LE_INT16(*keyFramePtr);
+	const int16 newAngle = ClampAngle(READ_LE_INT16(*keyFramePtr));
 	*keyFramePtr += 2;
 
-	lastAngle &= 0x3FF;
-	newAngle &= 0x3FF;
-
 	int16 angleDiff = newAngle - lastAngle;
 
 	int16 computedAngle;
@@ -168,7 +165,7 @@ void Animations::applyAnimStepRotation(uint8 **ptr, int32 bp, int32 bx, const ui
 	}
 
 	int16 *dest = (int16 *)*(ptr);
-	*dest = computedAngle & 0x3FF;
+	*dest = ClampAngle(computedAngle);
 	*(ptr) = *(ptr) + 2;
 }
 
@@ -867,7 +864,7 @@ void Animations::processActorAnimations(int32 actorIdx) { // DoAnim
 				actor->dynamicFlags.bIsRotationByAnim = 0;
 			}
 
-			actor->angle = (actor->angle + processLastRotationAngle - actor->lastRotationAngle) & 0x3FF;
+			actor->angle = ClampAngle(actor->angle + processLastRotationAngle - actor->lastRotationAngle);
 			actor->lastRotationAngle = processLastRotationAngle;
 
 			_engine->_movements->rotateActor(currentStepX, currentStepZ, actor->angle);
diff --git a/engines/twine/extra.cpp b/engines/twine/extra.cpp
index 6b5e940b92..3aab81ff8b 100644
--- a/engines/twine/extra.cpp
+++ b/engines/twine/extra.cpp
@@ -645,7 +645,7 @@ void Extra::processExtras() {
 			currentExtraZ = actor->z;
 
 			int32 tmpAngle = _engine->_movements->getAngleAndSetTargetActorDistance(extra->x, extra->z, currentExtraX, currentExtraZ);
-			int32 angle = (tmpAngle - extra->angle) & 0x3FF;
+			int32 angle = ClampAngle(tmpAngle - extra->angle);
 
 			if (angle > 400 && angle < 600) {
 				if (extra->strengthOfHit) {
@@ -691,7 +691,7 @@ void Extra::processExtras() {
 			int32 actorIdx = extra->actorIdx;
 
 			int32 tmpAngle = _engine->_movements->getAngleAndSetTargetActorDistance(extra->x, extra->z, extraKey->x, extraKey->z);
-			int32 angle = (tmpAngle - extra->angle) & 0x3FF;
+			int32 angle = ClampAngle(tmpAngle - extra->angle);
 
 			if (angle > 400 && angle < 600) {
 				_engine->_sound->playSample(Samples::ItemFound, 4096, 1, _engine->_scene->sceneHero->x, _engine->_scene->sceneHero->y, _engine->_scene->sceneHero->z, 0);
diff --git a/engines/twine/movements.cpp b/engines/twine/movements.cpp
index e66e774bc9..6c2a60db49 100644
--- a/engines/twine/movements.cpp
+++ b/engines/twine/movements.cpp
@@ -57,9 +57,9 @@ void Movements::getShadowPosition(int32 x, int32 y, int32 z) {
 }
 
 void Movements::setActorAngleSafe(int16 startAngle, int16 endAngle, int16 stepAngle, ActorMoveStruct *movePtr) {
-	movePtr->from = startAngle & 0x3FF;
-	movePtr->to = endAngle & 0x3FF;
-	movePtr->numOfStep = stepAngle & 0x3FF;
+	movePtr->from = ClampAngle(startAngle);
+	movePtr->to = ClampAngle(endAngle);
+	movePtr->numOfStep = ClampAngle(stepAngle);
 	movePtr->timeOfChange = _engine->lbaTime;
 }
 
@@ -137,7 +137,7 @@ int32 Movements::getAngleAndSetTargetActorDistance(int32 x1, int32 z1, int32 x2,
 		finalAngle = -finalAngle + 0x100;
 	}
 
-	return finalAngle & 0x3FF;
+	return ClampAngle(finalAngle);
 }
 
 int32 Movements::getRealAngle(ActorMoveStruct *movePtr) {
@@ -199,8 +199,8 @@ int32 Movements::getDistance3D(int32 x1, int32 y1, int32 z1, int32 x2, int32 y2,
 }
 
 void Movements::moveActor(int32 angleFrom, int32 angleTo, int32 speed, ActorMoveStruct *movePtr) { // ManualRealAngle
-	const int16 from = angleFrom & 0x3FF;
-	const int16 to = angleTo & 0x3FF;
+	const int16 from = ClampAngle(angleFrom);
+	const int16 to = ClampAngle(angleTo);
 
 	movePtr->from = from;
 	movePtr->to = to;
@@ -390,7 +390,7 @@ void Movements::processRandomAction(int actorIdx) {
 	}
 
 	if (actor->brickCausesDamage()) {
-		moveActor(actor->angle, (((_engine->getRandomNumber() & 0x100) + (actor->angle - 0x100)) & 0x3FF), actor->speed, &actor->move);
+		moveActor(actor->angle, ClampAngle((_engine->getRandomNumber() & 0x100) + (actor->angle - 0x100)), actor->speed, &actor->move);
 		actor->delayInMillis = _engine->getRandomNumber(300) + _engine->lbaTime + 300;
 		_engine->_animations->initAnim(AnimationTypes::kStanding, 0, AnimationTypes::kAnimInvalid, actorIdx);
 	}
@@ -398,7 +398,7 @@ void Movements::processRandomAction(int actorIdx) {
 	if (!actor->move.numOfStep) {
 		_engine->_animations->initAnim(AnimationTypes::kForward, 0, AnimationTypes::kAnimInvalid, actorIdx);
 		if (_engine->lbaTime > actor->delayInMillis) {
-			moveActor(actor->angle, (((_engine->getRandomNumber() & 0x100) + (actor->angle - 0x100)) & 0x3FF), actor->speed, &actor->move);
+			moveActor(actor->angle, ClampAngle((_engine->getRandomNumber() & 0x100) + (actor->angle - 0x100)), actor->speed, &actor->move);
 			actor->delayInMillis = _engine->getRandomNumber(300) + _engine->lbaTime + 300;
 		}
 	}
diff --git a/engines/twine/renderer.cpp b/engines/twine/renderer.cpp
index 1ab45a0693..42f04e07ba 100644
--- a/engines/twine/renderer.cpp
+++ b/engines/twine/renderer.cpp
@@ -157,9 +157,9 @@ void Renderer::applyRotation(int32 *targetMatrix, const int32 *currentMatrix) {
 
 	if (renderAngleX) {
 		int32 angle = renderAngleX;
-		int32 angleVar2 = shadeAngleTable[angle & 0x3FF];
-		angle += 0x100;
-		int32 angleVar1 = shadeAngleTable[angle & 0x3FF];
+		int32 angleVar2 = shadeAngleTable[ClampAngle(angle)];
+		angle += 256;
+		int32 angleVar1 = shadeAngleTable[ClampAngle(angle)];
 
 		matrix1[0] = currentMatrix[0];
 		matrix1[3] = currentMatrix[3];
@@ -179,9 +179,9 @@ void Renderer::applyRotation(int32 *targetMatrix, const int32 *currentMatrix) {
 
 	if (renderAngleZ) {
 		int32 angle = renderAngleZ;
-		int32 angleVar2 = shadeAngleTable[angle & 0x3FF];
-		angle += 0x100;
-		int32 angleVar1 = shadeAngleTable[angle & 0x3FF];
+		int32 angleVar2 = shadeAngleTable[ClampAngle(angle)];
+		angle += 256;
+		int32 angleVar1 = shadeAngleTable[ClampAngle(angle)];
 
 		matrix2[2] = matrix1[2];
 		matrix2[5] = matrix1[5];
@@ -201,9 +201,9 @@ void Renderer::applyRotation(int32 *targetMatrix, const int32 *currentMatrix) {
 
 	if (renderAngleY) {
 		int32 angle = renderAngleY;
-		int32 angleVar2 = shadeAngleTable[angle & 0x3FF]; // esi
-		angle += 0x100;
-		int32 angleVar1 = shadeAngleTable[angle & 0x3FF]; // ecx
+		int32 angleVar2 = shadeAngleTable[ClampAngle(angle)];
+		angle += 256;
+		int32 angleVar1 = shadeAngleTable[ClampAngle(angle)];
 
 		targetMatrix[1] = matrix2[1];
 		targetMatrix[4] = matrix2[4];
diff --git a/engines/twine/script_life_v1.cpp b/engines/twine/script_life_v1.cpp
index 99413b2aca..2ffc021879 100644
--- a/engines/twine/script_life_v1.cpp
+++ b/engines/twine/script_life_v1.cpp
@@ -228,8 +228,7 @@ static int32 processLifeConditions(TwinEEngine *engine, LifeScriptContext &ctx)
 			}
 
 			if (IS_HERO(targetActorIdx)) {
-				int32 heroAngle = ctx.actor->angle + 0x480 - newAngle + 0x400;
-				heroAngle &= 0x3FF;
+				int32 heroAngle = ClampAngle(ctx.actor->angle + 0x480 - newAngle + 0x400);
 
 				if (ABS(heroAngle) > 0x100) {
 					engine->_scene->currentScriptValue = MAX_TARGET_ACTOR_DISTANCE;
@@ -238,8 +237,7 @@ static int32 processLifeConditions(TwinEEngine *engine, LifeScriptContext &ctx)
 				}
 			} else {
 				if (engine->_actor->heroBehaviour == HeroBehaviourType::kDiscrete) {
-					int32 heroAngle = ctx.actor->angle + 0x480 - newAngle + 0x400;
-					heroAngle &= 0x3FF;
+					int32 heroAngle = ClampAngle(ctx.actor->angle + 0x480 - newAngle + 0x400);
 
 					if (ABS(heroAngle) > 0x100) {
 						engine->_scene->currentScriptValue = MAX_TARGET_ACTOR_DISTANCE;
diff --git a/engines/twine/script_move_v1.cpp b/engines/twine/script_move_v1.cpp
index 305728c91e..c4892427c5 100644
--- a/engines/twine/script_move_v1.cpp
+++ b/engines/twine/script_move_v1.cpp
@@ -300,7 +300,7 @@ static int32 mWAIT_NUM_ANIM(TwinEEngine *engine, MoveScriptContext &ctx) {
  */
 static int32 mSAMPLE(TwinEEngine *engine, MoveScriptContext &ctx) {
 	int32 sampleIdx = ctx.stream.readSint16LE();
-	engine->_sound->playSample(sampleIdx, 0x1000, 1, ctx.actor->x, ctx.actor->y, ctx.actor->z, ctx.actorIdx);
+	engine->_sound->playSample(sampleIdx, 4096, 1, ctx.actor->x, ctx.actor->y, ctx.actor->z, ctx.actorIdx);
 	return 0;
 }
 
@@ -533,7 +533,7 @@ static int32 mSAMPLE_RND(TwinEEngine *engine, MoveScriptContext &ctx) {
 static int32 mSAMPLE_ALWAYS(TwinEEngine *engine, MoveScriptContext &ctx) {
 	int32 sampleIdx = ctx.stream.readSint16LE();
 	if (!engine->_sound->isSamplePlaying(sampleIdx)) { // if its not playing
-		engine->_sound->playSample(sampleIdx, 0x1000, -1, ctx.actor->x, ctx.actor->y, ctx.actor->z, ctx.actorIdx);
+		engine->_sound->playSample(sampleIdx, 4096, -1, ctx.actor->x, ctx.actor->y, ctx.actor->z, ctx.actorIdx);
 	}
 	return 0;
 }
@@ -588,7 +588,7 @@ static int32 mREPEAT_SAMPLE(TwinEEngine *engine, MoveScriptContext &ctx) {
  */
 static int32 mSIMPLE_SAMPLE(TwinEEngine *engine, MoveScriptContext &ctx) {
 	int32 sampleIdx = ctx.stream.readSint16LE();
-	engine->_sound->playSample(sampleIdx, 0x1000, ctx.numRepeatSample, ctx.actor->x, ctx.actor->y, ctx.actor->z, ctx.actorIdx);
+	engine->_sound->playSample(sampleIdx, 4096, ctx.numRepeatSample, ctx.actor->x, ctx.actor->y, ctx.actor->z, ctx.actorIdx);
 	ctx.numRepeatSample = 1;
 	return 0;
 }
@@ -635,13 +635,11 @@ static int32 mANGLE_RND(TwinEEngine *engine, MoveScriptContext &ctx) {
 
 	if (engine->_scene->currentScriptValue == -1 && ctx.actor->move.numOfStep == 0) {
 		if (engine->getRandomNumber() & 1) {
-			engine->_scene->currentScriptValue = val1;
-			const int32 newAngle = ctx.actor->angle + 0x100 + (ABS(engine->_scene->currentScriptValue) >> 1);
-			engine->_scene->currentScriptValue = (newAngle - engine->getRandomNumber(engine->_scene->currentScriptValue)) & 0x3FF;
+			const int32 newAngle = ctx.actor->angle + 256 + (ABS(val1) >> 1);
+			engine->_scene->currentScriptValue = ClampAngle(newAngle - engine->getRandomNumber(val1));
 		} else {
-			engine->_scene->currentScriptValue = val1;
-			const int32 newAngle = ctx.actor->angle - 0x100 + (ABS(engine->_scene->currentScriptValue) >> 1);
-			engine->_scene->currentScriptValue = (newAngle - engine->getRandomNumber(engine->_scene->currentScriptValue)) & 0x3FF;
+			const int32 newAngle = ctx.actor->angle - 256 + (ABS(val1) >> 1);
+			engine->_scene->currentScriptValue = ClampAngle(newAngle - engine->getRandomNumber(val1));
 		}
 
 		engine->_movements->moveActor(ctx.actor->angle, engine->_scene->currentScriptValue, ctx.actor->speed, &ctx.actor->move);
diff --git a/engines/twine/shared.h b/engines/twine/shared.h
index e892e0ed8a..3e253633ac 100644
--- a/engines/twine/shared.h
+++ b/engines/twine/shared.h
@@ -118,6 +118,10 @@ enum class ExtraSpecialType {
 	kExplodeCloud = 1
 };
 
+inline int32 ClampAngle(int32 angle) {
+	return angle & 0x3FF;
+}
+
 }
 
 #endif


Commit: 699c8225c65f1b6292dfc62d21fec26cd7e76a9c
    https://github.com/scummvm/scummvm/commit/699c8225c65f1b6292dfc62d21fec26cd7e76a9c
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-20T18:34:50+01:00

Commit Message:
TWINE: replaced magic numbers with constants

and started to mark the angles - to be able to refacto them easier later on

Changed paths:
    engines/twine/actor.cpp
    engines/twine/animations.cpp
    engines/twine/animations.h
    engines/twine/collision.cpp
    engines/twine/extra.cpp
    engines/twine/extra.h
    engines/twine/gamestate.cpp
    engines/twine/menu.cpp
    engines/twine/movements.cpp
    engines/twine/redraw.cpp
    engines/twine/redraw.h
    engines/twine/renderer.cpp
    engines/twine/scene.cpp
    engines/twine/script_life_v1.cpp
    engines/twine/script_move_v1.cpp
    engines/twine/shared.h
    engines/twine/twine.cpp


diff --git a/engines/twine/actor.cpp b/engines/twine/actor.cpp
index d08ae1a3d5..031769e783 100644
--- a/engines/twine/actor.cpp
+++ b/engines/twine/actor.cpp
@@ -341,7 +341,7 @@ void Actor::initActor(int16 actorIdx) {
 
 		initSpriteActor(actorIdx);
 
-		_engine->_movements->setActorAngleSafe(0, 0, 0, &actor->move);
+		_engine->_movements->setActorAngleSafe(ANGLE_0, ANGLE_0, 0, &actor->move);
 
 		if (actor->staticFlags.bUsesClipping) {
 			actor->lastX = actor->x;
@@ -414,7 +414,7 @@ void Actor::resetActor(int16 actorIdx) {
 	actor->animType = 0;
 	actor->animPosition = 0;
 
-	_engine->_movements->setActorAngleSafe(0, 0, 0, &actor->move);
+	_engine->_movements->setActorAngleSafe(ANGLE_0, ANGLE_0, 0, &actor->move);
 
 	actor->positionInMoveScript = -1;
 	actor->positionInLifeScript = 0;
@@ -484,7 +484,7 @@ void Actor::processActorExtraBonus(int32 actorIdx) { // GiveExtraBonus
 		return;
 	}
 	if (actor->dynamicFlags.bIsDead) {
-		_engine->_extra->addExtraBonus(actor->x, actor->y, actor->z, 0x100, 0, bonusSprite, actor->bonusAmount);
+		_engine->_extra->addExtraBonus(actor->x, actor->y, actor->z, ANGLE_90, 0, bonusSprite, actor->bonusAmount);
 		// FIXME add constant for sample index
 		_engine->_sound->playSample(Samples::ItemPopup, 4096, 1, actor->x, actor->y, actor->z, actorIdx);
 	} else {
diff --git a/engines/twine/animations.cpp b/engines/twine/animations.cpp
index 3510f50391..e56f8b4659 100644
--- a/engines/twine/animations.cpp
+++ b/engines/twine/animations.cpp
@@ -129,7 +129,7 @@ int32 Animations::setAnimAtKeyframe(int32 keyframeIdx, uint8 *animPtr, uint8 *bo
 	currentStepZ = READ_LE_INT16(ptrToData + 4);
 
 	processRotationByAnim = READ_LE_INT16(ptrToData + 6);
-	processLastRotationAngle = READ_LE_INT16(ptrToData + 10);
+	processLastRotationAngle = ToAngle(READ_LE_INT16(ptrToData + 10));
 
 	return 1;
 }
@@ -153,10 +153,10 @@ void Animations::applyAnimStepRotation(uint8 **ptr, int32 bp, int32 bx, const ui
 
 	int16 computedAngle;
 	if (angleDiff) {
-		if (angleDiff < -0x200) {
-			angleDiff += 0x400;
-		} else if (angleDiff > 0x200) {
-			angleDiff -= 0x400;
+		if (angleDiff < -ANGLE_180) {
+			angleDiff += ANGLE_360;
+		} else if (angleDiff > ANGLE_180) {
+			angleDiff -= ANGLE_360;
 		}
 
 		computedAngle = lastAngle + (angleDiff * bp) / bx;
@@ -260,7 +260,7 @@ bool Animations::setModelAnimation(int32 animState, const uint8 *animPtr, uint8
 		currentStepZ = READ_LE_INT16(keyFramePtr + 6);
 
 		processRotationByAnim = READ_LE_INT16(keyFramePtr + 8);
-		processLastRotationAngle = READ_LE_INT16(keyFramePtr + 12);
+		processLastRotationAngle = ToAngle(READ_LE_INT16(keyFramePtr + 12));
 
 		return true;
 	}
@@ -270,7 +270,7 @@ bool Animations::setModelAnimation(int32 animState, const uint8 *animPtr, uint8
 	keyFramePtr += 8;
 
 	processRotationByAnim = READ_LE_INT16(keyFramePtr);
-	processLastRotationAngle = (READ_LE_INT16(keyFramePtr + 4) * eax) / keyFrameLength;
+	processLastRotationAngle = ToAngle((READ_LE_INT16(keyFramePtr + 4) * eax) / keyFrameLength);
 
 	lastKeyFramePtr += 8;
 	keyFramePtr += 8;
@@ -421,7 +421,7 @@ int32 Animations::verifyAnimAtKeyframe(int32 animIdx, uint8 *animPtr, uint8 *bod
 		currentStepZ = READ_LE_INT16(keyFramePtr + 6);
 
 		processRotationByAnim = READ_LE_INT16(keyFramePtr + 8);
-		processLastRotationAngle = READ_LE_INT16(keyFramePtr + 12);
+		processLastRotationAngle = ToAngle(READ_LE_INT16(keyFramePtr + 12));
 
 		return 1;
 	}
@@ -431,7 +431,7 @@ int32 Animations::verifyAnimAtKeyframe(int32 animIdx, uint8 *animPtr, uint8 *bod
 	keyFramePtr += 8;
 
 	processRotationByAnim = READ_LE_INT16(keyFramePtr);
-	processLastRotationAngle = (READ_LE_INT16(keyFramePtr + 4) * eax) / keyFrameLength;
+	processLastRotationAngle = ToAngle((READ_LE_INT16(keyFramePtr + 4) * eax) / keyFrameLength);
 
 	lastKeyFramePtr += 8;
 	keyFramePtr += 8;
@@ -494,26 +494,26 @@ void Animations::processAnimActions(int32 actorIdx) {
 			const int32 animPos = stream.readByte();
 			const int32 yHeight = stream.readSint16LE();
 			const int32 sprite = stream.readByte();
-			const int32 cx = stream.readSint16LE();
-			const int32 dx = actor->angle + stream.readSint16LE();
-			const int32 var_24 = stream.readSint16LE();
-			const int32 var_14 = stream.readByte();
+			const int32 xAngle = ToAngle(stream.readSint16LE());
+			const int32 yAngle = actor->angle + ToAngle(stream.readSint16LE());
+			const int32 xRotPoint = stream.readSint16LE();
+			const int32 extraAngle = ToAngle(stream.readByte());
 			const int32 strengthOfHit = stream.readByte();
 
 			if (animPos == actor->animPosition) {
-				_engine->_extra->addExtraThrow(actorIdx, actor->x, actor->y + yHeight, actor->z, sprite, cx, dx, var_24, var_14, strengthOfHit);
+				_engine->_extra->addExtraThrow(actorIdx, actor->x, actor->y + yHeight, actor->z, sprite, xAngle, yAngle, xRotPoint, extraAngle, strengthOfHit);
 			}
 			break;
 		}
 		case ACTION_THROW_MAGIC_BALL: {
 			const int32 animPos = stream.readByte();
-			const int32 var_8 = stream.readSint16LE();
-			const int32 dx = stream.readSint16LE();
-			const int32 var_24 = stream.readSint16LE();
-			const int32 var_14 = stream.readByte();
+			const int32 yOffset = stream.readSint16LE();
+			const int32 xAngle = ToAngle(stream.readSint16LE());
+			const int32 xRotPoint = stream.readSint16LE();
+			const int32 extraAngle = stream.readByte();
 
 			if (_engine->_gameState->magicBallIdx == -1 && animPos == actor->animPosition) {
-				_engine->_extra->addExtraThrowMagicball(actor->x, actor->y + var_8, actor->z, dx, actor->angle, var_24, var_14);
+				_engine->_extra->addExtraThrowMagicball(actor->x, actor->y + yOffset, actor->z, xAngle, actor->angle, xRotPoint, extraAngle);
 			}
 			break;
 		}
@@ -532,13 +532,13 @@ void Animations::processAnimActions(int32 actorIdx) {
 			if (animPos == actor->animPosition) {
 				// TODO: The folowing fetches 7 bytes, but the else block skips only 6 bytes.
 				// Please check if that's correct.
-				const int32 var_8 = stream.readSint16LE();
+				const int32 yOffset = stream.readSint16LE();
 				const int32 spriteIdx = stream.readByte();
 				const int32 targetActorIdx = stream.readByte();
 				const int32 maxSpeed = stream.readSint16LE();
 				const int32 strengthOfHit = stream.readByte();
 
-				_engine->_extra->addExtraAiming(actorIdx, actor->x, actor->y + var_8, actor->z, spriteIdx, targetActorIdx, maxSpeed, strengthOfHit);
+				_engine->_extra->addExtraAiming(actorIdx, actor->x, actor->y + yOffset, actor->z, spriteIdx, targetActorIdx, maxSpeed, strengthOfHit);
 			} else {
 				stream.skip(6);
 			}
@@ -548,21 +548,21 @@ void Animations::processAnimActions(int32 actorIdx) {
 			const int32 animPos = stream.readByte();
 			const int32 yHeight = stream.readSint16LE();
 			const int32 spriteIdx = stream.readByte();
-			const int32 dx = stream.readSint16LE();
-			const int32 angle = actor->angle + stream.readSint16LE();
-			const int32 var_24 = stream.readSint16LE();
-			const int32 var_14 = stream.readByte();
+			const int32 xAngle = ToAngle(stream.readSint16LE());
+			const int32 yAngle = actor->angle + ToAngle(stream.readSint16LE());
+			const int32 xRotPoint = stream.readSint16LE();
+			const int32 extraAngle = ToAngle(stream.readByte());
 			const int32 strengthOfHit = stream.readByte();
 
 			if (animPos == actor->animPosition) {
-				_engine->_extra->addExtraThrow(actorIdx, actor->x, actor->y + yHeight, actor->z, spriteIdx, dx, angle, var_24, var_14, strengthOfHit);
+				_engine->_extra->addExtraThrow(actorIdx, actor->x, actor->y + yHeight, actor->z, spriteIdx, xAngle, yAngle, xRotPoint, extraAngle, strengthOfHit);
 			}
 			break;
 		}
 		case ACTION_SAMPLE_STOP: {
 			const int32 animPos = stream.readByte();
 			const int32 sampleIdx = stream.readByte(); //why is it reading a byte but saving it in a 32bit variable?
-			stream.skip(1);               //what is the meaning of this extra byte?
+			stream.skip(1);               // TODO what is the meaning of this extra byte?
 
 			if (animPos == actor->animPosition) {
 				_engine->_sound->stopSample(sampleIdx);
@@ -599,10 +599,10 @@ void Animations::processAnimActions(int32 actorIdx) {
 			const int32 distanceY = stream.readSint16LE();
 			const int32 distanceZ = stream.readSint16LE();
 			const int32 spriteIdx = stream.readByte();
-			const int32 param1 = stream.readSint16LE();
-			const int32 angle = stream.readSint16LE();
-			const int32 param3 = stream.readSint16LE();
-			const int32 param4 = stream.readByte();
+			const int32 xAngle = ToAngle(stream.readSint16LE());
+			const int32 yAngle = ToAngle(stream.readSint16LE());
+			const int32 xRotPoint = stream.readSint16LE();
+			const int32 extraAngle = ToAngle(stream.readByte());
 			const int32 strength = stream.readByte();
 
 			if (animPos == actor->animPosition) {
@@ -613,7 +613,7 @@ void Animations::processAnimActions(int32 actorIdx) {
 				const int32 throwZ = _engine->_renderer->destZ + actor->z;
 
 				_engine->_extra->addExtraThrow(actorIdx, throwX, throwY, throwZ, spriteIdx,
-				                               param1, angle + actor->angle, param3, param4, strength);
+				                               xAngle, yAngle + actor->angle, xRotPoint, extraAngle, strength);
 			}
 			break;
 		}
@@ -623,10 +623,10 @@ void Animations::processAnimActions(int32 actorIdx) {
 			const int32 distanceY = stream.readSint16LE();
 			const int32 distanceZ = stream.readSint16LE();
 			const int32 spriteIdx = stream.readByte();
-			const int32 param1 = stream.readSint16LE();
-			const int32 angle = stream.readSint16LE();
-			const int32 param3 = stream.readSint16LE();
-			const int32 param4 = stream.readByte();
+			const int32 xAngle = ToAngle(stream.readSint16LE());
+			const int32 yAngle = ToAngle(stream.readSint16LE());
+			const int32 xRotPoint = stream.readSint16LE();
+			const int32 extraAngle = ToAngle(stream.readByte());
 			const int32 strength = stream.readByte();
 
 			if (animPos == actor->animPosition) {
@@ -639,7 +639,7 @@ void Animations::processAnimActions(int32 actorIdx) {
 				const int32 throwZ = _engine->_renderer->destZ + actor->z;
 
 				_engine->_extra->addExtraThrow(actorIdx, throwX, throwY, throwZ, spriteIdx,
-				                               param1 + newAngle, angle + actor->angle, param3, param4, strength);
+				                               xAngle + newAngle, yAngle + actor->angle, xRotPoint, extraAngle, strength);
 			}
 			break;
 		}
@@ -650,13 +650,13 @@ void Animations::processAnimActions(int32 actorIdx) {
 			const int32 distanceZ = stream.readSint16LE();
 			const int32 spriteIdx = stream.readByte();
 			const int32 targetActor = stream.readByte();
-			const int32 maxSpeed = stream.readSint16LE();
+			const int32 finalAngle = ToAngle(stream.readSint16LE());
 			const int32 strengthOfHit = stream.readByte();
 
 			if (animPos == actor->animPosition) {
 				_engine->_movements->rotateActor(distanceX, distanceZ, actor->angle);
 				_engine->_extra->addExtraAiming(actorIdx, actor->x + _engine->_renderer->destX, actor->y + distanceY, actor->z + distanceZ, spriteIdx,
-				                                targetActor, maxSpeed, strengthOfHit);
+				                                targetActor, finalAngle, strengthOfHit);
 			}
 			break;
 		}
@@ -767,16 +767,16 @@ void Animations::processActorAnimations(int32 actorIdx) { // DoAnim
 
 		if (!actor->dynamicFlags.bIsFalling) {
 			if (actor->speed) {
-				int32 angle = _engine->_movements->getRealValue(&actor->move);
-				if (!angle) {
+				int32 xAxisRotation = _engine->_movements->getRealValue(&actor->move);
+				if (!xAxisRotation) {
 					if (actor->move.to > 0) {
-						angle = 1;
+						xAxisRotation = 1;
 					} else {
-						angle = -1;
+						xAxisRotation = -1;
 					}
 				}
 
-				_engine->_movements->rotateActor(angle, 0, actor->animType);
+				_engine->_movements->rotateActor(xAxisRotation, 0, actor->animType);
 
 				_engine->_movements->processActorY = actor->y - _engine->_renderer->destZ;
 
@@ -785,18 +785,18 @@ void Animations::processActorAnimations(int32 actorIdx) { // DoAnim
 				_engine->_movements->processActorX = actor->x + _engine->_renderer->destX;
 				_engine->_movements->processActorZ = actor->z + _engine->_renderer->destZ;
 
-				_engine->_movements->setActorAngle(0, actor->speed, 50, &actor->move);
+				_engine->_movements->setActorAngle(ANGLE_0, actor->speed, 50, &actor->move);
 
 				if (actor->dynamicFlags.bIsSpriteMoving) {
 					if (actor->doorStatus) { // open door
 						if (_engine->_movements->getDistance2D(_engine->_movements->processActorX, _engine->_movements->processActorZ, actor->lastX, actor->lastZ) >= actor->doorStatus) {
-							if (actor->angle == 0) {
+							if (actor->angle == ANGLE_0) {
 								_engine->_movements->processActorZ = actor->lastZ + actor->doorStatus;
-							} else if (actor->angle == 0x100) {
+							} else if (actor->angle == ANGLE_90) {
 								_engine->_movements->processActorX = actor->lastX + actor->doorStatus;
-							} else if (actor->angle == 0x200) {
+							} else if (actor->angle == ANGLE_180) {
 								_engine->_movements->processActorZ = actor->lastZ - actor->doorStatus;
-							} else if (actor->angle == 0x300) {
+							} else if (actor->angle == ANGLE_270) {
 								_engine->_movements->processActorX = actor->lastX - actor->doorStatus;
 							}
 
@@ -804,23 +804,23 @@ void Animations::processActorAnimations(int32 actorIdx) { // DoAnim
 							actor->speed = 0;
 						}
 					} else { // close door
-						int16 updatePos = 0;
+						bool updatePos = false;
 
-						if (actor->angle == 0) {
+						if (actor->angle == ANGLE_0) {
 							if (_engine->_movements->processActorZ <= actor->lastZ) {
-								updatePos = 1;
+								updatePos = true;
 							}
-						} else if (actor->angle == 256) {
+						} else if (actor->angle == ANGLE_90) {
 							if (_engine->_movements->processActorX <= actor->lastX) {
-								updatePos = 1;
+								updatePos = true;
 							}
-						} else if (actor->angle == 512) {
+						} else if (actor->angle == ANGLE_180) {
 							if (_engine->_movements->processActorZ >= actor->lastZ) {
-								updatePos = 1;
+								updatePos = true;
 							}
-						} else if (actor->angle == 768) {
+						} else if (actor->angle == ANGLE_270) {
 							if (_engine->_movements->processActorX >= actor->lastX) {
-								updatePos = 1;
+								updatePos = true;
 							}
 						}
 
@@ -853,10 +853,9 @@ void Animations::processActorAnimations(int32 actorIdx) { // DoAnim
 		}
 	} else { // 3D actor
 		if (actor->previousAnimIdx != -1) {
-			int32 keyFramePassed;
 			uint8 *animPtr = _engine->_resources->animTable[actor->previousAnimIdx];
 
-			keyFramePassed = verifyAnimAtKeyframe(actor->animPosition, animPtr, _engine->_actor->bodyTable[actor->entity], &actor->animTimerData);
+			int32 keyFramePassed = verifyAnimAtKeyframe(actor->animPosition, animPtr, _engine->_actor->bodyTable[actor->entity], &actor->animTimerData);
 
 			if (processRotationByAnim) {
 				actor->dynamicFlags.bIsRotationByAnim = 1;
@@ -995,7 +994,7 @@ void Animations::processActorAnimations(int32 actorIdx) { // DoAnim
 
 		// process wall hit while running
 		if (_engine->_collision->causeActorDamage && !actor->dynamicFlags.bIsFalling && !currentlyProcessedActorIdx && _engine->_actor->heroBehaviour == HeroBehaviourType::kAthletic && actor->anim == AnimationTypes::kForward) {
-			_engine->_movements->rotateActor(actor->boudingBox.x.bottomLeft, actor->boudingBox.z.bottomLeft, actor->angle + 0x580);
+			_engine->_movements->rotateActor(actor->boudingBox.x.bottomLeft, actor->boudingBox.z.bottomLeft, actor->angle + ANGLE_360 + ANGLE_135);
 
 			_engine->_renderer->destX += _engine->_movements->processActorX;
 			_engine->_renderer->destZ += _engine->_movements->processActorZ;
diff --git a/engines/twine/animations.h b/engines/twine/animations.h
index 1e41850189..116b145fda 100644
--- a/engines/twine/animations.h
+++ b/engines/twine/animations.h
@@ -53,7 +53,7 @@ private:
 	/** Rotation by anim and not by engine */
 	int16 processRotationByAnim = 0; // processActorVar5
 	/** Last rotation angle */
-	int16 processLastRotationAngle = 0; // processActorVar6
+	int16 processLastRotationAngle = ANGLE_0; // processActorVar6
 
 	/** Current step X coornidate */
 	int16 currentStepX = 0;
diff --git a/engines/twine/collision.cpp b/engines/twine/collision.cpp
index b5443b6d15..08de2c3a86 100644
--- a/engines/twine/collision.cpp
+++ b/engines/twine/collision.cpp
@@ -371,7 +371,7 @@ int32 Collision::checkCollisionWithActors(int32 actorIdx) {
 				const int32 zRightTest = actorTest->z + actorTest->boudingBox.z.topRight;
 
 				if (xLeft < xRightTest && xRight > xLeftTest && yLeft < yRightTest && yRight > yLeftTest && zLeft < zRightTest && zRight > zLeftTest) {
-					_engine->_actor->hitActor(actorIdx, a, actor->strengthOfHit, actor->angle + 0x200);
+					_engine->_actor->hitActor(actorIdx, a, actor->strengthOfHit, actor->angle + ANGLE_90);
 					actor->dynamicFlags.bIsHitting = 0;
 				}
 			}
diff --git a/engines/twine/extra.cpp b/engines/twine/extra.cpp
index 3aab81ff8b..44bc8cb3c9 100644
--- a/engines/twine/extra.cpp
+++ b/engines/twine/extra.cpp
@@ -122,7 +122,7 @@ int32 Extra::addExtra(int32 actorIdx, int32 x, int32 y, int32 z, int32 spriteIdx
 		extra->destZ = maxSpeed;
 		extra->strengthOfHit = strengthOfHit;
 
-		_engine->_movements->setActorAngle(0, maxSpeed, 50, &extra->trackActorMove);
+		_engine->_movements->setActorAngle(ANGLE_0, maxSpeed, 50, &extra->trackActorMove);
 		const ActorStruct *actor = _engine->_scene->getActor(targetActor);
 		extra->angle = _engine->_movements->getAngleAndSetTargetActorDistance(x, z, actor->x, actor->z);
 		return i;
@@ -158,23 +158,23 @@ void Extra::resetExtras() {
 	}
 }
 
-void Extra::throwExtra(ExtraListStruct *extra, int32 var1, int32 angle, int32 var3, int32 var4) { // InitFly
+void Extra::throwExtra(ExtraListStruct *extra, int32 xAngle, int32 yAngle, int32 x, int32 extraAngle) { // InitFly
 	extra->type |= 2;
 
 	extra->lastX = extra->x;
 	extra->lastY = extra->y;
 	extra->lastZ = extra->z;
 
-	_engine->_movements->rotateActor(var3, 0, var1);
+	_engine->_movements->rotateActor(x, 0, xAngle);
 
 	extra->destY = -_engine->_renderer->destZ;
 
-	_engine->_movements->rotateActor(0, _engine->_renderer->destX, angle);
+	_engine->_movements->rotateActor(0, _engine->_renderer->destX, yAngle);
 
 	extra->destX = _engine->_renderer->destX;
 	extra->destZ = _engine->_renderer->destZ;
 
-	extra->angle = var4;
+	extra->angle = extraAngle;
 	extra->lifeTime = _engine->lbaTime;
 }
 
@@ -197,7 +197,7 @@ void Extra::addExtraSpecial(int32 x, int32 y, int32 z, ExtraSpecialType type) {
 			extra->z = z;
 
 			// same as InitFly
-			throwExtra(extra, _engine->getRandomNumber(256) + 128, _engine->getRandomNumber(1024), 50, 20);
+			throwExtra(extra, _engine->getRandomNumber(ANGLE_90) + ANGLE_45, _engine->getRandomNumber(ANGLE_360), 50, 20);
 
 			extra->strengthOfHit = 0;
 			extra->lifeTime = _engine->lbaTime;
@@ -253,7 +253,7 @@ int Extra::getBonusSprite(BonusParameter bonusParameter) const {
 	return bonusSprite;
 }
 
-int32 Extra::addExtraBonus(int32 x, int32 y, int32 z, int32 param, int32 angle, int32 type, int32 bonusAmount) { // ExtraBonus
+int32 Extra::addExtraBonus(int32 x, int32 y, int32 z, int32 xAngle, int32 yAngle, int32 type, int32 bonusAmount) { // ExtraBonus
 	for (int32 i = 0; i < EXTRA_MAX_ENTRIES; i++) {
 		ExtraListStruct *extra = &extraList[i];
 		if (extra->info0 != -1) {
@@ -271,7 +271,7 @@ int32 Extra::addExtraBonus(int32 x, int32 y, int32 z, int32 param, int32 angle,
 		extra->z = z;
 
 		// same as InitFly
-		throwExtra(extra, param, angle, 40, 15);
+		throwExtra(extra, xAngle, yAngle, 40, ToAngle(15));
 
 		extra->strengthOfHit = 0;
 		extra->lifeTime = _engine->lbaTime;
@@ -283,7 +283,7 @@ int32 Extra::addExtraBonus(int32 x, int32 y, int32 z, int32 param, int32 angle,
 	return -1;
 }
 
-int32 Extra::addExtraThrow(int32 actorIdx, int32 x, int32 y, int32 z, int32 spriteIdx, int32 var2, int32 angle, int32 var4, int32 var5, int32 strengthOfHit) { // ThrowExtra
+int32 Extra::addExtraThrow(int32 actorIdx, int32 x, int32 y, int32 z, int32 spriteIdx, int32 xAngle, int32 yAngle, int32 xRotPoint, int32 extraAngle, int32 strengthOfHit) { // ThrowExtra
 	for (int32 i = 0; i < EXTRA_MAX_ENTRIES; i++) {
 		ExtraListStruct *extra = &extraList[i];
 		if (extra->info0 != -1) {
@@ -296,7 +296,7 @@ int32 Extra::addExtraThrow(int32 actorIdx, int32 x, int32 y, int32 z, int32 spri
 		extra->z = z;
 
 		// same as InitFly
-		throwExtra(extra, var2, angle, var4, var5);
+		throwExtra(extra, xAngle, yAngle, xRotPoint, extraAngle);
 
 		extra->strengthOfHit = strengthOfHit;
 		extra->lifeTime = _engine->lbaTime;
@@ -309,7 +309,7 @@ int32 Extra::addExtraThrow(int32 actorIdx, int32 x, int32 y, int32 z, int32 spri
 	return -1;
 }
 
-int32 Extra::addExtraAiming(int32 actorIdx, int32 x, int32 y, int32 z, int32 spriteIdx, int32 targetActorIdx, int32 maxSpeed, int32 strengthOfHit) { // ExtraSearch
+int32 Extra::addExtraAiming(int32 actorIdx, int32 x, int32 y, int32 z, int32 spriteIdx, int32 targetActorIdx, int32 finalAngle, int32 strengthOfHit) { // ExtraSearch
 	for (int32 i = 0; i < EXTRA_MAX_ENTRIES; i++) {
 		ExtraListStruct *extra = &extraList[i];
 		if (extra->info0 != -1) {
@@ -323,9 +323,9 @@ int32 Extra::addExtraAiming(int32 actorIdx, int32 x, int32 y, int32 z, int32 spr
 		extra->z = z;
 		extra->actorIdx = actorIdx;
 		extra->lifeTime = targetActorIdx;
-		extra->destZ = maxSpeed;
+		extra->destZ = finalAngle;
 		extra->strengthOfHit = strengthOfHit;
-		_engine->_movements->setActorAngle(0, maxSpeed, 50, &extra->trackActorMove);
+		_engine->_movements->setActorAngle(ANGLE_0, finalAngle, 50, &extra->trackActorMove);
 		const ActorStruct *actor = _engine->_scene->getActor(targetActorIdx);
 		extra->angle = _engine->_movements->getAngleAndSetTargetActorDistance(x, z, actor->x, actor->z);
 
@@ -361,9 +361,9 @@ int32 Extra::addExtraAimingAtKey(int32 actorIdx, int32 x, int32 y, int32 z, int3
 		extra->y = y;
 		extra->z = z;
 		extra->actorIdx = extraIdx;
-		extra->destZ = 0x0FA0;
+		extra->destZ = 4000;
 		extra->strengthOfHit = 0;
-		_engine->_movements->setActorAngle(0, 0x0FA0, 50, &extra->trackActorMove);
+		_engine->_movements->setActorAngle(ANGLE_0, 4000, 50, &extra->trackActorMove);
 		extra->angle = _engine->_movements->getAngleAndSetTargetActorDistance(x, z, extraList[extraIdx].x, extraList[extraIdx].z);
 
 		return i;
@@ -372,7 +372,7 @@ int32 Extra::addExtraAimingAtKey(int32 actorIdx, int32 x, int32 y, int32 z, int3
 	return -1;
 }
 
-void Extra::addExtraThrowMagicball(int32 x, int32 y, int32 z, int32 param1, int32 angle, int32 param2, int32 param3) { // ThrowMagicBall
+void Extra::addExtraThrowMagicball(int32 x, int32 y, int32 z, int32 xAngle, int32 yAngle, int32 xRotPoint, int32 extraAngle) { // ThrowMagicBall
 	int32 ballSprite = -1;
 	int32 ballStrength = 0;
 	int32 extraIdx = -1;
@@ -410,21 +410,21 @@ void Extra::addExtraThrowMagicball(int32 x, int32 y, int32 z, int32 param1, int3
 
 	switch (_engine->_gameState->magicBallNumBounce) {
 	case 0:
-		_engine->_gameState->magicBallIdx = addExtraThrow(0, x, y, z, ballSprite, param1, angle, param2, param3, ballStrength);
+		_engine->_gameState->magicBallIdx = addExtraThrow(OWN_ACTOR_SCENE_INDEX, x, y, z, ballSprite, xAngle, yAngle, xRotPoint, extraAngle, ballStrength);
 		break;
 	case 1:
 		_engine->_gameState->magicBallAuxBounce = 4;
-		_engine->_gameState->magicBallIdx = addExtraThrow(0, x, y, z, ballSprite, param1, angle, param2, param3, ballStrength);
+		_engine->_gameState->magicBallIdx = addExtraThrow(OWN_ACTOR_SCENE_INDEX, x, y, z, ballSprite, xAngle, yAngle, xRotPoint, extraAngle, ballStrength);
 		break;
 	case 2:
 	case 3:
 	case 4:
 		_engine->_gameState->magicBallNumBounce = 1;
 		_engine->_gameState->magicBallAuxBounce = 4;
-		_engine->_gameState->magicBallIdx = addExtraThrow(0, x, y, z, ballSprite, param1, angle, param2, param3, ballStrength);
+		_engine->_gameState->magicBallIdx = addExtraThrow(OWN_ACTOR_SCENE_INDEX, x, y, z, ballSprite, xAngle, yAngle, xRotPoint, extraAngle, ballStrength);
 		break;
 	case 5:
-		_engine->_gameState->magicBallIdx = addExtraAimingAtKey(0, x, y, z, ballSprite, extraIdx);
+		_engine->_gameState->magicBallIdx = addExtraAimingAtKey(OWN_ACTOR_SCENE_INDEX, x, y, z, ballSprite, extraIdx);
 		break;
 	}
 
@@ -436,15 +436,15 @@ void Extra::addExtraThrowMagicball(int32 x, int32 y, int32 z, int32 param1, int3
 void Extra::drawSpecialShape(const int16 *shapeTable, int32 x, int32 y, int32 color, int32 angle, int32 size) {
 	int16 currentShapeTable = *(shapeTable++);
 
-	int16 var_8 = ((*(shapeTable++)) * size) >> 4;
-	int16 temp1 = ((*(shapeTable++)) * size) >> 4;
+	int16 var_x = ((*(shapeTable++)) * size) >> 4;
+	int16 var_z = ((*(shapeTable++)) * size) >> 4;
 
 	_engine->_redraw->renderLeft = 0x7D00;
 	_engine->_redraw->renderRight = -0x7D00;
 	_engine->_redraw->renderTop = 0x7D00;
 	_engine->_redraw->renderBottom = -0x7D00;
 
-	_engine->_movements->rotateActor(var_8, temp1, angle);
+	_engine->_movements->rotateActor(var_x, var_z, angle);
 
 	int32 computedX = _engine->_renderer->destX + x;
 	int32 computedY = _engine->_renderer->destZ + y;
@@ -471,8 +471,8 @@ void Extra::drawSpecialShape(const int16 *shapeTable, int32 x, int32 y, int32 co
 	int32 currentY = computedY;
 
 	while (numEntries < currentShapeTable) {
-		var_8 = ((*(shapeTable++)) * size) >> 4;
-		temp1 = ((*(shapeTable++)) * size) >> 4;
+		var_x = ((*(shapeTable++)) * size) >> 4;
+		var_z = ((*(shapeTable++)) * size) >> 4;
 
 		int32 oldComputedX = currentX;
 		int32 oldComputedY = currentY;
@@ -480,7 +480,7 @@ void Extra::drawSpecialShape(const int16 *shapeTable, int32 x, int32 y, int32 co
 		_engine->_renderer->projPosX = currentX;
 		_engine->_renderer->projPosY = currentY;
 
-		_engine->_movements->rotateActor(var_8, temp1, angle);
+		_engine->_movements->rotateActor(var_x, var_z, angle);
 
 		currentX = _engine->_renderer->destX + x;
 		currentY = _engine->_renderer->destZ + y;
@@ -673,7 +673,7 @@ void Extra::processExtras() {
 			extra->x += _engine->_renderer->destX;
 			extra->z += _engine->_renderer->destZ;
 
-			_engine->_movements->setActorAngle(0, extra->destZ, 50, &extra->trackActorMove);
+			_engine->_movements->setActorAngle(ANGLE_0, extra->destZ, 50, &extra->trackActorMove);
 
 			if (actorIdxAttacked == _engine->_collision->checkExtraCollisionWithActors(extra, actorIdx)) {
 				if (i == _engine->_gameState->magicBallIdx) {
@@ -693,7 +693,7 @@ void Extra::processExtras() {
 			int32 tmpAngle = _engine->_movements->getAngleAndSetTargetActorDistance(extra->x, extra->z, extraKey->x, extraKey->z);
 			int32 angle = ClampAngle(tmpAngle - extra->angle);
 
-			if (angle > 400 && angle < 600) {
+			if (angle > ToAngle(400) && angle < ToAngle(600)) {
 				_engine->_sound->playSample(Samples::ItemFound, 4096, 1, _engine->_scene->sceneHero->x, _engine->_scene->sceneHero->y, _engine->_scene->sceneHero->z, 0);
 
 				if (extraKey->info1 > 1) {
diff --git a/engines/twine/extra.h b/engines/twine/extra.h
index 8d0023de76..f7ce14229d 100644
--- a/engines/twine/extra.h
+++ b/engines/twine/extra.h
@@ -59,7 +59,7 @@ class Extra {
 private:
 	TwinEEngine *_engine;
 
-	void throwExtra(ExtraListStruct *extra, int32 var1, int32 angle, int32 var3, int32 var4);
+	void throwExtra(ExtraListStruct *extra, int32 xAngle, int32 yAngle, int32 x, int32 extraAngle);
 	void processMagicballBounce(ExtraListStruct *extra, int32 x, int32 y, int32 z);
 	int32 findExtraKey();
 	int32 addExtraAimingAtKey(int32 actorIdx, int32 x, int32 y, int32 z, int32 spriteIdx, int32 extraIdx);
@@ -73,9 +73,9 @@ public:
 
 	/**
 	 * Add extra explosion
-	 * @param x Explostion X coordinate
-	 * @param y Explostion Y coordinate
-	 * @param z Explostion Z coordinate
+	 * @param x Explosion X coordinate
+	 * @param y Explosion Y coordinate
+	 * @param z Explosion Z coordinate
 	 */
 	int32 addExtraExplode(int32 x, int32 y, int32 z);
 
@@ -83,10 +83,10 @@ public:
 	void resetExtras();
 
 	void addExtraSpecial(int32 x, int32 y, int32 z, ExtraSpecialType type);
-	int32 addExtraBonus(int32 x, int32 y, int32 z, int32 param, int32 angle, int32 type, int32 bonusAmount);
-	int32 addExtraThrow(int32 actorIdx, int32 x, int32 y, int32 z, int32 spriteIdx, int32 var2, int32 angle, int32 var4, int32 var5, int32 strengthOfHit);
-	int32 addExtraAiming(int32 actorIdx, int32 x, int32 y, int32 z, int32 spriteIdx, int32 targetActorIdx, int32 maxSpeed, int32 strengthOfHit);
-	void addExtraThrowMagicball(int32 x, int32 y, int32 z, int32 param1, int32 angle, int32 param2, int32 param3);
+	int32 addExtraBonus(int32 x, int32 y, int32 z, int32 xAngle, int32 yAngle, int32 type, int32 bonusAmount);
+	int32 addExtraThrow(int32 actorIdx, int32 x, int32 y, int32 z, int32 spriteIdx, int32 xAngle, int32 yAngle, int32 xRotPoint, int32 extraAngle, int32 strengthOfHit);
+	int32 addExtraAiming(int32 actorIdx, int32 x, int32 y, int32 z, int32 spriteIdx, int32 targetActorIdx, int32 finalAngle, int32 strengthOfHit);
+	void addExtraThrowMagicball(int32 x, int32 y, int32 z, int32 xAngle, int32 yAngle, int32 xRotPoint, int32 extraAngle);
 
 	void drawExtraSpecial(int32 extraIdx, int32 x, int32 y);
 
diff --git a/engines/twine/gamestate.cpp b/engines/twine/gamestate.cpp
index 42689889a3..8568be93f5 100644
--- a/engines/twine/gamestate.cpp
+++ b/engines/twine/gamestate.cpp
@@ -41,6 +41,7 @@
 #include "twine/resources.h"
 #include "twine/scene.h"
 #include "twine/screens.h"
+#include "twine/shared.h"
 #include "twine/sound.h"
 #include "twine/text.h"
 #include "twine/twine.h"
@@ -191,7 +192,7 @@ bool GameState::loadGame(Common::SeekableReadStream *file) {
 	_engine->_scene->newHeroX = file->readSint16LE();
 	_engine->_scene->newHeroY = file->readSint16LE();
 	_engine->_scene->newHeroZ = file->readSint16LE();
-	_engine->_scene->sceneHero->angle = file->readSint16LE();
+	_engine->_scene->sceneHero->angle = ToAngle(file->readSint16LE());
 	_engine->_actor->previousHeroAngle = _engine->_scene->sceneHero->angle;
 	_engine->_scene->sceneHero->body = file->readByte();
 
@@ -240,7 +241,7 @@ bool GameState::saveGame(Common::WriteStream *file) {
 	file->writeSint16LE(_engine->_scene->sceneHero->x);
 	file->writeSint16LE(_engine->_scene->sceneHero->y);
 	file->writeSint16LE(_engine->_scene->sceneHero->z);
-	file->writeSint16LE(_engine->_scene->sceneHero->angle);
+	file->writeSint16LE(FromAngle(_engine->_scene->sceneHero->angle));
 	file->writeByte(_engine->_scene->sceneHero->body);
 
 	// number of holomap locations
diff --git a/engines/twine/menu.cpp b/engines/twine/menu.cpp
index e29800b458..60321505d5 100644
--- a/engines/twine/menu.cpp
+++ b/engines/twine/menu.cpp
@@ -880,7 +880,7 @@ void Menu::processBehaviourMenu() {
 	_engine->_actor->heroAnimIdx[(byte)HeroBehaviourType::kAggressive] = _engine->_actor->heroAnimIdxAGGRESSIVE;
 	_engine->_actor->heroAnimIdx[(byte)HeroBehaviourType::kDiscrete] = _engine->_actor->heroAnimIdxDISCRETE;
 
-	_engine->_movements->setActorAngleSafe(_engine->_scene->sceneHero->angle, _engine->_scene->sceneHero->angle - 256, 50, &moveMenu);
+	_engine->_movements->setActorAngleSafe(_engine->_scene->sceneHero->angle, _engine->_scene->sceneHero->angle - ANGLE_90, 50, &moveMenu);
 
 	_engine->_screens->copyScreen(_engine->frontVideoBuffer, _engine->workVideoBuffer);
 
@@ -918,7 +918,7 @@ void Menu::processBehaviourMenu() {
 		if (tmpHeroBehaviour != _engine->_actor->heroBehaviour) {
 			drawBehaviour(tmpHeroBehaviour, _engine->_scene->sceneHero->angle, 1);
 			tmpHeroBehaviour = _engine->_actor->heroBehaviour;
-			_engine->_movements->setActorAngleSafe(_engine->_scene->sceneHero->angle, _engine->_scene->sceneHero->angle - 256, 50, &moveMenu);
+			_engine->_movements->setActorAngleSafe(_engine->_scene->sceneHero->angle, _engine->_scene->sceneHero->angle - ANGLE_90, 50, &moveMenu);
 			_engine->_animations->setAnimAtKeyframe(behaviourAnimState[(byte)_engine->_actor->heroBehaviour], _engine->_resources->animTable[_engine->_actor->heroAnimIdx[(byte)_engine->_actor->heroBehaviour]], behaviourEntity, &behaviourAnimData[(byte)_engine->_actor->heroBehaviour]);
 		}
 
diff --git a/engines/twine/movements.cpp b/engines/twine/movements.cpp
index 6c2a60db49..d0c08e713f 100644
--- a/engines/twine/movements.cpp
+++ b/engines/twine/movements.cpp
@@ -64,7 +64,7 @@ void Movements::setActorAngleSafe(int16 startAngle, int16 endAngle, int16 stepAn
 }
 
 void Movements::clearRealAngle(ActorStruct *actorPtr) {
-	setActorAngleSafe(actorPtr->angle, actorPtr->angle, 0, &actorPtr->move);
+	setActorAngleSafe(actorPtr->angle, actorPtr->angle, ANGLE_0, &actorPtr->move);
 }
 
 void Movements::setActorAngle(int16 startAngle, int16 endAngle, int16 stepAngle, ActorMoveStruct *movePtr) {
@@ -114,7 +114,7 @@ int32 Movements::getAngleAndSetTargetActorDistance(int32 x1, int32 z1, int32 x2,
 
 	const int32 destAngle = (difZ << 14) / targetActorDistance;
 
-	int32 startAngle = 0;
+	int32 startAngle = ANGLE_0;
 	//	stopAngle  = 0x100;
 
 	while (_engine->_renderer->shadeAngleTab3[startAngle] > destAngle) {
@@ -127,14 +127,14 @@ int32 Movements::getAngleAndSetTargetActorDistance(int32 x1, int32 z1, int32 x2,
 		}
 	}
 
-	int32 finalAngle = 128 + startAngle;
+	int32 finalAngle = ANGLE_45 + startAngle;
 
 	if (difX <= 0) {
 		finalAngle = -finalAngle;
 	}
 
 	if (flag) {
-		finalAngle = -finalAngle + 0x100;
+		finalAngle = -finalAngle + ANGLE_90;
 	}
 
 	return ClampAngle(finalAngle);
@@ -149,14 +149,7 @@ int32 Movements::getRealAngle(ActorMoveStruct *movePtr) {
 			return movePtr->to;
 		}
 
-		int32 remainingAngle = movePtr->to - movePtr->from;
-
-		if (remainingAngle < -0x200) {
-			remainingAngle += 0x400;
-		} else if (remainingAngle > 0x200) {
-			remainingAngle -= 0x400;
-		}
-
+		int32 remainingAngle = NormalizeAngle(movePtr->to - movePtr->from);
 		remainingAngle *= timePassed;
 		remainingAngle /= movePtr->numOfStep;
 		remainingAngle += movePtr->from;
@@ -185,7 +178,7 @@ int32 Movements::getRealValue(ActorMoveStruct *movePtr) {
 }
 
 void Movements::rotateActor(int32 x, int32 z, int32 angle) {
-	const double radians = 2 * M_PI * angle / 0x400;
+	const double radians = AngleToRadians(angle);
 	_engine->_renderer->destX = (int32)(x * cos(radians) + z * sin(radians));
 	_engine->_renderer->destZ = (int32)(-x * sin(radians) + z * cos(radians));
 }
@@ -206,14 +199,7 @@ void Movements::moveActor(int32 angleFrom, int32 angleTo, int32 speed, ActorMove
 	movePtr->to = to;
 
 	const int16 numOfStep = (from - to) << 6;
-
-	int32 numOfStepInt;
-	if (numOfStep < 0) {
-		numOfStepInt = -numOfStep;
-	} else {
-		numOfStepInt = numOfStep;
-	}
-
+	int32 numOfStepInt = ABS(numOfStep);
 	numOfStepInt >>= 6;
 
 	numOfStepInt *= speed;
@@ -359,11 +345,11 @@ void Movements::processManualAction(int actorIdx) {
 
 	int16 tempAngle;
 	if (_engine->_input->isActionActive(TwinEActionType::TurnLeft)) {
-		tempAngle = 0x100;
+		tempAngle = ANGLE_90;
 	} else if (_engine->_input->isActionActive(TwinEActionType::TurnRight)) {
-		tempAngle = -0x100;
+		tempAngle = -ANGLE_90;
 	} else {
-		tempAngle = 0;
+		tempAngle = ANGLE_0;
 	}
 
 	moveActor(actor->angle, actor->angle + tempAngle, actor->speed, &actor->move);
@@ -390,7 +376,7 @@ void Movements::processRandomAction(int actorIdx) {
 	}
 
 	if (actor->brickCausesDamage()) {
-		moveActor(actor->angle, ClampAngle((_engine->getRandomNumber() & 0x100) + (actor->angle - 0x100)), actor->speed, &actor->move);
+		moveActor(actor->angle, ClampAngle((_engine->getRandomNumber() & ANGLE_90) + (actor->angle - ANGLE_90)), actor->speed, &actor->move);
 		actor->delayInMillis = _engine->getRandomNumber(300) + _engine->lbaTime + 300;
 		_engine->_animations->initAnim(AnimationTypes::kStanding, 0, AnimationTypes::kAnimInvalid, actorIdx);
 	}
@@ -398,7 +384,7 @@ void Movements::processRandomAction(int actorIdx) {
 	if (!actor->move.numOfStep) {
 		_engine->_animations->initAnim(AnimationTypes::kForward, 0, AnimationTypes::kAnimInvalid, actorIdx);
 		if (_engine->lbaTime > actor->delayInMillis) {
-			moveActor(actor->angle, ClampAngle((_engine->getRandomNumber() & 0x100) + (actor->angle - 0x100)), actor->speed, &actor->move);
+			moveActor(actor->angle, ClampAngle((_engine->getRandomNumber() & ANGLE_90) + (actor->angle - ANGLE_90)), actor->speed, &actor->move);
 			actor->delayInMillis = _engine->getRandomNumber(300) + _engine->lbaTime + 300;
 		}
 	}
@@ -429,11 +415,11 @@ void Movements::processActorMovements(int32 actorIdx) {
 			return;
 		}
 
-		int16 tempAngle = 0;
+		int16 tempAngle = ANGLE_0;
 		if (_engine->_input->isActionActive(TwinEActionType::TurnLeft)) {
-			tempAngle = 0x100;
+			tempAngle = ANGLE_90;
 		} else if (_engine->_input->isActionActive(TwinEActionType::TurnRight)) {
-			tempAngle = -0x100;
+			tempAngle = -ANGLE_90;
 		}
 
 		moveActor(actor->angle, actor->angle + tempAngle, actor->speed, &actor->move);
diff --git a/engines/twine/redraw.cpp b/engines/twine/redraw.cpp
index 929d24bd6b..fba1941160 100644
--- a/engines/twine/redraw.cpp
+++ b/engines/twine/redraw.cpp
@@ -726,7 +726,7 @@ void Redraw::redrawEngineActions(int32 bgRedraw) { // fullRedraw
 	}
 
 	if (_engine->zoomScreen) {
-		//zoomScreenScale();
+		zoomScreenScale();
 	}
 }
 
@@ -766,10 +766,11 @@ void Redraw::drawBubble(int32 actorIdx) {
 }
 
 void Redraw::zoomScreenScale() {
+#if 0
+	// TODO: this is broken
 	Graphics::ManagedSurface zoomWorkVideoBuffer;
 	zoomWorkVideoBuffer.copyFrom(_engine->workVideoBuffer);
 
-	// TODO: this is broken
 	const uint8 *src = (const uint8 *)zoomWorkVideoBuffer.getPixels();
 	uint8 *dest = (uint8 *)_engine->workVideoBuffer.getPixels();
 	for (int h = 0; h < zoomWorkVideoBuffer.h; h++) {
@@ -782,6 +783,7 @@ void Redraw::zoomScreenScale() {
 	}
 	_engine->_screens->copyScreen(_engine->workVideoBuffer, _engine->frontVideoBuffer);
 	zoomWorkVideoBuffer.free();
+#endif
 }
 
 } // namespace TwinE
diff --git a/engines/twine/redraw.h b/engines/twine/redraw.h
index f352319165..0b595f9574 100644
--- a/engines/twine/redraw.h
+++ b/engines/twine/redraw.h
@@ -99,7 +99,7 @@ private:
 	 * @param listSize number of drawing objects in the list
 	 */
 	void sortDrawingList(DrawListStruct *list, int32 listSize);
-	void updateOverlayTypePosition(int16 X1, int16 Y1, int16 X2, int16 Y2);
+	void updateOverlayTypePosition(int16 x1, int16 y1, int16 x2, int16 y2);
 
 public:
 	Redraw(TwinEEngine *engine) : _engine(engine) {}
@@ -129,7 +129,7 @@ public:
 
 	OverlayListStruct overlayList[OVERLAY_MAX_ENTRIES];
 
-	void addOverlay(int16 type, int16 info0, int16 X, int16 Y, int16 info1, int16 posType, int16 lifeTime);
+	void addOverlay(int16 type, int16 info0, int16 x, int16 y, int16 info1, int16 posType, int16 lifeTime);
 
 	/**
 	 * Add a certain region to redraw list array
diff --git a/engines/twine/renderer.cpp b/engines/twine/renderer.cpp
index 42f04e07ba..0761320838 100644
--- a/engines/twine/renderer.cpp
+++ b/engines/twine/renderer.cpp
@@ -1702,7 +1702,7 @@ void Renderer::renderBehaviourModel(int32 boxLeft, int32 boxTop, int32 boxRight,
 	if (angle == -1) {
 		const int16 newAngle = _engine->_movements->getRealAngle(&_engine->_menu->moveMenu);
 		if (_engine->_menu->moveMenu.numOfStep == 0) {
-			_engine->_movements->setActorAngleSafe(newAngle, newAngle - 256, 50, &_engine->_menu->moveMenu);
+			_engine->_movements->setActorAngleSafe(newAngle, newAngle - ANGLE_90, 50, &_engine->_menu->moveMenu);
 		}
 		renderIsoModel(0, y, 0, 0, newAngle, 0, entityPtr);
 	} else {
diff --git a/engines/twine/scene.cpp b/engines/twine/scene.cpp
index 1fd03fadc5..95b42ad2a7 100644
--- a/engines/twine/scene.cpp
+++ b/engines/twine/scene.cpp
@@ -533,12 +533,12 @@ void Scene::processActorZones(int32 actorIdx) {
 				break;
 			case kLadder:
 				if (IS_HERO(actorIdx) && _engine->_actor->heroBehaviour != HeroBehaviourType::kProtoPack && (actor->anim == AnimationTypes::kForward || actor->anim == AnimationTypes::kTopLadder || actor->anim == AnimationTypes::kClimbLadder)) {
-					_engine->_movements->rotateActor(actor->boudingBox.x.bottomLeft, actor->boudingBox.z.bottomLeft, actor->angle + 0x580);
+					_engine->_movements->rotateActor(actor->boudingBox.x.bottomLeft, actor->boudingBox.z.bottomLeft, actor->angle + ANGLE_360 + ANGLE_135);
 					_engine->_renderer->destX += _engine->_movements->processActorX;
 					_engine->_renderer->destZ += _engine->_movements->processActorZ;
 
 					if (_engine->_renderer->destX >= 0 && _engine->_renderer->destZ >= 0 && _engine->_renderer->destX <= 0x7E00 && _engine->_renderer->destZ <= 0x7E00) {
-						if (_engine->_grid->getBrickShape(_engine->_renderer->destX, actor->y + 0x100, _engine->_renderer->destZ) != ShapeType::kNone) {
+						if (_engine->_grid->getBrickShape(_engine->_renderer->destX, actor->y + ANGLE_90, _engine->_renderer->destZ) != ShapeType::kNone) {
 							currentActorInZone = true;
 							if (actor->y >= ABS(zone->bottomLeft.y + zone->topRight.y) / 2) {
 								_engine->_animations->initAnim(AnimationTypes::kTopLadder, 2, AnimationTypes::kStanding, actorIdx); // reached end of ladder
diff --git a/engines/twine/script_life_v1.cpp b/engines/twine/script_life_v1.cpp
index 2ffc021879..124c3973e8 100644
--- a/engines/twine/script_life_v1.cpp
+++ b/engines/twine/script_life_v1.cpp
@@ -228,18 +228,18 @@ static int32 processLifeConditions(TwinEEngine *engine, LifeScriptContext &ctx)
 			}
 
 			if (IS_HERO(targetActorIdx)) {
-				int32 heroAngle = ClampAngle(ctx.actor->angle + 0x480 - newAngle + 0x400);
+				int32 heroAngle = ClampAngle(ctx.actor->angle + ANGLE_360 + ANGLE_45 - newAngle + ANGLE_360);
 
-				if (ABS(heroAngle) > 0x100) {
+				if (ABS(heroAngle) > ANGLE_90) {
 					engine->_scene->currentScriptValue = MAX_TARGET_ACTOR_DISTANCE;
 				} else {
 					engine->_scene->currentScriptValue = engine->_movements->targetActorDistance;
 				}
 			} else {
 				if (engine->_actor->heroBehaviour == HeroBehaviourType::kDiscrete) {
-					int32 heroAngle = ClampAngle(ctx.actor->angle + 0x480 - newAngle + 0x400);
+					int32 heroAngle = ClampAngle(ctx.actor->angle + ANGLE_360 + ANGLE_45 - newAngle + ANGLE_360);
 
-					if (ABS(heroAngle) > 0x100) {
+					if (ABS(heroAngle) > ANGLE_90) {
 						engine->_scene->currentScriptValue = MAX_TARGET_ACTOR_DISTANCE;
 					} else {
 						engine->_scene->currentScriptValue = engine->_movements->targetActorDistance;
@@ -955,7 +955,7 @@ static int32 lFOUND_OBJECT(TwinEEngine *engine, LifeScriptContext &ctx) {
 static int32 lSET_DOOR_LEFT(TwinEEngine *engine, LifeScriptContext &ctx) {
 	int32 distance = ctx.stream.readSint16LE();
 
-	ctx.actor->angle = 0x300;
+	ctx.actor->angle = ANGLE_270;
 	ctx.actor->x = ctx.actor->lastX - distance;
 	ctx.actor->dynamicFlags.bIsSpriteMoving = 0;
 	ctx.actor->speed = 0;
@@ -970,7 +970,7 @@ static int32 lSET_DOOR_LEFT(TwinEEngine *engine, LifeScriptContext &ctx) {
 static int32 lSET_DOOR_RIGHT(TwinEEngine *engine, LifeScriptContext &ctx) {
 	int32 distance = ctx.stream.readSint16LE();
 
-	ctx.actor->angle = 0x100;
+	ctx.actor->angle = ANGLE_90;
 	ctx.actor->x = ctx.actor->lastX + distance;
 	ctx.actor->dynamicFlags.bIsSpriteMoving = 0;
 	ctx.actor->speed = 0;
@@ -985,7 +985,7 @@ static int32 lSET_DOOR_RIGHT(TwinEEngine *engine, LifeScriptContext &ctx) {
 static int32 lSET_DOOR_UP(TwinEEngine *engine, LifeScriptContext &ctx) {
 	int32 distance = ctx.stream.readSint16LE();
 
-	ctx.actor->angle = 0x200;
+	ctx.actor->angle = ANGLE_180;
 	ctx.actor->z = ctx.actor->lastZ - distance;
 	ctx.actor->dynamicFlags.bIsSpriteMoving = 0;
 	ctx.actor->speed = 0;
@@ -1000,7 +1000,7 @@ static int32 lSET_DOOR_UP(TwinEEngine *engine, LifeScriptContext &ctx) {
 static int32 lSET_DOOR_DOWN(TwinEEngine *engine, LifeScriptContext &ctx) {
 	int32 distance = ctx.stream.readSint16LE();
 
-	ctx.actor->angle = 0;
+	ctx.actor->angle = ANGLE_0;
 	ctx.actor->z = ctx.actor->lastZ + distance;
 	ctx.actor->dynamicFlags.bIsSpriteMoving = 0;
 	ctx.actor->speed = 0;
@@ -1430,7 +1430,7 @@ static int32 lFULL_POINT(TwinEEngine *engine, LifeScriptContext &ctx) {
  */
 static int32 lBETA(TwinEEngine *engine, LifeScriptContext &ctx) {
 	int32 newAngle = ctx.stream.readSint16LE();
-	ctx.actor->angle = newAngle;
+	ctx.actor->angle = ToAngle(newAngle);
 	engine->_movements->clearRealAngle(ctx.actor);
 	return 0;
 }
diff --git a/engines/twine/script_move_v1.cpp b/engines/twine/script_move_v1.cpp
index c4892427c5..6d2a0d1179 100644
--- a/engines/twine/script_move_v1.cpp
+++ b/engines/twine/script_move_v1.cpp
@@ -164,15 +164,15 @@ static int32 mLOOP(TwinEEngine *engine, MoveScriptContext &ctx) {
  * @note Opcode @c 0x07
  */
 static int32 mANGLE(TwinEEngine *engine, MoveScriptContext &ctx) {
-	const int16 angle = ctx.stream.readSint16LE();
+	const int16 angle = ToAngle(ctx.stream.readSint16LE());
 	if (ctx.actor->staticFlags.bIsSpriteActor) {
 		return 0;
 	}
 	engine->_scene->currentScriptValue = angle;
 	if (ctx.actor->move.numOfStep == 0) {
-		engine->_movements->moveActor(ctx.actor->angle, engine->_scene->currentScriptValue, ctx.actor->speed, &ctx.actor->move);
+		engine->_movements->moveActor(ctx.actor->angle, angle, ctx.actor->speed, &ctx.actor->move);
 	}
-	if (ctx.actor->angle == engine->_scene->currentScriptValue) {
+	if (ctx.actor->angle == angle) {
 		engine->_movements->clearRealAngle(ctx.actor);
 		return 0;
 	}
@@ -248,7 +248,7 @@ static int32 mGOTO_SYM_POINT(TwinEEngine *engine, MoveScriptContext &ctx) {
 	engine->_renderer->destY = sp.y;
 	engine->_renderer->destZ = sp.z;
 
-	const int32 newAngle = 0x200 + engine->_movements->getAngleAndSetTargetActorDistance(ctx.actor->x, ctx.actor->z, sp.x, sp.z);
+	const int32 newAngle = ANGLE_180 + engine->_movements->getAngleAndSetTargetActorDistance(ctx.actor->x, ctx.actor->z, sp.x, sp.z);
 
 	if (ctx.actor->staticFlags.bIsSpriteActor) {
 		ctx.actor->angle = newAngle;
@@ -430,11 +430,11 @@ static int32 mBETA(TwinEEngine *engine, MoveScriptContext &ctx) {
 static int32 mOPEN_LEFT(TwinEEngine *engine, MoveScriptContext &ctx) {
 	const int16 doorStatus = ctx.stream.readSint16LE();
 	if (ctx.actor->staticFlags.bIsSpriteActor && ctx.actor->staticFlags.bUsesClipping) {
-		ctx.actor->angle = 0x300;
+		ctx.actor->angle = ANGLE_270;
 		ctx.actor->doorStatus = doorStatus;
 		ctx.actor->dynamicFlags.bIsSpriteMoving = 1;
 		ctx.actor->speed = 1000;
-		engine->_movements->setActorAngle(0, 1000, 50, &ctx.actor->move);
+		engine->_movements->setActorAngle(ANGLE_0, 1000, 50, &ctx.actor->move);
 	}
 	return 0;
 }
@@ -446,11 +446,11 @@ static int32 mOPEN_LEFT(TwinEEngine *engine, MoveScriptContext &ctx) {
 static int32 mOPEN_RIGHT(TwinEEngine *engine, MoveScriptContext &ctx) {
 	const int16 doorStatus = ctx.stream.readSint16LE();
 	if (ctx.actor->staticFlags.bIsSpriteActor && ctx.actor->staticFlags.bUsesClipping) {
-		ctx.actor->angle = 0x100;
+		ctx.actor->angle = ANGLE_90;
 		ctx.actor->doorStatus = doorStatus;
 		ctx.actor->dynamicFlags.bIsSpriteMoving = 1;
 		ctx.actor->speed = 1000;
-		engine->_movements->setActorAngle(0, 1000, 50, &ctx.actor->move);
+		engine->_movements->setActorAngle(ANGLE_0, 1000, 50, &ctx.actor->move);
 	}
 	return 0;
 }
@@ -462,11 +462,11 @@ static int32 mOPEN_RIGHT(TwinEEngine *engine, MoveScriptContext &ctx) {
 static int32 mOPEN_UP(TwinEEngine *engine, MoveScriptContext &ctx) {
 	const int16 doorStatus = ctx.stream.readSint16LE();
 	if (ctx.actor->staticFlags.bIsSpriteActor && ctx.actor->staticFlags.bUsesClipping) {
-		ctx.actor->angle = 0x200;
+		ctx.actor->angle = ANGLE_180;
 		ctx.actor->doorStatus = doorStatus;
 		ctx.actor->dynamicFlags.bIsSpriteMoving = 1;
 		ctx.actor->speed = 1000;
-		engine->_movements->setActorAngle(0, 1000, 50, &ctx.actor->move);
+		engine->_movements->setActorAngle(ANGLE_0, 1000, 50, &ctx.actor->move);
 	}
 	return 0;
 }
@@ -478,11 +478,11 @@ static int32 mOPEN_UP(TwinEEngine *engine, MoveScriptContext &ctx) {
 static int32 mOPEN_DOWN(TwinEEngine *engine, MoveScriptContext &ctx) {
 	const int16 doorStatus = ctx.stream.readSint16LE();
 	if (ctx.actor->staticFlags.bIsSpriteActor && ctx.actor->staticFlags.bUsesClipping) {
-		ctx.actor->angle = 0;
+		ctx.actor->angle = ANGLE_0;
 		ctx.actor->doorStatus = doorStatus;
 		ctx.actor->dynamicFlags.bIsSpriteMoving = 1;
 		ctx.actor->speed = 1000;
-		engine->_movements->setActorAngle(0, 1000, 50, &ctx.actor->move);
+		engine->_movements->setActorAngle(ANGLE_0, 1000, 50, &ctx.actor->move);
 	}
 	return 0;
 }
@@ -496,7 +496,7 @@ static int32 mCLOSE(TwinEEngine *engine, MoveScriptContext &ctx) {
 		ctx.actor->doorStatus = 0;
 		ctx.actor->dynamicFlags.bIsSpriteMoving = 1;
 		ctx.actor->speed = -1000;
-		engine->_movements->setActorAngle(0, -1000, 50, &ctx.actor->move);
+		engine->_movements->setActorAngle(ANGLE_0, -1000, 50, &ctx.actor->move);
 	}
 	return 0;
 }
@@ -598,7 +598,7 @@ static int32 mSIMPLE_SAMPLE(TwinEEngine *engine, MoveScriptContext &ctx) {
  * @note Opcode @c 0x21
  */
 static int32 mFACE_HERO(TwinEEngine *engine, MoveScriptContext &ctx) {
-	const int16 angle = ctx.stream.readSint16LE();
+	const int16 angle = ToAngle(ctx.stream.readSint16LE());
 	if (ctx.actor->staticFlags.bIsSpriteActor) {
 		return 0;
 	}
@@ -635,10 +635,10 @@ static int32 mANGLE_RND(TwinEEngine *engine, MoveScriptContext &ctx) {
 
 	if (engine->_scene->currentScriptValue == -1 && ctx.actor->move.numOfStep == 0) {
 		if (engine->getRandomNumber() & 1) {
-			const int32 newAngle = ctx.actor->angle + 256 + (ABS(val1) >> 1);
+			const int32 newAngle = ctx.actor->angle + ANGLE_90 + (ABS(val1) >> 1);
 			engine->_scene->currentScriptValue = ClampAngle(newAngle - engine->getRandomNumber(val1));
 		} else {
-			const int32 newAngle = ctx.actor->angle - 256 + (ABS(val1) >> 1);
+			const int32 newAngle = ctx.actor->angle - ANGLE_90 + (ABS(val1) >> 1);
 			engine->_scene->currentScriptValue = ClampAngle(newAngle - engine->getRandomNumber(val1));
 		}
 
diff --git a/engines/twine/shared.h b/engines/twine/shared.h
index 3e253633ac..6af695bf55 100644
--- a/engines/twine/shared.h
+++ b/engines/twine/shared.h
@@ -118,8 +118,45 @@ enum class ExtraSpecialType {
 	kExplodeCloud = 1
 };
 
-inline int32 ClampAngle(int32 angle) {
-	return angle & 0x3FF;
+#define ANGLE_360 1024
+#define ANGLE_270 768
+#define ANGLE_180 512
+#define ANGLE_135 384
+#define ANGLE_90 256
+#define ANGLE_45 128
+#define ANGLE_0 0
+
+inline int32 NormalizeAngle(int32 angle) {
+	if (angle < -ANGLE_180) {
+		angle += ANGLE_360;
+	} else if (angle > ANGLE_180) {
+		angle -= ANGLE_360;
+	}
+	return angle;
+}
+
+/**
+ * @param[in] angle The angle as input from game data
+ * @return The value as it is used at runtime
+ */
+inline constexpr int32 ToAngle(int32 angle) {
+	return angle;
+}
+
+/**
+ * @param[in] angle The angle as used at runtime
+ * @return The value as it should be used for storing in game data
+ */
+inline constexpr int32 FromAngle(int32 angle) {
+	return angle;
+}
+
+inline constexpr double AngleToRadians(int32 angle) {
+	return 2.0 * M_PI * angle / (double)ANGLE_360;
+}
+
+inline constexpr int32 ClampAngle(int32 angle) {
+	return angle & (ANGLE_360 - 1);
 }
 
 }
diff --git a/engines/twine/twine.cpp b/engines/twine/twine.cpp
index c725190861..ee6b842f40 100644
--- a/engines/twine/twine.cpp
+++ b/engines/twine/twine.cpp
@@ -491,7 +491,7 @@ int32 TwinEEngine::runGameEngine() { // mainLoopInteration
 				break;
 			case kiMagicBall:
 				if (_gameState->usingSabre) {
-					_actor->initModelActor(0, 0);
+					_actor->initModelActor(0, OWN_ACTOR_SCENE_INDEX);
 				}
 				_gameState->usingSabre = false;
 				break;
@@ -500,8 +500,8 @@ int32 TwinEEngine::runGameEngine() { // mainLoopInteration
 					if (_actor->heroBehaviour == HeroBehaviourType::kProtoPack) {
 						_actor->setBehaviour(HeroBehaviourType::kNormal);
 					}
-					_actor->initModelActor(InventoryItems::kiUseSabre, 0);
-					_animations->initAnim(AnimationTypes::kSabreUnknown, 1, AnimationTypes::kStanding, 0);
+					_actor->initModelActor(InventoryItems::kiUseSabre, OWN_ACTOR_SCENE_INDEX);
+					_animations->initAnim(AnimationTypes::kSabreUnknown, 1, AnimationTypes::kStanding, OWN_ACTOR_SCENE_INDEX);
 
 					_gameState->usingSabre = true;
 				}
@@ -668,7 +668,7 @@ int32 TwinEEngine::runGameEngine() { // mainLoopInteration
 		loopActorStep = 1;
 	}
 
-	_movements->setActorAngle(0, -256, 5, &loopMovePtr);
+	_movements->setActorAngle(ANGLE_0, -ANGLE_90, 5, &loopMovePtr);
 	disableScreenRecenter = false;
 
 	_scene->processEnvironmentSound();
@@ -744,7 +744,7 @@ int32 TwinEEngine::runGameEngine() { // mainLoopInteration
 								actor->controlMode = ControlMode::kNoMove;
 								actor->life = -1;
 								_actor->cropBottomScreen = _renderer->projPosY;
-								actor->staticFlags.bCanDrown |= 0x10;
+								actor->staticFlags.bCanDrown |= 0x10; // TODO: doesn't make sense
 							}
 						} else {
 							const int32 rnd = getRandomNumber(2000) + 3096;
@@ -824,7 +824,7 @@ int32 TwinEEngine::runGameEngine() { // mainLoopInteration
 		_renderer->projectPositionOnScreen(actor->x - (_grid->newCameraX << 9),
 		                                   actor->y - (_grid->newCameraY << 8),
 		                                   actor->z - (_grid->newCameraZ << 9));
-		if (_renderer->projPosX < 80 || _renderer->projPosX > 539 || _renderer->projPosY < 80 || _renderer->projPosY > 429) {
+		if (_renderer->projPosX < 80 || _renderer->projPosX >= SCREEN_WIDTH - 60 || _renderer->projPosY < 80 || _renderer->projPosY >= SCREEN_HEIGHT - 50) {
 			_grid->newCameraX = ((actor->x + 0x100) >> 9) + (((actor->x + 0x100) >> 9) - _grid->newCameraX) / 2;
 			_grid->newCameraY = actor->y >> 8;
 			_grid->newCameraZ = ((actor->z + 0x100) >> 9) + (((actor->z + 0x100) >> 9) - _grid->newCameraZ) / 2;
@@ -859,7 +859,7 @@ int32 TwinEEngine::runGameEngine() { // mainLoopInteration
 bool TwinEEngine::gameEngineLoop() {
 	_redraw->reqBgRedraw = true;
 	_screens->lockPalette = true;
-	_movements->setActorAngle(0, -256, 5, &loopMovePtr);
+	_movements->setActorAngle(ANGLE_0, -ANGLE_90, 5, &loopMovePtr);
 
 	while (quitGame == -1) {
 		uint32 start = g_system->getMillis();
@@ -944,7 +944,7 @@ void TwinEEngine::crossFade(const Graphics::ManagedSurface &buffer, const uint32
 	backupSurface.create(frontVideoBuffer.w, frontVideoBuffer.h, fmt);
 	newSurface.create(frontVideoBuffer.w, frontVideoBuffer.h, fmt);
 	tempSurface.create(frontVideoBuffer.w, frontVideoBuffer.h, Graphics::PixelFormat::createFormatCLUT8());
-	tempSurface.setPalette(palette, 0, 256);
+	tempSurface.setPalette(palette, 0, NUMOFCOLORS);
 
 	surfaceTable.create(frontVideoBuffer.w, frontVideoBuffer.h, fmt);
 
@@ -953,7 +953,7 @@ void TwinEEngine::crossFade(const Graphics::ManagedSurface &buffer, const uint32
 
 	for (int32 i = 0; i < 8; i++) {
 		surfaceTable.blitFrom(backupSurface);
-		surfaceTable.transBlitFrom(newSurface, 0, false, 0, i * 32);
+		surfaceTable.transBlitFrom(newSurface, 0, false, 0, i * NUMOFCOLORS / 8);
 		frontVideoBuffer.blitFrom(surfaceTable);
 		flip();
 		delaySkip(50);


Commit: 6fefa0d9b5b8bde852d678a2feb6d21da2340948
    https://github.com/scummvm/scummvm/commit/6fefa0d9b5b8bde852d678a2feb6d21da2340948
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-20T18:34:50+01:00

Commit Message:
TWINE: give_all_items enables the inventory

Changed paths:
    engines/twine/console.cpp


diff --git a/engines/twine/console.cpp b/engines/twine/console.cpp
index cc6c186c67..d9d4f35b68 100644
--- a/engines/twine/console.cpp
+++ b/engines/twine/console.cpp
@@ -136,6 +136,7 @@ bool TwinEConsole::doGiveAllItems(int argc, const char **argv) {
 		_engine->_gameState->gameFlags[i] = 1;
 		_engine->_gameState->inventoryFlags[i] = 1;
 	}
+	_engine->_gameState->gameFlags[GAMEFLAG_INVENTORY_DISABLED] = 0;
 	int amount = 10;
 	if (argc > 1) {
 		amount = atoi(argv[1]);




More information about the Scummvm-git-logs mailing list