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

mgerhardy martin.gerhardy at gmail.com
Mon Nov 23 15:48:40 UTC 2020


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

Summary:
79daf804a4 TWINE: moved methods into ActorMoveStruct
52e7025914 TWINE: further refactored the Text class
6d1c1d88ab TWINE: removed member from Text class and reduced cyclic complexity
e0dcabda38 TWINE: converted member to stack var
b16f8c55c5 TWINE: replaced magic numbers
ac0c5170b5 NEWS: mention the support for lba
f079ae1bb6 TWINE: added lba2 detection entries
44670275e7 TWINE: doxygen
a5dad05678 TWINE: the body index is not related to the inventory item idx


Commit: 79daf804a4a8b1b6e72ef67889d21b3c482ce8dc
    https://github.com/scummvm/scummvm/commit/79daf804a4a8b1b6e72ef67889d21b3c482ce8dc
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-22T23:19:35+01:00

Commit Message:
TWINE: moved methods into ActorMoveStruct

Changed paths:
    engines/twine/actor.cpp
    engines/twine/actor.h
    engines/twine/animations.cpp
    engines/twine/extra.cpp
    engines/twine/movements.cpp
    engines/twine/movements.h
    engines/twine/renderer.cpp
    engines/twine/twine.cpp


diff --git a/engines/twine/actor.cpp b/engines/twine/actor.cpp
index 031769e783..09d142ce86 100644
--- a/engines/twine/actor.cpp
+++ b/engines/twine/actor.cpp
@@ -510,4 +510,42 @@ void ActorStruct::loadModel(int32 modelIndex) {
 	}
 }
 
+int32 ActorMoveStruct::getRealAngle(int32 time) {
+	if (numOfStep) {
+		const int32 timePassed = time - timeOfChange;
+
+		if (timePassed >= numOfStep) { // rotation is finished
+			numOfStep = 0;
+			return to;
+		}
+
+		int32 remainingAngle = NormalizeAngle(to - from);
+		remainingAngle *= timePassed;
+		remainingAngle /= numOfStep;
+		remainingAngle += from;
+
+		return remainingAngle;
+	}
+
+	return to;
+}
+
+int32 ActorMoveStruct::getRealValue(int32 time) {
+	if (!numOfStep) {
+		return to;
+	}
+
+	if (time - timeOfChange >= numOfStep) {
+		numOfStep = 0;
+		return to;
+	}
+
+	int32 tempStep = to - from;
+	tempStep *= time - timeOfChange;
+	tempStep /= numOfStep;
+
+	return tempStep + from;
+}
+
+
 } // namespace TwinE
diff --git a/engines/twine/actor.h b/engines/twine/actor.h
index eac260e21c..3b7b11d3dd 100644
--- a/engines/twine/actor.h
+++ b/engines/twine/actor.h
@@ -40,6 +40,18 @@ struct ActorMoveStruct {
 	int16 to = 0;
 	int16 numOfStep = 0;
 	int32 timeOfChange = 0;
+
+	/**
+	 * Get actor real angle
+	 * @param time engine time used for interpolation
+	 */
+	int32 getRealAngle(int32 time);
+
+	/**
+	 * Get actor step
+	 * @param time engine time used for interpolation
+	 */
+	int32 getRealValue(int32 time);
 };
 
 /** Actors zone volumique points structure */
