[Scummvm-cvs-logs] CVS: scummvm/scumm/smush smush_font.cpp,1.2,1.3 smush_font.h,1.2,1.3

Max Horn fingolfin at users.sourceforge.net
Wed Jun 4 07:38:13 CEST 2003


Update of /cvsroot/scummvm/scummvm/scumm/smush
In directory sc8-pr-cvs1:/tmp/cvs-serv14955/smush

Modified Files:
	smush_font.cpp smush_font.h 
Log Message:
Patch #747021: DIG&CMI 2 byte charset support (very heavily modified by me; still needs more cleanup but already works well enough)

Index: smush_font.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/smush/smush_font.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- smush_font.cpp	30 Apr 2003 11:26:36 -0000	1.2
+++ smush_font.cpp	4 Jun 2003 14:37:43 -0000	1.3
@@ -79,7 +79,7 @@
 	}
 	
 	_nbChars = READ_LE_UINT16(_dataSrc + 10);
-	int32 offset = READ_BE_UINT32(_dataSrc + 4) + 8;
+	int offset = READ_BE_UINT32(_dataSrc + 4) + 8;
 	for (int l = 0; l < _nbChars; l++) {
 		if (READ_BE_UINT32(_dataSrc + offset) == 'FRME') {
 			offset += 8;
@@ -105,6 +105,14 @@
 }
 
 int SmushFont::getCharWidth(byte v) {
+	if(v >= 0x80 && g_scumm->_CJKMode) {
+		if(g_scumm->_gameId == GID_CMI)
+			return 8;
+		if(g_scumm->_gameId == GID_DIG)
+			return 6;
+		return 0;
+	}
+
 	if(v >= _nbChars)
 		error("invalid character in SmushFont::charWidth : %d (%d)", v, _nbChars);
 
@@ -112,6 +120,14 @@
 }
 
 int SmushFont::getCharHeight(byte v) {
+	if(v >= 0x80 && g_scumm->_CJKMode) {
+		if(g_scumm->_gameId == GID_CMI)
+			return 16;
+		if(g_scumm->_gameId == GID_DIG)
+			return 10;
+		return 0;
+	}
+
 	if(v >= _nbChars)
 		error("invalid character in SmushFont::charHeight : %d (%d)", v, _nbChars);
 
@@ -179,8 +195,8 @@
 	byte *dst = buffer + dst_width * y + x;
 
 	if(_original) {
-		for(int32 j = 0; j < h; j++) {
-			for(int32 i = 0; i < w; i++) {
+		for(int j = 0; j < h; j++) {
+			for(int i = 0; i < w; i++) {
 				char value = *src++;
 				if(value) dst[i] = value;
 			}
@@ -188,7 +204,7 @@
 		}
 	} else {
 		char color = (_color != -1) ? _color : 1;
-		if (_new_colors == true) {
+		if (_new_colors) {
 			for(int j = 0; j < h; j++) {
 				for(int i = 0; i < w; i++) {
 					char value = *src++;
@@ -219,6 +235,41 @@
 	return w;
 }
 
+int SmushFont::draw2byte(byte *buffer, int dst_width, int x, int y, int idx) {
+	int w = g_scumm->_2byteWidth;
+	int h = g_scumm->_2byteHeight;
+
+	byte *src = g_scumm->get2byteCharPtr(idx);
+	byte *dst = buffer + dst_width * (y + (g_scumm->_gameId == GID_CMI ? 7 : 2)) + x;
+	byte bits = 0;
+
+	if(_original) {
+		for(int j = 0; j < h; j++) {
+			for(int i = 0; i < w; i++) {
+				char value = 1;//*src++;
+				if(value) dst[i] = value;
+			}
+			dst += dst_width;
+		}
+	} else {
+		char color = (_color != -1) ? _color : 1;
+		if (_new_colors)
+			color = 0xff; //FIXME;
+		for(int j = 0; j < h; j++) {
+			for(int i = 0; i < w; i++) {
+				if((i % 8) == 0)
+					bits = *src++;
+				if (bits & revBitMask[i % 8]) {
+					dst[i + 1] = 0;
+					dst[i] = color;
+				}
+			}
+			dst += dst_width;
+		}
+	}
+	return w + 1;
+}
+
 static char **split(char *str, char sep) {
 	char **ret = new char *[62];
 	int n = 0;
@@ -243,8 +294,13 @@
 }
 
 void SmushFont::drawSubstring(char *str, byte *buffer, int dst_width, int x, int y) {
-	for(int i = 0; str[i] != 0; i++)
-		x += drawChar(buffer, dst_width, x, y, str[i]);
+	for(int i = 0; str[i] != 0; i++) {
+		if((byte)str[i] >= 0x80 && g_scumm->_CJKMode) {
+			x += draw2byte(buffer, dst_width, x, y, (byte)str[i] + 256 * (byte)str[i+1]);
+			i++;
+		} else
+			x += drawChar(buffer, dst_width, x, y, str[i]);
+	}
 }
 
 void SmushFont::drawStringAbsolute(char *str, byte *buffer, int dst_width, int x, int y) {
@@ -419,7 +475,7 @@
 	delete []substrings;
 }
 
-void SmushFont::drawStringWrapCentered(char *str, byte *buffer, int dst_width, int dst_height, int x, int32 y, int width) {
+void SmushFont::drawStringWrapCentered(char *str, byte *buffer, int dst_width, int dst_height, int x, int y, int width) {
 	debug(9, "SmushFont::drawStringWrapCentered(%s, %d, %d)", str, x, y);
 	
 	int max_substr_width = 0;

Index: smush_font.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/smush/smush_font.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- smush_font.h	17 Mar 2003 13:16:26 -0000	1.2
+++ smush_font.h	4 Jun 2003 14:37:43 -0000	1.3
@@ -50,6 +50,7 @@
 	int getStringWidth(char *str);
 	int getCharHeight(byte c);
 	int getStringHeight(char *str);
+	int draw2byte(byte *buffer, int dst_width, int x, int y, int idx);
 	int drawChar(byte *buffer, int dst_width, int x, int y, byte chr);
 	void drawSubstring(char *str, byte *buffer, int dst_width, int x, int y);
 	void decodeCodec(byte *dst, byte *src, int length);
@@ -60,7 +61,7 @@
 	void setColor(byte c) { _color = c; }
 	void drawStringCentered(char *str, byte *buffer, int dst_width, int dst_height, int y, int xmin, int width, int offset);
 	void drawStringWrap(char *str, byte *buffer, int dst_width, int dst_height, int x, int y, int width);
-	void drawStringWrapCentered(char *str, byte *buffer, int dst_width, int dst_height, int x, int32 y, int width);
+	void drawStringWrapCentered(char *str, byte *buffer, int dst_width, int dst_height, int x, int y, int width);
 	void drawStringAbsolute(char *str, byte *buffer, int dst_width, int x, int y);
 };
 





More information about the Scummvm-git-logs mailing list