Index: README
===================================================================
RCS file: /cvsroot/scummvm/scummvm/README,v
retrieving revision 1.108
diff -u -r1.108 README
--- README	27 May 2003 10:07:27 -0000	1.108
+++ README	1 Jun 2003 11:04:29 -0000
@@ -393,7 +393,7 @@
         es  - Spanish
         jp  - Japanese
         zh  - Chinese
-        ko  - Korean
+        kr  - Korean
         hb  - Hebrew
 
 Graphics filters:
Index: scumm.dsp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm.dsp,v
retrieving revision 1.41
diff -u -r1.41 scumm.dsp
--- scumm.dsp	30 May 2003 22:14:29 -0000	1.41
+++ scumm.dsp	1 Jun 2003 11:04:30 -0000
@@ -207,6 +207,10 @@
 # End Group

 # Begin Source File

 

+SOURCE=.\scumm\2byte_charset.cpp

+# End Source File

+# Begin Source File

+

 SOURCE=.\scumm\actor.cpp

 # End Source File

 # Begin Source File

Index: common/gameDetector.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/common/gameDetector.cpp,v
retrieving revision 1.101
diff -u -r1.101 gameDetector.cpp
--- common/gameDetector.cpp	29 May 2003 11:15:32 -0000	1.101
+++ common/gameDetector.cpp	1 Jun 2003 11:04:30 -0000
@@ -56,7 +56,7 @@
 	"\t-g<mode>      - graphics mode (normal,2x,3x,2xsai,super2xsai,supereagle,advmame2x,advmame3x,tv2x,dotmatrix)\n"
 	"\t-e<mode>      - set music engine (see README for details)\n"
 	"\t-a            - specify game is amiga version\n"
-	"\t-q<lang>      - specify language (en,de,fr,it,pt,es,jp,zh,ko,hb)\n"
+	"\t-q<lang>      - specify language (en,de,fr,it,pt,es,jp,zh,kr,hb)\n"
 	"\n"
 	"\t-c<num>       - use cdrom <num> for cd audio\n"
 	"\t-m<num>       - set music volume to <num> (0-255)\n"
@@ -117,7 +117,7 @@
 	{"es", "Spanish", ES_ESP},
 	{"jp", "Japanese", JA_JPN},
 	{"zh", "Chinese (Taiwan)", ZH_TWN},
-	{"ko", "Korean", KO_KOR},
+	{"kr", "Korean", KO_KOR},
 	{"hb", "Hebrew", HB_HEB},
 	{0, 0, 0}
 };
Index: scumm/charset.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/charset.cpp,v
retrieving revision 2.35
diff -u -r2.35 charset.cpp
--- scumm/charset.cpp	25 May 2003 20:38:44 -0000	2.35
+++ scumm/charset.cpp	1 Jun 2003 11:04:31 -0000
@@ -23,6 +23,8 @@
 #include "scumm.h"
 #include "nut_renderer.h"
 
