[Scummvm-cvs-logs] CVS: scummvm/scumm charset.h,2.17,2.18 nut_renderer.cpp,1.25,1.26 nut_renderer.h,1.7,1.8 scumm.h,1.238,1.239 scummvm.cpp,2.205,2.206 string.cpp,1.130,1.131
Max Horn
fingolfin at users.sourceforge.net
Wed Jun 4 07:38:14 CEST 2003
Update of /cvsroot/scummvm/scummvm/scumm
In directory sc8-pr-cvs1:/tmp/cvs-serv14955
Modified Files:
charset.h nut_renderer.cpp nut_renderer.h scumm.h scummvm.cpp
string.cpp
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: charset.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/charset.h,v
retrieving revision 2.17
retrieving revision 2.18
diff -u -d -r2.17 -r2.18
--- charset.h 21 May 2003 16:28:01 -0000 2.17
+++ charset.h 4 Jun 2003 14:37:42 -0000 2.18
@@ -76,6 +76,8 @@
protected:
byte *_fontPtr;
+ void drawBits1(VirtScreen *vs, byte *dst, const byte *src, byte *mask, int drawTop, int width, int height);
+
public:
CharsetRendererCommon(Scumm *vm) : CharsetRenderer(vm) {}
@@ -86,11 +88,9 @@
class CharsetRendererClassic : public CharsetRendererCommon {
protected:
- byte _bpp;
- byte *_charPtr;
-
int getCharWidth(byte chr);
- void drawBits(VirtScreen *vs, byte *dst, byte *mask, int drawTop, int width, int height);
+
+ void drawBitsN(VirtScreen *vs, byte *dst, const byte *src, byte *mask, byte bpp, int drawTop, int width, int height);
public:
CharsetRendererClassic(Scumm *vm) : CharsetRendererCommon(vm) {}
Index: nut_renderer.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/nut_renderer.cpp,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- nut_renderer.cpp 1 Jun 2003 14:30:26 -0000 1.25
+++ nut_renderer.cpp 4 Jun 2003 14:37:42 -0000 1.26
@@ -22,6 +22,7 @@
#include "scumm.h"
#include "nut_renderer.h"
+
NutRenderer::NutRenderer(Scumm *vm) {
_vm = vm;
_initialized = false;
@@ -133,7 +134,10 @@
return 0;
}
- return READ_LE_UINT16(_dataSrc + _offsets[c] + 6);
+ if(c & 0x80 && _vm->_CJKMode)
+ return 8;
+ else
+ return READ_LE_UINT16(_dataSrc + _offsets[c] + 6) + 2;
}
int32 NutRenderer::getCharHeight(byte c) {
@@ -143,7 +147,10 @@
return 0;
}
- return READ_LE_UINT16(_dataSrc + _offsets[c] + 8);
+ if(c & 0x80 && _vm->_CJKMode)
+ return 16;
+ else
+ return READ_LE_UINT16(_dataSrc + _offsets[c] + 8);
}
int32 NutRenderer::getStringWidth(const byte *string) {
@@ -208,23 +215,11 @@
byte pixel = *src++;
if (x + tx < 0 || x + tx >= _vm->_screenWidth || y + ty < 0 || y + ty >= _vm->_screenHeight)
continue;
-#if 1
if (pixel != 0) {
dst[tx] = color;
if (useMask)
mask[maskpos] |= maskmask;
}
-#else
- if (pixel != 0) {
- if (pixel == 0x01)
- pixel = (color == 0) ? 0xf : color;
- if (pixel == 0xff)
- pixel = 0x0;
- dst[tx] = pixel;
- if (useMask)
- mask[maskpos] |= maskmask;
- }
-#endif
maskmask >>= 1;
if (maskmask == 0) {
maskmask = 0x80;
@@ -237,5 +232,56 @@
x -= offsetX[i];
y -= offsetY[i];
+ }
+}
+
+void NutRenderer::draw2byte(int c, int32 x, int32 y, byte color, bool useMask) {
+ if (_loaded == false) {
+ debug(2, "NutRenderer::draw2byte() Font is not loaded");
+ return;
+ }
+
+ int width = g_scumm->_2byteWidth;
+ int height = g_scumm->_2byteHeight;
+ byte *src = g_scumm->get2byteCharPtr(c);
+ byte bits = 0;
+
+ byte *dst, *mask = NULL;
+ byte maskmask;
+ int maskpos;
+
+ dst = _vm->virtscr[0].screenPtr + y * _vm->_screenWidth + x + _vm->virtscr[0].xstart;
+ mask = _vm->getMaskBuffer(x, y, 0);
+
+// drawBits1(&_vm->virtscr[0], dst, src, mask, ?, width, height);
+ for (int ty = 0; ty < height; ty++) {
+ maskmask = revBitMask[x & 7];
+ maskpos = 0;
+ for (int tx = 0; tx < width; tx++) {
+ if((tx % 8) == 0)
+ bits = *src++;
+ if (x + tx < 0 || x + tx >= _vm->_screenWidth || y + ty < 0 || y + ty >= _vm->_screenHeight)
+ continue;
+ if (bits & revBitMask[tx % 8]) {
+ dst[tx] = color;
+ dst[tx+1] = 0;
+ if (useMask) {
+ mask[maskpos] |= maskmask;
+ if (maskmask == 1) {
+ mask[maskpos + 1] |= 0x80;
+ } else {
+ mask[maskpos] |= (maskmask >> 1);
+ }
+ }
+ }
+
+ maskmask >>= 1;
+ if (maskmask == 0) {
+ maskmask = 0x80;
+ maskpos++;
+ }
+ }
+ dst += _vm->_screenWidth;
+ mask += _vm->gdi._numStrips;
}
}
Index: nut_renderer.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/nut_renderer.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- nut_renderer.h 27 May 2003 15:31:13 -0000 1.7
+++ nut_renderer.h 4 Jun 2003 14:37:42 -0000 1.8
@@ -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.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/scumm.h,v
retrieving revision 1.238
retrieving revision 1.239
diff -u -d -r1.238 -r1.239
--- scumm.h 2 Jun 2003 23:54:51 -0000 1.238
+++ scumm.h 4 Jun 2003 14:37:42 -0000 1.239
@@ -1065,6 +1065,14 @@
void loadLanguageBundle();
public:
void translateText(const byte *text, byte *trans_buff); // Used by class ScummDialog
+
+ // Somewhat hackish stuff for 2 byte support (Chinese/Japanese/Korean)
+ bool _CJKMode;
+ int _2byteHeight;
+ int _2byteWidth;
+ byte *get2byteCharPtr(int idx);
+
+
protected:
#if defined(SCUMM_LITTLE_ENDIAN)
Index: scummvm.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/scummvm.cpp,v
retrieving revision 2.205
retrieving revision 2.206
diff -u -d -r2.205 -r2.206
--- scummvm.cpp 4 Jun 2003 13:15:06 -0000 2.205
+++ scummvm.cpp 4 Jun 2003 14:37:42 -0000 2.206
@@ -56,6 +56,26 @@
Scumm *g_scumm = 0;
ScummDebugger *g_debugger;
+byte *_2byteFontPtr;
+int _2byteWidth;
+int _2byteHeight;
+bool _CJKMode;
+
+byte *Scumm::get2byteCharPtr(int idx) {
+ /*
+ switch(language)
+ case korean:
+ return ( (idx % 256) - 0xb0) * 94 + (idx / 256) - 0xa1;
+ case japanese:
+ ...
+ case taiwan:
+ ...
+ */
+ idx = ( (idx % 256) - 0xb0) * 94 + (idx / 256) - 0xa1; // only for korean
+ return _2byteFontPtr + 2 * _2byteHeight * idx;
+}
+
+
extern NewGui *g_gui;
extern uint16 _debugLevel;
@@ -636,6 +656,52 @@
_saveLoadCompatible = false;
}
loadLanguageBundle();
+
+ // Load CJK font
+ if((_gameId == GID_DIG || _gameId == GID_CMI) && (_language == KO_KOR || _language == JA_JPN || _language == ZH_TWN)) {
+ File fp;
+ const char *fontFile = NULL;
+ _CJKMode = false;
+ switch(_language) {
+ case KO_KOR:
+ _CJKMode = true;
+ fontFile = "korean.fnt";
+ break;
+ case JA_JPN:
+ _CJKMode = true;
+ fontFile = (_gameId == GID_DIG) ? "kanji16.fnt" : "japanese.fnt";
+ break;
+ case ZH_TWN:
+ if(_gameId == GID_CMI) {
+ _CJKMode = true;
+ fontFile = "chinese.fnt";
+ }
+ break;
+ }
+ if(_CJKMode && fp.open(fontFile, getGameDataPath(), 1)) {
+ debug(2, "Loading CJK Font");
+ fp.seek(2,SEEK_CUR);
+ _2byteWidth = fp.readByte(); //FIXME: is this correct?
+ _2byteHeight = 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;
+ }
+ _2byteFontPtr = new byte[2 * _2byteHeight * numChar];
+ fp.read(_2byteFontPtr, 2 * _2byteHeight * numChar);
+ fp.close();
+ }
+ }
+
_audioNames = NULL;
}
@@ -643,6 +709,7 @@
{
delete [] _actors;
+ delete _2byteFontPtr;
delete _charset;
delete _pauseDialog;
delete _optionsDialog;
Index: string.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/string.cpp,v
retrieving revision 1.130
retrieving revision 1.131
diff -u -d -r1.130 -r1.131
--- string.cpp 2 Jun 2003 23:54:52 -0000 1.130
+++ string.cpp 4 Jun 2003 14:37:43 -0000 1.131
@@ -242,6 +242,8 @@
if (c != 0xFF) {
_charset->_left = _charset->_nextLeft;
_charset->_top = _charset->_nextTop;
+ if(c & 0x80 && _CJKMode)
+ c += *buffer++ * 256;
if (_features & GF_AFTER_V2 || _features & GF_AFTER_V3) {
_charset->printChar(c);
} else if (_features & GF_AFTER_V6) {
@@ -339,8 +341,8 @@
void Scumm::drawString(int a) {
byte buf[256];
byte *space;
- int i;
- byte fontHeight = 0, chr;
+ int i, c;
+ byte fontHeight = 0;
uint color;
_msgPtrToAdd = buf;
@@ -396,10 +398,10 @@
buf[1] = 0;
}
- for (i = 0; (chr = buf[i++]) != 0;) {
- if (chr == 0xFE || chr == 0xFF) {
- chr = buf[i++];
- switch (chr) {
+ for (i = 0; (c = buf[i++]) != 0;) {
+ if (c == 0xFE || c == 0xFF) {
+ c = buf[i++];
+ switch (c) {
case 9:
case 10:
case 13:
@@ -429,7 +431,9 @@
if (_string[a].no_talk_anim == 0)
_charset->_blitAlso = true;
}
- _charset->printChar(chr);
+ if(c >= 0x80 && _CJKMode)
+ c += buf[i++] * 256;
+ _charset->printChar(c);
_charset->_blitAlso = false;
}
}
@@ -701,7 +705,7 @@
// FIXME
byte *buf;
- byte c;
+ int c;
int i;
_charset->_ignoreCharsetMask = true;
@@ -731,6 +735,8 @@
if (c != 0 && c != 0xFF) {
_charset->_left = _charset->_nextLeft;
_charset->_top = _charset->_nextTop;
+ if(c >= 0x80 && _CJKMode)
+ c += *buf++ * 256;
_charset->printChar(c);
_charset->_nextLeft = _charset->_left;
_charset->_nextTop = _charset->_top;
More information about the Scummvm-git-logs
mailing list