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

sev- sev at scummvm.org
Fri Nov 6 18:55:05 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:
819dd59f77 JANITORIAL: Formatting fixes
100688c225 SCUMM: Moved out Korean-specific code into separate methods
f8216ed85f SCUMM: Fix warning


Commit: 819dd59f77b18864758a42d4a3d2ca141dcc2c7e
    https://github.com/scummvm/scummvm/commit/819dd59f77b18864758a42d4a3d2ca141dcc2c7e
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2020-11-06T19:53:05+01:00

Commit Message:
JANITORIAL: Formatting fixes

Changed paths:
    engines/scumm/charset.cpp


diff --git a/engines/scumm/charset.cpp b/engines/scumm/charset.cpp
index a8d57f8b52..fcc91f672f 100644
--- a/engines/scumm/charset.cpp
+++ b/engines/scumm/charset.cpp
@@ -95,11 +95,12 @@ void ScummEngine::loadCJKFont() {
 					}
 				}
 			}
-			if(_numLoadedFont == 0) {
+			if (_numLoadedFont == 0) {
 				warning("Cannot load any font for multi font");
 				_useMultiFont = 0;
-			} else
+			} else {
 				debug("%d fonts are loaded", _numLoadedFont);
+			}
 		}
 
 		if (!_useMultiFont) {
@@ -350,7 +351,7 @@ void CharsetRendererCommon::setCurID(int32 id) {
 	_fontHeight = _fontPtr[1];
 	_numChars = READ_LE_UINT16(_fontPtr + 2);
 
-	if(_vm->_useMultiFont) {
+	if (_vm->_useMultiFont) {
 		if (id == 6) {	// HACK: Fix inventory font error
 			_vm->_2byteFontPtr = _vm->_2byteMultiFontPtr[0];
 			_vm->_2byteWidth = _vm->_2byteMultiWidth[0];
@@ -400,7 +401,7 @@ void CharsetRendererV3::setCurID(int32 id) {
 	_widthTable = _fontPtr;
 	_fontPtr += _numChars;
 
-	if(_vm->_useMultiFont) {
+	if (_vm->_useMultiFont) {
 		if (id == 6) {	// HACK: Fix inventory font error
 			_vm->_2byteFontPtr = _vm->_2byteMultiFontPtr[0];
 			_vm->_2byteWidth = _vm->_2byteMultiWidth[0];


Commit: 100688c22517f390d95b3b3494fd4d843e25d32f
    https://github.com/scummvm/scummvm/commit/100688c22517f390d95b3b3494fd4d843e25d32f
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2020-11-06T19:53:05+01:00

Commit Message:
SCUMM: Moved out Korean-specific code into separate methods

Changed paths:
    engines/scumm/charset.cpp
    engines/scumm/charset.h
    engines/scumm/scumm.h


diff --git a/engines/scumm/charset.cpp b/engines/scumm/charset.cpp
index fcc91f672f..64fb1942a5 100644
--- a/engines/scumm/charset.cpp
+++ b/engines/scumm/charset.cpp
@@ -50,7 +50,6 @@ bool CharsetRenderer::isScummvmKorTarget() {
 }
 
 void ScummEngine::loadCJKFont() {
-	Common::File fp;
 	_useCJKMode = false;
 	_textSurfaceMultiplier = 1;
 	_newLineCharacter = 0;
@@ -59,66 +58,13 @@ void ScummEngine::loadCJKFont() {
 
 	// Special case for Korean
 	if (_language == Common::KO_KOR && (_game.version < 7 || _game.id == GID_FT)) {
-		int numChar = 2350;
-		_useCJKMode = true;
-
-		if (_game.version < 7 || _game.id == GID_FT)
-			_useMultiFont = 1;
-
-		if (_useMultiFont) {
-			debug("Loading Korean Multi Font System");
-			_numLoadedFont = 0;
-			_2byteFontPtr = NULL;
-			_2byteWidth = 0;
-			_2byteHeight = 0;
-			for (int i = 0; i < 20; i++) {
-				char fontFile[256];
-				snprintf(fontFile, sizeof(fontFile), "korean%02d.fnt", i);
-				_2byteMultiFontPtr[i] = NULL;
-				if (fp.open(fontFile)) {
-					_numLoadedFont++;
-					fp.readByte();
-					_2byteMultiShadow[i] = fp.readByte();
-					_2byteMultiWidth[i] = fp.readByte();
-					_2byteMultiHeight[i] = fp.readByte();
-
-					int fontSize = ((_2byteMultiWidth[i] + 7) / 8) * _2byteMultiHeight[i] * numChar;
-					_2byteMultiFontPtr[i] = new byte[fontSize];
-					warning("#%d, size %d, height =%d", i, fontSize, _2byteMultiHeight[i]);
-					fp.read(_2byteMultiFontPtr[i], fontSize);
-					fp.close();
-					if (_2byteFontPtr == NULL) {	// for non-initialized Smushplayer drawChar
-						_2byteFontPtr = _2byteMultiFontPtr[i];
-						_2byteWidth = _2byteMultiWidth[i];
-						_2byteHeight = _2byteMultiHeight[i];
-						_2byteShadow = _2byteMultiShadow[i];
-					}
-				}
-			}
-			if (_numLoadedFont == 0) {
-				warning("Cannot load any font for multi font");
-				_useMultiFont = 0;
-			} else {
-				debug("%d fonts are loaded", _numLoadedFont);
-			}
-		}
+		loadKorFont();
 
-		if (!_useMultiFont) {
-			debug("Loading Korean Single Font System");
-			if (fp.open("korean.fnt")) {
-				fp.seek(2, SEEK_CUR);
-				_2byteWidth = fp.readByte();
-				_2byteHeight = fp.readByte();
-				_2byteFontPtr = new byte[((_2byteWidth + 7) / 8) * _2byteHeight * numChar];
-				fp.read(_2byteFontPtr, ((_2byteWidth + 7) / 8) * _2byteHeight * numChar);
-				fp.close();
-			} else {
-				error("Couldn't load any font: %s", fp.getName());
-			}
-		}
 		return;
 	}
 
+	Common::File fp;
+
 	if (_game.version <= 5 && _game.platform == Common::kPlatformFMTowns && _language == Common::JA_JPN) { // FM-TOWNS v3 / v5 Kanji
 #if defined(DISABLE_TOWNS_DUAL_LAYER_MODE) || !defined(USE_RGB_COLOR)
 		GUIErrorMessage("FM-Towns Kanji font drawing requires dual graphics layer support which is disabled in this build");
@@ -226,6 +172,68 @@ void ScummEngine::loadCJKFont() {
 	}
 }
 
+void ScummEngine::loadKorFont() {
+	Common::File fp;
+	int numChar = 2350;
+	_useCJKMode = true;
+
+	if (_game.version < 7 || _game.id == GID_FT)
+		_useMultiFont = 1;
+
+	if (_useMultiFont) {
+		debug("Loading Korean Multi Font System");
+		_numLoadedFont = 0;
+		_2byteFontPtr = NULL;
+		_2byteWidth = 0;
+		_2byteHeight = 0;
+		for (int i = 0; i < 20; i++) {
+			char fontFile[256];
+			snprintf(fontFile, sizeof(fontFile), "korean%02d.fnt", i);
+			_2byteMultiFontPtr[i] = NULL;
+			if (fp.open(fontFile)) {
+				_numLoadedFont++;
+				fp.readByte();
+				_2byteMultiShadow[i] = fp.readByte();
+				_2byteMultiWidth[i] = fp.readByte();
+				_2byteMultiHeight[i] = fp.readByte();
+
+				int fontSize = ((_2byteMultiWidth[i] + 7) / 8) * _2byteMultiHeight[i] * numChar;
+				_2byteMultiFontPtr[i] = new byte[fontSize];
+				warning("#%d, size %d, height =%d", i, fontSize, _2byteMultiHeight[i]);
+				fp.read(_2byteMultiFontPtr[i], fontSize);
+				fp.close();
+				if (_2byteFontPtr == NULL) {	// for non-initialized Smushplayer drawChar
+					_2byteFontPtr = _2byteMultiFontPtr[i];
+					_2byteWidth = _2byteMultiWidth[i];
+					_2byteHeight = _2byteMultiHeight[i];
+					_2byteShadow = _2byteMultiShadow[i];
+				}
+			}
+		}
+		if (_numLoadedFont == 0) {
+			warning("Cannot load any font for multi font");
+			_useMultiFont = 0;
+		} else {
+			debug("%d fonts are loaded", _numLoadedFont);
+		}
+	}
+
+	if (!_useMultiFont) {
+		debug("Loading Korean Single Font System");
+		if (fp.open("korean.fnt")) {
+			fp.seek(2, SEEK_CUR);
+			_2byteWidth = fp.readByte();
+			_2byteHeight = fp.readByte();
+			_2byteFontPtr = new byte[((_2byteWidth + 7) / 8) * _2byteHeight * numChar];
+			fp.read(_2byteFontPtr, ((_2byteWidth + 7) / 8) * _2byteHeight * numChar);
+			fp.close();
+		} else {
+			error("Couldn't load any font: %s", fp.getName());
+		}
+	}
+	return;
+}
+
 byte *ScummEngine::get2byteCharPtr(int idx) {
 	if (_game.platform == Common::kPlatformFMTowns || _game.platform == Common::kPlatformPCEngine)
 		return 0;
@@ -697,66 +705,12 @@ void CharsetRendererPC::enableShadow(bool enable) {
 }
 
 void CharsetRendererPC::drawBits1(Graphics::Surface &dest, int x, int y, const byte *src, int drawTop, int width, int height) {
-	byte *dst = (byte *)dest.getBasePtr(x, y);
-
 	if (_vm->_useCJKMode && isScummvmKorTarget()) {
-		int y, x;
-		byte bits = 0;
-
-		// HACK: Since Korean fonts don't have shadow/stroke information,
-		//	   we use NUT-Renderer-like shadow drawing method.
-		bool useOldShadow = false;
-
-		int offsetX[14] = {-2, -2, -2, -1, 0, -1, 0, 1, -1, 1, -1, 0, 1, 0};
-		int offsetY[14] = {0, 1, 2, 2, 2, -1, -1, -1, 0, 0, 1, 1, 1, 0};
-		int cTable[14] = {_shadowColor, _shadowColor, _shadowColor,
-		                  _shadowColor, _shadowColor, _shadowColor, _shadowColor,
-		                  _shadowColor, _shadowColor, _shadowColor, _shadowColor,
-		                  _shadowColor, _shadowColor, _color};
-		int i = 0;
-
-		switch (_vm->_2byteShadow) {
-		case 1: // No shadow
-			i = 13;
-			break;
-		case 2: // SE direction shadow
-			i = 12;
-			break;
-		case 3: // Stroke & SW direction shadow ("Monkey2", "Indy4")
-			i = 0;
-			break;
-		default: // Stroke
-			i = 5;
-		}
-
-		const byte *origSrc = src;
-		byte *origDst = dst;
-
-		for (; i < 14; i++) {
-			src = origSrc;
-			dst = origDst;
-
-			for (y = 0; y < height && y + drawTop + offsetY[i] < dest.h; y++) {
-				for (x = 0; x < width && x + offsetY[i] < dest.w; x++) {
-					if ((x % 8) == 0)
-						bits = *src++;
-					if ((bits & revBitMask(x % 8)) && y + drawTop >= 0) {
-						if (_enableShadow) {
-							*(dst + 1) = _shadowColor;
-							*(dst + dest.pitch) = _shadowColor;
-							*(dst + dest.pitch + 1) = _shadowColor;
-						}
-						*(dst + (dest.pitch * offsetY[i]) + offsetX[i]) = cTable[i];
-					}
-					dst++;
-				}
-
-				dst += dest.pitch - width;
-			}
-		}
+		drawBits1Kor(dest, x, y, src, drawTop, width, height);
 		return;
 	}
 
+	byte *dst = (byte *)dest.getBasePtr(x, y);
 	byte bits = 0;
 	uint8 col = _color;
 	int pitch = dest.pitch - width * dest.format.bytesPerPixel;
@@ -784,6 +738,65 @@ void CharsetRendererPC::drawBits1(Graphics::Surface &dest, int x, int y, const b
 	}
 }
 
+void CharsetRendererPC::drawBits1Kor(Graphics::Surface &dest, int x1, int y1, const byte *src, int drawTop, int width, int height) {
+	byte *dst = (byte *)dest.getBasePtr(x1, y1);
+
+	int y, x;
+	byte bits = 0;
+
+	// HACK: Since Korean fonts don't have shadow/stroke information,
+	//	   we use NUT-Renderer-like shadow drawing method.
+	bool useOldShadow = false;
+
+	int offsetX[14] = {-2, -2, -2, -1, 0, -1, 0, 1, -1, 1, -1, 0, 1, 0};
+	int offsetY[14] = {0, 1, 2, 2, 2, -1, -1, -1, 0, 0, 1, 1, 1, 0};
+	int cTable[14] = {_shadowColor, _shadowColor, _shadowColor,
+						_shadowColor, _shadowColor, _shadowColor, _shadowColor,
+						_shadowColor, _shadowColor, _shadowColor, _shadowColor,
+						_shadowColor, _shadowColor, _color};
+	int i = 0;
+
+	switch (_vm->_2byteShadow) {
+	case 1: // No shadow
+		i = 13;
+		break;
+	case 2: // SE direction shadow
+		i = 12;
+		break;
+	case 3: // Stroke & SW direction shadow ("Monkey2", "Indy4")
+		i = 0;
+		break;
+	default: // Stroke
+		i = 5;
+	}
+
+	const byte *origSrc = src;
+	byte *origDst = dst;
+
+	for (; i < 14; i++) {
+		src = origSrc;
+		dst = origDst;
+
+		for (y = 0; y < height && y + drawTop + offsetY[i] < dest.h; y++) {
+			for (x = 0; x < width && x + offsetY[i] < dest.w; x++) {
+				if ((x % 8) == 0)
+					bits = *src++;
+				if ((bits & revBitMask(x % 8)) && y + drawTop >= 0) {
+					if (_enableShadow) {
+						*(dst + 1) = _shadowColor;
+						*(dst + dest.pitch) = _shadowColor;
+						*(dst + dest.pitch + 1) = _shadowColor;
+					}
+					*(dst + (dest.pitch * offsetY[i]) + offsetX[i]) = cTable[i];
+				}
+				dst++;
+			}
+
+			dst += dest.pitch - width;
+		}
+	}
+}
+
 int CharsetRendererV3::getDrawWidthIntern(uint16 chr) {
 	return getCharWidth(chr);
 }
diff --git a/engines/scumm/charset.h b/engines/scumm/charset.h
index 71d1965a07..606bdec306 100644
--- a/engines/scumm/charset.h
+++ b/engines/scumm/charset.h
@@ -144,6 +144,7 @@ class CharsetRendererPC : public CharsetRendererCommon {
 protected:
 	virtual void enableShadow(bool enable);
 	virtual void drawBits1(Graphics::Surface &dest, int x, int y, const byte *src, int drawTop, int width, int height);
+	void drawBits1Kor(Graphics::Surface &dest, int x1, int y1, const byte *src, int drawTop, int width, int height);
 
 public:
 	CharsetRendererPC(ScummEngine *vm) : CharsetRendererCommon(vm), _shadowType(kNoShadowType) { }
diff --git a/engines/scumm/scumm.h b/engines/scumm/scumm.h
index afc91eca12..98f3580880 100644
--- a/engines/scumm/scumm.h
+++ b/engines/scumm/scumm.h
@@ -358,6 +358,7 @@ protected:
 
 	virtual void loadLanguageBundle() {}
 	void loadCJKFont();
+	void loadKorFont();
 	void setupMusic(int midi);
 	void setTalkSpeed(int talkspeed);
 	int getTalkSpeed();


Commit: f8216ed85f2d1e969320177b3745cc9c5a2b082c
    https://github.com/scummvm/scummvm/commit/f8216ed85f2d1e969320177b3745cc9c5a2b082c
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2020-11-06T19:53:05+01:00

Commit Message:
SCUMM: Fix warning

Changed paths:
    engines/scumm/charset.cpp


diff --git a/engines/scumm/charset.cpp b/engines/scumm/charset.cpp
index 64fb1942a5..2a727ecaf5 100644
--- a/engines/scumm/charset.cpp
+++ b/engines/scumm/charset.cpp
@@ -746,7 +746,7 @@ void CharsetRendererPC::drawBits1Kor(Graphics::Surface &dest, int x1, int y1, co
 
 	// HACK: Since Korean fonts don't have shadow/stroke information,
 	//	   we use NUT-Renderer-like shadow drawing method.
-	bool useOldShadow = false;
+	//bool useOldShadow = false;
 
 	int offsetX[14] = {-2, -2, -2, -1, 0, -1, 0, 1, -1, 1, -1, 0, 1, 0};
 	int offsetY[14] = {0, 1, 2, 2, 2, -1, -1, -1, 0, 0, 1, 1, 1, 0};




More information about the Scummvm-git-logs mailing list