+bool _2byte_pos_hack;
+
 CharsetRenderer::CharsetRenderer(Scumm *vm) {
 
 	_nextLeft = 0;
@@ -79,6 +81,8 @@
 
 // do spacing for variable width old-style font
 int CharsetRendererClassic::getCharWidth(byte chr) {
+	if(chr >= 0x80 && _CJKMode)
+		return 6;
 	int spacing = 0;
 
 	int offs = READ_LE_UINT32(_fontPtr + chr * 4 + 4);
@@ -628,6 +632,7 @@
 	int offsX, offsY;
 	int d;
 	VirtScreen *vs;
+	int is2byte = 0;
 
 	_vm->checkRange(_vm->_maxCharsets - 1, 1, _curId, "Printing with bad charset %d");
 	
@@ -640,7 +645,9 @@
 	_bpp = *_fontPtr;
 	_vm->_charsetColorMap[1] = _color;
 
-	uint32 charOffs = READ_LE_UINT32(_fontPtr + chr * 4 + 4);
+	is2byte = (chr >= 0x80 && _CJKMode) ? 1 : 0;
+
+	uint32 charOffs = READ_LE_UINT32(_fontPtr + (is2byte ? 0x0f : chr) * 4 + 4); //HACK!
 
 	if (!charOffs)
 		return;
@@ -649,7 +656,7 @@
 
 	_charPtr = _fontPtr + charOffs;
 
-	width = _charPtr[0];
+	if(is2byte) width = _charPtr[0] - 1; else width = _charPtr[0]; //HACK!!!
 	height = _charPtr[1];
 	if (_firstChar) {
 		_str.left = 0;
@@ -721,7 +728,10 @@
 		dst = _vm->getResourceAddress(rtBuffer, vs->number + 5)
 			+ vs->xstart + drawTop * _vm->_screenWidth + _left;
 
-		drawBits(vs, dst, mask, drawTop, width, height);
+		if(is2byte)
+			draw2byte(vs, dst, mask, drawTop, chr);
+		else
+			drawBits(vs, dst, mask, drawTop, width, height);
 
 		int h = height;
 		do {
@@ -730,7 +740,10 @@
 			dst += _vm->_screenWidth;
 		} while (--h);
 	} else {
-		drawBits(vs, dst, mask, drawTop, width, height);
+		if(is2byte)
+			draw2byte(vs, dst, mask, drawTop, chr);
+		else
+			drawBits(vs, dst, mask, drawTop, width, height);
 	}
 	
 	_left += width;
@@ -844,8 +857,14 @@
 	int width = _current->getCharWidth(chr);
 	int height = _current->getCharHeight(chr);
 
+	if(chr >= 256 && _CJKMode)
+		width = 16;
+
 	_hasMask = true;
-	_current->drawChar((char)chr, _left, _top, _color, !_ignoreCharsetMask);
+	if(chr >= 256 && _CJKMode)
+		_current->draw2byte(chr, _left, _top + (_2byte_pos_hack ? 6 : 0), _color, !_ignoreCharsetMask);
+	else
+		_current->drawChar((char)chr, _left, _top, _color, !_ignoreCharsetMask);
 	_vm->updateDirtyRect(0, _left, _left + width, _top, _top + height, 0);
 
 	_left += width;
@@ -854,5 +873,7 @@
 
 	if (_top + height > _str.bottom)
 		_str.bottom = _top + height;
+
+	_2byte_pos_hack = false;
 }
 
Index: scumm/charset.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/charset.h,v
retrieving revision 2.17
diff -u -r2.17 charset.h
--- scumm/charset.h	21 May 2003 16:28:01 -0000	2.17
+++ scumm/charset.h	1 Jun 2003 11:04:31 -0000
@@ -90,6 +90,7 @@
 	byte *_charPtr;
 
 	int getCharWidth(byte chr);
+	void draw2byte(VirtScreen *vs, byte *dst, byte *mask, int drawTop, int idx);
 	void drawBits(VirtScreen *vs, byte *dst, byte *mask, int drawTop, int width, int height);
 
 public:
Index: scumm/module.mk
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/module.mk,v
retrieving revision 1.18
diff -u -r1.18 module.mk
--- scumm/module.mk	30 May 2003 19:00:31 -0000	1.18
+++ scumm/module.mk	1 Jun 2003 11:04:31 -0000
@@ -1,6 +1,7 @@
 MODULE := scumm
 
 SCUMM_OBJS = \
+	scumm/2byte_charset.o \
 	scumm/actor.o \
 	scumm/akos.o \
 	scumm/base-costume.o \
Index: scumm/nut_renderer.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/nut_renderer.cpp,v
retrieving revision 1.24
diff -u -r1.24 nut_renderer.cpp
--- scumm/nut_renderer.cpp	27 May 2003 15:31:12 -0000	1.24
+++ scumm/nut_renderer.cpp	1 Jun 2003 11:04:31 -0000
@@ -133,7 +133,10 @@
 		return 0;
 	}
 
-	return READ_LE_UINT16(_dataSrc + _offsets[c] + 6);
+	if(c & 0x80 && _CJKMode)
+		return 8;
+	else
+		return READ_LE_UINT16(_dataSrc + _offsets[c] + 6) + 2;
 }
 
 int32 NutRenderer::getCharHeight(byte c) {
@@ -143,7 +146,10 @@
 		return 0;
 	}
 
