Skip to content

Commit

Permalink
ADL: Fix word wrapping when last line is full
Browse files Browse the repository at this point in the history
  • Loading branch information
waltervn committed Jan 27, 2017
1 parent 280bcb9 commit 5a79b99
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions engines/adl/adl_v2.cpp
Expand Up @@ -183,30 +183,29 @@ Common::String AdlEngine_v2::loadMessage(uint idx) const {
void AdlEngine_v2::printString(const Common::String &str) {
Common::String s(str);
uint endPos = TEXT_WIDTH - 1;
uint startPos = 0;
uint pos = 0;

while (true) {
while (pos <= endPos && pos != s.size()) {
s.setChar(APPLECHAR(s[pos]), pos);
++pos;
}
while (pos < s.size()) {
s.setChar(APPLECHAR(s[pos]), pos);

if (pos == s.size())
break;
if (pos == endPos) {
while (s[pos] != APPLECHAR(' ') && s[pos] != APPLECHAR('\r')) {
if (pos-- == startPos)
error("Word wrapping failed");
}

while (s[pos] != APPLECHAR(' ') && s[pos] != APPLECHAR('\r'))
--pos;
s.setChar(APPLECHAR('\r'), pos);
endPos = pos + TEXT_WIDTH;
startPos = pos + 1;
}

s.setChar(APPLECHAR('\r'), pos);
endPos = pos + TEXT_WIDTH;
++pos;
}

pos = 0;
while (pos != s.size()) {
for (pos = 0; pos < s.size(); ++pos) {
checkTextOverflow(s[pos]);
_display->printChar(s[pos]);
++pos;
}

checkTextOverflow(APPLECHAR('\r'));
Expand Down

0 comments on commit 5a79b99

Please sign in to comment.