diff options
author | Martin Kiewitz | 2014-11-02 15:44:22 +0100 |
---|---|---|
committer | Martin Kiewitz | 2014-11-02 15:44:22 +0100 |
commit | 8ffd8793ed1f50872c572c6886a5e9100e8312e4 (patch) | |
tree | f41282cf5e0b058d895ad0e4952913602b1eecef | |
parent | 5aae18feb80ff7aa58ce6f7400d54673af58196b (diff) | |
download | scummvm-rg350-8ffd8793ed1f50872c572c6886a5e9100e8312e4.tar.gz scummvm-rg350-8ffd8793ed1f50872c572c6886a5e9100e8312e4.tar.bz2 scummvm-rg350-8ffd8793ed1f50872c572c6886a5e9100e8312e4.zip |
SCI: add support for \n and \r in Japanese text
fixes Police Quest 2 Japanese intro
thx to wjp for helping
-rw-r--r-- | engines/sci/engine/state.cpp | 45 |
1 files changed, 36 insertions, 9 deletions
diff --git a/engines/sci/engine/state.cpp b/engines/sci/engine/state.cpp index 7701822f6d..1b7fa7699e 100644 --- a/engines/sci/engine/state.cpp +++ b/engines/sci/engine/state.cpp @@ -227,26 +227,53 @@ Common::String SciEngine::getSciLanguageString(const Common::String &str, kLangu // Japanese including Kanji, displayed with system font // Convert half-width characters to full-width equivalents Common::String fullWidth; - byte c; + byte curChar, curChar2; + uint16 mappedChar; + + seeker++; + + while (1) { + curChar = *(seeker); + + switch (curChar) { + case 0: // Terminator NUL + return fullWidth; + case '\\': + // "\n", "\N", "\r" and "\R" were overwritten with SPACE + 0x0D in PC-9801 SSCI + // inside GetLongest() (text16). We do it here, because it's much cleaner and + // we have to process the text here anyway. + // Occurs for example in Police Quest 2 intro + curChar2 = *(seeker + 1); + switch (curChar2) { + case 'n': + case 'N': + case 'r': + case 'R': + fullWidth += ' '; + fullWidth += 0x0D; // CR + seeker += 2; + continue; + } + } + + seeker++; - while ((c = *(++seeker))) { - uint16 mappedChar = s_halfWidthSJISMap[c]; + mappedChar = s_halfWidthSJISMap[curChar]; if (mappedChar) { fullWidth += mappedChar >> 8; fullWidth += mappedChar & 0xFF; } else { // Copy double-byte character - char c2 = *(++seeker); - if (!c2) { - error("SJIS character %02X is missing second byte", c); + curChar2 = *(seeker++); + if (!curChar) { + error("SJIS character %02X is missing second byte", curChar); break; } - fullWidth += c; - fullWidth += c2; + fullWidth += curChar; + fullWidth += curChar2; } } - return fullWidth; } else { return Common::String(seeker + 1); } |