diff --git a/engines/twine/animations.cpp b/engines/twine/animations.cpp
index e56f8b4659..02c5148fbb 100644
--- a/engines/twine/animations.cpp
+++ b/engines/twine/animations.cpp
@@ -767,7 +767,7 @@ void Animations::processActorAnimations(int32 actorIdx) { // DoAnim
 
 		if (!actor->dynamicFlags.bIsFalling) {
 			if (actor->speed) {
-				int32 xAxisRotation = _engine->_movements->getRealValue(&actor->move);
+				int32 xAxisRotation = actor->move.getRealValue(_engine->lbaTime);
 				if (!xAxisRotation) {
 					if (actor->move.to > 0) {
 						xAxisRotation = 1;
diff --git a/engines/twine/extra.cpp b/engines/twine/extra.cpp
index 44bc8cb3c9..27a61c9269 100644
--- a/engines/twine/extra.cpp
+++ b/engines/twine/extra.cpp
@@ -661,7 +661,7 @@ void Extra::processExtras() {
 			}
 
 			const int32 angle2 = _engine->_movements->getAngleAndSetTargetActorDistance(extra->y, 0, currentExtraY, _engine->_movements->targetActorDistance);
-			int32 pos = _engine->_movements->getRealAngle(&extra->trackActorMove);
+			int32 pos = extra->trackActorMove.getRealAngle(_engine->lbaTime);
 			if (!pos) {
 				pos = 1;
 			}
@@ -711,7 +711,7 @@ void Extra::processExtras() {
 				continue;
 			}
 			int32 angle2 = _engine->_movements->getAngleAndSetTargetActorDistance(extra->y, 0, extraKey->y, _engine->_movements->targetActorDistance);
-			int32 pos = _engine->_movements->getRealAngle(&extra->trackActorMove);
+			int32 pos = extra->trackActorMove.getRealAngle(_engine->lbaTime);
 
 			if (!pos) {
 				pos = 1;
diff --git a/engines/twine/movements.cpp b/engines/twine/movements.cpp
index 8067a71fff..2d4db4ae5b 100644
--- a/engines/twine/movements.cpp
+++ b/engines/twine/movements.cpp
@@ -140,43 +140,6 @@ int32 Movements::getAngleAndSetTargetActorDistance(int32 x1, int32 z1, int32 x2,
 	return ClampAngle(finalAngle);
 }
 
-int32 Movements::getRealAngle(ActorMoveStruct *movePtr) {
-	if (movePtr->numOfStep) {
-		const int32 timePassed = _engine->lbaTime - movePtr->timeOfChange;
-
-		if (timePassed >= movePtr->numOfStep) { // rotation is finished
-			movePtr->numOfStep = 0;
-			return movePtr->to;
-		}
-
-		int32 remainingAngle = NormalizeAngle(movePtr->to - movePtr->from);
-		remainingAngle *= timePassed;
-		remainingAngle /= movePtr->numOfStep;
-		remainingAngle += movePtr->from;
-
-		return remainingAngle;
-	}
-
-	return movePtr->to;
-}
-
-int32 Movements::getRealValue(ActorMoveStruct *movePtr) {
-	if (!movePtr->numOfStep) {
-		return movePtr->to;
-	}
-
-	if (_engine->lbaTime - movePtr->timeOfChange >= movePtr->numOfStep) {
-		movePtr->numOfStep = 0;
-		return movePtr->to;
-	}
-
-	int32 tempStep = movePtr->to - movePtr->from;
-	tempStep *= _engine->lbaTime - movePtr->timeOfChange;
-	tempStep /= movePtr->numOfStep;
-
-	return tempStep + movePtr->from;
-}
-
 void Movements::rotateActor(int32 x, int32 z, int32 angle) {
 	const double radians = AngleToRadians(angle);
 	_engine->_renderer->destX = (int32)(x * cos(radians) + z * sin(radians));
@@ -267,7 +230,7 @@ bool Movements::processBehaviourExecution(int actorIdx) {
 		if (_engine->_actor->autoAgressive) {
 			ActorStruct *actor = _engine->_scene->getActor(actorIdx);
 			heroMoved = true;
-			actor->angle = getRealAngle(&actor->move);
+			actor->angle = actor->move.getRealAngle(_engine->lbaTime);
 			// TODO: previousLoopActionKey must be handled properly
 			if (!previousLoopActionKey || actor->anim == AnimationTypes::kStanding) {
 				const int32 aggresiveMode = _engine->getRandomNumber(3);
@@ -313,7 +276,7 @@ bool Movements::processAttackExecution(int actorIdx) {
 				_engine->_animations->initAnim(AnimationTypes::kThrowBall, 1, AnimationTypes::kStanding, actorIdx);
 			}
 
-			actor->angle = getRealAngle(&actor->move);
+			actor->angle = actor->move.getRealAngle(_engine->lbaTime);
 			return true;
 		}
 	} else if (_engine->_gameState->hasItem(InventoryItems::kiUseSabre)) {
@@ -323,7 +286,7 @@ bool Movements::processAttackExecution(int actorIdx) {
 
 		_engine->_animations->initAnim(AnimationTypes::kSabreAttack, 1, AnimationTypes::kStanding, actorIdx);
 
-		actor->angle = getRealAngle(&actor->move);
+		actor->angle = actor->move.getRealAngle(_engine->lbaTime);
 		return true;
 	}
 	return false;
@@ -356,7 +319,7 @@ void Movements::processMovementExecution(int actorIdx) {
 				_engine->_animations->initAnim(AnimationTypes::kTurnLeft, 0, AnimationTypes::kAnimInvalid, actorIdx);
 			} else {
 				if (!actor->dynamicFlags.bIsRotationByAnim) {
-					actor->angle = getRealAngle(&actor->move);
+					actor->angle = actor->move.getRealAngle(_engine->lbaTime);
 				}
 			}
 			heroMoved = true;
@@ -365,7 +328,7 @@ void Movements::processMovementExecution(int actorIdx) {
 				_engine->_animations->initAnim(AnimationTypes::kTurnRight, 0, AnimationTypes::kAnimInvalid, actorIdx);
 			} else {
 				if (!actor->dynamicFlags.bIsRotationByAnim) {
-					actor->angle = getRealAngle(&actor->move);
+					actor->angle = actor->move.getRealAngle(_engine->lbaTime);
 				}
 			}
 			heroMoved = true;
@@ -474,7 +437,7 @@ void Movements::processActorMovements(int32 actorIdx) {
 	}
 	if (!actor->staticFlags.bIsSpriteActor) {
 		if (actor->controlMode != ControlMode::kManual) {
-			actor->angle = getRealAngle(&actor->move);
+			actor->angle = actor->move.getRealAngle(_engine->lbaTime);
 		}
 	}
 
diff --git a/engines/twine/movements.h b/engines/twine/movements.h
index 23c3137981..c6bc891f87 100644
--- a/engines/twine/movements.h
+++ b/engines/twine/movements.h
@@ -192,18 +192,6 @@ public:
 	 */
 	int32 getAngleAndSetTargetActorDistance(int32 x1, int32 z1, int32 x2, int32 z2);
 
-	/**
-	 * Get actor real angle
-	 * @param movePtr time pointer to process
-	 */
-	int32 getRealAngle(ActorMoveStruct *movePtr);
-
-	/**
-	 * Get actor step
-	 * @param movePtr time pointer to process
-	 */
-	int32 getRealValue(ActorMoveStruct *movePtr);
-
 	/**
 	 * Rotate actor with a given angle
 	 * @param x Actor current X coordinate
diff --git a/engines/twine/renderer.cpp b/engines/twine/renderer.cpp
index 0761320838..b9520f91b5 100644
--- a/engines/twine/renderer.cpp
+++ b/engines/twine/renderer.cpp
@@ -23,6 +23,7 @@
 #include "twine/renderer.h"
 #include "common/textconsole.h"
 #include "common/util.h"
+#include "twine/actor.h"
 #include "twine/interface.h"
 #include "twine/menu.h"
 #include "twine/movements.h"
@@ -1700,9 +1701,10 @@ void Renderer::renderBehaviourModel(int32 boxLeft, int32 boxTop, int32 boxRight,
 	_engine->_interface->setClip(boxLeft, boxTop, tmpBoxRight, boxBottom);
 
 	if (angle == -1) {
-		const int16 newAngle = _engine->_movements->getRealAngle(&_engine->_menu->moveMenu);
-		if (_engine->_menu->moveMenu.numOfStep == 0) {
-			_engine->_movements->setActorAngleSafe(newAngle, newAngle - ANGLE_90, 50, &_engine->_menu->moveMenu);
+		ActorMoveStruct &move = _engine->_menu->moveMenu;
+		const int16 newAngle = move.getRealAngle(_engine->lbaTime);
+		if (move.numOfStep == 0) {
+			_engine->_movements->setActorAngleSafe(newAngle, newAngle - ANGLE_90, 50, &move);
 		}
 		renderIsoModel(0, y, 0, 0, newAngle, 0, entityPtr);
 	} else {
diff --git a/engines/twine/twine.cpp b/engines/twine/twine.cpp
index 4e7f56584f..7ab8f493dd 100644
--- a/engines/twine/twine.cpp
+++ b/engines/twine/twine.cpp
@@ -693,7 +693,7 @@ int32 TwinEEngine::runGameEngine() { // mainLoopInteration
 		}
 	}
 
-	loopActorStep = _movements->getRealValue(&loopMovePtr);
+	loopActorStep = loopMovePtr.getRealValue(lbaTime);
 	if (!loopActorStep) {
 		loopActorStep = 1;
 	}


Commit: 52e7025914f3c2c79bf601342579e15dec6c35e2
    https://github.com/scummvm/scummvm/commit/52e7025914f3c2c79bf601342579e15dec6c35e2
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-22T23:19:35+01:00

Commit Message:
TWINE: further refactored the Text class

removed unused member buf1 and renamed other members

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


diff --git a/engines/twine/text.cpp b/engines/twine/text.cpp
index 33f362c4a2..2d11f46984 100644
--- a/engines/twine/text.cpp
+++ b/engines/twine/text.cpp
@@ -21,6 +21,7 @@
  */
 
 #include "twine/text.h"
+#include "common/algorithm.h"
 #include "common/endian.h"
 #include "common/memstream.h"
 #include "common/scummsys.h"
@@ -290,14 +291,14 @@ void Text::initDialogueBox() { // InitDialWindow
 	}
 
 	_engine->copyBlockPhys(_dialTextBoxLeft, _dialTextBoxTop, _dialTextBoxRight, _dialTextBoxBottom);
-	_blendInCharactersPos = 0;
+	_fadeInCharactersPos = 0;
 	_engine->_interface->blitBox(_dialTextBoxLeft, _dialTextBoxTop, _dialTextBoxRight, _dialTextBoxBottom, _engine->frontVideoBuffer, _dialTextBoxLeft, _dialTextBoxTop, _engine->workVideoBuffer);
 }
 
 void Text::initInventoryDialogueBox() { // SecondInitDialWindow
 	_engine->_interface->blitBox(_dialTextBoxLeft, _dialTextBoxTop, _dialTextBoxRight, _dialTextBoxBottom, _engine->workVideoBuffer, _dialTextBoxLeft, _dialTextBoxTop, _engine->frontVideoBuffer);
 	_engine->copyBlockPhys(_dialTextBoxLeft, _dialTextBoxTop, _dialTextBoxRight, _dialTextBoxBottom);
-	_blendInCharactersPos = 0;
+	_fadeInCharactersPos = 0;
 }
 
 // TODO: refactor this code
@@ -307,14 +308,13 @@ void Text::initText(int32 index) {
 		return;
 	}
 
-	_progressiveTextBuffer = buf2;
+	_progressiveTextBufferPtr = _progressiveTextBuffer;
 
 	_hasValidTextHandle = true;
 
 	_dialTextBoxCurrentLine = 0;
-	buf1[0] = '\0';
-	buf2[0] = '\0';
-	_blendInCharactersPos = 0;
+	_progressiveTextBuffer[0] = '\0';
+	_fadeInCharactersPos = 0;
 	_dialTextYPos = _dialTextBoxLeft + 8;
 	_progressiveTextEnd = false;
 	_progressiveTextNextPage = false;
@@ -326,51 +326,48 @@ void Text::initText(int32 index) {
 }
 
 void Text::initProgressiveTextBuffer() {
-	buf2[0] = '\0';
-
-	int32 i = 0;
-	while (i < _dialTextBufferSize) {
-		strncat(buf2, " ", sizeof(buf2));
-		i++;
-	}
-
-	_progressiveTextBuffer = buf2;
+	Common::fill(&_progressiveTextBuffer[0], &_progressiveTextBuffer[256], ' ');
+	_progressiveTextBuffer[255] = '\0';
+	_progressiveTextBufferPtr = _progressiveTextBuffer;
 	_addLineBreakX = 16;
 	_dialTextBoxCurrentLine = 0;
 }
 
 void Text::fillFadeInBuffer(int16 x, int16 y, int16 chr) {
-	if (_blendInCharactersPos < 32) {
-		_blendInCharacters[_blendInCharactersPos].chr = chr;
-		_blendInCharacters[_blendInCharactersPos].x = x;
-		_blendInCharacters[_blendInCharactersPos].y = y;
-		_blendInCharactersPos++;
+	if (_fadeInCharactersPos < TEXT_MAX_FADE_IN_CHR) {
+		_fadeInCharacters[_fadeInCharactersPos].chr = chr;
+		_fadeInCharacters[_fadeInCharactersPos].x = x;
+		_fadeInCharacters[_fadeInCharactersPos].y = y;
+		_fadeInCharactersPos++;
 		return;
 	}
 	int32 counter2 = 0;
-	while (counter2 < 31) {
+	while (counter2 < TEXT_MAX_FADE_IN_CHR - 1) {
 		const int32 var1 = (counter2 + 1);
 		const int32 var2 = counter2;
-		_blendInCharacters[var2] = _blendInCharacters[var1];
+		_fadeInCharacters[var2] = _fadeInCharacters[var1];
 		counter2++;
 	}
-	_blendInCharacters[31].chr = chr;
-	_blendInCharacters[31].x = x;
-	_blendInCharacters[31].y = y;
+	_fadeInCharacters[TEXT_MAX_FADE_IN_CHR - 1].chr = chr;
+	_fadeInCharacters[TEXT_MAX_FADE_IN_CHR - 1].x = x;
+	_fadeInCharacters[TEXT_MAX_FADE_IN_CHR - 1].y = y;
 }
 
-Text::WordSize Text::getWordSize(const char *arg1, char *arg2) {
+Text::WordSize Text::getWordSize(const char *completeText, char *wordBuf, int32 wordBufSize) {
 	int32 temp = 0;
-	const char *arg2Save = arg2;
+	const char *arg2Save = wordBuf;
 
-	while (*arg1 != '\0' && *arg1 != '\1' && *arg1 != ' ') {
+	while (*completeText != '\0' && *completeText != '\1' && *completeText != ' ') {
 		temp++;
-		*arg2++ = *arg1++;
+		*wordBuf++ = *completeText++;
+		if (temp >= wordBufSize - 1) {
+			break;
+		}
 	}
 
 	WordSize size;
 	size.inChar = temp;
-	*arg2 = '\0';
+	*wordBuf = '\0';
 	size.inPixel = getTextSize(arg2Save);
 	return size;
 }
@@ -382,7 +379,7 @@ void Text::processTextLine() {
 
 	_addLineBreakX = 0;
 	printText8PrepareBufferVar2 = 0;
-	buf2[0] = 0;
+	_progressiveTextBuffer[0] = 0;
 
 	for (;;) {
 		if (*buffer == ' ') {
@@ -394,29 +391,30 @@ void Text::processTextLine() {
 		}
 
 		printText8Var8 = buffer;
-		WordSize wordSize = getWordSize(buffer, buf1);
+		char wordBuf[256] = "";
+		WordSize wordSize = getWordSize(buffer, wordBuf, sizeof(wordBuf));
 		if (_addLineBreakX + _dialCharSpace + wordSize.inPixel < _dialTextBoxParam2) {
 			char *temp = buffer + 1;
 			if (*buffer == 1) {
 				var4 = false;
 				buffer = temp;
 			} else {
-				if (*buf1 == '@') {
+				if (*wordBuf == '@') {
 					var4 = false;
 					buffer = temp;
 					if (_addLineBreakX == 0) {
 						_addLineBreakX = 7;
-						*((int16 *)buf2) = spaceChar;
+						*((int16 *)_progressiveTextBuffer) = ' ';
 					}
-					if (buf1[1] == 'P') {
+					if (wordBuf[1] == 'P') {
 						_dialTextBoxCurrentLine = _dialTextBoxLines;
 						buffer++;
 					}
 				} else {
 					buffer += wordSize.inChar;
 					printText8Var8 = buffer;
-					strncat(buf2, buf1, sizeof(buf2));
-					strncat(buf2, " ", sizeof(buf2)); // not 100% accurate
+					strncat(_progressiveTextBuffer, wordBuf, sizeof(_progressiveTextBuffer));
+					strncat(_progressiveTextBuffer, " ", sizeof(_progressiveTextBuffer)); // not 100% accurate
 					printText8PrepareBufferVar2++;
 
 					_addLineBreakX += wordSize.inPixel + _dialCharSpace;
@@ -444,7 +442,7 @@ void Text::processTextLine() {
 
 	printText8Var8 = buffer;
 
-	_progressiveTextBuffer = buf2;
+	_progressiveTextBufferPtr = _progressiveTextBuffer;
 }
 
 void Text::renderContinueReadingTriangle() {
@@ -475,7 +473,7 @@ void Text::renderContinueReadingTriangle() {
 void Text::fadeInCharacters(int32 counter, int32 fontColor) {
 	_engine->_system->delayMillis(15);
 	while (--counter >= 0) {
-		const BlendInCharacter *ptr = &_blendInCharacters[counter];
+		const BlendInCharacter *ptr = &_fadeInCharacters[counter];
 		setFontColor(fontColor);
 		drawCharacterShadow(ptr->x, ptr->y, ptr->chr, fontColor);
 		fontColor -= _dialTextStepSize;
@@ -505,7 +503,7 @@ int Text::updateProgressiveText() {
 		return 0;
 	}
 
-	if (*_progressiveTextBuffer == '\0') {
+	if (*_progressiveTextBufferPtr == '\0') {
 		if (_progressiveTextEnd) {
 			if (renderTextTriangle) {
 				renderContinueReadingTriangle();
@@ -516,7 +514,7 @@ int Text::updateProgressiveText() {
 		if (_progressiveTextNextPage) {
 			_engine->_interface->blitBox(_dialTextBoxLeft, _dialTextBoxTop, _dialTextBoxRight, _dialTextBoxBottom, _engine->workVideoBuffer, _dialTextBoxLeft, _dialTextBoxTop, _engine->frontVideoBuffer);
 			_engine->copyBlockPhys(_dialTextBoxLeft, _dialTextBoxTop, _dialTextBoxRight, _dialTextBoxBottom);
-			_blendInCharactersPos = 0;
+			_fadeInCharactersPos = 0;
 			_progressiveTextNextPage = false;
 			_dialTextYPos = _dialTextBoxLeft + 8;
 			_dialTextXPos = _dialTextBoxTop + 8;
@@ -530,15 +528,15 @@ int Text::updateProgressiveText() {
 	}
 
 	// RECHECK this later
-	if (*_progressiveTextBuffer == '\0') {
+	if (*_progressiveTextBufferPtr == '\0') {
 		return 1;
 	}
 
-	fillFadeInBuffer(_dialTextYPos, _dialTextXPos, *_progressiveTextBuffer);
-	fadeInCharacters(_blendInCharactersPos, _dialTextStartColor);
-	int8 charWidth = getCharWidth(*_progressiveTextBuffer);
+	fillFadeInBuffer(_dialTextYPos, _dialTextXPos, *_progressiveTextBufferPtr);
+	fadeInCharacters(_fadeInCharactersPos, _dialTextStartColor);
+	int8 charWidth = getCharWidth(*_progressiveTextBufferPtr);
 
-	if (*_progressiveTextBuffer != ' ') {
+	if (*_progressiveTextBufferPtr != ' ') {
 		_dialTextYPos += charWidth + 2;
 	} else {
 		if (printText10Var1 != 0) {
@@ -549,9 +547,9 @@ int Text::updateProgressiveText() {
 	}
 
 	// next character
-	_progressiveTextBuffer++;
+	_progressiveTextBufferPtr++;
 
-	if (*_progressiveTextBuffer != '\0') {
+	if (*_progressiveTextBufferPtr != '\0') {
 		return 1;
 	}
 
diff --git a/engines/twine/text.h b/engines/twine/text.h
index 40aee14cd4..312a89872a 100644
--- a/engines/twine/text.h
+++ b/engines/twine/text.h
@@ -98,6 +98,8 @@ enum _TextId {
 };
 }
 
+#define TEXT_MAX_FADE_IN_CHR 32
+
 class TwinEEngine;
 class Text {
 private:
@@ -123,7 +125,7 @@ private:
 		int32 inChar = 0;
 		int32 inPixel = 0;
 	};
-	WordSize getWordSize(const char *arg1, char *arg2);
+	WordSize getWordSize(const char *completeText, char *wordBuf, int32 wordBufSize);
 	void processTextLine();
 	// draw next page arrow polygon
 	void renderContinueReadingTriangle();
@@ -159,16 +161,13 @@ private:
 	/** Number of dialogues text entries */
 	int16 numDialTextEntries = 0;
 
-	const int16 spaceChar = 0x20;
-
 	// TODO: refactor all this variables and related functions
-	char buf1[256] {'\0'};
-	char buf2[256] {'\0'};
+	char _progressiveTextBuffer[256] {'\0'};
 	char *printText8Var8 = nullptr;
 	int32 printText10Var1 = 0;
 
 	int32 _dialTextXPos = 0;
-	char *_progressiveTextBuffer = nullptr;
+	char *_progressiveTextBufferPtr = nullptr;
 	int32 _dialTextBoxCurrentLine = 0;
 	int32 _dialTextYPos = 0;
 	bool _progressiveTextEnd = false;
@@ -179,8 +178,8 @@ private:
 		int16 x = 0;
 		int16 y = 0;
 	};
-	BlendInCharacter _blendInCharacters[32];
-	int32 _blendInCharactersPos = 0;
+	BlendInCharacter _fadeInCharacters[TEXT_MAX_FADE_IN_CHR];
+	int32 _fadeInCharactersPos = 0;
 	int32 printText8PrepareBufferVar2 = 0;
 	// ---
 


Commit: 6d1c1d88abad0ee2f6eafc074bcbb35524c72692
    https://github.com/scummvm/scummvm/commit/6d1c1d88abad0ee2f6eafc074bcbb35524c72692
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-22T23:19:35+01:00

Commit Message:
TWINE: removed member from Text class and reduced cyclic complexity

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


diff --git a/engines/twine/text.cpp b/engines/twine/text.cpp
index 2d11f46984..5f4f3bbae3 100644
--- a/engines/twine/text.cpp
+++ b/engines/twine/text.cpp
@@ -329,7 +329,6 @@ void Text::initProgressiveTextBuffer() {
 	Common::fill(&_progressiveTextBuffer[0], &_progressiveTextBuffer[256], ' ');
 	_progressiveTextBuffer[255] = '\0';
 	_progressiveTextBufferPtr = _progressiveTextBuffer;
-	_addLineBreakX = 16;
 	_dialTextBoxCurrentLine = 0;
 }
 
@@ -377,7 +376,7 @@ void Text::processTextLine() {
 	_dialCharSpace = 7;
 	bool var4 = true;
 
-	_addLineBreakX = 0;
+	int32 lineBreakX = 0;
 	printText8PrepareBufferVar2 = 0;
 	_progressiveTextBuffer[0] = 0;
 
@@ -393,37 +392,40 @@ void Text::processTextLine() {
 		printText8Var8 = buffer;
 		char wordBuf[256] = "";
 		WordSize wordSize = getWordSize(buffer, wordBuf, sizeof(wordBuf));
-		if (_addLineBreakX + _dialCharSpace + wordSize.inPixel < _dialTextBoxParam2) {
-			char *temp = buffer + 1;
-			if (*buffer == 1) {
-				var4 = false;
-				buffer = temp;
-			} else {
-				if (*wordBuf == '@') {
-					var4 = false;
-					buffer = temp;
-					if (_addLineBreakX == 0) {
-						_addLineBreakX = 7;
-						*((int16 *)_progressiveTextBuffer) = ' ';
-					}
-					if (wordBuf[1] == 'P') {
-						_dialTextBoxCurrentLine = _dialTextBoxLines;
-						buffer++;
-					}
-				} else {
-					buffer += wordSize.inChar;
-					printText8Var8 = buffer;
-					strncat(_progressiveTextBuffer, wordBuf, sizeof(_progressiveTextBuffer));
-					strncat(_progressiveTextBuffer, " ", sizeof(_progressiveTextBuffer)); // not 100% accurate
-					printText8PrepareBufferVar2++;
-
-					_addLineBreakX += wordSize.inPixel + _dialCharSpace;
-					if (*printText8Var8 != '\0') {
-						printText8Var8++;
-						continue;
-					}
-				}
+		if (lineBreakX + _dialCharSpace + wordSize.inPixel >= _dialTextBoxParam2) {
+			break;
+		}
+
+		if (*buffer == '\1') {
+			var4 = false;
+			buffer++;
+			break;
+		}
+
+		if (*wordBuf == '@') {
+			var4 = false;
+			buffer++;
+			if (lineBreakX == 0) {
+				lineBreakX = 7;
+				*((int16 *)_progressiveTextBuffer) = ' ';
+			}
+			if (wordBuf[1] == 'P') {
+				_dialTextBoxCurrentLine = _dialTextBoxLines;
+				buffer++;
 			}
+			break;
+		}
+
+		buffer += wordSize.inChar;
+		printText8Var8 = buffer;
+		strncat(_progressiveTextBuffer, wordBuf, sizeof(_progressiveTextBuffer));
+		strncat(_progressiveTextBuffer, " ", sizeof(_progressiveTextBuffer)); // not 100% accurate
+		printText8PrepareBufferVar2++;
+
+		lineBreakX += wordSize.inPixel + _dialCharSpace;
+		if (*printText8Var8 != '\0') {
+			printText8Var8++;
+			continue;
 		}
 		break;
 	}
@@ -436,8 +438,8 @@ void Text::processTextLine() {
 		if (printText8PrepareBufferVar2 == 0) {
 			printText8PrepareBufferVar2 = 1;
 		}
-		_dialCharSpace += (_dialTextBoxParam2 - _addLineBreakX) / printText8PrepareBufferVar2;
-		printText10Var1 = -2 * _addLineBreakX;
+		_dialCharSpace += (_dialTextBoxParam2 - lineBreakX) / printText8PrepareBufferVar2;
+		printText10Var1 = -2 * lineBreakX;
 	}
 
 	printText8Var8 = buffer;
diff --git a/engines/twine/text.h b/engines/twine/text.h
index 312a89872a..9c30c7aace 100644
--- a/engines/twine/text.h
+++ b/engines/twine/text.h
@@ -172,7 +172,6 @@ private:
 	int32 _dialTextYPos = 0;
 	bool _progressiveTextEnd = false;
 	bool _progressiveTextNextPage = false;
-	int32 _addLineBreakX = 0;
 	struct BlendInCharacter {
 		int16 chr = 0;
 		int16 x = 0;


Commit: e0dcabda383aa1bd62fd9c385fc31f472b0cf7fb
    https://github.com/scummvm/scummvm/commit/e0dcabda383aa1bd62fd9c385fc31f472b0cf7fb
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-22T23:19:35+01:00

Commit Message:
TWINE: converted member to stack var

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


diff --git a/engines/twine/text.cpp b/engines/twine/text.cpp
index 5f4f3bbae3..fabcab6b72 100644
--- a/engines/twine/text.cpp
+++ b/engines/twine/text.cpp
@@ -377,8 +377,8 @@ void Text::processTextLine() {
 	bool var4 = true;
 
 	int32 lineBreakX = 0;
-	printText8PrepareBufferVar2 = 0;
-	_progressiveTextBuffer[0] = 0;
+	int32 printText8PrepareBufferVar2 = 0;
+	_progressiveTextBuffer[0] = '\0';
 
 	for (;;) {
 		if (*buffer == ' ') {
@@ -407,7 +407,8 @@ void Text::processTextLine() {
 			buffer++;
 			if (lineBreakX == 0) {
 				lineBreakX = 7;
-				*((int16 *)_progressiveTextBuffer) = ' ';
+				*(_progressiveTextBuffer + 0) = ' ';
+				*(_progressiveTextBuffer + 1) = ' ';
 			}
 			if (wordBuf[1] == 'P') {
 				_dialTextBoxCurrentLine = _dialTextBoxLines;
diff --git a/engines/twine/text.h b/engines/twine/text.h
index 9c30c7aace..f125f4361d 100644
--- a/engines/twine/text.h
+++ b/engines/twine/text.h
@@ -179,8 +179,6 @@ private:
 	};
 	BlendInCharacter _fadeInCharacters[TEXT_MAX_FADE_IN_CHR];
 	int32 _fadeInCharactersPos = 0;
-	int32 printText8PrepareBufferVar2 = 0;
-	// ---
 
 	/** Current dialogue text pointer */
 	char *_currDialTextPtr = nullptr;


Commit: b16f8c55c5936fb7a2d44434c88aa071f7288b18
    https://github.com/scummvm/scummvm/commit/b16f8c55c5936fb7a2d44434c88aa071f7288b18
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-22T23:19:35+01:00

Commit Message:
TWINE: replaced magic numbers

Changed paths:
    engines/twine/text.cpp


diff --git a/engines/twine/text.cpp b/engines/twine/text.cpp
index fabcab6b72..969dff03e3 100644
--- a/engines/twine/text.cpp
+++ b/engines/twine/text.cpp
@@ -419,8 +419,8 @@ void Text::processTextLine() {
 
 		buffer += wordSize.inChar;
 		printText8Var8 = buffer;
-		strncat(_progressiveTextBuffer, wordBuf, sizeof(_progressiveTextBuffer));
-		strncat(_progressiveTextBuffer, " ", sizeof(_progressiveTextBuffer)); // not 100% accurate
+		strncat(_progressiveTextBuffer, wordBuf, sizeof(_progressiveTextBuffer) - strlen(_progressiveTextBuffer) - 1);
+		strncat(_progressiveTextBuffer, " ", sizeof(_progressiveTextBuffer) - strlen(_progressiveTextBuffer) - 1); // not 100% accurate
 		printText8PrepareBufferVar2++;
 
 		lineBreakX += wordSize.inPixel + _dialCharSpace;
@@ -657,7 +657,7 @@ void Text::setFontCrossColor(int32 color) {
 	_dialTextStepSize = -1;
 	_dialTextBufferSize = 14;
 	_dialTextStartColor = color << 4;
-	_dialTextStopColor = (color << 4) + 12;
+	_dialTextStopColor = _dialTextStartColor + 12;
 }
 
 void Text::setFontColor(int32 color) {
@@ -734,21 +734,24 @@ bool Text::getMenuText(int32 index, char *text, uint32 textSize) {
 	return true;
 }
 
-void Text::textClipFull() { // newGame2
-	_dialTextBoxLeft = 8;
-	_dialTextBoxTop = 8;
-	_dialTextBoxRight = 631;
+void Text::textClipFull() {
+	const int padding = 9;
+	_dialTextBoxLeft = padding - 1;
+	_dialTextBoxTop = padding - 1;
+	_dialTextBoxRight = SCREEN_WIDTH - padding;
+	_dialTextBoxBottom = SCREEN_HEIGHT - padding;
 
-	_dialTextBoxBottom = 471;
 	_dialTextBoxLines = 11;
 	_dialTextBoxParam2 = 607;
 }
 
-void Text::textClipSmall() { // newGame4
-	_dialTextBoxLeft = 16;
+void Text::textClipSmall() {
+	const int padding = 17;
+	_dialTextBoxLeft = padding - 1;
 	_dialTextBoxTop = 334;
-	_dialTextBoxRight = 623;
-	_dialTextBoxBottom = 463;
+	_dialTextBoxRight = SCREEN_WIDTH - padding;
+	_dialTextBoxBottom = SCREEN_HEIGHT - padding;
+
 	_dialTextBoxLines = 3;
 	_dialTextBoxParam2 = 591;
 }


Commit: ac0c5170b570e892699e363ec2f5816a9fcf1e6f
    https://github.com/scummvm/scummvm/commit/ac0c5170b570e892699e363ec2f5816a9fcf1e6f
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-22T23:19:35+01:00

Commit Message:
NEWS: mention the support for lba

Changed paths:
    NEWS.md


diff --git a/NEWS.md b/NEWS.md
index 2dd9fdd9a8..9819a3d8d3 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -9,6 +9,7 @@ For a more comprehensive changelog of the latest experimental code, see:
    - Added support for The Longest Journey.
    - Added support for Myst 3: Exile.
    - Added support for Hades' Challenge.
+   - Added support for Little Big Adventure.
 
  General:
    - Switched ScummVM GUI output to UTF-32.


Commit: f079ae1bb6bb7f35e3ca88c2b7d6d424c6e596f9
    https://github.com/scummvm/scummvm/commit/f079ae1bb6bb7f35e3ca88c2b7d6d424c6e596f9
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-22T23:19:35+01:00

Commit Message:
TWINE: added lba2 detection entries

Changed paths:
    engines/twine/detection.cpp


diff --git a/engines/twine/detection.cpp b/engines/twine/detection.cpp
index 9eb0d438a1..560c252b9f 100644
--- a/engines/twine/detection.cpp
+++ b/engines/twine/detection.cpp
@@ -470,6 +470,58 @@ static const ADGameDescription twineGameDescriptions[] = {
 		GUIO1(GUIO_NONE)
 	},
 
+	// Little Big Adventure 2
+
+	// Little Big Adventure 2 - Original European Version (EN, FR, DE, IT, ES)
+	// LBA2.EXE
+	// 4 Sep 2004 at 18:44
+	{
+		"lba2",
+		"CD Original European Version",
+
+		AD_ENTRY1s("LBA2.EXE", "ba915d65b3c7a743a87804f73f29675b", 616448),
+		Common::EN_ANY,
+		Common::kPlatformDOS,
+		ADGF_UNSTABLE,
+		GUIO1(GUIO_NONE)
+	},
+	{
+		"lba2",
+		"CD Original European Version",
+		AD_ENTRY1s("LBA2.EXE", "ba915d65b3c7a743a87804f73f29675b", 616448),
+		Common::FR_FRA,
+		Common::kPlatformDOS,
+		ADGF_UNSTABLE,
+		GUIO1(GUIO_NONE)
+	},
+	{
+		"lba2",
+		"CD Original European Version",
+		AD_ENTRY1s("LBA2.EXE", "ba915d65b3c7a743a87804f73f29675b", 616448),
+		Common::DE_DEU,
+		Common::kPlatformDOS,
+		ADGF_UNSTABLE,
+		GUIO1(GUIO_NONE)
+	},
+	{
+		"lba2",
+		"CD Original European Version",
+		AD_ENTRY1s("LBA2.EXE", "ba915d65b3c7a743a87804f73f29675b", 616448),
+		Common::IT_ITA,
+		Common::kPlatformDOS,
+		ADGF_UNSTABLE,
+		GUIO1(GUIO_NONE)
+	},
+	{
+		"lba2",
+		"CD Original European Version",
+		AD_ENTRY1s("LBA2.EXE", "ba915d65b3c7a743a87804f73f29675b", 616448),
+		Common::ES_ESP,
+		Common::kPlatformDOS,
+		ADGF_UNSTABLE,
+		GUIO1(GUIO_NONE)
+	},
+
 	AD_TABLE_END_MARKER
 };
 


Commit: 44670275e716fb618588db6bc016b6147acf95bf
    https://github.com/scummvm/scummvm/commit/44670275e716fb618588db6bc016b6147acf95bf
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-22T23:19:35+01:00

Commit Message:
TWINE: doxygen

Changed paths:
    engines/twine/hqr.h


diff --git a/engines/twine/hqr.h b/engines/twine/hqr.h
index 0885d99b67..154b4b53fc 100644
--- a/engines/twine/hqr.h
+++ b/engines/twine/hqr.h
@@ -62,7 +62,8 @@ int32 numEntries(const char *filename);
 
 /**
  * Get a HQR entry pointer with memory allocation
- * @param ptr pointer to save the entry
+ * @param ptr pointer to save the entry. This pointer is automatically freed and therefore must be initialized
+ * to @c nullptr on the first run.
  * @param filename HQR file name
  * @param index entry index to extract
  * @return entry real size
@@ -79,7 +80,8 @@ int32 getAllocEntry(uint8 **ptr, const char *filename, int32 index);
 int32 getVoxEntry(uint8 *ptr, const char *filename, int32 index, int32 hiddenIndex);
 /**
  * Get a HQR entry pointer with memory allocation
- * @param ptr pointer to save the entry
+ * @param ptr pointer to save the entry. This pointer is automatically freed and therefore must be initialized
+ * to @c nullptr on the first run.
  * @param filename HQR file name
  * @param index entry index to extract
  * @return entry real size


Commit: a5dad05678667ed4defa050923155e522a09c7a6
    https://github.com/scummvm/scummvm/commit/a5dad05678667ed4defa050923155e522a09c7a6
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-23T16:42:21+01:00

Commit Message:
TWINE: the body index is not related to the inventory item idx

Changed paths:
    engines/twine/twine.cpp


diff --git a/engines/twine/twine.cpp b/engines/twine/twine.cpp
index 7ab8f493dd..3f553860a2 100644
--- a/engines/twine/twine.cpp
+++ b/engines/twine/twine.cpp
@@ -445,11 +445,11 @@ void TwinEEngine::processInventoryAction() {
 		_gameState->usingSabre = false;
 		break;
 	case kiUseSabre:
-		if (_scene->sceneHero->body != InventoryItems::kiUseSabre) {
+		if (_scene->sceneHero->body != 2) {
 			if (_actor->heroBehaviour == HeroBehaviourType::kProtoPack) {
 				_actor->setBehaviour(HeroBehaviourType::kNormal);
 			}
-			_actor->initModelActor(InventoryItems::kiUseSabre, OWN_ACTOR_SCENE_INDEX);
+			_actor->initModelActor(2, OWN_ACTOR_SCENE_INDEX);
 			_animations->initAnim(AnimationTypes::kSabreUnknown, 1, AnimationTypes::kStanding, OWN_ACTOR_SCENE_INDEX);
 
 			_gameState->usingSabre = true;




More information about the Scummvm-git-logs mailing list