From 8ffd8793ed1f50872c572c6886a5e9100e8312e4 Mon Sep 17 00:00:00 2001 From: Martin Kiewitz Date: Sun, 2 Nov 2014 15:44:22 +0100 Subject: SCI: add support for \n and \r in Japanese text fixes Police Quest 2 Japanese intro thx to wjp for helping --- engines/sci/engine/state.cpp | 45 +++++++++++++++++++++++++++++++++++--------- 1 file changed, 36 insertions(+), 9 deletions(-) (limited to 'engines/sci') 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); } -- cgit v1.2.3