2001-10-09 14:30:12 +00:00
|
|
|
/* ScummVM - Scumm Interpreter
|
|
|
|
* Copyright (C) 2001 Ludvig Strigeus
|
2006-01-18 17:39:49 +00:00
|
|
|
* Copyright (C) 2001-2006 The ScummVM project
|
2001-10-09 14:30:12 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
2005-10-18 01:30:26 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2001-10-09 14:30:12 +00:00
|
|
|
*
|
2006-02-11 09:55:41 +00:00
|
|
|
* $URL$
|
|
|
|
* $Id$
|
2001-10-09 14:30:12 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2005-06-24 15:23:51 +00:00
|
|
|
#include "common/stdafx.h"
|
2003-12-27 15:22:59 +00:00
|
|
|
|
|
|
|
#include "common/config-manager.h"
|
|
|
|
|
2003-10-03 18:33:57 +00:00
|
|
|
#include "scumm/scumm.h"
|
|
|
|
#include "scumm/actor.h"
|
|
|
|
#include "scumm/charset.h"
|
|
|
|
#include "scumm/dialogs.h"
|
2006-03-03 15:16:02 +00:00
|
|
|
#include "scumm/file.h"
|
2004-01-06 17:28:29 +00:00
|
|
|
#include "scumm/imuse_digi/dimuse.h"
|
2005-04-28 22:17:23 +00:00
|
|
|
#include "scumm/intern.h"
|
2006-02-04 12:11:10 +00:00
|
|
|
#ifndef DISABLE_HE
|
2006-02-15 00:57:50 +00:00
|
|
|
#include "scumm/he/intern_he.h"
|
2006-02-04 12:11:10 +00:00
|
|
|
#endif
|
2003-10-03 18:33:57 +00:00
|
|
|
#include "scumm/verbs.h"
|
2006-04-23 18:52:39 +00:00
|
|
|
#include "scumm/he/sound_he.h"
|
2001-10-09 14:30:12 +00:00
|
|
|
|
2003-10-03 18:33:57 +00:00
|
|
|
namespace Scumm {
|
|
|
|
|
2006-01-10 00:34:13 +00:00
|
|
|
|
|
|
|
|
|
|
|
#pragma mark -
|
|
|
|
#pragma mark --- "High level" message code ---
|
|
|
|
#pragma mark -
|
|
|
|
|
|
|
|
|
2004-09-18 20:50:15 +00:00
|
|
|
void ScummEngine::printString(int m, const byte *msg) {
|
|
|
|
switch (m) {
|
|
|
|
case 0:
|
|
|
|
actorTalk(msg);
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
drawString(1, msg);
|
|
|
|
break;
|
|
|
|
case 2:
|
2005-06-13 07:09:12 +00:00
|
|
|
debugMessage(msg);
|
2004-09-18 20:50:15 +00:00
|
|
|
break;
|
|
|
|
case 3:
|
2004-11-22 22:32:46 +00:00
|
|
|
showMessageDialog(msg);
|
2004-09-18 20:50:15 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-06-13 07:09:12 +00:00
|
|
|
void ScummEngine::debugMessage(const byte *msg) {
|
2005-05-07 09:53:06 +00:00
|
|
|
byte buffer[500];
|
2005-05-26 14:14:32 +00:00
|
|
|
convertMessageToString(msg, buffer, sizeof(buffer));
|
2001-10-26 17:34:50 +00:00
|
|
|
|
2006-02-20 16:51:30 +00:00
|
|
|
// if ((_game.id == GID_CMI) && _debugMode) { // In CMI, debugMessage is used for printDebug output
|
2003-04-22 16:46:33 +00:00
|
|
|
if ((buffer[0] != 0xFF) && _debugMode) {
|
|
|
|
debug(0, "DEBUG: %s", buffer);
|
2002-12-28 12:22:39 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
if (buffer[0] == 0xFF && buffer[1] == 10) {
|
|
|
|
uint32 a, b;
|
2004-08-12 04:19:47 +00:00
|
|
|
int channel = 0;
|
2001-11-05 19:21:49 +00:00
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
a = buffer[2] | (buffer[3] << 8) | (buffer[6] << 16) | (buffer[7] << 24);
|
2002-07-07 20:25:23 +00:00
|
|
|
b = buffer[10] | (buffer[11] << 8) | (buffer[14] << 16) | (buffer[15] << 24);
|
2002-09-16 08:22:05 +00:00
|
|
|
|
|
|
|
// Sam and Max uses a caching system, printing empty messages
|
|
|
|
// and setting VAR_V6_SOUNDMODE beforehand. See patch 609791.
|
2006-02-20 16:51:30 +00:00
|
|
|
if (_game.id == GID_SAMNMAX)
|
2004-08-12 04:19:47 +00:00
|
|
|
channel = VAR(VAR_V6_SOUNDMODE);
|
|
|
|
|
2004-08-13 01:02:24 +00:00
|
|
|
if (channel != 2)
|
|
|
|
_sound->talkSound(a, b, 1, channel);
|
2003-06-09 00:35:32 +00:00
|
|
|
}
|
2001-10-09 14:30:12 +00:00
|
|
|
}
|
|
|
|
|
2004-11-22 22:32:46 +00:00
|
|
|
void ScummEngine::showMessageDialog(const byte *msg) {
|
2004-02-22 14:48:13 +00:00
|
|
|
// Original COMI used different code at this point.
|
|
|
|
// Seemed to use blastText for the messages
|
2005-05-07 09:53:06 +00:00
|
|
|
byte buf[500];
|
2001-10-09 14:30:12 +00:00
|
|
|
|
2005-05-26 14:14:32 +00:00
|
|
|
convertMessageToString(msg, buf, sizeof(buf));
|
2001-10-09 14:30:12 +00:00
|
|
|
|
2002-09-22 01:17:53 +00:00
|
|
|
if (_string[3].color == 0)
|
|
|
|
_string[3].color = 4;
|
2001-10-09 14:30:12 +00:00
|
|
|
|
2003-11-02 02:18:16 +00:00
|
|
|
InfoDialog dialog(this, (char*)buf);
|
2003-09-11 10:32:15 +00:00
|
|
|
VAR(VAR_KEYPRESS) = runDialog(dialog);
|
2001-10-09 14:30:12 +00:00
|
|
|
}
|
|
|
|
|
2006-01-10 00:34:13 +00:00
|
|
|
|
|
|
|
#pragma mark -
|
|
|
|
#pragma mark --- V6 blast text queue code ---
|
|
|
|
#pragma mark -
|
|
|
|
|
|
|
|
|
|
|
|
void ScummEngine_v6::enqueueText(const byte *text, int x, int y, byte color, byte charset, bool center) {
|
|
|
|
BlastText &bt = _blastTextQueue[_blastTextQueuePos++];
|
|
|
|
assert(_blastTextQueuePos <= ARRAYSIZE(_blastTextQueue));
|
|
|
|
|
|
|
|
convertMessageToString(text, bt.text, sizeof(bt.text));
|
|
|
|
bt.xpos = x;
|
|
|
|
bt.ypos = y;
|
|
|
|
bt.color = color;
|
|
|
|
bt.charset = charset;
|
|
|
|
bt.center = center;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScummEngine_v6::drawBlastTexts() {
|
|
|
|
byte *buf;
|
|
|
|
int c;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < _blastTextQueuePos; i++) {
|
|
|
|
|
|
|
|
buf = _blastTextQueue[i].text;
|
|
|
|
|
|
|
|
_charset->_top = _blastTextQueue[i].ypos + _screenTop;
|
|
|
|
_charset->_right = _screenWidth - 1;
|
|
|
|
_charset->_center = _blastTextQueue[i].center;
|
|
|
|
_charset->setColor(_blastTextQueue[i].color);
|
|
|
|
_charset->_disableOffsX = _charset->_firstChar = true;
|
|
|
|
_charset->setCurID(_blastTextQueue[i].charset);
|
|
|
|
|
|
|
|
do {
|
|
|
|
_charset->_left = _blastTextQueue[i].xpos;
|
|
|
|
|
|
|
|
// Center text if necessary
|
|
|
|
if (_charset->_center) {
|
|
|
|
_charset->_left -= _charset->getStringWidth(0, buf) / 2;
|
|
|
|
if (_charset->_left < 0)
|
|
|
|
_charset->_left = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
do {
|
|
|
|
c = *buf++;
|
|
|
|
|
|
|
|
// FIXME: This is a workaround for bugs #864030 and #1399843:
|
|
|
|
// In COMI, some text contains ASCII character 11 = 0xB. It's
|
|
|
|
// not quite clear what it is good for; so for now we just ignore
|
|
|
|
// it, which seems to match the original engine (BTW, traditionally,
|
|
|
|
// this is a 'vertical tab').
|
|
|
|
if (c == 0x0B)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (c != 0 && c != 0xFF && c != '\n') {
|
|
|
|
if (c & 0x80 && _useCJKMode) {
|
|
|
|
if (_language == Common::JA_JPN && !checkSJISCode(c)) {
|
|
|
|
c = 0x20; //not in S-JIS
|
|
|
|
} else {
|
|
|
|
c += *buf++ * 256;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
_charset->printChar(c, true);
|
|
|
|
}
|
|
|
|
} while (c && c != '\n');
|
|
|
|
|
|
|
|
_charset->_top += _charset->getFontHeight();
|
|
|
|
} while (c);
|
|
|
|
|
|
|
|
_blastTextQueue[i].rect = _charset->_str;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScummEngine_v6::removeBlastTexts() {
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < _blastTextQueuePos; i++) {
|
2006-09-17 23:35:09 +00:00
|
|
|
restoreBackground(_blastTextQueue[i].rect);
|
2006-01-10 00:34:13 +00:00
|
|
|
}
|
|
|
|
_blastTextQueuePos = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#pragma mark -
|
|
|
|
#pragma mark --- V7 subtitle queue code ---
|
|
|
|
#pragma mark -
|
|
|
|
|
|
|
|
|
2005-11-02 21:47:44 +00:00
|
|
|
#ifndef DISABLE_SCUMM_7_8
|
|
|
|
void ScummEngine_v7::processSubtitleQueue() {
|
|
|
|
for (int i = 0; i < _subtitleQueuePos; ++i) {
|
|
|
|
SubtitleText *st = &_subtitleQueue[i];
|
|
|
|
if (!ConfMan.getBool("subtitles") || VAR(VAR_VOICE_MODE) == 0)
|
|
|
|
// subtitles are disabled, don't display the text
|
|
|
|
continue;
|
|
|
|
if (!ConfMan.getBool("subtitles") && (!st->actorSpeechMsg || _mixer->isSoundHandleActive(_sound->_talkChannelHandle)))
|
|
|
|
// no subtitles and there's a speech variant of the message, don't display the text
|
|
|
|
continue;
|
|
|
|
enqueueText(st->text, st->xpos, st->ypos, st->color, st->charset, false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScummEngine_v7::addSubtitleToQueue(const byte *text, const Common::Point &pos, byte color, byte charset) {
|
|
|
|
if (text[0] && strcmp((const char *)text, " ") != 0) {
|
|
|
|
assert(_subtitleQueuePos < ARRAYSIZE(_subtitleQueue));
|
|
|
|
SubtitleText *st = &_subtitleQueue[_subtitleQueuePos];
|
|
|
|
int i = 0;
|
|
|
|
while (1) {
|
|
|
|
st->text[i] = text[i];
|
|
|
|
if (!text[i])
|
|
|
|
break;
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
st->xpos = pos.x;
|
|
|
|
st->ypos = pos.y;
|
|
|
|
st->color = color;
|
|
|
|
st->charset = charset;
|
|
|
|
st->actorSpeechMsg = _haveActorSpeechMsg;
|
|
|
|
++_subtitleQueuePos;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScummEngine_v7::clearSubtitleQueue() {
|
|
|
|
memset(_subtitleQueue, 0, sizeof(_subtitleQueue));
|
|
|
|
_subtitleQueuePos = 0;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2006-01-10 00:34:13 +00:00
|
|
|
|
|
|
|
|
|
|
|
#pragma mark -
|
|
|
|
#pragma mark --- Core message/subtitle code ---
|
|
|
|
#pragma mark -
|
|
|
|
|
|
|
|
|
2005-11-02 21:47:44 +00:00
|
|
|
bool ScummEngine::handleNextCharsetCode(Actor *a, int *code) {
|
2002-09-11 13:28:34 +00:00
|
|
|
uint32 talk_sound_a = 0;
|
|
|
|
uint32 talk_sound_b = 0;
|
2005-11-19 10:45:41 +00:00
|
|
|
int color, frme, c = 0, oldy;
|
2005-11-02 21:47:44 +00:00
|
|
|
bool endLoop = false;
|
|
|
|
byte *buffer = _charsetBuffer + _charsetBufPos;
|
|
|
|
while (!endLoop) {
|
|
|
|
c = *buffer++;
|
2006-02-20 16:51:30 +00:00
|
|
|
if (!(c == 0xFF || (_game.version <= 6 && c == 0xFE))) {
|
2005-11-02 21:47:44 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
c = *buffer++;
|
|
|
|
switch (c) {
|
|
|
|
case 1:
|
|
|
|
c = 13; // new line
|
|
|
|
endLoop = true;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
_haveMsg = 0;
|
|
|
|
_keepText = true;
|
|
|
|
endLoop = true;
|
|
|
|
break;
|
|
|
|
case 3:
|
2006-02-20 16:51:30 +00:00
|
|
|
_haveMsg = (_game.version >= 7) ? 1 : 0xFF;
|
2005-11-02 21:47:44 +00:00
|
|
|
_keepText = false;
|
|
|
|
endLoop = true;
|
|
|
|
break;
|
|
|
|
case 8:
|
|
|
|
// Ignore this code here. Occurs e.g. in MI2 when you
|
|
|
|
// talk to the carpenter on scabb island. It works like
|
|
|
|
// code 1 (=newline) in verb texts, but is ignored in
|
|
|
|
// spoken text (i.e. here). Used for very long verb
|
|
|
|
// sentences.
|
|
|
|
break;
|
|
|
|
case 9:
|
|
|
|
frme = buffer[0] | (buffer[1] << 8);
|
|
|
|
buffer += 2;
|
|
|
|
if (a)
|
|
|
|
a->startAnimActor(frme);
|
|
|
|
break;
|
|
|
|
case 10:
|
|
|
|
// Note the similarity to the code in debugMessage()
|
|
|
|
talk_sound_a = buffer[0] | (buffer[1] << 8) | (buffer[4] << 16) | (buffer[5] << 24);
|
|
|
|
talk_sound_b = buffer[8] | (buffer[9] << 8) | (buffer[12] << 16) | (buffer[13] << 24);
|
|
|
|
buffer += 14;
|
2006-02-20 16:51:30 +00:00
|
|
|
if (_game.heversion >= 60) {
|
2006-04-23 18:52:39 +00:00
|
|
|
((SoundHE *)_sound)->startHETalkSound(talk_sound_a);
|
2005-11-02 21:47:44 +00:00
|
|
|
} else {
|
|
|
|
_sound->talkSound(talk_sound_a, talk_sound_b, 2);
|
|
|
|
}
|
|
|
|
_haveActorSpeechMsg = false;
|
|
|
|
break;
|
|
|
|
case 12:
|
|
|
|
color = buffer[0] | (buffer[1] << 8);
|
|
|
|
buffer += 2;
|
|
|
|
if (color == 0xFF)
|
|
|
|
_charset->setColor(_charsetColor);
|
|
|
|
else
|
|
|
|
_charset->setColor(color);
|
|
|
|
break;
|
|
|
|
case 13:
|
|
|
|
debug(0, "handleNextCharsetCode: Unknown opcode 13 %d", READ_LE_UINT16(buffer));
|
|
|
|
buffer += 2;
|
|
|
|
break;
|
|
|
|
case 14:
|
|
|
|
oldy = _charset->getFontHeight();
|
|
|
|
_charset->setCurID(*buffer++);
|
|
|
|
buffer += 2;
|
2005-11-03 02:24:53 +00:00
|
|
|
memcpy(_charsetColorMap, _charsetData[_charset->getCurID()], 4);
|
2005-11-02 21:47:44 +00:00
|
|
|
_charset->_nextTop -= _charset->getFontHeight() - oldy;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
error("handleNextCharsetCode: invalid code %d", c);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
_charsetBufPos = buffer - _charsetBuffer;
|
|
|
|
*code = c;
|
|
|
|
return (c != 2 && c != 3);
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifndef DISABLE_HE
|
|
|
|
bool ScummEngine_v72he::handleNextCharsetCode(Actor *a, int *code) {
|
2006-02-20 16:51:30 +00:00
|
|
|
const int charsetCode = (_game.heversion >= 80) ? 127 : 64;
|
2005-11-02 21:47:44 +00:00
|
|
|
uint32 talk_sound_a = 0;
|
|
|
|
uint32 talk_sound_b = 0;
|
2005-11-19 10:45:41 +00:00
|
|
|
int i, c = 0;
|
2004-08-29 01:24:17 +00:00
|
|
|
char value[32];
|
2005-11-03 10:12:12 +00:00
|
|
|
bool endLoop = false;
|
2005-11-03 10:06:17 +00:00
|
|
|
bool endText = false;
|
2005-11-02 21:47:44 +00:00
|
|
|
byte *buffer = _charsetBuffer + _charsetBufPos;
|
2005-11-03 02:24:53 +00:00
|
|
|
while (!endLoop) {
|
2005-11-02 21:47:44 +00:00
|
|
|
c = *buffer++;
|
|
|
|
if (c != charsetCode) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
c = *buffer++;
|
|
|
|
switch (c) {
|
|
|
|
case 84:
|
|
|
|
i = 0;
|
|
|
|
c = *buffer++;
|
|
|
|
while (c != 44) {
|
|
|
|
value[i] = c;
|
|
|
|
c = *buffer++;
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
value[i] = 0;
|
|
|
|
talk_sound_a = atoi(value);
|
|
|
|
i = 0;
|
|
|
|
c = *buffer++;
|
|
|
|
while (c != charsetCode) {
|
|
|
|
value[i] = c;
|
|
|
|
c = *buffer++;
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
value[i] = 0;
|
|
|
|
talk_sound_b = atoi(value);
|
2006-04-23 18:52:39 +00:00
|
|
|
((SoundHE *)_sound)->startHETalkSound(talk_sound_a);
|
2005-11-02 21:47:44 +00:00
|
|
|
break;
|
|
|
|
case 104:
|
|
|
|
_haveMsg = 0;
|
|
|
|
_keepText = true;
|
2005-11-03 10:06:17 +00:00
|
|
|
endLoop = endText = true;
|
2005-11-02 21:47:44 +00:00
|
|
|
break;
|
|
|
|
case 110:
|
|
|
|
c = 13; // new line
|
2005-11-03 02:24:53 +00:00
|
|
|
endLoop = true;
|
2005-11-02 21:47:44 +00:00
|
|
|
break;
|
|
|
|
case 116:
|
|
|
|
i = 0;
|
2005-11-03 02:24:53 +00:00
|
|
|
memset(value, 0, sizeof(value));
|
2005-11-02 21:47:44 +00:00
|
|
|
c = *buffer++;
|
|
|
|
while (c != charsetCode) {
|
|
|
|
value[i] = c;
|
|
|
|
c = *buffer++;
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
value[i] = 0;
|
|
|
|
talk_sound_a = atoi(value);
|
|
|
|
talk_sound_b = 0;
|
2006-04-23 18:52:39 +00:00
|
|
|
((SoundHE *)_sound)->startHETalkSound(talk_sound_a);
|
2005-11-02 21:47:44 +00:00
|
|
|
break;
|
|
|
|
case 119:
|
|
|
|
_haveMsg = 0xFF;
|
|
|
|
_keepText = false;
|
2005-11-03 10:06:17 +00:00
|
|
|
endLoop = endText = true;
|
2005-11-02 21:47:44 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
error("handleNextCharsetCode: invalid code %d", c);
|
|
|
|
}
|
2005-11-03 02:24:53 +00:00
|
|
|
}
|
2005-11-02 21:47:44 +00:00
|
|
|
_charsetBufPos = buffer - _charsetBuffer;
|
|
|
|
*code = c;
|
2005-11-03 10:06:17 +00:00
|
|
|
return (endText == 0);
|
2005-11-02 21:47:44 +00:00
|
|
|
}
|
|
|
|
#endif
|
2002-02-13 17:33:52 +00:00
|
|
|
|
2005-11-02 21:47:44 +00:00
|
|
|
void ScummEngine::CHARSET_1() {
|
|
|
|
Actor *a;
|
|
|
|
int t, c = 0;
|
|
|
|
#ifndef DISABLE_SCUMM_7_8
|
|
|
|
byte subtitleBuffer[200];
|
|
|
|
byte *subtitleLine = subtitleBuffer;
|
|
|
|
Common::Point subtitlePos;
|
|
|
|
|
2006-02-20 16:51:30 +00:00
|
|
|
if (_game.version >= 7) {
|
2005-11-02 21:47:44 +00:00
|
|
|
((ScummEngine_v7 *)this)->processSubtitleQueue();
|
|
|
|
}
|
|
|
|
#endif
|
2004-10-23 23:08:53 +00:00
|
|
|
|
2006-03-12 00:53:30 +00:00
|
|
|
if (_game.heversion >= 70 && _haveMsg == 3) {
|
|
|
|
stopTalk();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2002-06-02 12:07:12 +00:00
|
|
|
if (!_haveMsg)
|
|
|
|
return;
|
|
|
|
|
2006-03-14 09:33:37 +00:00
|
|
|
if (_game.version >= 4 && _game.version <= 6) {
|
2006-05-06 22:49:57 +00:00
|
|
|
// Do nothing while the camera is moving
|
2003-11-16 20:52:57 +00:00
|
|
|
if ((camera._dest.x / 8) != (camera._cur.x / 8) || camera._cur.x != camera._last.x)
|
2002-04-11 17:19:16 +00:00
|
|
|
return;
|
2002-03-06 00:18:22 +00:00
|
|
|
}
|
|
|
|
|
2001-10-09 14:30:12 +00:00
|
|
|
a = NULL;
|
2004-03-15 03:33:08 +00:00
|
|
|
if (getTalkingActor() != 0xFF)
|
|
|
|
a = derefActorSafe(getTalkingActor(), "CHARSET_1");
|
2001-10-09 14:30:12 +00:00
|
|
|
|
2004-08-18 12:20:26 +00:00
|
|
|
if (a && _string[0].overhead != 0) {
|
2004-09-29 22:06:24 +00:00
|
|
|
int s;
|
|
|
|
|
2006-11-19 00:39:48 +00:00
|
|
|
_string[0].xpos = a->getPos().x - virtscr[0].xstart;
|
|
|
|
_string[0].ypos = a->getPos().y - a->getElevation() - _screenTop;
|
2004-09-29 22:06:24 +00:00
|
|
|
|
2006-02-20 16:51:30 +00:00
|
|
|
if (_game.version <= 5) {
|
2001-10-09 14:30:12 +00:00
|
|
|
|
2003-05-08 15:48:50 +00:00
|
|
|
if (VAR(VAR_V5_TALK_STRING_Y) < 0) {
|
2005-03-11 01:10:06 +00:00
|
|
|
s = (a->_scaley * (int)VAR(VAR_V5_TALK_STRING_Y)) / 0xFF;
|
2004-09-29 22:06:24 +00:00
|
|
|
_string[0].ypos += (int)(((VAR(VAR_V5_TALK_STRING_Y) - s) / 2) + s);
|
2001-10-23 19:51:50 +00:00
|
|
|
} else {
|
2003-05-08 15:48:50 +00:00
|
|
|
_string[0].ypos = (int)VAR(VAR_V5_TALK_STRING_Y);
|
2001-10-23 19:51:50 +00:00
|
|
|
}
|
|
|
|
|
2001-10-09 14:30:12 +00:00
|
|
|
} else {
|
2005-03-11 01:10:06 +00:00
|
|
|
s = a->_scalex * a->_talkPosX / 0xFF;
|
|
|
|
_string[0].xpos += ((a->_talkPosX - s) / 2) + s;
|
2002-04-24 04:26:09 +00:00
|
|
|
|
2005-03-11 01:10:06 +00:00
|
|
|
s = a->_scaley * a->_talkPosY / 0xFF;
|
|
|
|
_string[0].ypos += ((a->_talkPosY - s) / 2) + s;
|
2004-08-18 12:20:26 +00:00
|
|
|
|
|
|
|
if (_string[0].ypos > _screenHeight - 40)
|
|
|
|
_string[0].ypos = _screenHeight - 40;
|
2001-10-09 14:30:12 +00:00
|
|
|
}
|
2003-05-12 22:08:39 +00:00
|
|
|
|
|
|
|
if (_string[0].ypos < 1)
|
|
|
|
_string[0].ypos = 1;
|
|
|
|
|
|
|
|
if (_string[0].xpos < 80)
|
|
|
|
_string[0].xpos = 80;
|
|
|
|
if (_string[0].xpos > _screenWidth - 80)
|
|
|
|
_string[0].xpos = _screenWidth - 80;
|
2001-10-09 14:30:12 +00:00
|
|
|
}
|
2001-10-23 19:51:50 +00:00
|
|
|
|
2003-09-09 20:54:19 +00:00
|
|
|
_charset->_top = _string[0].ypos + _screenTop;
|
2002-12-25 21:04:47 +00:00
|
|
|
_charset->_startLeft = _charset->_left = _string[0].xpos;
|
2004-08-14 16:30:39 +00:00
|
|
|
_charset->_right = _string[0].right;
|
|
|
|
_charset->_center = _string[0].center;
|
|
|
|
_charset->setColor(_charsetColor);
|
2001-10-09 14:30:12 +00:00
|
|
|
|
2005-03-11 01:10:06 +00:00
|
|
|
if (a && a->_charset)
|
|
|
|
_charset->setCurID(a->_charset);
|
2002-12-04 15:00:35 +00:00
|
|
|
else
|
2002-12-25 21:04:47 +00:00
|
|
|
_charset->setCurID(_string[0].charset);
|
2002-12-04 15:00:35 +00:00
|
|
|
|
2006-02-20 16:51:30 +00:00
|
|
|
if (_game.version >= 5)
|
2005-11-02 21:47:44 +00:00
|
|
|
memcpy(_charsetColorMap, _charsetData[_charset->getCurID()], 4);
|
2002-04-11 17:19:16 +00:00
|
|
|
|
2002-06-02 12:07:12 +00:00
|
|
|
if (_talkDelay)
|
2001-10-09 14:30:12 +00:00
|
|
|
return;
|
2002-04-11 17:19:16 +00:00
|
|
|
|
2006-05-06 22:49:57 +00:00
|
|
|
if ((_game.version <= 6 && _haveMsg == 1) ||
|
|
|
|
(_game.version == 7 && _haveMsg != 1) ||
|
|
|
|
(_game.version == 8 && VAR(VAR_HAVE_MSG))) {
|
|
|
|
|
2006-03-10 06:05:49 +00:00
|
|
|
if (_game.heversion >= 60) {
|
|
|
|
if (_sound->isSoundRunning(1) == 0)
|
|
|
|
stopTalk();
|
|
|
|
} else {
|
|
|
|
if ((_sound->_sfxMode & 2) == 0)
|
|
|
|
stopTalk();
|
|
|
|
}
|
2001-10-09 14:30:12 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2002-09-22 01:17:53 +00:00
|
|
|
if (a && !_string[0].no_talk_anim) {
|
2004-09-28 19:28:59 +00:00
|
|
|
a->runActorTalkScript(a->_talkStartFrame);
|
2001-11-05 19:21:49 +00:00
|
|
|
_useTalkAnims = true;
|
2001-10-09 14:30:12 +00:00
|
|
|
}
|
|
|
|
|
2005-11-02 21:47:44 +00:00
|
|
|
_talkDelay = (VAR_DEFAULT_TALK_DELAY != 0xFF) ? VAR(VAR_DEFAULT_TALK_DELAY) : 60;
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2001-10-09 14:30:12 +00:00
|
|
|
if (!_keepText) {
|
2006-02-20 16:51:30 +00:00
|
|
|
if (_game.version >= 7) {
|
2005-11-02 21:47:44 +00:00
|
|
|
#ifndef DISABLE_SCUMM_7_8
|
|
|
|
((ScummEngine_v7 *)this)->clearSubtitleQueue();
|
|
|
|
_charset->_nextLeft = _string[0].xpos;
|
|
|
|
_charset->_nextTop = _string[0].ypos;
|
|
|
|
#endif
|
|
|
|
} else {
|
|
|
|
_charset->restoreCharsetBg();
|
|
|
|
}
|
2001-10-09 14:30:12 +00:00
|
|
|
}
|
2002-04-11 17:19:16 +00:00
|
|
|
|
2002-12-25 21:04:47 +00:00
|
|
|
t = _charset->_right - _string[0].xpos - 1;
|
|
|
|
if (_charset->_center) {
|
|
|
|
if (t > _charset->_nextLeft)
|
|
|
|
t = _charset->_nextLeft;
|
2003-11-16 21:26:10 +00:00
|
|
|
t *= 2;
|
2001-10-09 14:30:12 +00:00
|
|
|
}
|
2001-11-05 19:21:49 +00:00
|
|
|
|
2006-02-20 16:51:30 +00:00
|
|
|
if (_game.version > 3)
|
2005-11-02 21:47:44 +00:00
|
|
|
_charset->addLinebreaks(0, _charsetBuffer + _charsetBufPos, 0, t);
|
2001-10-09 14:30:12 +00:00
|
|
|
|
2002-12-25 21:04:47 +00:00
|
|
|
if (_charset->_center) {
|
2005-11-02 21:47:44 +00:00
|
|
|
_charset->_nextLeft -= _charset->getStringWidth(0, _charsetBuffer + _charsetBufPos) / 2;
|
2002-12-25 21:04:47 +00:00
|
|
|
if (_charset->_nextLeft < 0)
|
|
|
|
_charset->_nextLeft = 0;
|
2001-10-09 14:30:12 +00:00
|
|
|
}
|
|
|
|
|
2002-12-25 21:04:47 +00:00
|
|
|
_charset->_disableOffsX = _charset->_firstChar = !_keepText;
|
2001-10-09 14:30:12 +00:00
|
|
|
|
2005-11-02 21:47:44 +00:00
|
|
|
while (handleNextCharsetCode(a, &c)) {
|
2002-04-11 17:19:16 +00:00
|
|
|
if (c == 0) {
|
2005-11-02 21:47:44 +00:00
|
|
|
// End of text reached, set _haveMsg accordingly
|
2006-02-20 16:51:30 +00:00
|
|
|
_haveMsg = (_game.version >= 7) ? 2 : 1;
|
2001-10-09 14:30:12 +00:00
|
|
|
_keepText = false;
|
|
|
|
break;
|
|
|
|
}
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2001-10-16 10:01:48 +00:00
|
|
|
if (c == 13) {
|
2002-04-11 17:19:16 +00:00
|
|
|
newLine:;
|
2003-05-14 13:30:52 +00:00
|
|
|
_charset->_nextLeft = _string[0].xpos;
|
2005-11-02 21:47:44 +00:00
|
|
|
#ifndef DISABLE_SCUMM_7_8
|
2006-02-20 16:51:30 +00:00
|
|
|
if (_game.version >= 7 && subtitleLine != subtitleBuffer) {
|
2005-11-02 21:47:44 +00:00
|
|
|
((ScummEngine_v7 *)this)->addSubtitleToQueue(subtitleBuffer, subtitlePos, _charsetColor, _charset->getCurID());
|
|
|
|
subtitleLine = subtitleBuffer;
|
|
|
|
}
|
|
|
|
#endif
|
2003-05-14 13:30:52 +00:00
|
|
|
if (_charset->_center) {
|
2005-11-02 21:47:44 +00:00
|
|
|
_charset->_nextLeft -= _charset->getStringWidth(0, _charsetBuffer + _charsetBufPos) / 2;
|
2003-05-14 13:30:52 +00:00
|
|
|
}
|
2005-11-02 21:47:44 +00:00
|
|
|
|
2006-05-29 12:45:11 +00:00
|
|
|
if (_game.version == 0) {
|
2005-09-23 12:35:30 +00:00
|
|
|
break;
|
2006-02-20 16:51:30 +00:00
|
|
|
} else if (!(_game.platform == Common::kPlatformFMTowns) && _string[0].height) {
|
2005-03-18 15:04:37 +00:00
|
|
|
_charset->_nextTop += _string[0].height;
|
|
|
|
} else {
|
|
|
|
_charset->_nextTop += _charset->getFontHeight();
|
|
|
|
}
|
2006-02-20 16:51:30 +00:00
|
|
|
if (_game.version > 3) {
|
2003-05-14 13:30:52 +00:00
|
|
|
// FIXME - is this really needed?
|
2002-12-25 21:04:47 +00:00
|
|
|
_charset->_disableOffsX = true;
|
2001-10-09 14:30:12 +00:00
|
|
|
}
|
2003-05-14 13:30:52 +00:00
|
|
|
continue;
|
2001-10-16 10:01:48 +00:00
|
|
|
}
|
2001-10-09 14:30:12 +00:00
|
|
|
|
2006-05-07 11:47:17 +00:00
|
|
|
// Handle line overflow for V3. See also bug #1306269.
|
|
|
|
if (_game.version == 3 && _charset->_nextLeft >= _screenWidth) {
|
|
|
|
_charset->_nextLeft = _screenWidth;
|
|
|
|
}
|
|
|
|
// Handle line breaks for V1-V2
|
|
|
|
if (_game.version <= 2 && _charset->_nextLeft >= _screenWidth) {
|
|
|
|
goto newLine;
|
|
|
|
}
|
|
|
|
|
2005-11-02 21:47:44 +00:00
|
|
|
_charset->_left = _charset->_nextLeft;
|
|
|
|
_charset->_top = _charset->_nextTop;
|
2005-11-27 10:32:21 +00:00
|
|
|
|
2006-02-20 16:51:30 +00:00
|
|
|
if (_game.version >= 7) {
|
2005-11-02 21:47:44 +00:00
|
|
|
#ifndef DISABLE_SCUMM_7_8
|
|
|
|
if (subtitleLine == subtitleBuffer) {
|
|
|
|
subtitlePos.x = _charset->_left;
|
|
|
|
subtitlePos.y = _charset->_top;
|
2003-06-09 00:35:32 +00:00
|
|
|
}
|
2005-11-02 21:47:44 +00:00
|
|
|
*subtitleLine++ = c;
|
|
|
|
*subtitleLine = '\0';
|
|
|
|
#endif
|
2005-11-03 10:06:17 +00:00
|
|
|
} else {
|
2005-11-27 10:32:21 +00:00
|
|
|
if (c & 0x80 && _useCJKMode) {
|
|
|
|
if (_language == Common::JA_JPN && !checkSJISCode(c)) {
|
|
|
|
c = 0x20; //not in S-JIS
|
|
|
|
} else {
|
|
|
|
byte *buffer = _charsetBuffer + _charsetBufPos;
|
|
|
|
c += *buffer++ * 256; //LE
|
|
|
|
_charsetBufPos = buffer - _charsetBuffer;
|
|
|
|
}
|
|
|
|
}
|
2006-02-20 16:51:30 +00:00
|
|
|
if (_game.version <= 3) {
|
2006-01-10 00:28:10 +00:00
|
|
|
_charset->printChar(c, false);
|
2001-10-26 17:34:50 +00:00
|
|
|
} else {
|
2006-02-20 16:51:30 +00:00
|
|
|
if (_game.features & GF_HE_NOSUBTITLES) {
|
2005-10-15 11:03:32 +00:00
|
|
|
// HE games which use sprites for subtitles
|
2006-02-20 16:51:30 +00:00
|
|
|
} else if (_game.heversion >= 60 && !ConfMan.getBool("subtitles") && _sound->isSoundRunning(1)) {
|
2005-05-08 14:31:27 +00:00
|
|
|
// Special case for HE games
|
2006-02-20 16:51:30 +00:00
|
|
|
} else if (_game.id == GID_LOOM && !ConfMan.getBool("subtitles") && (_sound->pollCD())) {
|
2006-01-24 03:46:22 +00:00
|
|
|
// Special case for Loom (CD), since it only uses CD audio.for sound
|
2005-11-02 21:47:44 +00:00
|
|
|
} else if (!ConfMan.getBool("subtitles") && (!_haveActorSpeechMsg || _mixer->isSoundHandleActive(_sound->_talkChannelHandle))) {
|
2003-06-09 00:51:09 +00:00
|
|
|
// Subtitles are turned off, and there is a voice version
|
2005-07-30 21:11:48 +00:00
|
|
|
// of this message -> don't print it.
|
2005-10-15 11:03:32 +00:00
|
|
|
} else {
|
2006-01-10 00:28:10 +00:00
|
|
|
_charset->printChar(c, false);
|
2005-10-15 11:03:32 +00:00
|
|
|
}
|
2001-10-09 14:30:12 +00:00
|
|
|
}
|
2002-12-25 21:04:47 +00:00
|
|
|
_charset->_nextLeft = _charset->_left;
|
|
|
|
_charset->_nextTop = _charset->_top;
|
2001-10-09 14:30:12 +00:00
|
|
|
}
|
|
|
|
|
2006-02-20 16:51:30 +00:00
|
|
|
if (_game.version <= 2) {
|
2005-11-02 21:47:44 +00:00
|
|
|
_talkDelay += _defaultTalkDelay;
|
|
|
|
VAR(VAR_CHARCOUNT)++;
|
|
|
|
} else {
|
|
|
|
_talkDelay += (int)VAR(VAR_CHARINC);
|
|
|
|
}
|
|
|
|
}
|
2001-11-05 19:21:49 +00:00
|
|
|
|
2005-11-02 21:47:44 +00:00
|
|
|
#ifndef DISABLE_SCUMM_7_8
|
2006-02-20 16:51:30 +00:00
|
|
|
if (_game.version >= 7 && subtitleLine != subtitleBuffer) {
|
2005-11-02 21:47:44 +00:00
|
|
|
((ScummEngine_v7 *)this)->addSubtitleToQueue(subtitleBuffer, subtitlePos, _charsetColor, _charset->getCurID());
|
|
|
|
}
|
|
|
|
#endif
|
2002-05-25 08:53:08 +00:00
|
|
|
}
|
|
|
|
|
2004-03-15 03:09:48 +00:00
|
|
|
void ScummEngine::drawString(int a, const byte *msg) {
|
2005-04-13 06:30:02 +00:00
|
|
|
byte buf[270];
|
2002-12-04 15:00:35 +00:00
|
|
|
byte *space;
|
2003-06-04 14:37:43 +00:00
|
|
|
int i, c;
|
|
|
|
byte fontHeight = 0;
|
2001-10-26 17:34:50 +00:00
|
|
|
uint color;
|
2006-02-20 16:51:30 +00:00
|
|
|
int code = (_game.heversion >= 80) ? 127 : 64;
|
2002-04-11 17:19:16 +00:00
|
|
|
|
2004-10-23 23:08:53 +00:00
|
|
|
bool cmi_pos_hack = false;
|
|
|
|
|
2005-05-26 14:14:32 +00:00
|
|
|
convertMessageToString(msg, buf, sizeof(buf));
|
2001-10-09 14:30:12 +00:00
|
|
|
|
2006-02-20 16:51:30 +00:00
|
|
|
if (_game.version >= 7) {
|
2006-01-14 21:26:19 +00:00
|
|
|
// I recently disabled charset mask related code for V7+ games, thinking
|
|
|
|
// that it should never be needed there. Well, I missed on case: In this
|
|
|
|
// method, it could potentially still be used. Now the question is:
|
|
|
|
// Does this actually ever happen? Basically, drawString is called from
|
|
|
|
// two spots: First off, from drawVerb, which I *think* is not used for
|
|
|
|
// V7+ games (but I am not 100% sure), and secondly from printString().
|
|
|
|
// The latter is much harder to predict. Maybe in some obscure place it
|
|
|
|
// is used after all?
|
|
|
|
//
|
|
|
|
// Hence I am adding this error message, hoping that either somebody
|
|
|
|
// triggers it (at which point I can investigate), or, if nobody ever
|
|
|
|
// triggers it, we can assume that it's safe to keep this error even
|
|
|
|
// after the release.
|
|
|
|
//
|
|
|
|
// TODO/FIXME: Remove or update this hack before the next release!
|
|
|
|
error("drawString(%d, '%s') -- please inform Fingolfin about this crash!", a, buf);
|
|
|
|
}
|
|
|
|
|
2003-09-09 20:54:19 +00:00
|
|
|
_charset->_top = _string[a].ypos + _screenTop;
|
2002-12-25 21:04:47 +00:00
|
|
|
_charset->_startLeft = _charset->_left = _string[a].xpos;
|
|
|
|
_charset->_right = _string[a].right;
|
|
|
|
_charset->_center = _string[a].center;
|
2003-04-27 18:49:27 +00:00
|
|
|
_charset->setColor(_string[a].color);
|
2002-12-25 21:04:47 +00:00
|
|
|
_charset->_disableOffsX = _charset->_firstChar = true;
|
|
|
|
_charset->setCurID(_string[a].charset);
|
2002-02-16 19:03:14 +00:00
|
|
|
|
2006-02-20 16:51:30 +00:00
|
|
|
if (_game.version >= 5)
|
2005-11-03 02:24:53 +00:00
|
|
|
memcpy(_charsetColorMap, _charsetData[_charset->getCurID()], 4);
|
2002-02-16 19:03:14 +00:00
|
|
|
|
2003-05-14 13:30:52 +00:00
|
|
|
fontHeight = _charset->getFontHeight();
|
|
|
|
|
2002-12-04 21:46:05 +00:00
|
|
|
// trim from the right
|
2004-03-15 02:21:04 +00:00
|
|
|
byte *tmp = buf;
|
2001-10-09 14:30:12 +00:00
|
|
|
space = NULL;
|
2004-03-15 02:21:04 +00:00
|
|
|
while (*tmp) {
|
|
|
|
if (*tmp == ' ') {
|
2002-04-11 17:19:16 +00:00
|
|
|
if (!space)
|
2004-03-15 02:21:04 +00:00
|
|
|
space = tmp;
|
2001-10-09 14:30:12 +00:00
|
|
|
} else {
|
|
|
|
space = NULL;
|
|
|
|
}
|
2004-03-15 02:21:04 +00:00
|
|
|
tmp++;
|
2001-10-09 14:30:12 +00:00
|
|
|
}
|
2002-04-11 17:19:16 +00:00
|
|
|
if (space)
|
|
|
|
*space = '\0';
|
2002-12-25 21:04:47 +00:00
|
|
|
if (_charset->_center) {
|
2003-11-16 20:52:57 +00:00
|
|
|
_charset->_left -= _charset->getStringWidth(a, buf) / 2;
|
2001-10-09 14:30:12 +00:00
|
|
|
}
|
|
|
|
|
2006-02-20 16:51:30 +00:00
|
|
|
const bool ignoreCharsetMask = (_game.version < 7);
|
2002-10-06 06:09:32 +00:00
|
|
|
|
2001-10-09 14:30:12 +00:00
|
|
|
if (!buf[0]) {
|
|
|
|
buf[0] = ' ';
|
|
|
|
buf[1] = 0;
|
|
|
|
}
|
|
|
|
|
2003-06-04 14:37:43 +00:00
|
|
|
for (i = 0; (c = buf[i++]) != 0;) {
|
2006-02-20 16:51:30 +00:00
|
|
|
if (_game.heversion >= 72 && c == code) {
|
2004-09-19 12:22:47 +00:00
|
|
|
c = buf[i++];
|
|
|
|
switch (c) {
|
|
|
|
case 110:
|
|
|
|
if (_charset->_center) {
|
|
|
|
_charset->_left = _charset->_startLeft - _charset->getStringWidth(a, buf + i);
|
|
|
|
} else {
|
|
|
|
_charset->_left = _charset->_startLeft;
|
|
|
|
}
|
|
|
|
_charset->_top += fontHeight;
|
|
|
|
break;
|
|
|
|
}
|
2006-09-01 12:20:08 +00:00
|
|
|
} else if ((c == 0xFF || (_game.version <= 6 && c == 0xFE)) && (_game.heversion <= 71)) {
|
2003-06-04 14:37:43 +00:00
|
|
|
c = buf[i++];
|
|
|
|
switch (c) {
|
2001-10-09 14:30:12 +00:00
|
|
|
case 9:
|
2002-04-11 17:19:16 +00:00
|
|
|
case 10:
|
|
|
|
case 13:
|
|
|
|
case 14:
|
2001-10-09 14:30:12 +00:00
|
|
|
i += 2;
|
|
|
|
break;
|
2002-04-11 17:19:16 +00:00
|
|
|
case 1:
|
|
|
|
case 8:
|
2002-12-25 21:04:47 +00:00
|
|
|
if (_charset->_center) {
|
2002-12-25 21:42:22 +00:00
|
|
|
_charset->_left = _charset->_startLeft - _charset->getStringWidth(a, buf + i);
|
2001-10-09 14:30:12 +00:00
|
|
|
} else {
|
2002-12-25 21:04:47 +00:00
|
|
|
_charset->_left = _charset->_startLeft;
|
2001-10-09 14:30:12 +00:00
|
|
|
}
|
2006-02-20 16:51:30 +00:00
|
|
|
if (!(_game.platform == Common::kPlatformFMTowns) && _string[0].height) {
|
2005-03-18 23:31:58 +00:00
|
|
|
_charset->_nextTop += _string[0].height;
|
|
|
|
} else {
|
|
|
|
_charset->_top += fontHeight;
|
|
|
|
}
|
2001-10-26 17:34:50 +00:00
|
|
|
break;
|
|
|
|
case 12:
|
2002-04-11 17:19:16 +00:00
|
|
|
color = buf[i] + (buf[i + 1] << 8);
|
|
|
|
i += 2;
|
|
|
|
if (color == 0xFF)
|
2003-04-27 18:49:27 +00:00
|
|
|
_charset->setColor(_string[a].color);
|
2001-10-26 17:34:50 +00:00
|
|
|
else
|
2003-04-27 18:49:27 +00:00
|
|
|
_charset->setColor(color);
|
2001-10-26 17:34:50 +00:00
|
|
|
break;
|
2001-10-09 14:30:12 +00:00
|
|
|
}
|
|
|
|
} else {
|
2006-02-20 16:51:30 +00:00
|
|
|
if (a == 1 && _game.version >= 6) {
|
2004-01-19 19:09:08 +00:00
|
|
|
// FIXME: The following code is a bit nasty. It is used for the
|
|
|
|
// Highway surfing game in Sam&Max; there, _blitAlso is set to
|
2004-01-25 15:08:41 +00:00
|
|
|
// true when writing the highscore numbers. It is also in DOTT
|
|
|
|
// for parts the intro and for drawing newspaper headlines. It
|
|
|
|
// is also used for scores in bowling mini game in fbear and
|
|
|
|
// for names in load/save screen of all HE games. Maybe it is
|
|
|
|
// also being used in other places.
|
|
|
|
//
|
2004-01-19 19:09:08 +00:00
|
|
|
// A better name for _blitAlso might be _imprintOnBackground
|
2004-01-25 15:08:41 +00:00
|
|
|
|
2004-01-06 12:02:18 +00:00
|
|
|
if (_string[a].no_talk_anim == false) {
|
2005-08-14 01:41:52 +00:00
|
|
|
//debug(0, "Would have set _charset->_blitAlso = true (wanted to print '%c' = %d)", c, c);
|
2004-01-19 19:09:08 +00:00
|
|
|
_charset->_blitAlso = true;
|
2004-01-06 12:02:18 +00:00
|
|
|
}
|
2002-10-02 17:23:19 +00:00
|
|
|
}
|
2004-10-23 23:08:53 +00:00
|
|
|
if (c & 0x80 && _useCJKMode) {
|
|
|
|
if (_language == Common::JA_JPN && !checkSJISCode(c)) {
|
|
|
|
c = 0x20; //not in S-JIS
|
|
|
|
} else {
|
|
|
|
c += buf[i++] * 256;
|
2006-02-20 16:51:30 +00:00
|
|
|
if (_game.id == GID_CMI) {
|
2004-10-23 23:08:53 +00:00
|
|
|
cmi_pos_hack = true;
|
|
|
|
_charset->_top += 6;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-01-10 00:28:10 +00:00
|
|
|
_charset->printChar(c, ignoreCharsetMask);
|
2002-12-25 21:04:47 +00:00
|
|
|
_charset->_blitAlso = false;
|
2004-10-23 23:08:53 +00:00
|
|
|
|
2005-05-08 21:49:52 +00:00
|
|
|
if (cmi_pos_hack) {
|
2004-10-23 23:08:53 +00:00
|
|
|
cmi_pos_hack = false;
|
|
|
|
_charset->_top -= 6;
|
|
|
|
}
|
2001-10-09 14:30:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
if (a == 0) {
|
2002-12-25 21:04:47 +00:00
|
|
|
_charset->_nextLeft = _charset->_left;
|
|
|
|
_charset->_nextTop = _charset->_top;
|
2003-06-09 00:35:32 +00:00
|
|
|
}
|
2002-10-02 17:23:19 +00:00
|
|
|
|
2003-05-15 22:30:32 +00:00
|
|
|
_string[a].xpos = _charset->_str.right + 8; // Indy3: Fixes Grail Diary text positioning
|
2001-10-09 14:30:12 +00:00
|
|
|
}
|
|
|
|
|
2006-09-01 12:04:40 +00:00
|
|
|
int ScummEngine::convertMessageToString(const byte *msg, byte *dst, int dstSize) {
|
|
|
|
uint num = 0;
|
|
|
|
uint32 val;
|
|
|
|
byte chr;
|
|
|
|
const byte *src;
|
|
|
|
byte *end;
|
|
|
|
byte transBuf[384];
|
|
|
|
|
|
|
|
assert(dst);
|
|
|
|
end = dst + dstSize;
|
|
|
|
|
|
|
|
if (msg == NULL) {
|
|
|
|
debug(0, "Bad message in convertMessageToString, ignoring");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_game.version >= 7) {
|
|
|
|
translateText(msg, transBuf);
|
|
|
|
src = transBuf;
|
|
|
|
} else {
|
|
|
|
src = msg;
|
|
|
|
}
|
|
|
|
|
|
|
|
num = 0;
|
|
|
|
|
|
|
|
while (1) {
|
|
|
|
chr = src[num++];
|
2002-04-11 17:19:16 +00:00
|
|
|
if (chr == 0)
|
2001-10-09 14:30:12 +00:00
|
|
|
break;
|
|
|
|
if (chr == 0xFF) {
|
2004-04-04 00:29:13 +00:00
|
|
|
chr = src[num++];
|
2004-08-02 20:55:35 +00:00
|
|
|
|
|
|
|
// WORKAROUND for bug #985948, a script bug in Indy3. Apparently,
|
|
|
|
// a german 'sz' was encoded incorrectly as 0xFF2E. We replace
|
|
|
|
// this by the correct encoding here. See also ScummEngine::resStrLen().
|
2006-02-20 16:51:30 +00:00
|
|
|
if (_game.id == GID_INDY3 && chr == 0x2E) {
|
2004-08-02 20:55:35 +00:00
|
|
|
*dst++ = 0xE1;
|
|
|
|
continue;
|
|
|
|
}
|
2006-08-26 22:02:16 +00:00
|
|
|
|
|
|
|
// WORKAROUND for bug #1514457: Yet another script bug in Indy3.
|
|
|
|
// Once more a german 'sz' was encoded incorrectly, but this time
|
|
|
|
// they simply encoded it as 0xFF instead of 0xE1. Happens twice
|
|
|
|
// in script 71.
|
|
|
|
if (_game.id == GID_INDY3 && chr == 0x20 && vm.slot[_currentScript].number == 71) {
|
|
|
|
num--;
|
|
|
|
*dst++ = 0xE1;
|
|
|
|
continue;
|
|
|
|
}
|
2004-08-02 20:55:35 +00:00
|
|
|
|
2004-01-08 17:30:36 +00:00
|
|
|
if (chr == 1 || chr == 2 || chr == 3 || chr == 8) {
|
|
|
|
// Simply copy these special codes
|
2004-04-04 00:29:13 +00:00
|
|
|
*dst++ = 0xFF;
|
|
|
|
*dst++ = chr;
|
2004-01-08 17:30:36 +00:00
|
|
|
} else {
|
2006-02-20 16:51:30 +00:00
|
|
|
val = (_game.version == 8) ? READ_LE_UINT32(src + num) : READ_LE_UINT16(src + num);
|
2004-01-08 17:30:36 +00:00
|
|
|
switch (chr) {
|
|
|
|
case 4:
|
2005-05-26 14:14:32 +00:00
|
|
|
dst += convertIntMessage(dst, end - dst, val);
|
2004-01-08 17:30:36 +00:00
|
|
|
break;
|
|
|
|
case 5:
|
2005-05-26 14:14:32 +00:00
|
|
|
dst += convertVerbMessage(dst, end - dst, val);
|
2004-01-08 17:30:36 +00:00
|
|
|
break;
|
|
|
|
case 6:
|
2005-05-26 14:16:43 +00:00
|
|
|
dst += convertNameMessage(dst, end - dst, val);
|
2004-01-08 17:30:36 +00:00
|
|
|
break;
|
|
|
|
case 7:
|
2005-05-26 14:14:32 +00:00
|
|
|
dst += convertStringMessage(dst, end - dst, val);
|
2004-01-08 17:30:36 +00:00
|
|
|
break;
|
|
|
|
case 9:
|
|
|
|
case 10:
|
|
|
|
case 12:
|
|
|
|
case 13:
|
|
|
|
case 14:
|
|
|
|
// Simply copy these special codes
|
2004-04-04 00:29:13 +00:00
|
|
|
*dst++ = 0xFF;
|
|
|
|
*dst++ = chr;
|
|
|
|
*dst++ = src[num+0];
|
|
|
|
*dst++ = src[num+1];
|
2006-02-20 16:51:30 +00:00
|
|
|
if (_game.version == 8) {
|
2004-04-04 00:29:13 +00:00
|
|
|
*dst++ = src[num+2];
|
|
|
|
*dst++ = src[num+3];
|
2004-01-08 17:30:36 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
2005-08-14 01:41:52 +00:00
|
|
|
error("convertMessageToString(): string escape sequence %d unknown", chr);
|
2002-12-28 01:57:19 +00:00
|
|
|
}
|
2006-02-20 16:51:30 +00:00
|
|
|
num += (_game.version == 8) ? 4 : 2;
|
2001-10-09 14:30:12 +00:00
|
|
|
}
|
|
|
|
} else {
|
2006-02-20 16:51:30 +00:00
|
|
|
if (!(chr == '@' && _game.heversion <= 71)) {
|
2004-04-04 00:29:13 +00:00
|
|
|
*dst++ = chr;
|
2001-10-09 14:30:12 +00:00
|
|
|
}
|
|
|
|
}
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2004-03-15 02:21:04 +00:00
|
|
|
// Check for a buffer overflow
|
2004-04-04 00:29:13 +00:00
|
|
|
if (dst >= end)
|
2005-05-26 14:14:32 +00:00
|
|
|
error("convertMessageToString: buffer overflow!");
|
2004-03-15 02:21:04 +00:00
|
|
|
}
|
2004-04-04 00:29:13 +00:00
|
|
|
*dst = 0;
|
2005-03-30 17:30:47 +00:00
|
|
|
|
2004-04-04 00:29:13 +00:00
|
|
|
return dstSize - (end - dst);
|
2001-10-09 14:30:12 +00:00
|
|
|
}
|
|
|
|
|
2006-09-02 05:49:59 +00:00
|
|
|
#ifndef DISABLE_HE
|
|
|
|
int ScummEngine_v72he::convertMessageToString(const byte *msg, byte *dst, int dstSize) {
|
|
|
|
uint num = 0;
|
|
|
|
byte chr;
|
|
|
|
const byte *src;
|
|
|
|
byte *end;
|
|
|
|
|
|
|
|
assert(dst);
|
|
|
|
end = dst + dstSize;
|
|
|
|
|
|
|
|
if (msg == NULL) {
|
|
|
|
debug(0, "Bad message in convertMessageToString, ignoring");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
src = msg;
|
|
|
|
num = 0;
|
|
|
|
|
|
|
|
while (1) {
|
|
|
|
chr = src[num++];
|
|
|
|
if (_game.heversion >= 80 && src[num - 1] == '(' && (src[num] == 'p' || src[num] == 'P')) {
|
|
|
|
// Filter out the following prefixes in subtitles
|
|
|
|
// (pickup4)
|
|
|
|
// (PU1)
|
|
|
|
// (PU2)
|
|
|
|
while (src[num++] != ')');
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if ((_game.features & GF_HE_LOCALIZED) && chr == '[') {
|
|
|
|
while (src[num++] != ']');
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (chr == 0)
|
|
|
|
break;
|
|
|
|
|
|
|
|
*dst++ = chr;
|
|
|
|
|
|
|
|
// Check for a buffer overflow
|
|
|
|
if (dst >= end)
|
|
|
|
error("convertMessageToString: buffer overflow!");
|
|
|
|
}
|
|
|
|
*dst = 0;
|
|
|
|
|
|
|
|
return dstSize - (end - dst);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2005-05-26 14:14:32 +00:00
|
|
|
int ScummEngine::convertIntMessage(byte *dst, int dstSize, int var) {
|
2003-05-24 23:39:40 +00:00
|
|
|
int num;
|
2002-04-11 17:19:16 +00:00
|
|
|
|
2001-10-09 14:30:12 +00:00
|
|
|
num = readVar(var);
|
2004-04-04 00:29:13 +00:00
|
|
|
return snprintf((char *)dst, dstSize, "%d", num);
|
2001-10-09 14:30:12 +00:00
|
|
|
}
|
|
|
|
|
2005-05-26 14:14:32 +00:00
|
|
|
int ScummEngine::convertVerbMessage(byte *dst, int dstSize, int var) {
|
2002-12-29 19:51:27 +00:00
|
|
|
int num, k;
|
2002-04-11 17:19:16 +00:00
|
|
|
|
2001-10-09 14:30:12 +00:00
|
|
|
num = readVar(var);
|
|
|
|
if (num) {
|
2003-12-26 23:11:35 +00:00
|
|
|
for (k = 1; k < _numVerbs; k++) {
|
2002-12-29 19:51:27 +00:00
|
|
|
if (num == _verbs[k].verbid && !_verbs[k].type && !_verbs[k].saveid) {
|
2003-07-15 21:30:53 +00:00
|
|
|
const byte *ptr = getResourceAddress(rtVerb, k);
|
2005-05-26 14:14:32 +00:00
|
|
|
return convertMessageToString(ptr, dst, dstSize);
|
2001-10-09 14:30:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2004-04-04 00:29:13 +00:00
|
|
|
return 0;
|
2001-10-09 14:30:12 +00:00
|
|
|
}
|
|
|
|
|
2005-05-26 14:16:43 +00:00
|
|
|
int ScummEngine::convertNameMessage(byte *dst, int dstSize, int var) {
|
2001-10-09 14:30:12 +00:00
|
|
|
int num;
|
|
|
|
|
|
|
|
num = readVar(var);
|
2004-03-19 23:19:57 +00:00
|
|
|
if (num) {
|
|
|
|
const byte *ptr = getObjOrActorName(num);
|
2004-04-02 20:31:39 +00:00
|
|
|
if (ptr) {
|
2005-05-26 14:14:32 +00:00
|
|
|
return convertMessageToString(ptr, dst, dstSize);
|
2004-04-02 20:31:39 +00:00
|
|
|
}
|
2001-10-09 14:30:12 +00:00
|
|
|
}
|
2004-04-04 00:29:13 +00:00
|
|
|
return 0;
|
2001-10-09 14:30:12 +00:00
|
|
|
}
|
|
|
|
|
2005-05-26 14:14:32 +00:00
|
|
|
int ScummEngine::convertStringMessage(byte *dst, int dstSize, int var) {
|
2003-07-15 21:30:53 +00:00
|
|
|
const byte *ptr;
|
2001-10-24 20:12:52 +00:00
|
|
|
|
2006-02-20 16:51:30 +00:00
|
|
|
if (_game.version <= 2) {
|
2004-03-19 23:19:57 +00:00
|
|
|
byte chr;
|
2004-04-04 00:29:13 +00:00
|
|
|
int i = 0;
|
2004-03-19 23:19:57 +00:00
|
|
|
while ((chr = (byte)_scummVars[var++])) {
|
2004-04-04 00:29:13 +00:00
|
|
|
if (chr != '@') {
|
|
|
|
*dst++ = chr;
|
|
|
|
i++;
|
|
|
|
}
|
2004-03-19 23:19:57 +00:00
|
|
|
}
|
|
|
|
|
2004-04-04 00:29:13 +00:00
|
|
|
return i;
|
2004-03-19 23:19:57 +00:00
|
|
|
}
|
|
|
|
|
2006-02-20 16:51:30 +00:00
|
|
|
if (_game.version == 3 || (_game.version >= 6 && _game.heversion < 72))
|
2002-07-12 21:36:20 +00:00
|
|
|
var = readVar(var);
|
2002-04-11 17:19:16 +00:00
|
|
|
|
2001-10-09 14:30:12 +00:00
|
|
|
if (var) {
|
2001-10-24 20:12:52 +00:00
|
|
|
ptr = getStringAddress(var);
|
2001-10-09 14:30:12 +00:00
|
|
|
if (ptr) {
|
2005-05-26 14:14:32 +00:00
|
|
|
return convertMessageToString(ptr, dst, dstSize);
|
2001-10-09 14:30:12 +00:00
|
|
|
}
|
2004-01-08 17:30:36 +00:00
|
|
|
}
|
2004-04-04 00:29:13 +00:00
|
|
|
return 0;
|
2001-10-09 14:30:12 +00:00
|
|
|
}
|
|
|
|
|
2006-01-10 00:34:13 +00:00
|
|
|
|
|
|
|
#pragma mark -
|
|
|
|
#pragma mark --- Charset initialisation ---
|
|
|
|
#pragma mark -
|
|
|
|
|
|
|
|
|
2005-05-14 22:56:41 +00:00
|
|
|
#ifndef DISABLE_HE
|
2005-05-05 13:16:50 +00:00
|
|
|
void ScummEngine_v80he::initCharset(int charsetno) {
|
|
|
|
ScummEngine::initCharset(charsetno);
|
|
|
|
VAR(VAR_CURRENT_CHARSET) = charsetno;
|
|
|
|
}
|
2005-05-14 22:56:41 +00:00
|
|
|
#endif
|
2005-05-05 13:16:50 +00:00
|
|
|
|
2003-10-02 22:42:03 +00:00
|
|
|
void ScummEngine::initCharset(int charsetno) {
|
2006-02-20 16:51:30 +00:00
|
|
|
if (_game.id == GID_FT) {
|
2006-09-17 20:36:48 +00:00
|
|
|
if (!_res->isResourceLoaded(rtCharset, charsetno))
|
2004-08-14 19:39:16 +00:00
|
|
|
loadCharset(charsetno);
|
|
|
|
} else {
|
|
|
|
if (!getResourceAddress(rtCharset, charsetno))
|
|
|
|
loadCharset(charsetno);
|
|
|
|
}
|
2001-10-09 14:30:12 +00:00
|
|
|
|
2004-04-05 23:54:58 +00:00
|
|
|
_string[0]._default.charset = charsetno;
|
|
|
|
_string[1]._default.charset = charsetno;
|
2001-10-09 14:30:12 +00:00
|
|
|
|
2006-01-10 21:13:43 +00:00
|
|
|
memcpy(_charsetColorMap, _charsetData[charsetno], sizeof(_charsetColorMap));
|
2001-10-09 14:30:12 +00:00
|
|
|
}
|
2002-12-25 21:42:22 +00:00
|
|
|
|
2003-06-02 23:18:52 +00:00
|
|
|
|
2006-01-10 00:34:13 +00:00
|
|
|
#pragma mark -
|
|
|
|
#pragma mark --- Translation/localization code ---
|
|
|
|
#pragma mark -
|
2003-06-02 23:18:52 +00:00
|
|
|
|
|
|
|
|
2005-05-14 22:56:41 +00:00
|
|
|
#ifndef DISABLE_SCUMM_7_8
|
2005-11-02 21:47:44 +00:00
|
|
|
static int indexCompare(const void *p1, const void *p2) {
|
2005-10-17 15:00:23 +00:00
|
|
|
const ScummEngine_v7::LangIndexNode *i1 = (const ScummEngine_v7::LangIndexNode *) p1;
|
|
|
|
const ScummEngine_v7::LangIndexNode *i2 = (const ScummEngine_v7::LangIndexNode *) p2;
|
2003-02-14 16:01:55 +00:00
|
|
|
|
|
|
|
return strcmp(i1->tag, i2->tag);
|
|
|
|
}
|
|
|
|
|
2004-03-15 02:21:04 +00:00
|
|
|
// Create an index of the language file.
|
2005-04-28 22:17:23 +00:00
|
|
|
void ScummEngine_v7::loadLanguageBundle() {
|
2004-07-26 23:15:01 +00:00
|
|
|
ScummFile file;
|
2003-02-14 16:01:55 +00:00
|
|
|
int32 size;
|
2002-09-17 09:18:47 +00:00
|
|
|
|
2006-02-20 16:51:30 +00:00
|
|
|
if (_game.id == GID_DIG) {
|
2004-07-26 23:15:01 +00:00
|
|
|
openFile(file, "language.bnd");
|
2006-02-20 16:51:30 +00:00
|
|
|
} else if (_game.id == GID_CMI) {
|
2004-07-26 23:15:01 +00:00
|
|
|
openFile(file, "language.tab");
|
2003-01-30 08:10:16 +00:00
|
|
|
} else {
|
|
|
|
return;
|
|
|
|
}
|
2003-06-07 00:49:36 +00:00
|
|
|
if (file.isOpen() == false) {
|
2002-09-17 09:18:47 +00:00
|
|
|
_existLanguageFile = false;
|
|
|
|
return;
|
|
|
|
}
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2003-05-30 23:24:29 +00:00
|
|
|
_existLanguageFile = true;
|
2003-01-30 08:10:16 +00:00
|
|
|
|
2003-02-14 16:01:55 +00:00
|
|
|
size = file.size();
|
2003-03-07 23:55:28 +00:00
|
|
|
_languageBuffer = (char *)calloc(1, size+1);
|
2003-02-14 16:01:55 +00:00
|
|
|
file.read(_languageBuffer, size);
|
2002-09-17 09:18:47 +00:00
|
|
|
file.close();
|
2003-02-14 16:01:55 +00:00
|
|
|
|
2003-05-30 23:24:29 +00:00
|
|
|
int32 i;
|
|
|
|
char *ptr = _languageBuffer;
|
2003-02-14 16:01:55 +00:00
|
|
|
|
2003-05-30 23:24:29 +00:00
|
|
|
// Count the number of lines in the language file.
|
2004-03-15 02:21:04 +00:00
|
|
|
for (_languageIndexSize = 0; ; _languageIndexSize++) {
|
2003-05-30 23:24:29 +00:00
|
|
|
ptr = strpbrk(ptr, "\n\r");
|
|
|
|
if (ptr == NULL)
|
|
|
|
break;
|
|
|
|
while (*ptr == '\n' || *ptr == '\r')
|
|
|
|
ptr++;
|
|
|
|
}
|
2003-02-14 16:01:55 +00:00
|
|
|
|
2003-05-30 23:24:29 +00:00
|
|
|
// Fill the language file index. This is just an array of
|
|
|
|
// tags and offsets. I did consider using a balanced tree
|
|
|
|
// instead, but the extra overhead in the node structure would
|
|
|
|
// easily have doubled the memory consumption of the index.
|
2005-06-04 21:21:18 +00:00
|
|
|
// And anyway, using qsort + bsearch gives us the exact same
|
|
|
|
// O(log(n)) access time anyway ;-).
|
2003-02-14 16:01:55 +00:00
|
|
|
|
2003-05-30 23:24:29 +00:00
|
|
|
_languageIndex = (LangIndexNode *)calloc(_languageIndexSize, sizeof(LangIndexNode));
|
2003-02-14 16:01:55 +00:00
|
|
|
|
2003-05-30 23:24:29 +00:00
|
|
|
ptr = _languageBuffer;
|
2003-02-14 16:01:55 +00:00
|
|
|
|
2006-02-20 16:51:30 +00:00
|
|
|
if (_game.id == GID_DIG) {
|
2003-05-30 23:24:29 +00:00
|
|
|
int lineCount = _languageIndexSize;
|
|
|
|
const char *baseTag = "";
|
|
|
|
byte enc = 0; // Initially assume the language file is not encoded
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2003-05-30 23:24:29 +00:00
|
|
|
// We'll determine the real index size as we go.
|
|
|
|
_languageIndexSize = 0;
|
|
|
|
for (i = 0; i < lineCount; i++) {
|
|
|
|
if (*ptr == '!') {
|
|
|
|
// Don't know what a line with '!' means, just ignore it
|
2005-11-27 10:32:21 +00:00
|
|
|
} else if (*ptr == 'h') {
|
|
|
|
// File contains Korean text (Hangul). just ignore it
|
2003-05-30 23:24:29 +00:00
|
|
|
} else if (*ptr == 'e') {
|
|
|
|
// File is encoded!
|
|
|
|
enc = 0x13;
|
|
|
|
} else if (*ptr == '@') {
|
|
|
|
// A new 'base tag'
|
|
|
|
baseTag = ptr + 1;
|
|
|
|
} else if (*ptr == '#') {
|
|
|
|
// Number of subtags following a given basetag. We don't need that
|
|
|
|
// information so we just skip it
|
|
|
|
} else if (isdigit(*ptr)) {
|
|
|
|
int idx = 0;
|
|
|
|
// A number (up to three digits)...
|
|
|
|
while (isdigit(*ptr)) {
|
|
|
|
idx = idx * 10 + (*ptr - '0');
|
|
|
|
ptr++;
|
|
|
|
}
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2003-05-30 23:24:29 +00:00
|
|
|
// ...followed by a slash...
|
|
|
|
assert(*ptr == '/');
|
|
|
|
ptr++;
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2003-05-30 23:24:29 +00:00
|
|
|
// ...and then the translated message, possibly encoded
|
|
|
|
_languageIndex[_languageIndexSize].offset = ptr - _languageBuffer;
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2003-05-30 23:24:29 +00:00
|
|
|
// Decode string if necessary.
|
|
|
|
if (enc) {
|
|
|
|
while (*ptr != '\n' && *ptr != '\r')
|
|
|
|
*ptr++ ^= enc;
|
|
|
|
}
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2003-05-30 23:24:29 +00:00
|
|
|
// The tag is the basetag, followed by a dot and then the index
|
|
|
|
sprintf(_languageIndex[_languageIndexSize].tag, "%s.%03d", baseTag, idx);
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2003-05-30 23:24:29 +00:00
|
|
|
// That was another index entry
|
|
|
|
_languageIndexSize++;
|
2005-03-30 17:30:47 +00:00
|
|
|
} else {
|
|
|
|
error("Unknwon languag.bnd entry found: '%s'\n", ptr);
|
2003-05-30 23:24:29 +00:00
|
|
|
}
|
2003-02-14 16:01:55 +00:00
|
|
|
|
2003-05-30 23:24:29 +00:00
|
|
|
// Skip over newlines (and turn them into null bytes)
|
|
|
|
ptr = strpbrk(ptr, "\n\r");
|
|
|
|
if (ptr == NULL)
|
|
|
|
break;
|
|
|
|
while (*ptr == '\n' || *ptr == '\r')
|
|
|
|
*ptr++ = 0;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
for (i = 0; i < _languageIndexSize; i++) {
|
2003-05-30 22:57:19 +00:00
|
|
|
// First 8 chars in the line give the string ID / 'tag'
|
2003-05-30 23:32:02 +00:00
|
|
|
int j;
|
|
|
|
for (j = 0; j < 8 && !isspace(*ptr); j++, ptr++)
|
2003-05-30 22:57:19 +00:00
|
|
|
_languageIndex[i].tag[j] = toupper(*ptr);
|
2003-02-14 16:01:55 +00:00
|
|
|
_languageIndex[i].tag[j] = 0;
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2003-05-30 22:57:19 +00:00
|
|
|
// After that follows a single space which we skip
|
|
|
|
assert(isspace(*ptr));
|
|
|
|
ptr++;
|
2005-06-04 21:21:18 +00:00
|
|
|
|
2003-05-30 22:57:19 +00:00
|
|
|
// Then comes the translated string: we record an offset to that.
|
2003-02-14 16:01:55 +00:00
|
|
|
_languageIndex[i].offset = ptr - _languageBuffer;
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2003-05-30 22:57:19 +00:00
|
|
|
// Skip over newlines (and turn them into null bytes)
|
2003-02-14 16:01:55 +00:00
|
|
|
ptr = strpbrk(ptr, "\n\r");
|
|
|
|
if (ptr == NULL)
|
|
|
|
break;
|
|
|
|
while (*ptr == '\n' || *ptr == '\r')
|
2003-05-30 22:57:19 +00:00
|
|
|
*ptr++ = 0;
|
2005-06-04 21:21:18 +00:00
|
|
|
|
|
|
|
// Convert '\n' code to a newline. See also bug #902415.
|
|
|
|
char *src, *dst;
|
|
|
|
src = dst = _languageBuffer + _languageIndex[i].offset;
|
|
|
|
while (*src) {
|
|
|
|
if (src[0] == '\\' && src[1] == 'n') {
|
|
|
|
*dst++ = '\n';
|
|
|
|
src += 2;
|
|
|
|
} else {
|
|
|
|
*dst++ = *src++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*dst = 0;
|
2003-02-14 16:01:55 +00:00
|
|
|
}
|
|
|
|
}
|
2003-05-30 23:24:29 +00:00
|
|
|
|
|
|
|
// Sort the index nodes. We'll later use bsearch on it, which is just as efficient
|
|
|
|
// as using a binary tree, speed wise.
|
|
|
|
qsort(_languageIndex, _languageIndexSize, sizeof(LangIndexNode), indexCompare);
|
2002-09-17 09:18:47 +00:00
|
|
|
}
|
|
|
|
|
2005-04-28 22:17:23 +00:00
|
|
|
void ScummEngine_v7::playSpeech(const byte *ptr) {
|
2006-02-20 16:51:30 +00:00
|
|
|
if ((_game.id == GID_DIG || _game.id == GID_CMI) && ptr[0]) {
|
2003-07-15 21:30:53 +00:00
|
|
|
char pointer[20];
|
2004-04-02 21:42:42 +00:00
|
|
|
strcpy(pointer, (const char *)ptr);
|
2003-07-15 21:30:53 +00:00
|
|
|
|
|
|
|
// Play speech
|
2006-02-20 16:51:30 +00:00
|
|
|
if (!(_game.features & GF_DEMO) && (_game.id == GID_CMI)) // CMI demo does not have .IMX for voice
|
2004-01-06 17:28:29 +00:00
|
|
|
strcat(pointer, ".IMX");
|
2003-07-15 21:30:53 +00:00
|
|
|
|
2004-03-19 23:19:57 +00:00
|
|
|
_sound->stopTalkSound();
|
2004-08-02 17:55:14 +00:00
|
|
|
_imuseDigital->stopSound(kTalkSoundID);
|
2004-03-19 23:19:57 +00:00
|
|
|
_imuseDigital->startVoice(kTalkSoundID, pointer);
|
2004-07-24 14:24:34 +00:00
|
|
|
_sound->talkSound(0, 0, 2);
|
2003-07-15 21:30:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-04-28 22:17:23 +00:00
|
|
|
void ScummEngine_v7::translateText(const byte *text, byte *trans_buff) {
|
2004-04-02 21:42:42 +00:00
|
|
|
LangIndexNode target;
|
2004-04-02 21:55:30 +00:00
|
|
|
LangIndexNode *found = NULL;
|
2004-04-02 21:42:42 +00:00
|
|
|
int i;
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2005-03-30 17:30:47 +00:00
|
|
|
trans_buff[0] = 0;
|
|
|
|
_lastStringTag[0] = 0;
|
2005-04-06 18:57:58 +00:00
|
|
|
|
|
|
|
// WORKAROUND for bug #1172655.
|
2006-02-20 16:51:30 +00:00
|
|
|
if (_game.id == GID_DIG && text[0] != '/') {
|
2005-04-06 18:57:58 +00:00
|
|
|
if (!strcmp((const char *)text, "faint light"))
|
|
|
|
text = (const byte *)"/NEW.007/faint light";
|
|
|
|
else if (!strcmp((const char *)text, "glowing crystal"))
|
|
|
|
text = (const byte *)"/NEW.008/glowing crystal";
|
|
|
|
else if (!strcmp((const char *)text, "glowing crystals"))
|
|
|
|
text = (const byte *)"/NEW.009/glowing crystals";
|
|
|
|
else if (!strcmp((const char *)text, "pit"))
|
|
|
|
text = (const byte *)"/NEW.010/pit";
|
|
|
|
else if (!strcmp((const char *)text, "You wish."))
|
|
|
|
text = (const byte *)"/NEW.011/You wish.";
|
|
|
|
else if (!strcmp((const char *)text, "In your dreams."))
|
|
|
|
text = (const byte *)"/NEW.012/In your dreams";
|
|
|
|
else if (!strcmp((const char *)text, "left"))
|
|
|
|
text = (const byte *)"/CATHPLAT.068/left";
|
|
|
|
else if (!strcmp((const char *)text, "right"))
|
|
|
|
text = (const byte *)"/CATHPLAT.070/right";
|
|
|
|
else if (!strcmp((const char *)text, "right"))
|
|
|
|
text = (const byte *)"/CATHPLAT.067/top";
|
|
|
|
else if (!strcmp((const char *)text, "exit"))
|
|
|
|
text = (const byte *)"/SKY.008/exit";
|
|
|
|
else if (!strcmp((const char *)text, "unattached lens"))
|
|
|
|
text = (const byte *)"/NEW.013/unattached lens";
|
|
|
|
else if (!strcmp((const char *)text, "lens slot"))
|
|
|
|
text = (const byte *)"/NEW.014/lens slot";
|
|
|
|
}
|
|
|
|
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2006-02-20 16:51:30 +00:00
|
|
|
if (_game.version >= 7 && text[0] == '/') {
|
2004-04-02 21:55:30 +00:00
|
|
|
// Extract the string tag from the text: /..../
|
2004-04-02 21:42:42 +00:00
|
|
|
for (i = 0; (i < 12) && (text[i + 1] != '/'); i++)
|
|
|
|
_lastStringTag[i] = target.tag[i] = toupper(text[i + 1]);
|
|
|
|
_lastStringTag[i] = target.tag[i] = 0;
|
|
|
|
text += i + 2;
|
|
|
|
|
2004-04-02 21:55:30 +00:00
|
|
|
// If a language file was loaded, try to find a translated version
|
|
|
|
// by doing a lookup on the string tag.
|
2004-04-02 21:42:42 +00:00
|
|
|
if (_existLanguageFile) {
|
2005-04-06 18:57:58 +00:00
|
|
|
// HACK: These are used for the object line in COMI when
|
2004-04-02 21:42:42 +00:00
|
|
|
// using one object on another. I don't know if the
|
|
|
|
// text in the language file is a placeholder or if
|
|
|
|
// we're supposed to use it, but at least in the
|
|
|
|
// English version things will work so much better if
|
|
|
|
// we can't find translations for these.
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2005-04-06 18:57:58 +00:00
|
|
|
if (*text && strcmp(target.tag, "PU_M001") != 0 && strcmp(target.tag, "PU_M002") != 0)
|
2004-04-02 21:42:42 +00:00
|
|
|
found = (LangIndexNode *)bsearch(&target, _languageIndex, _languageIndexSize, sizeof(LangIndexNode), indexCompare);
|
2004-04-02 21:55:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (found != NULL) {
|
|
|
|
strcpy((char *)trans_buff, _languageBuffer + found->offset);
|
|
|
|
|
2006-02-20 16:51:30 +00:00
|
|
|
if ((_game.id == GID_DIG) && !(_game.features & GF_DEMO)) {
|
2004-04-02 21:55:30 +00:00
|
|
|
// Replace any '%___' by the corresponding special codes in the source text
|
|
|
|
const byte *src = text;
|
|
|
|
char *dst = (char *)trans_buff;
|
|
|
|
|
|
|
|
while ((dst = strstr(dst, "%___"))) {
|
|
|
|
// Search for a special code in the message.
|
|
|
|
while (*src && *src != 0xFF) {
|
|
|
|
src++;
|
2004-04-02 20:31:39 +00:00
|
|
|
}
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2004-04-02 21:55:30 +00:00
|
|
|
// Replace the %___ by the special code. Luckily, we can do
|
|
|
|
// that in-place.
|
|
|
|
if (*src == 0xFF) {
|
|
|
|
memcpy(dst, src, 4);
|
|
|
|
src += 4;
|
|
|
|
dst += 4;
|
|
|
|
} else
|
|
|
|
break;
|
2003-03-08 17:39:18 +00:00
|
|
|
}
|
|
|
|
}
|
2004-04-02 21:55:30 +00:00
|
|
|
} else {
|
|
|
|
// Default: just copy the string
|
|
|
|
memcpy(trans_buff, text, resStrLen(text) + 1);
|
2002-09-17 09:18:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-05-14 22:56:41 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
void ScummEngine::translateText(const byte *text, byte *trans_buff) {
|
|
|
|
// Default: just copy the string
|
|
|
|
memcpy(trans_buff, text, resStrLen(text) + 1);
|
|
|
|
}
|
|
|
|
|
2003-10-03 18:33:57 +00:00
|
|
|
} // End of namespace Scumm
|