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

bluegr bluegr at gmail.com
Tue Jun 8 21:39:00 UTC 2021


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

Summary:
d069086332 TRECISION: Rename _textCol -> _textColor
6ce7d3a985 TRECISION: Remove mask color params and simplify the blinking char code


Commit: d069086332b4f912f6db17c228056ed97f4ba837
    https://github.com/scummvm/scummvm/commit/d069086332b4f912f6db17c228056ed97f4ba837
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2021-06-09T00:19:04+03:00

Commit Message:
TRECISION: Rename _textCol -> _textColor

Changed paths:
    engines/trecision/dialog.cpp
    engines/trecision/struct.h
    engines/trecision/text.cpp
    engines/trecision/text.h
    engines/trecision/utils.cpp


diff --git a/engines/trecision/dialog.cpp b/engines/trecision/dialog.cpp
index d759a80e6e..c3657f0338 100644
--- a/engines/trecision/dialog.cpp
+++ b/engines/trecision/dialog.cpp
@@ -637,7 +637,7 @@ void DialogManager::dialogHandler(int numFrame) {
 			++_curSubTitle;
 			_vm->_drawText._rect.left = _subTitles[i]._x;
 			_vm->_drawText._rect.top = _subTitles[i]._y;
-			_vm->_drawText._textCol = _subTitles[i]._color;
+			_vm->_drawText._textColor = _subTitles[i]._color;
 			_vm->_drawText._text = _vm->_sentence[_subTitles[i]._sentence];
 		}
 	}
