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

wonst719 wonst719 at gmail.com
Mon Nov 9 16:11:11 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:
1ce198f06b SCUMM: Replace Scumm::checkHangul() with Scumm::checkKSCode()
b99a748b4e SCUMM: Add comment for Korean postposition handling
a9541ca48b SCUMM: Cleanup Korean line break processing


Commit: 1ce198f06b1c41ee7f350cbb31ce4ee8ef12f75b
    https://github.com/scummvm/scummvm/commit/1ce198f06b1c41ee7f350cbb31ce4ee8ef12f75b
Author: wonst719 (wonst719 at gmail.com)
Date: 2020-11-10T01:10:09+09:00

Commit Message:
SCUMM: Replace Scumm::checkHangul() with Scumm::checkKSCode()

- the two functions were identical

Changed paths:
    engines/scumm/ks_check.cpp
    engines/scumm/ks_check.h
    engines/scumm/string.cpp


diff --git a/engines/scumm/ks_check.cpp b/engines/scumm/ks_check.cpp
index 5024b03352..50255c9382 100644
--- a/engines/scumm/ks_check.cpp
+++ b/engines/scumm/ks_check.cpp
@@ -175,18 +175,6 @@ static byte jongsungTable[2350] = {
 	 0,  4,  8, 16, 17, 21,  0,  1,  4,  8, 16, 17, 19, 21
 };
 
