mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-05 09:10:29 +00:00
SCUMM: in-place verb strings reversal
This commit is contained in:
parent
80218a5203
commit
0625518e9f
File diff suppressed because it is too large
Load Diff
@ -248,10 +248,8 @@ void ScummEngine_v7::addSubtitleToQueue(const byte *text, const Common::Point &p
|
||||
assert(_subtitleQueuePos < ARRAYSIZE(_subtitleQueue));
|
||||
SubtitleText *st = &_subtitleQueue[_subtitleQueuePos];
|
||||
int i = 0;
|
||||
|
||||
// int len = strlen((const char *)text);
|
||||
while (1) {
|
||||
st->text[i] = text[i]; // text[len - i - 1];
|
||||
st->text[i] = text[i];
|
||||
if (!text[i])
|
||||
break;
|
||||
++i;
|
||||
@ -609,6 +607,7 @@ void ScummEngine::CHARSET_1() {
|
||||
|
||||
_charset->addLinebreaks(0, _charsetBuffer + _charsetBufPos, 0, maxwidth);
|
||||
}
|
||||
|
||||
if (_charset->_center) {
|
||||
_nextLeft -= _charset->getStringWidth(0, _charsetBuffer + _charsetBufPos) / 2;
|
||||
if (_nextLeft < 0)
|
||||
@ -637,21 +636,10 @@ void ScummEngine::CHARSET_1() {
|
||||
int start = 0;
|
||||
char* text = ltext + ll;
|
||||
|
||||
|
||||
|
||||
// for (int u = 0; u < strlen(text); u++) {
|
||||
// char buffy[30] = {0};
|
||||
// sprintf(buffy, "[%d-%c],", text[u], text[u]);
|
||||
// debugN(buffy);
|
||||
// }
|
||||
// debugN("\n");
|
||||
|
||||
|
||||
char* current = text;
|
||||
while(1) {
|
||||
if (*current == 13 || *current == 0 || *current == -1 || *current == -2) {
|
||||
|
||||
// ignore the line break for interface texts
|
||||
// ignore the line break for verbs texts
|
||||
if (*(current + 1) == 8) {
|
||||
*(current + 1) = *current;
|
||||
*current = 8;
|
||||
@ -690,9 +678,8 @@ void ScummEngine::CHARSET_1() {
|
||||
if (*current == 3) {
|
||||
break;
|
||||
}
|
||||
if (*current == 0x0A) {
|
||||
if (*current == 0x0A || *current == 0x0C) {
|
||||
start += 2;
|
||||
i +=2;
|
||||
current += 2;
|
||||
}
|
||||
start++;
|
||||
@ -708,17 +695,6 @@ void ScummEngine::CHARSET_1() {
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
// warning("REVERSED");
|
||||
// for (int u = 0; u < strlen(text); u++) {
|
||||
// char buffy[30] = {0};
|
||||
// sprintf(buffy, "[%d-%c],", text[u], text[u]);
|
||||
// debugN(buffy);
|
||||
// }
|
||||
// debugN("\n\n\n\n\n");
|
||||
|
||||
|
||||
}
|
||||
|
||||
while (handleNextCharsetCode(a, &c)) {
|
||||
@ -752,7 +728,6 @@ void ScummEngine::CHARSET_1() {
|
||||
break; // FIXME: Is this necessary? Only would be relevant for v0 games
|
||||
}
|
||||
|
||||
// warning("SETTING");
|
||||
_charset->_left = _nextLeft;
|
||||
_charset->_top = _nextTop;
|
||||
|
||||
@ -791,7 +766,6 @@ void ScummEngine::CHARSET_1() {
|
||||
_charset->printChar(c, false);
|
||||
}
|
||||
}
|
||||
// warning("RESETING");
|
||||
_nextLeft = _charset->_left;
|
||||
_nextTop = _charset->_top;
|
||||
}
|
||||
@ -1001,14 +975,9 @@ void ScummEngine::drawString(int a, const byte *msg) {
|
||||
while (ltext[ll] == -1) {
|
||||
ll += 4;
|
||||
}
|
||||
byte fin[270] = {0};
|
||||
|
||||
memcpy(fin, ltext, ll);
|
||||
int pos = 0;
|
||||
int start = 0;
|
||||
char* text = (char*)ltext + ll;
|
||||
|
||||
strncpy((char*)fin + ll, text, strlen(text));
|
||||
char* current = text;
|
||||
while(1) {
|
||||
if (*current == 13 || *current == 0 || *current == -1 || *current == -2) {
|
||||
@ -1032,7 +1001,7 @@ void ScummEngine::drawString(int a, const byte *msg) {
|
||||
buff[pos - sthead] = stack[sthead];
|
||||
--sthead;
|
||||
}
|
||||
memcpy(fin + ll + start, buff, pos);
|
||||
memcpy(text + start, buff, pos);
|
||||
start += pos + 1;
|
||||
pos = -1;
|
||||
if (*current == -1 || *current == -2) {
|
||||
@ -1040,9 +1009,8 @@ void ScummEngine::drawString(int a, const byte *msg) {
|
||||
if (*current == 3) {
|
||||
break;
|
||||
}
|
||||
if (*current == 0x0A) {
|
||||
if (*current == 0x0A || *current == 0x0C) {
|
||||
start += 2;
|
||||
pos +=2;
|
||||
current += 2;
|
||||
}
|
||||
start++;
|
||||
@ -1058,7 +1026,6 @@ void ScummEngine::drawString(int a, const byte *msg) {
|
||||
}
|
||||
break;
|
||||
}
|
||||
memcpy(buf, fin, start + pos + ll);
|
||||
|
||||
if (_game.id == GID_INDY4 && ltext[0] == 127) {
|
||||
buf[start + pos + ll] = 127;
|
||||
@ -1067,7 +1034,6 @@ void ScummEngine::drawString(int a, const byte *msg) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
_charset->_top = _string[a].ypos + _screenTop;
|
||||
_charset->_startLeft = _charset->_left = _string[a].xpos;
|
||||
_charset->_right = _string[a].right;
|
||||
@ -1128,7 +1094,6 @@ void ScummEngine::drawString(int a, const byte *msg) {
|
||||
if (_charset->_center) {
|
||||
_charset->_left -= _charset->getStringWidth(a, buf) / 2;
|
||||
} else if (_game.version >= 4 && _game.version < 7 && _game.id != GID_SAMNMAX && (_language == Common::HE_ISR || true)) {
|
||||
// warning("FIRST BOTTTOMd");
|
||||
if (_game.id != GID_INDY4 || buf[0] == 127) {
|
||||
if (_game.id == GID_INDY4 && buf[0] == 127) {
|
||||
buf[0] = 32;
|
||||
@ -1198,7 +1163,6 @@ void ScummEngine::drawString(int a, const byte *msg) {
|
||||
if (_charset->_center) {
|
||||
_charset->_left = _charset->_startLeft - _charset->getStringWidth(a, buf + i);
|
||||
} else if (_game.version >= 4 && _game.version < 7 && (_language == Common::HE_ISR || true)) {
|
||||
// warning("SECOND BOTTOM");
|
||||
if (_charset->getStringWidth(a, buf + i) > _screenWidth) {
|
||||
int ll = 0;
|
||||
byte* ltext = buf + i;
|
||||
@ -1493,20 +1457,7 @@ int ScummEngine::convertNameMessage(byte *dst, int dstSize, int var) {
|
||||
if (num) {
|
||||
const byte *ptr = getObjOrActorName(num);
|
||||
if (ptr) {
|
||||
int retval = convertMessageToString(ptr, dst, dstSize);
|
||||
|
||||
// if (_game.version >= 7 && (_language == Common::HE_ISR || true)) {
|
||||
// byte rev[384] = {0};
|
||||
// int lens = strlen((const char *)dst);
|
||||
|
||||
// for (int l = 0; l < lens; l++) {
|
||||
// rev[l] = dst[lens - l - 1];
|
||||
// }
|
||||
// rev[lens] = '\0';
|
||||
// strcpy((char *)dst, (const char *)rev);
|
||||
// }
|
||||
|
||||
return retval;
|
||||
return convertMessageToString(ptr, dst, dstSize);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
@ -1534,19 +1485,7 @@ int ScummEngine::convertStringMessage(byte *dst, int dstSize, int var) {
|
||||
if (var) {
|
||||
ptr = getStringAddress(var);
|
||||
if (ptr) {
|
||||
int retval = convertMessageToString(ptr, dst, dstSize);
|
||||
|
||||
// if (_game.version >= 7 && (_language == Common::HE_ISR || true)) {
|
||||
// byte rev[384] = {0};
|
||||
// int lens = strlen((const char *)dst);
|
||||
|
||||
// for (int l = 0; l < lens; l++) {
|
||||
// rev[l] = dst[lens - l - 1];
|
||||
// }
|
||||
// rev[lens] = '\0';
|
||||
// strcpy((char *)dst, (const char *)rev);
|
||||
// }
|
||||
return retval;
|
||||
return convertMessageToString(ptr, dst, dstSize);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
@ -1846,16 +1785,6 @@ void ScummEngine_v7::translateText(const byte *text, byte *trans_buff) {
|
||||
}
|
||||
|
||||
if (found != NULL) {
|
||||
//char rev[384] = {0};
|
||||
//strcpy(rev, _languageBuffer + found->offset);
|
||||
//int len = strlen(rev);
|
||||
//for (int l = 0; l < len; l++) {
|
||||
// trans_buff[l] = rev[len - l - 1];
|
||||
//}
|
||||
//trans_buff[len] = '\0';
|
||||
|
||||
// OR
|
||||
|
||||
strcpy((char *)trans_buff, _languageBuffer + found->offset);
|
||||
|
||||
if ((_game.id == GID_DIG) && !(_game.features & GF_DEMO)) {
|
||||
@ -1892,4 +1821,4 @@ void ScummEngine::translateText(const byte *text, byte *trans_buff) {
|
||||
memcpy(trans_buff, text, resStrLen(text) + 1);
|
||||
}
|
||||
|
||||
} // End of namespace Scumm
|
||||
} // End of namespace Scumm
|
@ -1002,8 +1002,6 @@ void ScummEngine_v7::drawVerb(int verb, int mode) {
|
||||
// occur in FT; subtype 10, which is used for the speech associated
|
||||
// with the string).
|
||||
byte buf[384] = {0};
|
||||
// byte rev[384] = {0};
|
||||
|
||||
convertMessageToString(msg, buf, sizeof(buf));
|
||||
msg = buf;
|
||||
while (*msg == 0xFF)
|
||||
@ -1013,23 +1011,6 @@ void ScummEngine_v7::drawVerb(int verb, int mode) {
|
||||
int oldID = _charset->getCurID();
|
||||
_charset->setCurID(vs->charset_nr);
|
||||
|
||||
// // reverse string for rtl support
|
||||
// if ((_language == Common::HE_ISR || true)/* && !(_game.id == GID_FT && (_charset->getCurID() == 6 || _charset->getCurID() == 7))*/) {
|
||||
|
||||
// int lens = strlen((const char *)msg);
|
||||
|
||||
// for (int l = 0; l < lens; l++) {
|
||||
// rev[l] = msg[lens - l - 1];
|
||||
// }
|
||||
// rev[lens] = '\0';
|
||||
// msg = rev;
|
||||
// }
|
||||
|
||||
// char numt[10] ={0};
|
||||
// sprintf(numt, "%d, %d\n", _charset->getCurID(), oldID);
|
||||
// warning(numt);
|
||||
|
||||
|
||||
// Compute the text rect
|
||||
if ((_language == Common::HE_ISR || true)/* && !(_game.id == GID_FT && (_charset->getCurID() == 6 || _charset->getCurID() == 7))*/) {
|
||||
vs->curRect.left = _screenWidth - _charset->getStringWidth(0, buf);
|
||||
|
Loading…
Reference in New Issue
Block a user