aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorSven Hesse2012-07-07 19:14:06 +0200
committerSven Hesse2012-07-30 01:44:45 +0200
commit10b9be285149dd21bc38710c1a685800fab75e01 (patch)
tree0ce1913d5384242c4b98ec8397d86b776761a9f1 /engines
parent5b02192477cbdc9e8251bd48cac764d6fa61d024 (diff)
downloadscummvm-rg350-10b9be285149dd21bc38710c1a685800fab75e01.tar.gz
scummvm-rg350-10b9be285149dd21bc38710c1a685800fab75e01.tar.bz2
scummvm-rg350-10b9be285149dd21bc38710c1a685800fab75e01.zip
GOB: Add Util::toCP850Lower() / toCP850Upper()
Diffstat (limited to 'engines')
-rw-r--r--engines/gob/util.cpp66
-rw-r--r--engines/gob/util.h5
2 files changed, 71 insertions, 0 deletions
diff --git a/engines/gob/util.cpp b/engines/gob/util.cpp
index e1c16c3257..5ac4ef024e 100644
--- a/engines/gob/util.cpp
+++ b/engines/gob/util.cpp
@@ -247,6 +247,72 @@ int16 Util::translateKey(const Common::KeyState &key) {
return 0;
}
+static const uint8 kLowerToUpper[][2] = {
+ {0x81, 0x9A},
+ {0x82, 0x90},
+ {0x83, 0xB6},
+ {0x84, 0x8E},
+ {0x85, 0xB7},
+ {0x86, 0x8F},
+ {0x87, 0x80},
+ {0x88, 0xD2},
+ {0x89, 0xD3},
+ {0x8A, 0xD4},
+ {0x8B, 0xD8},
+ {0x8C, 0xD7},
+ {0x8D, 0xDE},
+ {0x91, 0x92},
+ {0x93, 0xE2},
+ {0x94, 0x99},
+ {0x95, 0xE3},
+ {0x96, 0xEA},
+ {0x97, 0xEB},
+ {0x95, 0xE3},
+ {0x96, 0xEA},
+ {0x97, 0xEB},
+ {0x9B, 0x9D},
+ {0xA0, 0xB5},
+ {0xA1, 0xD6},
+ {0xA2, 0xE0},
+ {0xA3, 0xE9},
+ {0xA4, 0xA5},
+ {0xC6, 0xC7},
+ {0xD0, 0xD1},
+ {0xE4, 0xE5},
+ {0xE7, 0xE8},
+ {0xEC, 0xED}
+};
+
+char Util::toCP850Lower(char cp850) {
+ const uint8 cp = (unsigned char)cp850;
+ if (cp <= 32)
+ return cp850;
+
+ if (cp <= 127)
+ return tolower(cp850);
+
+ for (uint i = 0; i < ARRAYSIZE(kLowerToUpper); i++)
+ if (cp == kLowerToUpper[i][1])
+ return (char)kLowerToUpper[i][0];
+
+ return cp850;
+}
+
+char Util::toCP850Upper(char cp850) {
+ const uint8 cp = (unsigned char)cp850;
+ if (cp <= 32)
+ return cp850;
+
+ if (cp <= 127)
+ return toupper(cp850);
+
+ for (uint i = 0; i < ARRAYSIZE(kLowerToUpper); i++)
+ if (cp == kLowerToUpper[i][0])
+ return (char)kLowerToUpper[i][1];
+
+ return cp850;
+}
+
int16 Util::getKey() {
Common::KeyState key;
diff --git a/engines/gob/util.h b/engines/gob/util.h
index 2e568ad169..a4984c6207 100644
--- a/engines/gob/util.h
+++ b/engines/gob/util.h
@@ -143,6 +143,11 @@ public:
/** Read a constant-length string out of a stream. */
static Common::String readString(Common::SeekableReadStream &stream, int n);
+ /** Convert a character in CP850 encoding to the equivalent lower case character. */
+ static char toCP850Lower(char cp850);
+ /** Convert a character in CP850 encoding to the equivalent upper case character. */
+ static char toCP850Upper(char cp850);
+
Util(GobEngine *vm);
protected: