[Scummvm-cvs-logs] SF.net SVN: scummvm:[53196] scummvm/trunk/engines/scumm

athrxx at users.sourceforge.net athrxx at users.sourceforge.net
Wed Oct 13 00:17:00 CEST 2010


Revision: 53196
          http://scummvm.svn.sourceforge.net/scummvm/?rev=53196&view=rev
Author:   athrxx
Date:     2010-10-12 22:17:00 +0000 (Tue, 12 Oct 2010)

Log Message:
-----------
SCUMM/FM-TOWNS: start fixing japanese font drawing

Modified Paths:
--------------
    scummvm/trunk/engines/scumm/charset.cpp
    scummvm/trunk/engines/scumm/charset.h

Modified: scummvm/trunk/engines/scumm/charset.cpp
===================================================================
--- scummvm/trunk/engines/scumm/charset.cpp	2010-10-12 22:16:21 UTC (rev 53195)
+++ scummvm/trunk/engines/scumm/charset.cpp	2010-10-12 22:17:00 UTC (rev 53196)
@@ -456,30 +456,60 @@
 }
 
 int CharsetRendererCommon::getFontHeight() {
-	if (_vm->_useCJKMode)
-		return MAX(_vm->_2byteHeight + 1, _fontHeight);
-	else
+	if (_vm->_useCJKMode) {
+		if (_vm->_game.platform == Common::kPlatformFMTowns) {
+			static const uint8 sjisFontHeightM1[] = { 0, 9, 10, 9, 10, 9, 10, 0, 0 };
+			static const uint8 sjisFontHeightM2[] = { 8, 8, 9, 9, 9, 8, 9, 9, 9, 8 };
+			static const uint8 sjisFontHeightI4[] = { 8, 8, 9, 9, 9, 8, 8, 8, 8, 8 };
+			const uint8 *htbl = (_vm->_game.id == GID_MONKEY) ? sjisFontHeightM1 : ((_vm->_game.id == GID_INDY4) ? sjisFontHeightI4 : sjisFontHeightM2);
+			return htbl[_curId];			
+		} else {
+			return MAX(_vm->_2byteHeight + 1, _fontHeight);
+		}
+	} else
 		return _fontHeight;
 }
 
 // do spacing for variable width old-style font
-int CharsetRendererClassic::getCharWidth(byte chr) {
-	if (chr >= 0x80 && _vm->_useCJKMode)
-		return _vm->_2byteWidth / 2;
+int CharsetRendererClassic::getCharWidth(uint16 chr) {
 	int spacing = 0;
 
-	int offs = READ_LE_UINT32(_fontPtr + chr * 4 + 4);
-	if (offs) {
-		spacing = _fontPtr[offs] + (signed char)_fontPtr[offs + 2];
+	if (_vm->_game.platform == Common::kPlatformFMTowns) {
+		if (_vm->_useCJKMode) {
+			if ((chr & 0xff00) == 0xfd00) {
+				chr &= 0xff;
+			} else if (chr >= 256) {
+				spacing = 9;
+			} else if (chr >= 128) {
+				spacing = 5;
+			}
+
+			if (spacing) {
+				static const uint8 sjisWidthM1[] = { 0, 1, 0, 0, 0, 0, 0, 0, 0, 0 };
+				static const uint8 sjisWidthM2[] = { 0, 1, 1, 1, 1, 0, 1, 1, 1, 0 };
+				static const uint8 sjisWidthI4[] = { 0, 0, 1, 1, 1, 0, 0, 0, 0, 0 };
+				const uint8 *wtbl = (_vm->_game.id == GID_MONKEY) ? sjisWidthM1 : ((_vm->_game.id == GID_INDY4) ? sjisWidthI4 : sjisWidthM2);
+				spacing += wtbl[_curId];
+			}
+		}
+	} else if (chr >= 0x80 && _vm->_useCJKMode) {
+		return _vm->_2byteWidth / 2;
 	}
 
+	if (!spacing) {
+		int offs = READ_LE_UINT32(_fontPtr + chr * 4 + 4);
+		if (offs) {
+			spacing = _fontPtr[offs] + (signed char)_fontPtr[offs + 2];
+		}
+	}
+
 	return spacing;
 }
 
 int CharsetRenderer::getStringWidth(int arg, const byte *text) {
 	int pos = 0;
 	int width = 1;
-	byte chr;
+	uint16 chr;
 	int oldID = getCurID();
 	int code = (_vm->_game.heversion >= 80) ? 127 : 64;
 
@@ -537,12 +567,18 @@
 				}
 			}
 		}
