[Scummvm-git-logs] scummvm master -> 547f41097481bcbda198cf41c45385593dc3adab

mgerhardy martin.gerhardy at gmail.com
Thu Nov 26 22:13:41 UTC 2020


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

Summary:
390336f5fc TWINE: converted parameter to bool
0b29c0cd3c TWINE: replaced magic numbers
547f410974 TWINE: convert member to local var


Commit: 390336f5fcb4d53147c3be774d4c4d64ea0d847c
    https://github.com/scummvm/scummvm/commit/390336f5fcb4d53147c3be774d4c4d64ea0d847c
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-26T23:13:22+01:00

Commit Message:
TWINE: converted parameter to bool

Changed paths:
    engines/twine/debug.cpp
    engines/twine/gamestate.cpp
    engines/twine/redraw.cpp
    engines/twine/redraw.h
    engines/twine/scene.cpp
    engines/twine/script_life_v1.cpp
    engines/twine/twine.cpp


diff --git a/engines/twine/debug.cpp b/engines/twine/debug.cpp
index 63f29635c7..bb752cccdf 100644
--- a/engines/twine/debug.cpp
+++ b/engines/twine/debug.cpp
@@ -193,7 +193,7 @@ void Debug::debugResetButton(int32 type) {
 }
 
 void Debug::debugRedrawScreen() {
-	_engine->_redraw->redrawEngineActions(1);
+	_engine->_redraw->redrawEngineActions(true);
 	_engine->_screens->copyScreen(_engine->frontVideoBuffer, _engine->workVideoBuffer);
 	debugDrawWindows();
 }
