diff options
author | Walter van Niftrik | 2010-04-19 00:13:01 +0000 |
---|---|---|
committer | Walter van Niftrik | 2010-04-19 00:13:01 +0000 |
commit | fa846bfebc4e79158b86739067cabc5d5de85b7d (patch) | |
tree | dcd40e71f3f26cb73c526db8f707fce743e9102b | |
parent | 96b71b37456bc3aa21a2f98b35abde883e2e9527 (diff) | |
download | scummvm-rg350-fa846bfebc4e79158b86739067cabc5d5de85b7d.tar.gz scummvm-rg350-fa846bfebc4e79158b86739067cabc5d5de85b7d.tar.bz2 scummvm-rg350-fa846bfebc4e79158b86739067cabc5d5de85b7d.zip |
SCI: For Japanese system-font strings, convert half-width characters to
full-width characters.
svn-id: r48707
-rw-r--r-- | engines/sci/engine/state.cpp | 65 |
1 files changed, 62 insertions, 3 deletions
diff --git a/engines/sci/engine/state.cpp b/engines/sci/engine/state.cpp index ea33b0e668..a8093e0224 100644 --- a/engines/sci/engine/state.cpp +++ b/engines/sci/engine/state.cpp @@ -37,6 +37,38 @@ namespace Sci { +// Maps half-width single-byte SJIS to full-width double-byte SJIS +// Note: SSCI maps 0x5C (the Yen symbol) to 0x005C, which terminates +// the string with the leading 0x00 byte. We map Yen to 0x818F. +static const uint16 s_halfWidthSJISMap[256] = { + 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, 0x81A8, 0x81A9, 0x81AA, 0x81AB, + 0x8140, 0x8149, 0x818D, 0x8194, 0x8190, 0x8193, 0x8195, 0x818C, + 0x8169, 0x816A, 0x8196, 0x817B, 0x8143, 0x817C, 0x8144, 0x815E, + 0x824F, 0x8250, 0x8251, 0x8252, 0x8253, 0x8254, 0x8255, 0x8256, + 0x8257, 0x8258, 0x8146, 0x8147, 0x8183, 0x8181, 0x8184, 0x8148, + 0x8197, 0x8260, 0x8261, 0x8262, 0x8263, 0x8264, 0x8265, 0x8266, + 0x8267, 0x8268, 0x8269, 0x826A, 0x826B, 0x826C, 0x826D, 0x826E, + 0x826F, 0x8270, 0x8271, 0x8272, 0x8273, 0x8274, 0x8275, 0x8276, + 0x8277, 0x8278, 0x8279, 0x816D, 0x818F /* 0x005C */, 0x816E, 0x814F, 0x8151, + 0x8280, 0x8281, 0x8282, 0x8283, 0x8284, 0x8285, 0x8286, 0x8287, + 0x8288, 0x8289, 0x828A, 0x828B, 0x828C, 0x828D, 0x828E, 0x828F, + 0x8290, 0x8291, 0x8292, 0x8293, 0x8294, 0x8295, 0x8296, 0x8297, + 0x8298, 0x8299, 0x829A, 0x816F, 0x8162, 0x8170, 0x8160, 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, 0, + 0x8140, 0x8142, 0x8175, 0x8176, 0x8141, 0x8145, 0x8392, 0x8340, + 0x8342, 0x8344, 0x8346, 0x8348, 0x8383, 0x8385, 0x8387, 0x8362, + 0x815C, 0x8341, 0x8343, 0x8345, 0x8347, 0x8349, 0x834A, 0x834C, + 0x834E, 0x8350, 0x8352, 0x8354, 0x8356, 0x8358, 0x835A, 0x835C, + 0x835E, 0x8360, 0x8363, 0x8365, 0x8367, 0x8369, 0x836A, 0x836B, + 0x836C, 0x836D, 0x836E, 0x8371, 0x8374, 0x8377, 0x837A, 0x837D, + 0x837E, 0x8380, 0x8381, 0x8382, 0x8384, 0x8386, 0x8388, 0x8389, + 0x838A, 0x838B, 0x838C, 0x838D, 0x838F, 0x8393, 0x814A, 0x814B, + 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 +}; + EngineState::EngineState(Vocabulary *voc, SegManager *segMan) : _voc(voc), _segMan(segMan), _dirseeker() { @@ -136,15 +168,42 @@ Common::String SciEngine::getSciLanguageString(const char *str, kLanguage lang, break; } - seeker++; + ++seeker; } // Return the secondary language found in the string if (lang2) *lang2 = secondLang; - if (secondLang == lang) - return Common::String(seeker + 2); + if (secondLang == lang) { + if (*(++seeker) == 'J') { + // Japanese including Kanji, displayed with system font + // Convert half-width characters to full-width equivalents + Common::String fullWidth; + byte c; + + while ((c = *(++seeker))) { + uint16 mappedChar = s_halfWidthSJISMap[c]; + if (mappedChar) { + fullWidth += mappedChar >> 8; + fullWidth += mappedChar & 0xFF; + } else { + // Copy double-byte character + char c2 = *(++seeker); + if (!c2) { + warning("SJIS character %02X is missing second byte", c); + break; + } + fullWidth += c; + fullWidth += c2; + } + } + + return fullWidth; + } else { + return Common::String(seeker + 1); + } + } if (seeker) return Common::String(str, seeker - str); |