-		if ((chr & 0x80) && _vm->_useCJKMode) {
-			pos++;
-			width += _vm->_2byteWidth;
-		} else {
-			width += getCharWidth(chr);
+
+		if (_vm->_useCJKMode) {
+			if (_vm->_game.platform == Common::kPlatformFMTowns) {
+				if ((chr >= 0x80 && chr <= 0x9f) || (chr >= 0xe0 && chr <= 0xfd))
+					chr = (chr << 8) | text[pos++];
+			} else if (chr & 0x80) {
+				pos++;
+				width += _vm->_2byteWidth;
+				continue;
+			}
 		}
+		width += getCharWidth(chr);
 	}
 
 	setCurID(oldID);
@@ -634,7 +670,7 @@
 	setCurID(oldID);
 }
 
-int CharsetRendererV3::getCharWidth(byte chr) {
+int CharsetRendererV3::getCharWidth(uint16 chr) {
 	if (chr & 0x80 && _vm->_useCJKMode)
 		return _vm->_2byteWidth / 2;
 	int spacing = 0;
@@ -1258,7 +1294,7 @@
 	return _current->getCharHeight(chr);
 }
 
-int CharsetRendererNut::getCharWidth(byte chr) {
+int CharsetRendererNut::getCharWidth(uint16 chr) {
 	assert(_current);
 	return _current->getCharWidth(chr);
 }

Modified: scummvm/trunk/engines/scumm/charset.h
===================================================================
--- scummvm/trunk/engines/scumm/charset.h	2010-10-12 22:16:21 UTC (rev 53195)
+++ scummvm/trunk/engines/scumm/charset.h	2010-10-12 22:17:00 UTC (rev 53196)
@@ -89,7 +89,7 @@
 
 	virtual int getFontHeight() = 0;
 	virtual int getCharHeight(byte chr) { return getFontHeight(); }
-	virtual int getCharWidth(byte chr) = 0;
+	virtual int getCharWidth(uint16 chr) = 0;
 
 	virtual void setColor(byte color) { _color = color; translateColor(); }
 
@@ -134,7 +134,7 @@
 	void printChar(int chr, bool ignoreCharsetMask);
 	void drawChar(int chr, const Graphics::Surface &s, int x, int y);
 
-	int getCharWidth(byte chr);
+	int getCharWidth(uint16 chr);
 };
 
 class CharsetRendererNES : public CharsetRendererCommon {
@@ -151,7 +151,7 @@
 	void drawChar(int chr, const Graphics::Surface &s, int x, int y);
 
 	int getFontHeight() { return 8; }
-	int getCharWidth(byte chr) { return 8; }
+	int getCharWidth(uint16 chr) { return 8; }
 };
 
 class CharsetRendererV3 : public CharsetRendererCommon {
@@ -165,7 +165,7 @@
 	void drawChar(int chr, const Graphics::Surface &s, int x, int y);
 	void setCurID(int32 id);
 	void setColor(byte color);
-	int getCharWidth(byte chr);
+	int getCharWidth(uint16 chr);
 };
 
 #ifdef USE_RGB_COLOR
@@ -189,7 +189,7 @@
 	~CharsetRendererV2();
 
 	void setCurID(int32 id) {}
-	int getCharWidth(byte chr) { return 8; }
+	int getCharWidth(uint16 chr) { return 8; }
 };
 
 #ifdef ENABLE_SCUMM_7_8
@@ -208,7 +208,7 @@
 
 	int getFontHeight();
 	int getCharHeight(byte chr);
-	int getCharWidth(byte chr);
+	int getCharWidth(uint16 chr);
 };
 #endif
 


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list