diff --git a/engines/twine/gamestate.cpp b/engines/twine/gamestate.cpp
index b4b936709d..03567b0357 100644
--- a/engines/twine/gamestate.cpp
+++ b/engines/twine/gamestate.cpp
@@ -274,7 +274,7 @@ void GameState::processFoundItem(int32 item) {
 
 	// Hide hero in scene
 	_engine->_scene->sceneHero->staticFlags.bIsHidden = 1;
-	_engine->_redraw->redrawEngineActions(1);
+	_engine->_redraw->redrawEngineActions(true);
 	_engine->_scene->sceneHero->staticFlags.bIsHidden = 0;
 
 	_engine->_screens->copyScreen(_engine->frontVideoBuffer, _engine->workVideoBuffer);
@@ -436,7 +436,7 @@ void GameState::processGameoverAnimation() {
 
 	// workaround to fix hero redraw after drowning
 	_engine->_scene->sceneHero->staticFlags.bIsHidden = 1;
-	_engine->_redraw->redrawEngineActions(1);
+	_engine->_redraw->redrawEngineActions(true);
 	_engine->_scene->sceneHero->staticFlags.bIsHidden = 0;
 
 	// TODO: drawInGameTransBox
diff --git a/engines/twine/redraw.cpp b/engines/twine/redraw.cpp
index 6d94449ee2..54ebcf667a 100644
--- a/engines/twine/redraw.cpp
+++ b/engines/twine/redraw.cpp
@@ -192,9 +192,9 @@ void Redraw::addOverlay(int16 type, int16 info0, int16 x, int16 y, int16 info1,
 	}
 }
 
-void Redraw::updateOverlayTypePosition(int16 X1, int16 Y1, int16 X2, int16 Y2) {
-	const int16 newX = X2 - X1;
-	const int16 newY = Y2 - Y1;
+void Redraw::updateOverlayTypePosition(int16 x1, int16 y1, int16 x2, int16 y2) {
+	const int16 newX = x2 - x1;
+	const int16 newY = y2 - y1;
 
 	for (int32 i = 0; i < ARRAYSIZE(overlayList); i++) {
 		OverlayListStruct *overlay = &overlayList[i];
@@ -206,7 +206,7 @@ void Redraw::updateOverlayTypePosition(int16 X1, int16 Y1, int16 X2, int16 Y2) {
 }
 
 // TODO: convert to bool and check if this isn't always true...
-void Redraw::redrawEngineActions(int32 bgRedraw) { // fullRedraw
+void Redraw::redrawEngineActions(bool bgRedraw) { // fullRedraw
 	int16 tmp_projPosX = _engine->_renderer->projPosXScreen;
 	int16 tmp_projPosY = _engine->_renderer->projPosYScreen;
 
diff --git a/engines/twine/redraw.h b/engines/twine/redraw.h
index 09dd965aaa..3b814d961f 100644
--- a/engines/twine/redraw.h
+++ b/engines/twine/redraw.h
@@ -142,7 +142,7 @@ public:
 	 * This is responsible for the entire game screen redraw
 	 * @param bgRedraw true if we want to redraw background grid, false if we want to update certain screen areas
 	 */
-	void redrawEngineActions(int32 bgRedraw);
+	void redrawEngineActions(bool bgRedraw);
 
 	/** Draw dialogue sprite image */
 	void drawBubble(int32 actorIdx);
diff --git a/engines/twine/scene.cpp b/engines/twine/scene.cpp
index 5bcc2ea7ba..79981db7d3 100644
--- a/engines/twine/scene.cpp
+++ b/engines/twine/scene.cpp
@@ -528,7 +528,7 @@ void Scene::processActorZones(int32 actorIdx) {
 					talkingActor = actorIdx;
 					_engine->_text->drawTextFullscreen(zone->infoData.DisplayText.textIdx);
 					_engine->unfreezeTime();
-					_engine->_redraw->redrawEngineActions(1);
+					_engine->_redraw->redrawEngineActions(true);
 				}
 				break;
 			case kLadder:
diff --git a/engines/twine/script_life_v1.cpp b/engines/twine/script_life_v1.cpp
index c9db46f5dd..c665bf20b1 100644
--- a/engines/twine/script_life_v1.cpp
+++ b/engines/twine/script_life_v1.cpp
@@ -652,7 +652,7 @@ static int32 lMESSAGE(TwinEEngine *engine, LifeScriptContext &ctx) {
 	engine->_scene->talkingActor = ctx.actorIdx;
 	engine->_text->drawTextFullscreen(textIdx);
 	engine->unfreezeTime();
-	engine->_redraw->redrawEngineActions(1);
+	engine->_redraw->redrawEngineActions(true);
 
 	return 0;
 }
@@ -917,7 +917,7 @@ static int32 lMESSAGE_OBJ(TwinEEngine *engine, LifeScriptContext &ctx) {
 	engine->_scene->talkingActor = otherActorIdx;
 	engine->_text->drawTextFullscreen(textIdx);
 	engine->unfreezeTime();
-	engine->_redraw->redrawEngineActions(1);
+	engine->_redraw->redrawEngineActions(true);
 
 	return 0;
 }
@@ -941,7 +941,7 @@ static int32 lFOUND_OBJECT(TwinEEngine *engine, LifeScriptContext &ctx) {
 	engine->freezeTime();
 	engine->_gameState->processFoundItem(item);
 	engine->unfreezeTime();
-	engine->_redraw->redrawEngineActions(1);
+	engine->_redraw->redrawEngineActions(true);
 
 	return 0;
 }
@@ -1282,7 +1282,7 @@ static int32 lASK_CHOICE(TwinEEngine *engine, LifeScriptContext &ctx) {
 	engine->_gameState->processGameChoices(choiceIdx);
 	engine->_gameState->numChoices = 0;
 	engine->unfreezeTime();
-	engine->_redraw->redrawEngineActions(1);
+	engine->_redraw->redrawEngineActions(true);
 
 	return 0;
 }
@@ -1304,7 +1304,7 @@ static int32 lBIG_MESSAGE(TwinEEngine *engine, LifeScriptContext &ctx) {
 	engine->_text->drawTextFullscreen(textIdx);
 	engine->_text->textClipSmall();
 	engine->unfreezeTime();
-	engine->_redraw->redrawEngineActions(1);
+	engine->_redraw->redrawEngineActions(true);
 
 	return 0;
 }
@@ -1442,7 +1442,7 @@ static int32 lGRM_OFF(TwinEEngine *engine, LifeScriptContext &ctx) {
 		engine->_grid->useCellingGrid = -1;
 		engine->_grid->cellingGridIdx = -1;
 		engine->_grid->createGridMap();
-		engine->_redraw->redrawEngineActions(1);
+		engine->_redraw->redrawEngineActions(true);
 	}
 
 	return 0;
@@ -1569,7 +1569,7 @@ static int32 lASK_CHOICE_OBJ(TwinEEngine *engine, LifeScriptContext &ctx) {
 	engine->_gameState->processGameChoices(choiceIdx);
 	engine->_gameState->numChoices = 0;
 	engine->unfreezeTime();
-	engine->_redraw->redrawEngineActions(1);
+	engine->_redraw->redrawEngineActions(true);
 
 	return 0;
 }
diff --git a/engines/twine/twine.cpp b/engines/twine/twine.cpp
index 2e6540877c..759ed8ab67 100644
--- a/engines/twine/twine.cpp
+++ b/engines/twine/twine.cpp
@@ -554,7 +554,7 @@ void TwinEEngine::processInventoryAction() {
 	}
 	case kiBonusList: {
 		unfreezeTime();
-		_redraw->redrawEngineActions(1);
+		_redraw->redrawEngineActions(true);
 		freezeTime();
 		_text->initTextBank(TextBankId::Inventory_Intro_and_Holomap);
 		_text->textClipFull();
@@ -576,7 +576,7 @@ void TwinEEngine::processInventoryAction() {
 		break;
 	}
 
-	_redraw->redrawEngineActions(1);
+	_redraw->redrawEngineActions(true);
 }
 
 void TwinEEngine::processOptionsMenu() {
@@ -585,7 +585,7 @@ void TwinEEngine::processOptionsMenu() {
 	_menu->inGameOptionsMenu();
 	// TODO: play music
 	_sound->resumeSamples();
-	_redraw->redrawEngineActions(1);
+	_redraw->redrawEngineActions(true);
 }
 
 void TwinEEngine::centerScreenOnActor() {
@@ -640,14 +640,14 @@ int32 TwinEEngine::runGameEngine() { // mainLoopInteration
 			}
 			if (giveUp == 1) {
 				unfreezeTime();
-				_redraw->redrawEngineActions(1);
+				_redraw->redrawEngineActions(true);
 				ScopedEngineFreeze freeze(this);
 				autoSave();
 				quitGame = 0;
 				return 0;
 			}
 			unfreezeTime();
-			_redraw->redrawEngineActions(1);
+			_redraw->redrawEngineActions(true);
 		}
 
 		if (_input->toggleActionIfActive(TwinEActionType::OptionsMenu)) {
@@ -689,7 +689,7 @@ int32 TwinEEngine::runGameEngine() { // mainLoopInteration
 			freezeTime();
 			_menu->processBehaviourMenu();
 			unfreezeTime();
-			_redraw->redrawEngineActions(1);
+			_redraw->redrawEngineActions(true);
 		}
 
 		// use Proto-Pack
@@ -723,7 +723,7 @@ int32 TwinEEngine::runGameEngine() { // mainLoopInteration
 			_holomap->processHolomap();
 			_screens->lockPalette = true;
 			unfreezeTime();
-			_redraw->redrawEngineActions(1);
+			_redraw->redrawEngineActions(true);
 		}
 
 		// Process Pause
@@ -740,7 +740,7 @@ int32 TwinEEngine::runGameEngine() { // mainLoopInteration
 				g_system->delayMillis(10);
 			} while (!_input->toggleActionIfActive(TwinEActionType::Pause));
 			unfreezeTime();
-			_redraw->redrawEngineActions(1);
+			_redraw->redrawEngineActions(true);
 		}
 	}
 
@@ -907,7 +907,7 @@ int32 TwinEEngine::runGameEngine() { // mainLoopInteration
 	// workaround to fix hero redraw after drowning
 	if (_actor->cropBottomScreen && _redraw->reqBgRedraw) {
 		_scene->sceneHero->staticFlags.bIsHidden = 1;
-		_redraw->redrawEngineActions(1);
+		_redraw->redrawEngineActions(true);
 		_scene->sceneHero->staticFlags.bIsHidden = 0;
 	}
 


Commit: 0b29c0cd3c7eefa819afdf0484bba45e9488b070
    https://github.com/scummvm/scummvm/commit/0b29c0cd3c7eefa819afdf0484bba45e9488b070
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-26T23:13:22+01:00

Commit Message:
TWINE: replaced magic numbers

Changed paths:
    engines/twine/debug.cpp
    engines/twine/menu.cpp
    engines/twine/menu.h


diff --git a/engines/twine/debug.cpp b/engines/twine/debug.cpp
index bb752cccdf..bc3f1857d3 100644
--- a/engines/twine/debug.cpp
+++ b/engines/twine/debug.cpp
@@ -401,15 +401,15 @@ int32 Debug::debugProcessButton(int32 x, int32 y) {
 }
 
 void Debug::debugPlasmaWindow(const char *text, int32 color) {
-	int32 textSize;
 	_engine->_menu->processPlasmaEffect(0, 5, color);
 	if (!(_engine->getRandomNumber() % 5)) {
-		_engine->_menu->plasmaEffectPtr[_engine->getRandomNumber() % 320 * 10 + 6400] = 255;
+		_engine->_menu->plasmaEffectPtr[_engine->getRandomNumber() % PLASMA_WIDTH * 10 + 6400] = 255;
 	}
-	textSize = _engine->_text->getTextSize(text);
+	int32 textSize = _engine->_text->getTextSize(text);
 	_engine->_text->drawText((SCREEN_WIDTH / 2) - (textSize / 2), 10, text);
-	_engine->_menu->drawBox(5, 5, 634, 50);
-	_engine->copyBlockPhys(5, 5, 634, 50);
+	const Common::Rect rect(5, 5, 634, 50);
+	_engine->_menu->drawBox(rect);
+	_engine->copyBlockPhys(rect);
 }
 
 void Debug::debugProcessWindow() {
diff --git a/engines/twine/menu.cpp b/engines/twine/menu.cpp
index f28681ccae..b15617bfa8 100644
--- a/engines/twine/menu.cpp
+++ b/engines/twine/menu.cpp
@@ -207,8 +207,9 @@ void Menu::plasmaEffectRenderFrame() {
 	// flip the double-buffer while scrolling the effect vertically:
 	uint8 *dest = plasmaEffectPtr;
 	const uint8 *src = plasmaEffectPtr + (PLASMA_HEIGHT + 1) * PLASMA_WIDTH;
-	for (int32 i = 0; i < PLASMA_HEIGHT * PLASMA_WIDTH; i++)
+	for (int32 i = 0; i < PLASMA_HEIGHT * PLASMA_WIDTH; i++) {
 		*(dest++) = *(src++);
+	}
 }
 
 void Menu::processPlasmaEffect(int32 left, int32 top, int32 color) {
@@ -220,14 +221,18 @@ void Menu::processPlasmaEffect(int32 left, int32 top, int32 color) {
 	uint8 *out = (uint8 *)_engine->frontVideoBuffer.getBasePtr(left, top);
 
 	for (int32 y = 0; y < PLASMA_HEIGHT / 2; y++) {
+		int32 yOffset = y * SCREEN_WIDTH;
+		const uint8 *colPtr = &in[y * PLASMA_WIDTH];
 		for (int32 x = 0; x < PLASMA_WIDTH; x++) {
-			const uint8 c = MIN(in[y * PLASMA_WIDTH + x] / 2 + color, max_value);
+			const uint8 c = MIN(*colPtr / 2 + color, max_value);
 			/* 2x2 squares sharing the same pixel color: */
-			const int32 target = 2 * (y * SCREEN_WIDTH + x);
+			const int32 target = 2 * yOffset;
 			out[target + 0] = c;
 			out[target + 1] = c;
 			out[target + SCREEN_WIDTH + 0] = c;
 			out[target + SCREEN_WIDTH + 1] = c;
+			++colPtr;
+			++yOffset;
 		}
 	}
 }
@@ -791,8 +796,11 @@ void Menu::drawInfoMenu(int16 left, int16 top) {
 	_engine->_interface->resetClip();
 	const int32 width = 450;
 	const int32 height = 80;
-	drawBox(left, top, left + width, top + height);
-	_engine->_interface->drawSplittedBox(Common::Rect(left + 1, top + 1, left + width - 1, top + height - 1), 0);
+	const Common::Rect rect(left, top, left + width, top + height);
+	drawBox(rect);
+	Common::Rect splittedBoxRect(rect);
+	splittedBoxRect.grow(-1);
+	_engine->_interface->drawSplittedBox(splittedBoxRect, 0);
 
 	int32 newBoxLeft2 = left + 9;
 
@@ -805,14 +813,14 @@ void Menu::drawInfoMenu(int16 left, int16 top) {
 	int32 boxTop = top + 10;
 	int32 boxBottom = top + 25;
 	_engine->_interface->drawSplittedBox(Common::Rect(newBoxLeft, boxTop, boxLeft, boxBottom), 91);
-	drawBox(left + 25, top + 10, left + 324, top + 10 + 14);
+	drawBox(newBoxLeft, boxTop, left + 324, boxTop + 14);
 
 	if (!_engine->_gameState->inventoryDisabled() && _engine->_gameState->hasItem(InventoryItems::kiTunic)) {
 		_engine->_grid->drawSprite(0, newBoxLeft2, top + 36, _engine->_resources->spriteTable[SPRITEHQR_MAGICPOINTS]);
 		if (_engine->_gameState->magicLevelIdx > 0) {
 			_engine->_interface->drawSplittedBox(Common::Rect(newBoxLeft, top + 35, _engine->_screens->crossDot(newBoxLeft, boxRight, 80, _engine->_gameState->inventoryMagicPoints), top + 50), 75);
 		}
-		drawBox(left + 25, top + 35, left + _engine->_gameState->magicLevelIdx * 80 + 20, top + 35 + 15);
+		drawBox(newBoxLeft, top + 35, left + _engine->_gameState->magicLevelIdx * 80 + 20, top + 35 + 15);
 	}
 
 	boxLeft = left + 340;
@@ -844,7 +852,7 @@ void Menu::drawInfoMenu(int16 left, int16 top) {
 		_engine->_grid->drawSprite(0, _engine->_screens->crossDot(left + 25, left + 325, 10, i) + 2, top + 60, _engine->_resources->spriteTable[SPRITEHQR_CLOVERLEAF]);
 	}
 
-	_engine->copyBlockPhys(left, top, left + 450, top + 135);
+	_engine->copyBlockPhys(left, top, left + width, top + 135);
 }
 
 Common::Rect Menu::calcBehaviourRect(HeroBehaviourType behaviour) const {
diff --git a/engines/twine/menu.h b/engines/twine/menu.h
index 37d1f08095..3f113482c0 100644
--- a/engines/twine/menu.h
+++ b/engines/twine/menu.h
@@ -30,7 +30,7 @@
 namespace TwinE {
 
 #define MAX_BUTTONS 10
-#define PLASMA_WIDTH 320
+#define PLASMA_WIDTH (SCREEN_WIDTH / 2)
 #define PLASMA_HEIGHT 50
 #define kQuitEngine 9998
 


Commit: 547f41097481bcbda198cf41c45385593dc3adab
    https://github.com/scummvm/scummvm/commit/547f41097481bcbda198cf41c45385593dc3adab
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-26T23:13:22+01:00

Commit Message:
TWINE: convert member to local var

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


diff --git a/engines/twine/text.cpp b/engines/twine/text.cpp
index b197e04252..c3bb51aa05 100644
--- a/engines/twine/text.cpp
+++ b/engines/twine/text.cpp
@@ -252,18 +252,18 @@ void Text::drawText(int32 x, int32 y, const char *dialogue) {
 		if (currChar == ' ') {
 			x += _dialCharSpace;
 		} else {
-			_dialTextSize = getCharWidth(currChar);
+			int32 dialTextSize = getCharWidth(currChar);
 			drawCharacter(x, y, currChar); // draw the character on screen
 			// add the length of the space between 2 characters
 			x += _dialSpaceBetween;
 			// add the length of the current character
-			x += _dialTextSize;
+			x += dialTextSize;
 		}
 	} while (1);
 }
 
 int32 Text::getTextSize(const char *dialogue) { // SizeFont
-	_dialTextSize = 0;
+	int32 dialTextSize = 0;
 
 	do {
 		const uint8 currChar = (uint8) * (dialogue++);
@@ -272,14 +272,14 @@ int32 Text::getTextSize(const char *dialogue) { // SizeFont
 		}
 
 		if (currChar == ' ') {
-			_dialTextSize += _dialCharSpace;
+			dialTextSize += _dialCharSpace;
 		} else {
-			_dialTextSize += _dialSpaceBetween;
-			_dialTextSize += getCharWidth(currChar);
+			dialTextSize += _dialSpaceBetween;
+			dialTextSize += getCharWidth(currChar);
 		}
 	} while (1);
 
-	return _dialTextSize;
+	return dialTextSize;
 }
 
 void Text::initDialogueBox() { // InitDialWindow
diff --git a/engines/twine/text.h b/engines/twine/text.h
index 6b1523839d..e810fa2f8c 100644
--- a/engines/twine/text.h
+++ b/engines/twine/text.h
@@ -184,8 +184,6 @@ private:
 	/** Current dialogue text size */
 	int32 _currDialTextSize = 0;
 
-	/** Dialogue text size */
-	int32 _dialTextSize = 0;
 	/** Pixel size between dialogue text */
 	int32 _dialSpaceBetween = 0;
 	/** Pixel size of the space character */




More information about the Scummvm-git-logs mailing list