diff --git a/engines/illusions/duckman/duckman_credits.cpp b/engines/illusions/duckman/duckman_credits.cpp index f6e7bee300..3a6f15a2fb 100644 --- a/engines/illusions/duckman/duckman_credits.cpp +++ b/engines/illusions/duckman/duckman_credits.cpp @@ -189,7 +189,9 @@ Common::Point DuckmanCredits::getItemPosition(int index) { void DuckmanCredits::charToWChar(char *text, uint16 *wtext, uint size) { while (*text != 0 && size > 1) { - *wtext++ = (byte)*text++; + WRITE_LE_UINT16(wtext, (byte)*text); + wtext++; + text++; --size; } *wtext++ = 0; diff --git a/engines/illusions/menusystem.cpp b/engines/illusions/menusystem.cpp index e4d230a167..afc458cf3e 100644 --- a/engines/illusions/menusystem.cpp +++ b/engines/illusions/menusystem.cpp @@ -443,7 +443,7 @@ uint BaseMenuSystem::drawMenuText(BaseMenu *menu) { if (!_vm->_screenText->insertText(text, menu->_fontId, dimensions, textPt, flags, menu->_backgroundColor, menu->_borderColor, 0xFF, 0xFF, 0xFF, outTextPtr)) { --lineCount; for ( ; *outTextPtr; ++outTextPtr) { - if (*outTextPtr == 13) + if (*outTextPtr == CONSTANT_LE_16(13)) --lineCount; } } @@ -606,16 +606,19 @@ MenuTextBuilder::MenuTextBuilder() : _pos(0) { void MenuTextBuilder::appendString(const Common::String &value) { for (uint i = 0; i < value.size(); ++i) { - _text[_pos++] = value[i]; + WRITE_LE_UINT16(&_text[_pos], value[i]); + _pos++; } } void MenuTextBuilder::appendNewLine() { - _text[_pos++] = '\r'; + WRITE_LE_UINT16(&_text[_pos], '\r'); + _pos++; } void MenuTextBuilder::finalize() { - _text[_pos] = '\0'; + WRITE_LE_UINT16(&_text[_pos], '\0'); + _pos++; } // BaseMenuAction diff --git a/engines/illusions/resources/fontresource.cpp b/engines/illusions/resources/fontresource.cpp index 8d11e92b48..15e29a9537 100644 --- a/engines/illusions/resources/fontresource.cpp +++ b/engines/illusions/resources/fontresource.cpp @@ -67,11 +67,11 @@ void CharRange::load(byte *dataStart, Common::SeekableReadStream &stream) { } CharInfo *CharRange::getCharInfo(uint16 c) { - return &_charInfos[c - _firstChar]; + return &_charInfos[TO_LE_16(c) - _firstChar]; } bool CharRange::containsChar(uint16 c) { - return c >= _firstChar && c <= _lastChar; + return c >= _firstChar && TO_LE_16(c) <= _lastChar; } // FontResource diff --git a/engines/illusions/resources/talkresource.cpp b/engines/illusions/resources/talkresource.cpp index 83ff98a9a7..9c9c525249 100644 --- a/engines/illusions/resources/talkresource.cpp +++ b/engines/illusions/resources/talkresource.cpp @@ -50,13 +50,6 @@ void TalkEntry::load(byte *dataStart, Common::SeekableReadStream &stream) { _voiceName = dataStart + voiceNameOffs; debug(0, "TalkEntry::load() _talkId: %08X; textOffs: %08X; tblOffs: %08X; voiceNameOffs: %08X", _talkId, textOffs, tblOffs, voiceNameOffs); - -#if defined(SCUMM_BIG_ENDIAN) - for (byte *ptr = (byte *)_text; ptr != _tblPtr; ptr += 2) { - WRITE_UINT16(ptr, SWAP_BYTES_16(READ_UINT16(ptr))); - } -#endif - } // TalkResource diff --git a/engines/illusions/textdrawer.cpp b/engines/illusions/textdrawer.cpp index f626316066..82bd19cdbb 100644 --- a/engines/illusions/textdrawer.cpp +++ b/engines/illusions/textdrawer.cpp @@ -84,7 +84,7 @@ bool TextDrawer::wrapTextIntern(int16 x, int16 y, int16 maxWidth, int16 maxHeigh bool lineBreak = false; bool done = false; - bool hasChar13 = textHasChar(13); + bool hasChar13 = textHasChar(CONSTANT_LE_16(13)); uint16 *lineStartText = _text; uint16 *currText = _text; @@ -104,7 +104,7 @@ bool TextDrawer::wrapTextIntern(int16 x, int16 y, int16 maxWidth, int16 maxHeigh currWordWidth += getCharWidth(*currText); ++currText; ++currWordLen; - } while (*currText != 32 && *(currText - 1) != 32 && !hasChar13 && *currText != 13 && *currText); + } while (*currText != CONSTANT_LE_16(32) && *(currText - 1) != CONSTANT_LE_16(32) && !hasChar13 && *currText != CONSTANT_LE_16(13) && *currText); if (currWordWidth - _font->_widthC > maxWidth) { while (currWordWidth + currLineWidth - _font->_widthC > maxWidth) { @@ -120,7 +120,7 @@ bool TextDrawer::wrapTextIntern(int16 x, int16 y, int16 maxWidth, int16 maxHeigh } else { currLineWidth += currWordWidth; currLineLen += currWordLen; - if (*currText == 0 || *currText == 13) + if (*currText == CONSTANT_LE_16(0) || *currText == CONSTANT_LE_16(13)) lineBreak = true; if (lineBreak) { currWordLen = 0; @@ -146,13 +146,13 @@ bool TextDrawer::wrapTextIntern(int16 x, int16 y, int16 maxWidth, int16 maxHeigh _textLines.push_back(TextLine(lineStartText, currLineLen, textPosX, textPosY)); - if (*currText == 13) { + if (*currText == CONSTANT_LE_16(13)) { ++currText; - if (*currText == 10) + if (*currText == CONSTANT_LE_16(10)) ++currText; - while (*currText == 13) { + while (*currText == CONSTANT_LE_16(13)) { ++currText; - if (*currText == 10) + if (*currText == CONSTANT_LE_16(10)) ++currText; _textLines.push_back(TextLine()); textPosY += _font->_lineIncr + _font->_charHeight; @@ -160,7 +160,7 @@ bool TextDrawer::wrapTextIntern(int16 x, int16 y, int16 maxWidth, int16 maxHeigh lineStartText = currText; } else { lineStartText = currText - currWordLen; - if (*lineStartText == 32) { + if (*lineStartText == CONSTANT_LE_16(32)) { ++lineStartText; --currWordLen; currWordWidth -= spaceWidth; @@ -205,7 +205,7 @@ bool TextDrawer::textHasChar(uint16 c) { } int16 TextDrawer::getSpaceWidth() { - return getCharWidth(32); + return getCharWidth(CONSTANT_LE_16(32)); } int16 TextDrawer::getCharWidth(uint16 c) {