diff --git a/engines/trecision/struct.h b/engines/trecision/struct.h
index 94842d7284..c6f008eae6 100644
--- a/engines/trecision/struct.h
+++ b/engines/trecision/struct.h
@@ -164,7 +164,7 @@ class TrecisionEngine;
 struct SDText {
 	Common::Rect _rect;
 	Common::Rect _subtitleRect;
-	uint16 _textCol;
+	uint16 _textColor;
 	uint16 _shadowCol;
 	Common::String _text;
 	Common::String _drawTextLines[MAXDTEXTLINES];
diff --git a/engines/trecision/text.cpp b/engines/trecision/text.cpp
index 6579f4c9b4..b88808c893 100644
--- a/engines/trecision/text.cpp
+++ b/engines/trecision/text.cpp
@@ -381,7 +381,7 @@ void TextManager::addText(Common::Point pos, const char *text, uint16 textCol, u
 	StackText t;
 	t._x = pos.x;
 	t._y = pos.y;
-	t._textCol = textCol;
+	t._textColor = textCol;
 	t._shadowCol = shadowCol;
 	t._clear = false;
 	t._text = text;
@@ -420,7 +420,7 @@ void TextManager::drawText(StackText *text) {
 	uint16 height = _curString.calcHeight(_vm);
 	_curString._subtitleRect = Common::Rect(_curString._rect.width(), height);
 	_curString._rect.setHeight(height);
-	_curString._textCol = text->_textCol;
+	_curString._textColor = text->_textColor;
 	_curString._shadowCol = text->_shadowCol;
 
 	if (_curString._rect.top <= height)
diff --git a/engines/trecision/text.h b/engines/trecision/text.h
index 8c3fae53ce..79a633bbfc 100644
--- a/engines/trecision/text.h
+++ b/engines/trecision/text.h
@@ -36,7 +36,7 @@ class TrecisionEngine;
 struct StackText {
 	uint16 _x;
 	uint16 _y;
-	uint16 _textCol, _shadowCol;
+	uint16 _textColor, _shadowCol;
 	Common::String _text;
 	bool _clear;
 };
diff --git a/engines/trecision/utils.cpp b/engines/trecision/utils.cpp
index 5f34b06836..758c72e04c 100644
--- a/engines/trecision/utils.cpp
+++ b/engines/trecision/utils.cpp
@@ -297,13 +297,13 @@ int TrecisionEngine::getRoomObjectIndex(uint16 objectId) {
  * SDText
  ************************************************/
 void SDText::set(SDText *org) {
-	set(org->_rect, org->_subtitleRect, org->_textCol, org->_shadowCol, org->_text);
+	set(org->_rect, org->_subtitleRect, org->_textColor, org->_shadowCol, org->_text);
 }
 
 void SDText::set(Common::Rect rect, Common::Rect subtitleRect, uint16 textCol, uint16 shadowCol, const Common::String &text) {
 	_rect = rect;
 	_subtitleRect = subtitleRect;
-	_textCol = textCol;
+	_textColor = textCol;
 	_shadowCol = shadowCol;
 	_text = text;
 
@@ -373,7 +373,7 @@ uint16 SDText::calcHeight(TrecisionEngine *vm) {
 }
 
 void SDText::draw(TrecisionEngine *vm, Graphics::Surface *externalSurface) {
-	uint16 tmpTextCol = _textCol;
+	uint16 tmpTextCol = _textColor;
 	uint16 tmpShadowCol = _shadowCol;
 	vm->_graphicsMgr->updatePixelFormat(&tmpTextCol, 1);
 	if (_shadowCol != MASKCOL)


Commit: 6ce7d3a985bdd9dac719d8f6dc7883e9f2e006eb
    https://github.com/scummvm/scummvm/commit/6ce7d3a985bdd9dac719d8f6dc7883e9f2e006eb
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2021-06-09T00:38:47+03:00

Commit Message:
TRECISION: Remove mask color params and simplify the blinking char code

The mask or shadow color was always MASKCOL, so we don't need to
specify it as a parameter

Changed paths:
    engines/trecision/dialog.cpp
    engines/trecision/graphics.cpp
    engines/trecision/graphics.h
    engines/trecision/inventory.cpp
    engines/trecision/saveload.cpp
    engines/trecision/script.cpp
    engines/trecision/struct.h
    engines/trecision/text.cpp
    engines/trecision/text.h
    engines/trecision/trecision.cpp
    engines/trecision/trecision.h
    engines/trecision/utils.cpp
    engines/trecision/video.cpp


diff --git a/engines/trecision/dialog.cpp b/engines/trecision/dialog.cpp
index c3657f0338..7bc3fcd3ab 100644
--- a/engines/trecision/dialog.cpp
+++ b/engines/trecision/dialog.cpp
@@ -93,7 +93,6 @@ void DialogManager::dialogPrint(int x, int y, int c, const Common::String &txt)
 		Common::Rect(x, y, _vm->textLength(txt) + x, y),
 		Common::Rect(0, 0, MAXX, MAXY),
 		c,
-		MASKCOL,
 		txt
 	);
 	curChoice.draw(_vm);
diff --git a/engines/trecision/graphics.cpp b/engines/trecision/graphics.cpp
index 61c4e08616..08fec9cb70 100644
--- a/engines/trecision/graphics.cpp
+++ b/engines/trecision/graphics.cpp
@@ -339,6 +339,12 @@ void GraphicsManager::clearScreenBufferSaveSlotDescriptions() {
 	_screenBuffer.fillRect(Common::Rect(0, FIRSTLINE + ICONDY + 10, MAXX, MAXY), 0);
 }
 
+uint16 GraphicsManager::convertToScreenFormat(uint16 color) const {
+	uint8 r, g, b;
+	kImageFormat.colorToRGB(color, r, g, b);
+	return (uint16)_screenFormat.RGBToColor(r, g, b);
+}
+
 void GraphicsManager::updatePixelFormat(uint16 *p, uint32 len) const {
 	if (_screenFormat == kImageFormat)
 		return;
@@ -685,14 +691,14 @@ uint16 GraphicsManager::getCharWidth(byte character) {
 	return _font[character * 3 + 2];
 }
 
-void GraphicsManager::drawChar(byte curChar, uint16 shadowCol, uint16 textCol, uint16 line, Common::Rect rect, Common::Rect subtitleRect, uint16 inc, Graphics::Surface *externalSurface) {
+void GraphicsManager::drawChar(byte curChar, uint16 textColor, uint16 line, Common::Rect rect, Common::Rect subtitleRect, uint16 inc, Graphics::Surface *externalSurface) {
 	const uint16 charOffset = _font[curChar * 3] + (uint16)(_font[curChar * 3 + 1] << 8);
 	uint16 fontDataOffset = 768;
 	const uint16 charWidth = getCharWidth(curChar);
 
 	for (uint16 y = line * CARHEI; y < (line + 1) * CARHEI; ++y) {
 		uint16 curPos = 0;
-		uint16 curColor = shadowCol;
+		uint16 curColor = MASKCOL;
 
 		while (curPos <= charWidth - 1) {
 			if (y >= subtitleRect.top && y < subtitleRect.bottom) {
@@ -714,12 +720,12 @@ void GraphicsManager::drawChar(byte curChar, uint16 shadowCol, uint16 textCol, u
 			curPos += _font[charOffset + fontDataOffset];
 			++fontDataOffset;
 
-			if (curColor == shadowCol)
+			if (curColor == MASKCOL)
 				curColor = 0;
 			else if (curColor == 0)
-				curColor = textCol;
-			else if (curColor == textCol)
-				curColor = shadowCol;
+				curColor = textColor;
+			else if (curColor == textColor)
+				curColor = MASKCOL;
 		}
 	}
 }
diff --git a/engines/trecision/graphics.h b/engines/trecision/graphics.h
index 16c37bb83f..df043b74c2 100644
--- a/engines/trecision/graphics.h
+++ b/engines/trecision/graphics.h
@@ -90,6 +90,7 @@ public:
 	void setSaveSlotThumbnail(byte iconSlot, const Graphics::Surface *thumbnail);
 	void readSurface(Common::SeekableReadStream *stream, Graphics::Surface *surface, uint16 width, uint16 height, uint16 count = 1);
 
+	uint16 convertToScreenFormat(uint16 color) const;
 	void updatePixelFormat(uint16 *p, uint32 len) const;
 
 	void shadow(uint16 x, uint16 y, uint8 num);
@@ -99,7 +100,7 @@ public:
 	void addDirtyRect(Common::Rect rect, bool translateRect, bool updateActorRect = false);
 
 	uint16 getCharWidth(byte character);
-	void drawChar(byte curChar, uint16 shadowCol, uint16 textCol, uint16 line, Common::Rect rect, Common::Rect subtitleRect, uint16 inc, Graphics::Surface *externalSurface);
+	void drawChar(byte curChar, uint16 textColor, uint16 line, Common::Rect rect, Common::Rect subtitleRect, uint16 inc, Graphics::Surface *externalSurface);
 
 	bool isCursorVisible();
 	void showCursor();
diff --git a/engines/trecision/inventory.cpp b/engines/trecision/inventory.cpp
index 32c79de2b6..dbe9a1eb93 100644
--- a/engines/trecision/inventory.cpp
+++ b/engines/trecision/inventory.cpp
@@ -246,7 +246,7 @@ void TrecisionEngine::showInventoryName(uint16 obj, bool showhide) {
 		_lastInv = (obj | 0x8000);
 		if (_lastInv)
 			_textMgr->clearLastText();
-		_textMgr->addText(pos, desc.c_str(), COLOR_INVENTORY, MASKCOL);
+		_textMgr->addText(pos, desc.c_str(), COLOR_INVENTORY);
 	} else {
 		if (obj == _lastInv)
 			return;
@@ -268,7 +268,7 @@ void TrecisionEngine::showInventoryName(uint16 obj, bool showhide) {
 			_textMgr->clearLastText();
 
 		if (_inventoryObj[obj]._name)
-			_textMgr->addText(pos, _objName[_inventoryObj[obj]._name], COLOR_INVENTORY, MASKCOL);
+			_textMgr->addText(pos, _objName[_inventoryObj[obj]._name], COLOR_INVENTORY);
 	}
 }
 
diff --git a/engines/trecision/saveload.cpp b/engines/trecision/saveload.cpp
index 606be10c24..c875fbca97 100644
--- a/engines/trecision/saveload.cpp
+++ b/engines/trecision/saveload.cpp
@@ -88,7 +88,6 @@ bool TrecisionEngine::dataSave() {
 		Common::Rect(0, TOP - 20, MAXX, CARHEI + (TOP - 20)),
 		Common::Rect(0, 0, MAXX, CARHEI),
 		MOUSECOL,
-		MASKCOL,
 		_sysText[kMessageSavePosition]);
 	drawText.draw(this);
 
@@ -138,7 +137,6 @@ insave:
 					Common::Rect(posx, FIRSTLINE + ICONDY + 10, LenText + posx, CARHEI + (FIRSTLINE + ICONDY + 10)),
 					Common::Rect(0, 0, LenText, CARHEI),
 					MOUSECOL,
-					MASKCOL,
 					saveNames[CurPos].c_str());
 				drawText.draw(this);
 
@@ -209,14 +207,10 @@ insave:
 				Common::Rect(posx, FIRSTLINE + ICONDY + 10, LenText + posx, CARHEI + (FIRSTLINE + ICONDY + 10)),
 				Common::Rect(0, 0, LenText, CARHEI),
 				MOUSECOL,
-				MASKCOL,
 				saveNames[CurPos].c_str());
 
-			if ((readTime() / 8) & 1)
-				_blinkLastDTextChar = 0x0000;
-
-			drawText.draw(this);
-			_blinkLastDTextChar = MASKCOL;
+			const bool hideLastChar = (readTime() / 8) & 1;
+			drawText.draw(this, hideLastChar);
 
 			saveNames[CurPos].deleteLastChar(); // remove blinking cursor
 
@@ -280,7 +274,6 @@ bool TrecisionEngine::dataLoad() {
 		Common::Rect(0, TOP - 20, MAXX, CARHEI + (TOP - 20)),
 		Common::Rect(0, 0, MAXX, CARHEI),
 		MOUSECOL,
-		MASKCOL,
 		_sysText[kMessageLoadPosition]);
 	drawText.draw(this);
 
@@ -330,7 +323,6 @@ bool TrecisionEngine::dataLoad() {
 					Common::Rect(posX, FIRSTLINE + ICONDY + 10, lenText + posX, CARHEI + (FIRSTLINE + ICONDY + 10)),
 					Common::Rect(0, 0, lenText, CARHEI),
 					MOUSECOL,
-					MASKCOL,
 					saveNames[CurPos].c_str());
 				drawText.draw(this);
 
diff --git a/engines/trecision/script.cpp b/engines/trecision/script.cpp
index 619b2aae1c..3c84246fcb 100644
--- a/engines/trecision/script.cpp
+++ b/engines/trecision/script.cpp
@@ -107,7 +107,6 @@ bool TrecisionEngine::quitPrompt() {
 		Common::Rect(0, TOP - 20, MAXX, CARHEI + (TOP - 20)),
 		Common::Rect(0, 0, MAXX, CARHEI),
 		MOUSECOL,
-		MASKCOL,
 		_sysText[kMessageConfirmExit]
 	);
 	drawText.draw(this);
@@ -131,7 +130,6 @@ void TrecisionEngine::demoOver() {
 		Common::Rect(0, TOP - 20, MAXX, CARHEI + (TOP - 20)),
 		Common::Rect(0, 0, MAXX, CARHEI),
 		MOUSECOL,
-		MASKCOL,
 		_sysText[kMessageDemoOver]
 	);
 	drawText.draw(this);
diff --git a/engines/trecision/struct.h b/engines/trecision/struct.h
index c6f008eae6..abfeba7073 100644
--- a/engines/trecision/struct.h
+++ b/engines/trecision/struct.h
@@ -165,14 +165,13 @@ struct SDText {
 	Common::Rect _rect;
 	Common::Rect _subtitleRect;
 	uint16 _textColor;
-	uint16 _shadowCol;
 	Common::String _text;
 	Common::String _drawTextLines[MAXDTEXTLINES];
 
 	void set(SDText *org);
-	void set(Common::Rect rect, Common::Rect subtitleRect, uint16 textCol, uint16 shadowCol, const Common::String &text);
+	void set(Common::Rect rect, Common::Rect subtitleRect, uint16 textCol, const Common::String &text);
 
-	void draw(TrecisionEngine *vm, Graphics::Surface *externalSurface = nullptr);
+	void draw(TrecisionEngine *vm, bool hideLastChar = false, Graphics::Surface *externalSurface = nullptr);
 	uint16 calcHeight(TrecisionEngine *vm);
 };
 
diff --git a/engines/trecision/text.cpp b/engines/trecision/text.cpp
index b88808c893..626ad74222 100644
--- a/engines/trecision/text.cpp
+++ b/engines/trecision/text.cpp
@@ -142,7 +142,7 @@ void TextManager::characterContinueTalk() {
 
 	clearLastText();
 	if (ConfMan.getBool("subtitles"))
-		addText(pos, _subString[_curSubString], COLOR_OBJECT, MASKCOL);
+		addText(pos, _subString[_curSubString], COLOR_OBJECT);
 
 	if (!_vm->_flagDialogActive) {
 		if (_curSubString)
@@ -191,7 +191,7 @@ void TextManager::someoneContinueTalk() {
 
 	clearLastText();
 	if (ConfMan.getBool("subtitles"))
-		addText(pos, _subString[_curSubString], HYELLOW, MASKCOL);
+		addText(pos, _subString[_curSubString], HYELLOW);
 
 	if (_curSubString)
 		_lastFilename = Common::String::format("s%04d%c.wav", _curSentenceId, _curSubString + 'a');
@@ -299,7 +299,7 @@ void TextManager::showObjName(uint16 obj, bool show) {
 
 		if (_vm->_lastObj)
 			clearLastText();
-		addText(pos, desc.c_str(), COLOR_INVENTORY, MASKCOL);
+		addText(pos, desc.c_str(), COLOR_INVENTORY);
 	} else {
 		if (!obj || !show) {
 			clearLastText();
@@ -330,7 +330,7 @@ void TextManager::showObjName(uint16 obj, bool show) {
 		if (_vm->_lastObj)
 			clearLastText();
 		_vm->_lastObj = obj;
-		addText(pos, desc.c_str(), COLOR_OBJECT, MASKCOL);
+		addText(pos, desc.c_str(), COLOR_OBJECT);
 	}
 }
 
@@ -377,12 +377,11 @@ void TextManager::characterSayInAction(uint16 ss) {
 	characterContinueTalk();
 }
 
-void TextManager::addText(Common::Point pos, const char *text, uint16 textCol, uint16 shadowCol) {
+void TextManager::addText(Common::Point pos, const char *text, uint16 textCol) {
 	StackText t;
 	t._x = pos.x;
 	t._y = pos.y;
 	t._textColor = textCol;
-	t._shadowCol = shadowCol;
 	t._clear = false;
 	t._text = text;
 
@@ -421,7 +420,6 @@ void TextManager::drawText(StackText *text) {
 	_curString._subtitleRect = Common::Rect(_curString._rect.width(), height);
 	_curString._rect.setHeight(height);
 	_curString._textColor = text->_textColor;
-	_curString._shadowCol = text->_shadowCol;
 
 	if (_curString._rect.top <= height)
 		_curString._rect.top += height;
diff --git a/engines/trecision/text.h b/engines/trecision/text.h
index 79a633bbfc..ffd0045eef 100644
--- a/engines/trecision/text.h
+++ b/engines/trecision/text.h
@@ -36,7 +36,7 @@ class TrecisionEngine;
 struct StackText {
 	uint16 _x;
 	uint16 _y;
-	uint16 _textColor, _shadowCol;
+	uint16 _textColor;
 	Common::String _text;
 	bool _clear;
 };
@@ -79,7 +79,7 @@ public:
 	void characterSay(uint16 i);
 	void characterSayInAction(uint16 ss);
 
-	void addText(Common::Point pos, const char *text, uint16 textCol, uint16 shadowCol);
+	void addText(Common::Point pos, const char *text, uint16 textCol);
 	void clearLastText();
 	void drawText(StackText *text);
 	void clearText();
diff --git a/engines/trecision/trecision.cpp b/engines/trecision/trecision.cpp
index 8d297c04a8..e75d6da5b0 100644
--- a/engines/trecision/trecision.cpp
+++ b/engines/trecision/trecision.cpp
@@ -151,7 +151,6 @@ TrecisionEngine::TrecisionEngine(OSystem *syst, const ADGameDescription *desc) :
 		_maskPointers[i] = nullptr;
 	}
 
-	_blinkLastDTextChar = MASKCOL;
 	_curTime = 0;
 	_characterSpeakTime = 0;
 
diff --git a/engines/trecision/trecision.h b/engines/trecision/trecision.h
index a73d5c77ae..542478f5db 100644
--- a/engines/trecision/trecision.h
+++ b/engines/trecision/trecision.h
@@ -318,7 +318,6 @@ public:
 	uint16 *_objPointers[MAXOBJINROOM];
 	uint8 *_maskPointers[MAXOBJINROOM];
 
-	uint16 _blinkLastDTextChar;
 	uint32 _curTime;
 	uint32 _characterSpeakTime;
 
diff --git a/engines/trecision/utils.cpp b/engines/trecision/utils.cpp
index 758c72e04c..adae94059f 100644
--- a/engines/trecision/utils.cpp
+++ b/engines/trecision/utils.cpp
@@ -297,14 +297,13 @@ int TrecisionEngine::getRoomObjectIndex(uint16 objectId) {
  * SDText
  ************************************************/
 void SDText::set(SDText *org) {
-	set(org->_rect, org->_subtitleRect, org->_textColor, org->_shadowCol, org->_text);
+	set(org->_rect, org->_subtitleRect, org->_textColor, org->_text);
 }
 
-void SDText::set(Common::Rect rect, Common::Rect subtitleRect, uint16 textCol, uint16 shadowCol, const Common::String &text) {
+void SDText::set(Common::Rect rect, Common::Rect subtitleRect, uint16 textCol, const Common::String &text) {
 	_rect = rect;
 	_subtitleRect = subtitleRect;
 	_textColor = textCol;
-	_shadowCol = shadowCol;
 	_text = text;
 
 	// Clean output buffer
@@ -372,13 +371,9 @@ uint16 SDText::calcHeight(TrecisionEngine *vm) {
 	return 0;
 }
 
-void SDText::draw(TrecisionEngine *vm, Graphics::Surface *externalSurface) {
-	uint16 tmpTextCol = _textColor;
-	uint16 tmpShadowCol = _shadowCol;
-	vm->_graphicsMgr->updatePixelFormat(&tmpTextCol, 1);
-	if (_shadowCol != MASKCOL)
-		vm->_graphicsMgr->updatePixelFormat(&tmpShadowCol, 1);
-
+void SDText::draw(TrecisionEngine *vm, bool hideLastChar, Graphics::Surface *externalSurface) {
+	uint16 textColor = vm->_graphicsMgr->convertToScreenFormat(_textColor);
+	
 	if (_text.empty())
 		return;
 
@@ -395,10 +390,10 @@ void SDText::draw(TrecisionEngine *vm, Graphics::Surface *externalSurface) {
 		for (uint index = 0; index < curText.size(); ++index) {
 			const byte curChar = curText[index];
 
-			if (index == curText.size() - 1 && vm->_blinkLastDTextChar != MASKCOL)
-				tmpTextCol = vm->_blinkLastDTextChar;
+			if (index == curText.size() - 1 && hideLastChar)
+				textColor = vm->_graphicsMgr->convertToScreenFormat(0);
 
-			vm->_graphicsMgr->drawChar(curChar, tmpShadowCol, tmpTextCol, line, _rect, _subtitleRect, inc, externalSurface);
+			vm->_graphicsMgr->drawChar(curChar, textColor, line, _rect, _subtitleRect, inc, externalSurface);
 
 			inc += vm->_graphicsMgr->getCharWidth(curChar);
 		}
diff --git a/engines/trecision/video.cpp b/engines/trecision/video.cpp
index d642d72886..3319c8052a 100644
--- a/engines/trecision/video.cpp
+++ b/engines/trecision/video.cpp
@@ -220,7 +220,6 @@ void AnimManager::drawFrameSubtitles(Graphics::Surface *surface, int frameNum) {
 	// fixed coordinates
 	_vm->_drawText._rect = Common::Rect(20, 380 - TOP, MAXX - 40 + 20, _vm->_drawText.calcHeight(_vm) + (380 - TOP));
 	_vm->_drawText._subtitleRect = Common::Rect(MAXX, MAXY);
-	_vm->_drawText._shadowCol = MASKCOL;
 	_vm->_drawText.draw(_vm, surface);
 }
 




More information about the Scummvm-git-logs mailing list