aboutsummaryrefslogtreecommitdiff
path: root/scumm/smush/smush_font.cpp
diff options
context:
space:
mode:
authorMax Horn2003-06-04 14:37:43 +0000
committerMax Horn2003-06-04 14:37:43 +0000
commit6fd0e4a07f7502cf88e0d65a7030836196c15852 (patch)
tree15622623c1b5e89dea1ae57d208101cf93d4d3e3 /scumm/smush/smush_font.cpp
parent97aaab94108c3ddbac82a130ddb4f4050867a880 (diff)
downloadscummvm-rg350-6fd0e4a07f7502cf88e0d65a7030836196c15852.tar.gz
scummvm-rg350-6fd0e4a07f7502cf88e0d65a7030836196c15852.tar.bz2
scummvm-rg350-6fd0e4a07f7502cf88e0d65a7030836196c15852.zip
Patch #747021: DIG&CMI 2 byte charset support (very heavily modified by me; still needs more cleanup but already works well enough)
svn-id: r8293
Diffstat (limited to 'scumm/smush/smush_font.cpp')
-rw-r--r--scumm/smush/smush_font.cpp70
1 files changed, 63 insertions, 7 deletions
diff --git a/scumm/smush/smush_font.cpp b/scumm/smush/smush_font.cpp
index 7741ad8205..fe9e2333bc 100644
--- a/scumm/smush/smush_font.cpp
+++ b/scumm/smush/smush_font.cpp
@@ -79,7 +79,7 @@ bool SmushFont::loadFont(const char *filename, const char *directory) {
}
_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 @@ bool SmushFont::loadFont(const char *filename, const char *directory) {
}
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::getCharWidth(byte v) {
}
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 @@ int SmushFont::drawChar(byte *buffer, int dst_width, int x, int y, byte chr) {
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 @@ int SmushFont::drawChar(byte *buffer, int dst_width, int x, int y, byte chr) {
}
} 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 @@ int SmushFont::drawChar(byte *buffer, int dst_width, int x, int y, byte chr) {
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 @@ static char **split(char *str, char sep) {
}
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 @@ void SmushFont::drawStringWrap(char *str, byte *buffer, int dst_width, int dst_h
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;