aboutsummaryrefslogtreecommitdiff
path: root/engines/kyra
diff options
context:
space:
mode:
authorJohannes Schickel2009-06-21 01:15:24 +0000
committerJohannes Schickel2009-06-21 01:15:24 +0000
commitdb7484b7ba00ef9c06240799dcc8dc7e4ff3364c (patch)
treeeedf23269921f0ee37941560880232dd3c38d003 /engines/kyra
parent89607d994b2ca93788a62cab87bf8dc66f2804b5 (diff)
downloadscummvm-rg350-db7484b7ba00ef9c06240799dcc8dc7e4ff3364c.tar.gz
scummvm-rg350-db7484b7ba00ef9c06240799dcc8dc7e4ff3364c.tar.bz2
scummvm-rg350-db7484b7ba00ef9c06240799dcc8dc7e4ff3364c.zip
Moved CP850<->ISO-8859-1 conversion to Util.
svn-id: r41720
Diffstat (limited to 'engines/kyra')
-rw-r--r--engines/kyra/gui_lol.cpp33
-rw-r--r--engines/kyra/lol.h5
-rw-r--r--engines/kyra/staticres.cpp15
-rw-r--r--engines/kyra/util.cpp63
-rw-r--r--engines/kyra/util.h10
5 files changed, 81 insertions, 45 deletions
diff --git a/engines/kyra/gui_lol.cpp b/engines/kyra/gui_lol.cpp
index 22caaa9bb6..dcc0900b5d 100644
--- a/engines/kyra/gui_lol.cpp
+++ b/engines/kyra/gui_lol.cpp
@@ -29,6 +29,7 @@
#include "kyra/screen_lol.h"
#include "kyra/gui_lol.h"
#include "kyra/resource.h"
+#include "kyra/util.h"
#include "common/savefile.h"
#include "graphics/scaler.h"
@@ -2408,14 +2409,7 @@ void GUI_LoL::setupSavegameNames(Menu &menu, int num) {
strncpy(s, header.description.c_str(), 80);
s[79] = 0;
- for (uint32 ii = 0; ii < strlen(s); ii++) {
- for (int iii = 0; iii < _vm->_fontConversionTableSize; iii += 2) {
- if ((uint8)s[ii] == _vm->_fontConversionTable[iii]) {
- s[ii] = (uint8)_vm->_fontConversionTable[iii + 1];
- break;
- }
- }
- }
+ Util::convertISOToDOS(s);
menu.item[i].itemString = s;
s += (strlen(s) + 1);
@@ -2468,16 +2462,12 @@ int GUI_LoL::getInput() {
int inputFlag = _vm->checkInput(_menuButtonList);
if (_currentMenu == &_savenameMenu && _keyPressed.ascii){
- for (int i = 0; i < _vm->_fontConversionTableSize; i += 2) {
- if (_keyPressed.ascii == _vm->_fontConversionTable[i]) {
- _keyPressed.ascii = _vm->_fontConversionTable[i + 1];
- break;
- }
- }
+ char inputKey = _keyPressed.ascii;
+ Util::convertISOToDOS(inputKey);
- if (_keyPressed.ascii > 31 && _keyPressed.ascii < 226) {
+ if ((uint8)inputKey > 31 && (uint8)inputKey < 226) {
_saveDescription[strlen(_saveDescription) + 1] = 0;
- _saveDescription[strlen(_saveDescription)] = _keyPressed.ascii;
+ _saveDescription[strlen(_saveDescription)] = inputKey;
inputFlag |= 0x8000;
} else if (_keyPressed.keycode == Common::KEYCODE_BACKSPACE && strlen(_saveDescription)) {
_saveDescription[strlen(_saveDescription) - 1] = 0;
@@ -2631,15 +2621,8 @@ int GUI_LoL::clickedDeathMenu(Button *button) {
int GUI_LoL::clickedSavenameMenu(Button *button) {
updateMenuButton(button);
if (button->arg == _savenameMenu.item[0].itemId) {
- for (uint32 i = 0; i < strlen(_saveDescription); i++) {
- for (int ii = 0; ii < _vm->_fontConversionTableSize; ii += 2) {
- if ((uint8)_saveDescription[i] == _vm->_fontConversionTable[ii + 1]) {
- _saveDescription[i] = (char)_vm->_fontConversionTable[ii];
- break;
- }
- }
- }
-
+ Util::convertDOSToISO(_saveDescription);
+
int slot = _menuResult == -2 ? getNextSavegameSlot() : _menuResult;
Graphics::Surface thumb;
createScreenThumbnail(thumb);
diff --git a/engines/kyra/lol.h b/engines/kyra/lol.h
index 32adc8347d..187c873d2e 100644
--- a/engines/kyra/lol.h
+++ b/engines/kyra/lol.h
@@ -853,11 +853,6 @@ private:
static const char * const _languageExt[];
- // TODO: Rethink of a proper way for conversion, currently our GUI charset isn't defined
- // properly, thus this might not work on every system.
- static const uint8 _fontConversionTable[];
- static const int _fontConversionTableSize;
-
// graphics
void setupScreenDims();
void initSceneWindowDialogue(int controlMode);
diff --git a/engines/kyra/staticres.cpp b/engines/kyra/staticres.cpp
index d5c75bf89e..34d63e29e8 100644
--- a/engines/kyra/staticres.cpp
+++ b/engines/kyra/staticres.cpp
@@ -3323,21 +3323,6 @@ const int LoLEngine::_outroMonsterScaleTableY[] = {
0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100
};
-const uint8 LoLEngine::_fontConversionTable[] = {
- (const uint8)'Ä', 0x8e, (const uint8)'ä', 0x84, (const uint8)'Ö', 0x99,
- (const uint8)'ö', 0x94, (const uint8)'Ü', 0x9a, (const uint8)'ü', 0x81,
- (const uint8)'ß', 0xe1, (const uint8)'É', 0x90, (const uint8)'é', 0x82,
- (const uint8)'è', 0x8a, (const uint8)'ê', 0x88, (const uint8)'à', 0x85,
- (const uint8)'â', 0x83, (const uint8)'ô', 0x93, (const uint8)'Ç', 0x80,
- (const uint8)'ç', 0x87, (const uint8)'ë', 0x89, (const uint8)'å', 0x86,
- (const uint8)'ï', 0x8b, (const uint8)'î', 0x8c, (const uint8)'ì', 0x8d,
- (const uint8)'Å', 0x8f, (const uint8)'æ', 0x91, (const uint8)'Æ', 0x92,
- (const uint8)'ò', 0x95, (const uint8)'û', 0x96, (const uint8)'ù', 0x97,
- (const uint8)'á', 0xa0
-};
-
-const int LoLEngine::_fontConversionTableSize = ARRAYSIZE(LoLEngine::_fontConversionTable);
-
#endif // ENABLE_LOL
} // End of namespace Kyra
diff --git a/engines/kyra/util.cpp b/engines/kyra/util.cpp
index 794a1c78e3..fe02ba49ba 100644
--- a/engines/kyra/util.cpp
+++ b/engines/kyra/util.cpp
@@ -85,5 +85,68 @@ void Util::decodeString2(const char *src, char *dst) {
*dst = 0;
}
+void Util::convertDOSToISO(char *str) {
+ uint8 *s = (uint8 *)str;
+
+ for (; *s; ++s) {
+ if (*s >= 128) {
+ uint8 c = _charMapDOSToISO[*s - 128];
+
+ if (!c)
+ c = 0x20;
+
+ *s = c;
+ }
+ }
+}
+
+void Util::convertISOToDOS(char *str) {
+ while (*str)
+ convertISOToDOS(*str++);
+}
+
+void Util::convertISOToDOS(char &c) {
+ uint8 code = (uint8)c;
+ if (code >= 128) {
+ code = _charMapISOToDOS[code - 128];
+ if (!code)
+ code = 0x20;
+ }
+
+ c = code;
+}
+
+// CP850 to ISO-8859-1 (borrowed from engines/saga/font_map.cpp)
+const uint8 Util::_charMapDOSToISO[128] = {
+ 199, 252, 233, 226, 228, 224, 229, 231, 234, 235, 232,
+ 239, 238, 236, 196, 197, 201, 230, 198, 244, 246, 242,
+ 251, 249, 255, 214, 220, 248, 163, 216, 215, 0, 225,
+ 237, 243, 250, 241, 209, 170, 186, 191, 174, 172, 189,
+ 188, 161, 171, 187, 0, 0, 0, 0, 0, 193, 194,
+ 192, 169, 0, 0, 0, 0, 162, 165, 0, 0, 0,
+ 0, 0, 0, 0, 227, 195, 0, 0, 0, 0, 0,
+ 0, 0, 164, 240, 208, 202, 203, 200, 0, 205, 206,
+ 207, 0, 0, 0, 0, 166, 204, 0, 211, 223, 212,
+ 210, 245, 213, 181, 254, 222, 218, 219, 217, 253, 221,
+ 175, 180, 173, 177, 0, 190, 182, 167, 247, 184, 176,
+ 168, 183, 185, 179, 178, 0, 160
+};
+
+// ISO-8859-1 to CP850
+const uint8 Util::_charMapISOToDOS[128] = {
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255,
+ 173, 189, 156, 207, 190, 221, 245, 249, 184, 166, 174,
+ 170, 240, 169, 238, 248, 241, 253, 252, 239, 230, 244,
+ 250, 247, 251, 167, 175, 172, 171, 243, 168, 183, 181,
+ 182, 199, 142, 143, 146, 128, 212, 144, 210, 211, 222,
+ 214, 215, 216, 209, 165, 227, 224, 226, 229, 153, 158,
+ 157, 235, 233, 234, 154, 237, 232, 225, 133, 160, 131,
+ 198, 132, 134, 145, 135, 138, 130, 136, 137, 141, 161,
+ 140, 139, 208, 164, 149, 162, 147, 228, 148, 246, 155,
+ 151, 163, 150, 129, 236, 231, 152
+};
+
} // end of namespace Kyra
diff --git a/engines/kyra/util.h b/engines/kyra/util.h
index ee869d9c04..6850a4d757 100644
--- a/engines/kyra/util.h
+++ b/engines/kyra/util.h
@@ -34,6 +34,16 @@ class Util {
public:
static int decodeString1(const char *src, char *dst);
static void decodeString2(const char *src, char *dst);
+
+ // Since our current GUI font uses ISO-8859-1, this
+ // conversion functionallty uses that as a base.
+ static void convertDOSToISO(char *str);
+ static void convertISOToDOS(char *str);
+ static void convertISOToDOS(char &c);
+
+private:
+ static const uint8 _charMapDOSToISO[128];
+ static const uint8 _charMapISOToDOS[128];
};
} // end of namespace Kyra