aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorathrxx2012-12-30 00:14:38 +0100
committerathrxx2013-01-09 20:29:20 +0100
commitee479f289f7b94c124caf40cdebe02540bc45f56 (patch)
treea73d9f7b0a9e269a76514c6e144383bd9a3159c1
parent0b38615a431582f499f28da3b038f12e0c216c56 (diff)
downloadscummvm-rg350-ee479f289f7b94c124caf40cdebe02540bc45f56.tar.gz
scummvm-rg350-ee479f289f7b94c124caf40cdebe02540bc45f56.tar.bz2
scummvm-rg350-ee479f289f7b94c124caf40cdebe02540bc45f56.zip
KYRA: (LOL/FM-TOWNS) - adapt text displayer
-rw-r--r--engines/kyra/text_lol.cpp13
-rw-r--r--engines/kyra/text_rpg.cpp137
-rw-r--r--engines/kyra/text_rpg.h2
3 files changed, 104 insertions, 48 deletions
diff --git a/engines/kyra/text_lol.cpp b/engines/kyra/text_lol.cpp
index 9aad10529d..6e77db1f8a 100644
--- a/engines/kyra/text_lol.cpp
+++ b/engines/kyra/text_lol.cpp
@@ -136,18 +136,16 @@ void TextDisplayer_LoL::expandField() {
void TextDisplayer_LoL::printDialogueText(int dim, char *str, EMCState *script, const uint16 *paramList, int16 paramIndex) {
int oldDim = 0;
- const bool isPc98 = (_vm->gameFlags().platform == Common::kPlatformPC98);
-
if (dim == 3) {
if (_vm->_updateFlags & 2) {
oldDim = clearDim(4);
- _textDimData[4].color1 = isPc98 ? 0x33 : 254;
+ _textDimData[4].color1 = _vm->gameFlags().use16ColorMode ? 0x33 : 254;
_textDimData[4].color2 = _screen->_curDim->unkA;
} else {
oldDim = clearDim(3);
- _textDimData[3].color1 = isPc98 ? 0x33 : 192;
+ _textDimData[3].color1 = _vm->gameFlags().use16ColorMode ? 0x33 : 192;
_textDimData[3].color2 = _screen->_curDim->unkA;
- if (!isPc98)
+ if (!_vm->gameFlags().use16ColorMode)
_screen->copyColor(192, 254);
_vm->enableTimer(11);
_vm->_textColorFlag = 0;
@@ -157,7 +155,7 @@ void TextDisplayer_LoL::printDialogueText(int dim, char *str, EMCState *script,
oldDim = _screen->curDimIndex();
_screen->setScreenDim(dim);
_lineCount = 0;
- _textDimData[dim].color1 = isPc98 ? 0x33 : 254;
+ _textDimData[dim].color1 = _vm->gameFlags().use16ColorMode ? 0x33 : 254;
_textDimData[dim].color2 = _screen->_curDim->unkA;
}
@@ -228,10 +226,9 @@ void TextDisplayer_LoL::printMessage(uint16 type, const char *str, ...) {
void TextDisplayer_LoL::preprocessString(char *str, EMCState *script, const uint16 *paramList, int16 paramIndex) {
char *dst = _dialogueBuffer;
- const bool isPc98 = (_vm->gameFlags().platform == Common::kPlatformPC98);
for (char *s = str; *s;) {
- if (isPc98) {
+ if (_vm->gameFlags().lang == Common::JA_JPN) {
uint8 c = *s;
if (c >= 0xE0 || (c > 0x80 && c < 0xA0)) {
*dst++ = *s++;
diff --git a/engines/kyra/text_rpg.cpp b/engines/kyra/text_rpg.cpp
index f9861cfb77..b6b09e9225 100644
--- a/engines/kyra/text_rpg.cpp
+++ b/engines/kyra/text_rpg.cpp
@@ -36,7 +36,7 @@ enum {
TextDisplayer_rpg::TextDisplayer_rpg(KyraRpgEngine *engine, Screen *scr) : _vm(engine), _screen(scr),
_lineCount(0), _printFlag(false), _lineWidth(0), _numCharsTotal(0), _allowPageBreak(true),
- _numCharsLeft(0), _numCharsPrinted(0), _sjisLineBreakFlag(false), _waitButtonMode(1) {
+ _numCharsLeft(0), _numCharsPrinted(0), _sjisTextModeLineBreak(false), _waitButtonMode(1) {
_dialogueBuffer = new char[kEoBTextBufferSize];
memset(_dialogueBuffer, 0, kEoBTextBufferSize);
@@ -102,8 +102,6 @@ void TextDisplayer_rpg::removePageBreakFlag() {
}
void TextDisplayer_rpg::displayText(char *str, ...) {
- const bool isPc98 = (_vm->gameFlags().platform == Common::kPlatformPC98);
-
_printFlag = false;
_lineWidth = 0;
@@ -125,7 +123,9 @@ void TextDisplayer_rpg::displayText(char *str, ...) {
const ScreenDim *sd = _screen->_curDim;
int sdx = _screen->curDimIndex();
- bool pc98PrintFlag = (isPc98 && (sdx == 3 || sdx == 4 || sdx == 5 || sdx == 15)) ? true : false;
+ bool sjisTextMode = (_vm->gameFlags().lang == Common::JA_JPN && _vm->gameFlags().use16ColorMode && (sdx == 3 || sdx == 4 || sdx == 5 || sdx == 15)) ? true : false;
+ int sjisOffs = sjisTextMode ? 8 : 9;
+
uint16 charsPerLine = (sd->w << 3) / (_screen->getFontWidth() + _screen->_charWidth);
while (c) {
@@ -146,15 +146,25 @@ void TextDisplayer_rpg::displayText(char *str, ...) {
c = parseCommand();
}
- if (isPc98) {
+ if (_vm->gameFlags().lang == Common::JA_JPN) {
uint8 cu = (uint8) c;
if (cu >= 0xE0 || (cu > 0x80 && cu < 0xA0)) {
- _currentLine[_numCharsLeft++] = c;
- _currentLine[_numCharsLeft++] = parseCommand();
- _currentLine[_numCharsLeft] = '\0';
- _lineWidth += 8;
- if ((_textDimData[sdx].column + _lineWidth) > (sd->w << 3))
+ if (sjisTextMode) {
+ _currentLine[_numCharsLeft++] = c;
+ _currentLine[_numCharsLeft++] = parseCommand();
+ _currentLine[_numCharsLeft] = '\0';
+ }
+
+ if ((_textDimData[sdx].column + _lineWidth + sjisOffs) > (sd->w << 3))
printLine(_currentLine);
+
+ if (!sjisTextMode) {
+ _currentLine[_numCharsLeft++] = c;
+ _currentLine[_numCharsLeft++] = parseCommand();
+ _currentLine[_numCharsLeft] = '\0';
+ }
+
+ _lineWidth += sjisOffs;
c = parseCommand();
continue;
}
@@ -189,10 +199,10 @@ void TextDisplayer_rpg::displayText(char *str, ...) {
break;
case 12:
- if (isPc98)
- _sjisLineBreakFlag = true;
+ if (sjisTextMode)
+ _sjisTextModeLineBreak = true;
printLine(_currentLine);
- _sjisLineBreakFlag = false;
+ _sjisTextModeLineBreak = false;
_lineCount++;
_textDimData[sdx].column = 0;
_textDimData[sdx].line++;
@@ -208,7 +218,7 @@ void TextDisplayer_rpg::displayText(char *str, ...) {
default:
if (_vm->game() == GI_LOL || (unsigned char)c > 30) {
- _lineWidth += (pc98PrintFlag ? 4 : _screen->getCharWidth((uint8)c));
+ _lineWidth += (sjisTextMode ? 4 : (_screen->_currentFont == Screen::FID_SJIS_FNT ? 9 : _screen->getCharWidth((uint8)c)));
_currentLine[_numCharsLeft++] = c;
_currentLine[_numCharsLeft] = 0;
@@ -280,10 +290,9 @@ void TextDisplayer_rpg::readNextPara() {
}
void TextDisplayer_rpg::printLine(char *str) {
- const bool isPc98 = (_vm->gameFlags().platform == Common::kPlatformPC98);
const ScreenDim *sd = _screen->_curDim;
int sdx = _screen->curDimIndex();
- bool pc98PrintFlag = (isPc98 && (sdx == 3 || sdx == 4 || sdx == 5 || sdx == 15)) ? true : false;
+ bool sjisTextMode = (_vm->gameFlags().lang == Common::JA_JPN && _vm->gameFlags().use16ColorMode && (sdx == 3 || sdx == 4 || sdx == 5 || sdx == 15)) ? true : false;
int fh = (_screen->_currentFont == Screen::FID_SJIS_FNT) ? 9 : (_screen->getFontHeight() + _screen->_charOffset);
int lines = (sd->h - _screen->_charOffset) / fh;
@@ -307,13 +316,15 @@ void TextDisplayer_rpg::printLine(char *str) {
}
int x1 = (sd->sx << 3) + _textDimData[sdx].column;
- int y = sd->sy + (pc98PrintFlag ? (_textDimData[sdx].line << 3) : (fh * _textDimData[sdx].line));
+ int y = sd->sy + (sjisTextMode ? (_textDimData[sdx].line << 3) : (fh * _textDimData[sdx].line));
int w = sd->w << 3;
int lw = _lineWidth;
int s = _numCharsLeft;
char c = 0;
+ uint8 twoByteCharOffs = 0;
- if (pc98PrintFlag) {
+
+ if (sjisTextMode) {
bool ct = true;
if ((lw + _textDimData[sdx].column) > w) {
@@ -321,7 +332,7 @@ void TextDisplayer_rpg::printLine(char *str) {
// cut off line to leave space for "MORE" button
w -= _vm->guiSettings()->buttons.waitReserve;
} else {
- if (!_sjisLineBreakFlag || (_lineCount + 1 < lines - 1))
+ if (!_sjisTextModeLineBreak || (_lineCount + 1 < lines - 1))
ct = false;
else
// cut off line to leave space for "MORE" button
@@ -344,41 +355,88 @@ void TextDisplayer_rpg::printLine(char *str) {
s = n2;
}
} else {
- if ((lw + _textDimData[sdx].column) > w) {
+ if (_vm->gameFlags().lang == Common::JA_JPN) {
+ for (int i = 0; i < s; ++i) {
+ uint8 cu = (uint8) str[i];
+ if (cu >= 0xE0 || (cu > 0x80 && cu < 0xA0))
+ twoByteCharOffs = 8;
+ }
+ }
+
+ if ((lw + _textDimData[sdx].column) >= w) {
if ((lines - 1) <= _lineCount && _allowPageBreak)
// cut off line to leave space for "MORE" button
w -= _vm->guiSettings()->buttons.waitReserve;
w -= _textDimData[sdx].column;
- int n2 = 0;
- int n1 = s - 1;
+ int lineLastCharPos = 0;
+ int strPos = s - 1;
+
+ if (twoByteCharOffs) {
+ lw = 0;
+ int prevStrPos = 0;
+ c = str[0];
+
+ for (strPos = 0; strPos < s; ++strPos) {
+ uint8 cu = (uint8) str[strPos];
+ if (cu >= 0xE0 || (cu > 0x80 && cu < 0xA0)) {
+ lw += 9;
+ strPos++;
+ } else {
+ lw += _screen->getCharWidth((uint8)c);
+ }
+
+ if (!lineLastCharPos && w < lw + twoByteCharOffs)
+ lineLastCharPos = prevStrPos;
+
+ if (lineLastCharPos && c == ' ') {
+ s = strPos;
+ _printFlag = false;
+ break;
+ }
+ prevStrPos = strPos;
+ c = (char) cu;
+ }
- while (n1 > 0) {
- //cut off line after last space
- c = str[n1];
+ if (!lineLastCharPos) {
+ lineLastCharPos = s - 1;
+ if (lineLastCharPos && str[lineLastCharPos] == ' ') {
+ s = strPos;
+ _printFlag = false;
+ }
+ }
- lw -= _screen->getCharWidth((uint8)c);
+ lw = _lineWidth;
- if (!n2 && lw <= w)
- n2 = n1;
+ } else {
+ while (strPos > 0) {
+ //cut off line after last space
+ c = str[strPos];
- if (n2 && c == ' ') {
- s = n1;
- _printFlag = false;
- break;
+ lw -= _screen->getCharWidth((uint8)c);
+
+ if (!lineLastCharPos && lw <= w)
+ lineLastCharPos = strPos;
+
+ if (lineLastCharPos && c == ' ') {
+ s = strPos;
+ _printFlag = false;
+ break;
+ }
+ strPos--;
}
- n1--;
}
-
- if (!n1) {
+
+ if (!strPos) {
if (_textDimData[sdx].column && !_printFlag) {
s = lw = 0;
_printFlag = true;
} else {
- s = n2;
+ s = lineLastCharPos;
}
}
+
}
}
@@ -386,7 +444,7 @@ void TextDisplayer_rpg::printLine(char *str) {
str[s] = 0;
uint8 col = _textDimData[sdx].color1;
- if (isPc98 && (sdx == 2 || sdx == 3 || sdx == 4 || sdx == 5 || sdx == 15)) {
+ if (sjisTextMode && (sdx == 2 || sdx == 3 || sdx == 4 || sdx == 5 || sdx == 15)) {
switch (_textDimData[sdx].color1) {
case 0x88:
col = 0x41;
@@ -413,6 +471,7 @@ void TextDisplayer_rpg::printLine(char *str) {
_screen->printText(str, x1 & ~3, (y + 8) & ~7, col, 0);
} else {
_screen->printText(str, x1, y, col, _textDimData[sdx].color2);
+ _screen->updateScreen();
}
_textDimData[sdx].column += lw;
@@ -432,9 +491,9 @@ void TextDisplayer_rpg::printLine(char *str) {
str[len] = 0;
_numCharsLeft = strlen(str);
- _lineWidth = pc98PrintFlag ? (_numCharsLeft << 2) : _screen->getTextWidth(str);
+ _lineWidth = sjisTextMode ? (_numCharsLeft << 2) : (_screen->_currentFont == Screen::FID_SJIS_FNT ? _numCharsLeft * 9: _screen->getTextWidth(str));
- if (!_numCharsLeft && _textDimData[sdx].column < (sd->w << 3))
+ if (!_numCharsLeft && (_textDimData[sdx].column + twoByteCharOffs) <= (sd->w << 3))
return;
_textDimData[sdx].column = 0;
diff --git a/engines/kyra/text_rpg.h b/engines/kyra/text_rpg.h
index 5ad8899484..eb8617a371 100644
--- a/engines/kyra/text_rpg.h
+++ b/engines/kyra/text_rpg.h
@@ -79,7 +79,7 @@ protected:
uint32 _numCharsPrinted;
bool _printFlag;
- bool _sjisLineBreakFlag;
+ bool _sjisTextModeLineBreak;
char _pageBreakString[20];
char _scriptParaString[11];