-int checkHangul(byte hi, byte lo) {
-	// hi: xx
-	// lo: yy
-	if ((0xA1 > lo) || (0xFE < lo)) {
-		return 0;
-	}
-	if ((hi >= 0xB0) && (hi <= 0xC8)) {
-		return 1;
-	}
-	return 0;
-}
-
 // check for jongsung (final consonant)
 byte checkJongsung(byte hi, byte lo) {
 	uint16 index = ((hi - 0xb0) * 94 + lo - 0xa1);
diff --git a/engines/scumm/ks_check.h b/engines/scumm/ks_check.h
index 289fbcc4f6..74a2d0fe99 100644
--- a/engines/scumm/ks_check.h
+++ b/engines/scumm/ks_check.h
@@ -26,10 +26,9 @@
 #include "common/scummsys.h"
 
 namespace Scumm {
-	
-	int checkHangul(byte hi, byte lo);
-	byte checkJongsung(byte hi, byte lo);
-	
+
+byte checkJongsung(byte hi, byte lo);
+
 } // End of namespace Scumm
 
 #endif
diff --git a/engines/scumm/string.cpp b/engines/scumm/string.cpp
index 5b722317a5..51141c7e2b 100644
--- a/engines/scumm/string.cpp
+++ b/engines/scumm/string.cpp
@@ -1491,7 +1491,7 @@ int ScummEngine::convertNameMessage(byte *dst, int dstSize, int var) {
 					for (int i = len; i > 1; i--) {
 						byte k1 = ptr[i - 2];
 						byte k2 = ptr[i - 1];
-						if (checkHangul(k1, k2)) {
+						if (checkKSCode(k1, k2)) {
 							int jongsung = checkJongsung(k1, k2);
 							if (jongsung)
 								_krStrPost |= 1;
@@ -1552,7 +1552,7 @@ int ScummEngine::convertStringMessage(byte *dst, int dstSize, int var) {
 				for (int i = resStrLen(ptr); i > 1; i--) {
 					byte k1 = ptr[i - 2];
 					byte k2 = ptr[i - 1];
-					if (checkHangul(k1, k2)) {
+					if (checkKSCode(k1, k2)) {
 						int jongsung = checkJongsung(k1, k2);
 						if (jongsung)
 							_krStrPost |= 1;


Commit: b99a748b4e6df759d30fe4042e17d81ef9ec3ea9
    https://github.com/scummvm/scummvm/commit/b99a748b4e6df759d30fe4042e17d81ef9ec3ea9
Author: wonst719 (wonst719 at gmail.com)
Date: 2020-11-10T01:10:09+09:00

Commit Message:
SCUMM: Add comment for Korean postposition handling

Changed paths:
    engines/scumm/string.cpp


diff --git a/engines/scumm/string.cpp b/engines/scumm/string.cpp
index 51141c7e2b..a90f73e333 100644
--- a/engines/scumm/string.cpp
+++ b/engines/scumm/string.cpp
@@ -1412,6 +1412,8 @@ int ScummEngine::convertVerbMessage(byte *dst, int dstSize, int var) {
 		for (k = 1; k < _numVerbs; k++) {
 			// Fix ZAK FM-TOWNS bug #1013617 by emulating exact (inconsistant?) behavior of the original code
 			if (num == _verbs[k].verbid && !_verbs[k].type && (!_verbs[k].saveid || (_game.version == 3 && _game.platform == Common::kPlatformFMTowns))) {
+				// Process variation of Korean postpositions
+				// Used by Korean fan translated games (monkey1, monkey2)
 				if (isKorVerbGlue) {
 					static const byte code0380[4] = {0xFF, 0x07, 0x03, 0x80};                                 // "eul/reul"
 					static const byte code0480[4] = {0xFF, 0x07, 0x04, 0x80};                                 // "wa/gwa"
@@ -1484,6 +1486,8 @@ int ScummEngine::convertNameMessage(byte *dst, int dstSize, int var) {
 		const byte *ptr = getObjOrActorName(num);
 		if (ptr) {
 			int increment = convertMessageToString(ptr, dst, dstSize);
+			// Save the final consonant (jongsung) of the last Korean character
+			// Used by Korean fan translated games (monkey1, monkey2)
 			if (isScummvmKorTarget() && _useCJKMode) {
 				_krStrPost = 0;
 				int len = resStrLen(ptr);
@@ -1527,6 +1531,8 @@ int ScummEngine::convertStringMessage(byte *dst, int dstSize, int var) {
 	if (_game.version == 3 || (_game.version >= 6 && _game.heversion < 72))
 		var = readVar(var);
 
+	// Process variation of Korean postpositions
+	// Used by Korean fan translated games (monkey1, monkey2)
 	if (isScummvmKorTarget() && _useCJKMode && (var & (1 << 15))) {
 		int idx;
 		static const byte codeIdx[] = {0x00, 0x00, 0xC0, 0xB8, 0x00, 0x00, 0xC0, 0xCC, 0xB0, 0xA1, 0xC0, 0xCC, 0xB8, 0xA6, 0xC0, 0xBB, 0xBF, 0xCD, 0xB0, 0xFA, 0xB4, 0xC2, 0xC0, 0xBA};
@@ -1547,6 +1553,8 @@ int ScummEngine::convertStringMessage(byte *dst, int dstSize, int var) {
 		ptr = getStringAddress(var);
 		if (ptr) {
 			int increment = convertMessageToString(ptr, dst, dstSize);
+			// Save the final consonant (jongsung) of the last Korean character
+			// Used by Korean fan translated games (monkey1, monkey2)
 			if (isScummvmKorTarget() && _useCJKMode) {
 				_krStrPost = 0;
 				for (int i = resStrLen(ptr); i > 1; i--) {


Commit: a9541ca48b5d34c475bd394dfebbb6af531a63a0
    https://github.com/scummvm/scummvm/commit/a9541ca48b5d34c475bd394dfebbb6af531a63a0
Author: wonst719 (wonst719 at gmail.com)
Date: 2020-11-10T01:10:09+09:00

Commit Message:
SCUMM: Cleanup Korean line break processing

Changed paths:
    engines/scumm/charset.cpp


diff --git a/engines/scumm/charset.cpp b/engines/scumm/charset.cpp
index 365ae6f2d8..05806aa481 100644
--- a/engines/scumm/charset.cpp
+++ b/engines/scumm/charset.cpp
@@ -618,11 +618,6 @@ void CharsetRenderer::addLinebreaks(int a, byte *str, int pos, int maxwidth) {
 		if (chr == _vm->_newLineCharacter)
 			lastspace = pos - 1;
 
-		if (_vm->_useCJKMode && _vm->isScummvmKorTarget()) {
-			if (_center == false && chr == '(' && pos - 3 >= origPos && checkKSCode(str[pos -3], str[pos -2]))
-				lastKoreanLineBreak = pos - 1;
-		}
-
 		if (_vm->_useCJKMode) {
 			if (_vm->_game.platform == Common::kPlatformFMTowns) {
 				if (checkSJISCode(chr))
@@ -633,13 +628,6 @@ void CharsetRenderer::addLinebreaks(int a, byte *str, int pos, int maxwidth) {
 			} else if (chr & 0x80) {
 				pos++;
 				curw += _vm->_2byteWidth;
-				if (_vm->isScummvmKorTarget() && checkKSCode(chr, str[pos])) {
-					if (_center == false
-						&& !(pos - 4 >= origPos && str[pos - 3] == '`' && str[pos - 4] == ' ')	// prevents hanging quotation mark at the end of line
-						&& !(pos - 4 >= origPos && str[pos - 3] == '\'' && str[pos - 4] == ' ')	// prevents hanging single quotation mark at the end of line
-						&& !(pos -3 >= origPos && str[pos -3] == '('))	// prevents hanging parenthesis at the end of line
-						lastKoreanLineBreak = pos - 2;
-				}
 				// Original keeps glyph width and character dimensions separately
 				if (_vm->_language == Common::KO_KOR || _vm->_language == Common::ZH_TWN) {
 					curw++;
@@ -647,6 +635,21 @@ void CharsetRenderer::addLinebreaks(int a, byte *str, int pos, int maxwidth) {
 			} else if (chr != _vm->_newLineCharacter) {
 				curw += getCharWidth(chr);
 			}
+
+			if (_vm->isScummvmKorTarget() && !_center) {
+				// Break Korean words at any character
+				// Used in Korean fan translated games
+				if (chr & 0x80) {
+					if (checkKSCode(chr, str[pos - 1])
+					    && !(pos - 4 >= origPos && str[pos - 3] == '`' && str[pos - 4] == ' ')  // prevents hanging quotation mark at the end of line
+					    && !(pos - 4 >= origPos && str[pos - 3] == '\'' && str[pos - 4] == ' ') // prevents hanging single quotation mark at the end of line
+					    && !(pos - 3 >= origPos && str[pos - 3] == '('))  // prevents hanging parenthesis at the end of line
+						lastKoreanLineBreak = pos - 2;
+				} else {
+					if (chr == '(' && pos - 3 >= origPos && checkKSCode(str[pos - 3], str[pos - 2]))
+						lastKoreanLineBreak = pos - 1;
+				}
+			}
 		} else {
 			curw += getCharWidth(chr);
 		}
@@ -661,20 +664,24 @@ void CharsetRenderer::addLinebreaks(int a, byte *str, int pos, int maxwidth) {
 				curw = 1;
 				pos = lastspace + 1;
 				lastspace = -1;
-			} else if (lastspace >= lastKoreanLineBreak) {
-				str[lastspace] = 0xD;
-				curw = 1;
-				pos = lastspace + 1;
-				lastspace = -1;
-				lastKoreanLineBreak = -1;
 			} else {
-				byte* breakPtr = str + lastKoreanLineBreak;
-				memmove(breakPtr + 1, breakPtr, strLength - lastKoreanLineBreak + 1);
-				str[lastKoreanLineBreak] = 0xD;
-				curw = 1;
-				pos = lastKoreanLineBreak + 1;
-				lastspace = -1;
-				lastKoreanLineBreak = -1;
+				// Handle Korean line break mode (break Korean words at any character)
+				// Used in Korean fan translated games
+				if (lastspace >= lastKoreanLineBreak) {
+					str[lastspace] = 0xD;
+					curw = 1;
+					pos = lastspace + 1;
+					lastspace = -1;
+					lastKoreanLineBreak = -1;
+				} else {
+					byte *breakPtr = str + lastKoreanLineBreak;
+					memmove(breakPtr + 1, breakPtr, strLength - lastKoreanLineBreak + 1);
+					str[lastKoreanLineBreak] = 0xD;
+					curw = 1;
+					pos = lastKoreanLineBreak + 1;
+					lastspace = -1;
+					lastKoreanLineBreak = -1;
+				}
 			}
 		}
 	}




More information about the Scummvm-git-logs mailing list