-	return READ_LE_UINT16(_dataSrc + _offsets[c] + 8);
+	if(c & 0x80 && _CJKMode)
+		return 16;
+	else
+		return READ_LE_UINT16(_dataSrc + _offsets[c] + 8);
 }
 
 int32 NutRenderer::getStringWidth(const byte *string) {
Index: scumm/nut_renderer.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/nut_renderer.h,v
retrieving revision 1.7
diff -u -r1.7 nut_renderer.h
--- scumm/nut_renderer.h	27 May 2003 15:31:13 -0000	1.7
+++ scumm/nut_renderer.h	1 Jun 2003 11:04:31 -0000
@@ -41,6 +41,7 @@
 	~NutRenderer();
 
 	bool loadFont(const char *filename, const char *dir);
+	void draw2byte(int c, int32 x, int32 y, byte color, bool useMask);
 	void drawChar(byte c, int32 x, int32 y, byte color, bool useMask);
 //	void drawString(const char *string, int32 x, int32 y, byte color, int32 mode);
 	int32 getCharWidth(byte c);
Index: scumm/script_v8.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v8.cpp,v
retrieving revision 2.175
diff -u -r2.175 script_v8.cpp
--- scumm/script_v8.cpp	31 May 2003 21:42:33 -0000	2.175
+++ scumm/script_v8.cpp	1 Jun 2003 11:04:32 -0000
@@ -599,7 +599,10 @@
 			if (c != 0 && c != 0xFF) {
 				_charset->_left = _charset->_nextLeft;
 				_charset->_top = _charset->_nextTop;
-				_charset->printChar(c);
+				if(c >= 0x80 && _CJKMode)
+					_charset->printChar(c + (*buf++ * 256));
+				else
+					_charset->printChar(c);
 				_charset->_nextLeft = _charset->_left;
 				_charset->_nextTop = _charset->_top;
 			}
Index: scumm/scumm.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/scumm.h,v
retrieving revision 1.232
diff -u -r1.232 scumm.h
--- scumm/scumm.h	31 May 2003 12:17:57 -0000	1.232
+++ scumm/scumm.h	1 Jun 2003 11:04:32 -0000
@@ -1069,6 +1069,7 @@
 
 	void loadLanguageBundle();
 public:
+	bool checkCJKLanguage();
 	void translateText(const byte *text, byte *trans_buff);	// Used by class ScummDialog
 protected:
 
@@ -1202,6 +1203,14 @@
 
 // This is a constant lookup table of reverse bit masks
 extern const byte revBitMask[8];
+
+//nasty hacks
+extern bool _CJKMode;
+extern int _gid;
+extern char *_2byte;
+extern int _2byte_height;
+extern int _2byte_width;
+extern bool _2byte_pos_hack;
 
 /* Direction conversion functions (between old dir and new dir format) */
 int newDirToOldDir(int dir);
Index: scumm/scummvm.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/scummvm.cpp,v
retrieving revision 2.199
diff -u -r2.199 scummvm.cpp
--- scumm/scummvm.cpp	1 Jun 2003 04:03:40 -0000	2.199
+++ scumm/scummvm.cpp	1 Jun 2003 11:04:33 -0000
@@ -56,6 +56,12 @@
 Scumm *g_scumm = 0;
 ScummDebugger *g_debugger;
 
+int _gid;
+char *_2byte;
+int _2byte_width;
+int _2byte_height;
+bool _CJKMode;
+
 extern NewGui *g_gui;
 extern uint16 _debugLevel;
 
@@ -634,6 +640,51 @@
 		_saveLoadCompatible = false;
 	}
 	loadLanguageBundle();
+
+	// Load CJK font
+	if((_gameId == GID_DIG || _gameId == GID_CMI) && checkCJKLanguage()) {
+		_gid = _gameId;
+		File _fp;
+		char _fontFile[16];
+		_CJKMode = true;
+		switch(_language) {
+		case KO_KOR:
+			strcpy(_fontFile, "korean.fnt");
+			break;
+		case JA_JPN:
+			strcpy(_fontFile, (_gameId == GID_DIG) ? "kanji16.fnt" : "japanese.fnt");
+			break;
+		case ZH_TWN:
+			if(_gameId == GID_CMI)
+				strcpy(_fontFile, "chinese.fnt");
+			else
+				_CJKMode = false;
+			break;
+		}
+		if(_CJKMode && _fp.open(_fontFile, getGameDataPath(), 1)) {
+			debug(2, "Loading CJK Font");
+			_fp.seek(2,SEEK_CUR);
+			_2byte_width = _fp.readByte(); //FIXME: is this correct?
+			_2byte_height = _fp.readByte();
+
+			int numChar = 0;
+			switch(_language) {
+			case KO_KOR:
+				numChar = 2350;
+				break;
+			case JA_JPN:
+				numChar = (_gameId == GID_DIG) ? 1 : 1; //FIXME
+				break;
+			case ZH_TWN:
+				numChar = 1; //FIXME
+				break;
+			}
+			_2byte = new char[2 * _2byte_height * numChar];
+			_fp.read(_2byte, 2 * _2byte_height * numChar);
+			_fp.close();
+		}
+	}
+
 	_audioNames = NULL;
 }
 
