aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorEugene Sandulenko2013-06-26 20:46:14 -0400
committerEugene Sandulenko2013-09-06 14:48:16 +0300
commitd4e572843df01ce2307ca696ebc1db2775701205 (patch)
tree5b8acb198c13285eba9acdb2943d414a36299b45 /engines
parentee5dc16eaa138bfeca7f914b4314ef03bcfd7352 (diff)
downloadscummvm-rg350-d4e572843df01ce2307ca696ebc1db2775701205.tar.gz
scummvm-rg350-d4e572843df01ce2307ca696ebc1db2775701205.tar.bz2
scummvm-rg350-d4e572843df01ce2307ca696ebc1db2775701205.zip
FULLPIPE: Transcode Cyrillic into UTF-8 for debugging convenience
Diffstat (limited to 'engines')
-rw-r--r--engines/fullpipe/scene.cpp2
-rw-r--r--engines/fullpipe/stateloader.cpp2
-rw-r--r--engines/fullpipe/utils.cpp48
-rw-r--r--engines/fullpipe/utils.h1
4 files changed, 50 insertions, 3 deletions
diff --git a/engines/fullpipe/scene.cpp b/engines/fullpipe/scene.cpp
index ee7a4dd570..fb51b3b121 100644
--- a/engines/fullpipe/scene.cpp
+++ b/engines/fullpipe/scene.cpp
@@ -118,7 +118,7 @@ bool Scene::load(MfcArchive &file) {
_sceneId = file.readUint16LE();
_scstringObj = file.readPascalString();
- debug(0, "scene: <%s>", _scstringObj);
+ debug(0, "scene: <%s>", transCyrillic((byte *)_scstringObj));
int count = file.readUint16LE();
debug(7, "scene.ani: %d", count);
diff --git a/engines/fullpipe/stateloader.cpp b/engines/fullpipe/stateloader.cpp
index 3c5a442496..1f9b090d01 100644
--- a/engines/fullpipe/stateloader.cpp
+++ b/engines/fullpipe/stateloader.cpp
@@ -401,7 +401,7 @@ bool CGameVar::load(MfcArchive &file) {
for (int i = 0; i < file.getLevel(); i++)
debugN(6, " ");
- debugN(6, "<%s>: ", _stringObj);
+ debugN(6, "<%s>: ", transCyrillic((byte *)_stringObj));
switch (_varType) {
case 0:
diff --git a/engines/fullpipe/utils.cpp b/engines/fullpipe/utils.cpp
index 14388f7db3..0b75ab5ede 100644
--- a/engines/fullpipe/utils.cpp
+++ b/engines/fullpipe/utils.cpp
@@ -99,7 +99,7 @@ char *MfcArchive::readPascalString(bool twoByte) {
tmp = (char *)calloc(len + 1, 1);
read(tmp, len);
- debug(9, "readPascalString: %d <%s>", len, tmp);
+ debug(9, "readPascalString: %d <%s>", len, transCyrillic((byte *)tmp));
return tmp;
}
@@ -360,4 +360,50 @@ char *genFileName(int superId, int sceneId, const char *ext) {
return s;
}
+// Translates cp-1251..utf-8
+byte *transCyrillic(byte *s) {
+ static byte tmp[1024];
+
+ static int trans[] = { 0xa8, 0xd081, 0xb8, 0xd191, 0xc0, 0xd090,
+ 0xc1, 0xd091, 0xc2, 0xd092, 0xc3, 0xd093, 0xc4, 0xd094,
+ 0xc5, 0xd095, 0xc6, 0xd096, 0xc7, 0xd097, 0xc8, 0xd098,
+ 0xc9, 0xd099, 0xca, 0xd09a, 0xcb, 0xd09b, 0xcc, 0xd09c,
+ 0xcd, 0xd09d, 0xce, 0xd09e, 0xcf, 0xd09f, 0xd0, 0xd0a0,
+ 0xd1, 0xd0a1, 0xd2, 0xd0a2, 0xd3, 0xd0a3, 0xd4, 0xd0a4,
+ 0xd5, 0xd0a5, 0xd6, 0xd0a6, 0xd7, 0xd0a7, 0xd8, 0xd0a8,
+ 0xd9, 0xd0a9, 0xda, 0xd0aa, 0xdb, 0xd0ab, 0xdc, 0xd0ac,
+ 0xdd, 0xd0ad, 0xde, 0xd0ae, 0xdf, 0xd0af, 0xe0, 0xd0b0,
+ 0xe1, 0xd0b1, 0xe2, 0xd0b2, 0xe3, 0xd0b3, 0xe4, 0xd0b4,
+ 0xe5, 0xd0b5, 0xe6, 0xd0b6, 0xe7, 0xd0b7, 0xe8, 0xd0b8,
+ 0xe9, 0xd0b9, 0xea, 0xd0ba, 0xeb, 0xd0bb, 0xec, 0xd0bc,
+ 0xed, 0xd0bd, 0xee, 0xd0be, 0xef, 0xd0bf, 0xf0, 0xd180,
+ 0xf1, 0xd181, 0xf2, 0xd182, 0xf3, 0xd183, 0xf4, 0xd184,
+ 0xf5, 0xd185, 0xf6, 0xd186, 0xf7, 0xd187, 0xf8, 0xd188,
+ 0xf9, 0xd189, 0xfa, 0xd18a, 0xfb, 0xd18b, 0xfc, 0xd18c,
+ 0xfd, 0xd18d, 0xfe, 0xd18e, 0xff, 0xd18f };
+
+ int i = 0;
+
+ for (byte *p = s; *p; p++) {
+ if (*p < 128) {
+ tmp[i++] = *p;
+ } else {
+ int j;
+ for (j = 0; trans[j]; j += 2) {
+ if (trans[j] == *p) {
+ tmp[i++] = (trans[j + 1] >> 8) & 0xff;
+ tmp[i++] = trans[j + 1] & 0xff;
+ break;
+ }
+ }
+
+ assert(trans[j]);
+ }
+ }
+
+ tmp[i] = 0;
+
+ return tmp;
+}
+
} // End of namespace Fullpipe
diff --git a/engines/fullpipe/utils.h b/engines/fullpipe/utils.h
index 94fdf4b5ca..4588541bc1 100644
--- a/engines/fullpipe/utils.h
+++ b/engines/fullpipe/utils.h
@@ -127,6 +127,7 @@ struct CNode {
typedef Common::Array<void *> CPtrList;
char *genFileName(int superId, int sceneId, const char *ext);
+byte *transCyrillic(byte *s);
} // End of namespace Fullpipe