@@ -641,6 +692,7 @@
 {
 	delete [] _actors;
 	
+	delete _2byte;
 	delete _charset;
 	delete _pauseDialog;
 	delete _optionsDialog;
Index: scumm/string.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/string.cpp,v
retrieving revision 1.127
diff -u -r1.127 string.cpp
--- scumm/string.cpp	31 May 2003 12:17:58 -0000	1.127
+++ scumm/string.cpp	1 Jun 2003 11:04:34 -0000
@@ -241,6 +241,11 @@
 		if (c != 0xFF) {
 			_charset->_left = _charset->_nextLeft;
 			_charset->_top = _charset->_nextTop;
+			if(c & 0x80 && _CJKMode) {
+				c += *buffer++ * 256;
+				if(_gameId == GID_CMI)
+					_2byte_pos_hack = true; //HACK: �������� y��ǥ�� ���� �ʴ�.
+			}
 			if (_features & GF_AFTER_V2 || _features & GF_AFTER_V3) {
 				_charset->printChar(c);
 			} else if (_features & GF_AFTER_V6) {
@@ -371,7 +376,10 @@
 		if (c != 0 && c != 0xFF) {
 			_charset->_left = _charset->_nextLeft;
 			_charset->_top = _charset->_nextTop;
-			_charset->printChar(c);
+			if(c & 0x80 && _CJKMode)
+				_charset->printChar(c + ((*buf++) * 256));
+			else
+				_charset->printChar(c);
 			_charset->_nextLeft = _charset->_left;
 			_charset->_nextTop = _charset->_top;
 		}
@@ -477,7 +485,13 @@
 				if (_string[a].no_talk_anim == 0)
 					_charset->_blitAlso = true;
 			}
-			_charset->printChar(chr);
+			if(chr >= 0x80 && _CJKMode) {
+				if(_gameId == GID_CMI)
+					_2byte_pos_hack = true;
+				_charset->printChar(chr + (buf[i++] * 256));
+			}
+			else
+				_charset->printChar(chr);
 			_charset->_blitAlso = false;
 		}
 	}
Index: scumm/smush/smush_font.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/smush/smush_font.cpp,v
retrieving revision 1.2
diff -u -r1.2 smush_font.cpp
--- scumm/smush/smush_font.cpp	30 Apr 2003 11:26:36 -0000	1.2
+++ scumm/smush/smush_font.cpp	1 Jun 2003 11:04:34 -0000
@@ -105,6 +105,9 @@
 }
 
 int SmushFont::getCharWidth(byte v) {
+	if(v >= 0x80 && _CJKMode)
+		return get2byteCharWidth();
+
 	if(v >= _nbChars)
 		error("invalid character in SmushFont::charWidth : %d (%d)", v, _nbChars);
 
@@ -112,6 +115,9 @@
 }
 
 int SmushFont::getCharHeight(byte v) {
+	if(v >= 0x80 && _CJKMode)
+		return get2byteCharHeight();
+
 	if(v >= _nbChars)
 		error("invalid character in SmushFont::charHeight : %d (%d)", v, _nbChars);
 
@@ -243,8 +249,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 && _CJKMode) {
+			x += draw2byte(buffer, dst_width, x, y, str[i], 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) {
Index: scumm/smush/smush_font.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/smush/smush_font.h,v
retrieving revision 1.2
diff -u -r1.2 smush_font.h
--- scumm/smush/smush_font.h	17 Mar 2003 13:16:26 -0000	1.2
+++ scumm/smush/smush_font.h	1 Jun 2003 11:04:34 -0000
@@ -46,10 +46,13 @@
 
 protected:
 
+	int get2byteCharWidth();
+	int get2byteCharHeight();
 	int getCharWidth(byte c);
 	int getStringWidth(char *str);
 	int getCharHeight(byte c);
 	int getStringHeight(char *str);
+	int draw2byte(byte *buffer, int dst_width, int x, int y, byte fst, byte snd);
 	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);
