2001-10-09 14:30:12 +00:00
|
|
|
/* ScummVM - Scumm Interpreter
|
|
|
|
* Copyright (C) 2001 Ludvig Strigeus
|
2003-03-06 21:46:56 +00:00
|
|
|
* Copyright (C) 2001-2003 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
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*
|
2001-11-06 20:00:47 +00:00
|
|
|
* $Header$
|
2001-10-09 14:30:12 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "stdafx.h"
|
|
|
|
#include "scumm.h"
|
2002-05-14 23:32:34 +00:00
|
|
|
#include "actor.h"
|
2002-12-25 21:04:47 +00:00
|
|
|
#include "charset.h"
|
2002-10-27 12:26:41 +00:00
|
|
|
#include "dialogs.h"
|
2002-11-29 15:13:49 +00:00
|
|
|
#include "verbs.h"
|
2002-08-29 23:45:15 +00:00
|
|
|
#include "scumm/sound.h"
|
2001-10-09 14:30:12 +00:00
|
|
|
|
2003-03-06 17:58:13 +00:00
|
|
|
void Scumm::unkMessage1() {
|
2001-11-05 19:21:49 +00:00
|
|
|
byte buffer[100];
|
|
|
|
_msgPtrToAdd = buffer;
|
2001-10-09 14:30:12 +00:00
|
|
|
_messagePtr = addMessageToStack(_messagePtr);
|
2001-10-26 17:34:50 +00:00
|
|
|
|
2003-04-22 16:46:33 +00:00
|
|
|
// if ((_gameId == GID_CMI) && _debugMode) { // In CMI, unkMessage1 is used for printDebug output
|
|
|
|
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;
|
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.
|
|
|
|
// FIXME: There are other VAR_V6_SOUNDMODE states, as
|
|
|
|
// mentioned in the patch. FIXME after iMUSE is done.
|
2003-05-08 15:48:50 +00:00
|
|
|
if (_gameId != GID_SAMNMAX || (VAR(VAR_V6_SOUNDMODE) != 2))
|
2002-09-16 08:22:05 +00:00
|
|
|
_sound->talkSound(a, b, 1, -1);
|
2002-12-28 12:22:39 +00:00
|
|
|
}
|
2001-10-09 14:30:12 +00:00
|
|
|
}
|
|
|
|
|
2003-03-06 17:58:13 +00:00
|
|
|
void Scumm::unkMessage2() {
|
2001-10-09 14:30:12 +00:00
|
|
|
byte buf[100], *tmp;
|
|
|
|
|
|
|
|
_msgPtrToAdd = buf;
|
|
|
|
tmp = _messagePtr = addMessageToStack(_messagePtr);
|
|
|
|
|
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
|
|
|
|
2002-11-20 13:20:39 +00:00
|
|
|
InfoDialog* dialog = new InfoDialog(_newgui, this, (char*)buf);
|
2002-12-21 12:34:17 +00:00
|
|
|
// FIXME: I know this is the right thing to do for MI1 and MI2. For
|
|
|
|
// all other games it's just a guess.
|
2003-05-08 15:48:50 +00:00
|
|
|
VAR(VAR_KEYPRESS) = runDialog (dialog);
|
2002-11-20 13:20:39 +00:00
|
|
|
delete dialog;
|
2002-10-27 12:26:41 +00:00
|
|
|
|
2001-10-09 14:30:12 +00:00
|
|
|
_messagePtr = tmp;
|
|
|
|
}
|
|
|
|
|
2003-03-06 17:58:13 +00:00
|
|
|
void Scumm::CHARSET_1() {
|
2002-09-11 13:28:34 +00:00
|
|
|
uint32 talk_sound_a = 0;
|
|
|
|
uint32 talk_sound_b = 0;
|
2001-10-09 14:30:12 +00:00
|
|
|
int s, i, t, c;
|
2002-09-11 13:28:34 +00:00
|
|
|
int frme = -1;
|
2001-10-09 14:30:12 +00:00
|
|
|
Actor *a;
|
2002-04-11 17:19:16 +00:00
|
|
|
byte *buffer;
|
2002-09-11 13:28:34 +00:00
|
|
|
bool has_talk_sound = false;
|
|
|
|
bool has_anim = false;
|
2002-02-13 17:33:52 +00:00
|
|
|
|
2002-06-02 12:07:12 +00:00
|
|
|
if (!_haveMsg)
|
|
|
|
return;
|
|
|
|
|
2002-07-31 13:33:07 +00:00
|
|
|
// FIXME: This Zak check fixes several hangs (Yak hang, and opening
|
|
|
|
// 'secret room while walking' hang. It doesn't do the camera check
|
|
|
|
// when the talk target isn't an actor. The question is, can we make
|
|
|
|
// this a more general case? Does it really need to be Zak specific?
|
2003-05-08 15:48:50 +00:00
|
|
|
if (!(_features & GF_AFTER_V7) && !(_gameId==GID_ZAK256 && VAR(VAR_TALK_ACTOR) == 0xFF)) {
|
2002-07-07 20:25:23 +00:00
|
|
|
if ((camera._dest.x >> 3) != (camera._cur.x >> 3) || 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;
|
2003-05-08 15:48:50 +00:00
|
|
|
if (VAR(VAR_TALK_ACTOR) != 0xFF)
|
|
|
|
a = derefActorSafe(VAR(VAR_TALK_ACTOR), "CHARSET_1");
|
2001-10-09 14:30:12 +00:00
|
|
|
|
2002-09-22 01:17:53 +00:00
|
|
|
if (a && _string[0].overhead != 0) {
|
2001-11-26 19:57:57 +00:00
|
|
|
if (!(_features & GF_AFTER_V6)) {
|
2003-05-10 21:49:59 +00:00
|
|
|
_string[0].xpos = a->x - camera._cur.x + (_screenWidth / 2);
|
2001-10-09 14:30:12 +00:00
|
|
|
|
2003-05-08 15:48:50 +00:00
|
|
|
if (VAR(VAR_V5_TALK_STRING_Y) < 0) {
|
|
|
|
s = (a->scaley * (int)VAR(VAR_V5_TALK_STRING_Y)) / 0xFF;
|
|
|
|
_string[0].ypos = ((VAR(VAR_V5_TALK_STRING_Y) - s) >> 1) + s - a->elevation + a->y;
|
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 {
|
2003-05-12 22:08:39 +00:00
|
|
|
s = a->scaley * a->talkPosY / 0xFF;
|
|
|
|
_string[0].ypos = ((a->talkPosY - s) >> 1) + s - a->elevation + a->y;
|
2002-04-24 04:26:09 +00:00
|
|
|
|
2003-05-10 21:49:59 +00:00
|
|
|
if (_string[0].ypos < camera._cur.y - (_screenHeight / 2))
|
|
|
|
_string[0].ypos = camera._cur.y - (_screenHeight / 2);
|
2002-04-11 17:19:16 +00:00
|
|
|
|
2003-05-12 22:08:39 +00:00
|
|
|
s = a->scalex * a->talkPosX / 0xFF;
|
|
|
|
_string[0].xpos = ((a->talkPosX - s) >> 1) + s + a->x - camera._cur.x + (_screenWidth / 2);
|
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
|
|
|
|
2002-12-25 21:04:47 +00:00
|
|
|
_charset->_top = _string[0].ypos;
|
|
|
|
_charset->_startLeft = _charset->_left = _string[0].xpos;
|
2001-10-09 14:30:12 +00:00
|
|
|
|
|
|
|
if (a && a->charset)
|
2002-12-25 21:04:47 +00:00
|
|
|
_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
|
|
|
|
2002-12-25 21:04:47 +00:00
|
|
|
_charset->_center = _string[0].center;
|
|
|
|
_charset->_right = _string[0].right;
|
2003-04-27 18:49:27 +00:00
|
|
|
_charset->setColor(_charsetColor);
|
2002-04-11 17:19:16 +00:00
|
|
|
|
2003-05-14 13:30:52 +00:00
|
|
|
if (!(_features & GF_AFTER_V2 || _features & GF_AFTER_V3)) // FIXME
|
2002-04-11 17:19:16 +00:00
|
|
|
for (i = 0; i < 4; i++)
|
2002-12-26 00:21:19 +00:00
|
|
|
_charsetColorMap[i] = _charsetData[_charset->getCurID()][i];
|
2002-04-11 17:19:16 +00:00
|
|
|
|
2001-10-09 14:30:12 +00:00
|
|
|
if (_keepText) {
|
2002-12-25 21:04:47 +00:00
|
|
|
_charset->_strLeft = gdi._mask_left;
|
|
|
|
_charset->_strRight = gdi._mask_right;
|
|
|
|
_charset->_strTop = gdi._mask_top;
|
|
|
|
_charset->_strBottom = gdi._mask_bottom;
|
2001-10-09 14:30:12 +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
|
|
|
|
2002-06-02 12:07:12 +00:00
|
|
|
if (_haveMsg != 0xFF && _haveMsg != 0xFE) {
|
2002-12-29 01:21:58 +00:00
|
|
|
// FIXME: DIG and CMI never set sfxMode or any actor talk data...
|
|
|
|
// This hack will force the backup cutoff system to be used instead,
|
|
|
|
// unless the talkChannel is null (eg, this string has no sound attached)
|
|
|
|
if ((_gameId == GID_CMI || _gameId == GID_DIG) && (_sound->_talkChannel > 0))
|
2003-03-23 13:14:54 +00:00
|
|
|
return;
|
2002-12-29 01:21:58 +00:00
|
|
|
|
2002-08-14 20:43:56 +00:00
|
|
|
if (_sound->_sfxMode == 0)
|
2001-11-05 19:21:49 +00:00
|
|
|
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) {
|
2002-09-11 13:28:34 +00:00
|
|
|
has_anim = true;
|
2001-11-05 19:21:49 +00:00
|
|
|
_useTalkAnims = true;
|
2001-10-09 14:30:12 +00:00
|
|
|
}
|
|
|
|
|
2002-10-20 13:19:15 +00:00
|
|
|
// HACK: Most of the audio sync in Loom is handled by the "MI1
|
|
|
|
// timer", but some of it depends on text strings timing out at
|
|
|
|
// the right moment.
|
|
|
|
|
|
|
|
if (_gameId == GID_LOOM256) {
|
|
|
|
_defaultTalkDelay = 100;
|
2003-05-08 15:48:50 +00:00
|
|
|
VAR(VAR_CHARINC) = 5;
|
2002-10-20 13:19:15 +00:00
|
|
|
}
|
|
|
|
|
2001-10-09 14:30:12 +00:00
|
|
|
_talkDelay = _defaultTalkDelay;
|
|
|
|
|
|
|
|
if (!_keepText) {
|
2003-05-14 13:30:52 +00:00
|
|
|
if ((_features & GF_AFTER_V2 || _features & GF_AFTER_V3) && _gameId != GID_LOOM) {
|
2002-09-22 01:17:53 +00:00
|
|
|
gdi._mask_left = _string[0].xpos;
|
|
|
|
gdi._mask_top = _string[0].ypos;
|
|
|
|
gdi._mask_bottom = _string[0].ypos + 8;
|
2003-05-10 21:49:59 +00:00
|
|
|
gdi._mask_right = _screenWidth;
|
2002-09-22 01:17:53 +00:00
|
|
|
if (_string[0].ypos <= 16) // If we are cleaning the text line, clean 2 lines.
|
2002-02-19 22:36:09 +00:00
|
|
|
gdi._mask_bottom = 16;
|
|
|
|
}
|
2001-10-09 14:30:12 +00:00
|
|
|
restoreCharsetBg();
|
|
|
|
}
|
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;
|
2001-10-09 14:30:12 +00:00
|
|
|
t <<= 1;
|
|
|
|
}
|
2001-11-05 19:21:49 +00:00
|
|
|
|
2002-12-26 00:21:19 +00:00
|
|
|
buffer = _charsetBuffer + _charsetBufPos;
|
2003-05-14 13:50:28 +00:00
|
|
|
if (!(_features & GF_AFTER_V2))
|
|
|
|
_charset->addLinebreaks(0, buffer, 0, t);
|
2001-10-09 14:30:12 +00:00
|
|
|
|
2002-12-25 21:04:47 +00:00
|
|
|
if (_charset->_center) {
|
2002-12-25 21:42:22 +00:00
|
|
|
_charset->_nextLeft -= _charset->getStringWidth(0, buffer) >> 1;
|
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
|
|
|
|
|
|
|
do {
|
2001-11-05 19:21:49 +00:00
|
|
|
c = *buffer++;
|
2002-04-11 17:19:16 +00:00
|
|
|
if (c == 0) {
|
2002-06-02 12:07:12 +00:00
|
|
|
// End of text reached, set _haveMsg to 1 so that the text will be
|
|
|
|
// removed next time CHARSET_1 is called.
|
2001-10-09 14:30:12 +00:00
|
|
|
_haveMsg = 1;
|
|
|
|
_keepText = false;
|
|
|
|
break;
|
|
|
|
}
|
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;
|
|
|
|
if (_charset->_center) {
|
|
|
|
_charset->_nextLeft -= _charset->getStringWidth(0, buffer) >> 1;
|
|
|
|
}
|
|
|
|
_charset->_nextTop += _charset->getFontHeight();
|
|
|
|
if (!(_features & GF_AFTER_V2 || _features & GF_AFTER_V3)) {
|
|
|
|
// 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
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
if (c == 0xFE)
|
|
|
|
c = 0xFF;
|
2001-10-16 10:01:48 +00:00
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
if (c != 0xFF) {
|
2002-12-25 21:04:47 +00:00
|
|
|
_charset->_left = _charset->_nextLeft;
|
|
|
|
_charset->_top = _charset->_nextTop;
|
2003-05-14 13:30:52 +00:00
|
|
|
if (_features & GF_AFTER_V2 || _features & GF_AFTER_V3) {
|
2002-12-25 21:57:01 +00:00
|
|
|
_charset->printChar(c);
|
2002-12-25 21:14:26 +00:00
|
|
|
} else if (_features & GF_AFTER_V6) {
|
|
|
|
if (!_noSubtitles || (_haveMsg != 0xFE && _haveMsg != 0xFF))
|
2002-12-25 21:04:47 +00:00
|
|
|
_charset->printChar(c);
|
2001-10-26 17:34:50 +00:00
|
|
|
} else {
|
2002-12-25 21:14:26 +00:00
|
|
|
if (!_noSubtitles || _haveMsg != 0xFE)
|
2002-12-25 21:04:47 +00:00
|
|
|
_charset->printChar(c);
|
2001-10-09 14:30:12 +00:00
|
|
|
}
|
2001-10-26 17:34:50 +00:00
|
|
|
|
2002-12-25 21:04:47 +00:00
|
|
|
_charset->_nextLeft = _charset->_left;
|
|
|
|
_charset->_nextTop = _charset->_top;
|
2003-05-14 13:30:52 +00:00
|
|
|
if (_features & GF_AFTER_V2) {
|
|
|
|
_talkDelay += _defaultTalkDelay / 20;
|
|
|
|
VAR(VAR_CHARCOUNT)++;
|
|
|
|
} else
|
|
|
|
_talkDelay += (int)VAR(VAR_CHARINC);
|
2001-10-16 10:01:48 +00:00
|
|
|
continue;
|
2001-10-09 14:30:12 +00:00
|
|
|
}
|
2001-10-16 10:01:48 +00:00
|
|
|
|
2001-11-05 19:21:49 +00:00
|
|
|
c = *buffer++;
|
2002-09-16 23:48:42 +00:00
|
|
|
switch(c) {
|
|
|
|
case 1:
|
2001-10-16 10:01:48 +00:00
|
|
|
goto newLine;
|
2002-09-16 23:48:42 +00:00
|
|
|
case 2:
|
2001-10-16 10:01:48 +00:00
|
|
|
_haveMsg = 0;
|
|
|
|
_keepText = true;
|
|
|
|
break;
|
2002-09-16 23:48:42 +00:00
|
|
|
case 3:
|
|
|
|
if (_haveMsg != 0xFE)
|
|
|
|
_haveMsg = 0xFF;
|
|
|
|
_keepText = false;
|
|
|
|
break;
|
|
|
|
case 9:
|
2001-11-05 19:21:49 +00:00
|
|
|
frme = *buffer++;
|
2002-04-11 17:19:16 +00:00
|
|
|
frme |= *buffer++ << 8;
|
2002-09-11 13:28:34 +00:00
|
|
|
has_anim = true;
|
2002-09-16 23:48:42 +00:00
|
|
|
break;
|
|
|
|
case 10:
|
2002-09-11 13:28:34 +00:00
|
|
|
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);
|
|
|
|
has_talk_sound = true;
|
2001-11-05 19:21:49 +00:00
|
|
|
buffer += 14;
|
2002-07-07 20:25:23 +00:00
|
|
|
|
2002-06-02 12:07:12 +00:00
|
|
|
// Set flag that speech variant exist of this msg
|
|
|
|
if (_haveMsg == 0xFF)
|
|
|
|
_haveMsg = 0xFE;
|
2002-09-16 23:48:42 +00:00
|
|
|
break;
|
|
|
|
case 12:
|
|
|
|
int color;
|
|
|
|
color = *buffer++;
|
|
|
|
color |= *buffer++ << 8;
|
|
|
|
if (color == 0xFF)
|
2003-04-27 18:49:27 +00:00
|
|
|
_charset->setColor(_charsetColor);
|
2002-09-16 23:48:42 +00:00
|
|
|
else
|
2003-04-27 18:49:27 +00:00
|
|
|
_charset->setColor(color);
|
2002-09-16 23:48:42 +00:00
|
|
|
break;
|
|
|
|
case 13:
|
|
|
|
buffer += 2;
|
|
|
|
break;
|
|
|
|
case 14: {
|
2002-12-25 21:42:22 +00:00
|
|
|
int oldy = _charset->getFontHeight();
|
2001-10-16 10:01:48 +00:00
|
|
|
|
2002-12-25 21:04:47 +00:00
|
|
|
_charset->setCurID(*buffer++);
|
2001-11-05 19:21:49 +00:00
|
|
|
buffer += 2;
|
2002-04-11 17:19:16 +00:00
|
|
|
for (i = 0; i < 4; i++)
|
2002-12-26 00:21:19 +00:00
|
|
|
_charsetColorMap[i] = _charsetData[_charset->getCurID()][i];
|
2002-12-25 21:42:22 +00:00
|
|
|
_charset->_nextTop -= _charset->getFontHeight() - oldy;
|
2002-09-16 23:48:42 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
2001-10-16 10:01:48 +00:00
|
|
|
warning("CHARSET_1: invalid code %d", c);
|
2001-10-09 14:30:12 +00:00
|
|
|
}
|
2002-09-16 23:48:42 +00:00
|
|
|
if (c == 3 || c == 2)
|
|
|
|
break;
|
|
|
|
|
2001-10-09 14:30:12 +00:00
|
|
|
} while (1);
|
|
|
|
|
2002-09-11 13:28:34 +00:00
|
|
|
// Even if talkSound() is called, we may still have to call
|
|
|
|
// startAnimActor() since actorTalk() may already have caused the
|
|
|
|
// wrong animation frame to be drawn, and the talkSound() won't be
|
|
|
|
// processed until after the next screen update. Bleah.
|
|
|
|
|
|
|
|
if (has_talk_sound)
|
|
|
|
_sound->talkSound(talk_sound_a, talk_sound_b, 2, frme);
|
|
|
|
if (a && has_anim)
|
|
|
|
a->startAnimActor(frme != -1 ? frme : a->talkFrame1);
|
|
|
|
|
2002-12-26 00:21:19 +00:00
|
|
|
_charsetBufPos = buffer - _charsetBuffer;
|
2001-11-05 19:21:49 +00:00
|
|
|
|
2002-12-25 21:04:47 +00:00
|
|
|
gdi._mask_left = _charset->_strLeft;
|
|
|
|
gdi._mask_right = _charset->_strRight;
|
|
|
|
gdi._mask_top = _charset->_strTop;
|
|
|
|
gdi._mask_bottom = _charset->_strBottom;
|
2002-05-25 08:53:08 +00:00
|
|
|
}
|
|
|
|
|
2003-03-06 17:58:13 +00:00
|
|
|
void Scumm::drawDescString(byte *msg) {
|
2002-10-06 07:23:08 +00:00
|
|
|
byte c, *buf, buffer[256];
|
2002-10-06 06:09:32 +00:00
|
|
|
|
2002-10-06 07:23:08 +00:00
|
|
|
buf = _msgPtrToAdd = buffer;
|
|
|
|
addMessageToStack(msg);
|
2002-10-06 06:09:32 +00:00
|
|
|
|
2002-12-26 00:21:19 +00:00
|
|
|
_charsetBufPos = 0;
|
2003-05-10 21:49:59 +00:00
|
|
|
_string[0].ypos += camera._cur.y - (_screenHeight / 2);
|
2002-12-25 21:04:47 +00:00
|
|
|
_charset->_top = _string[0].ypos;
|
|
|
|
_charset->_startLeft = _charset->_left = _string[0].xpos;
|
2003-05-10 21:49:59 +00:00
|
|
|
_charset->_right = _screenWidth - 1;
|
2002-12-25 21:04:47 +00:00
|
|
|
_charset->_center = _string[0].center;
|
2003-04-27 18:49:27 +00:00
|
|
|
_charset->setColor(_string[0].color);
|
2002-12-25 21:04:47 +00:00
|
|
|
_charset->_disableOffsX = _charset->_firstChar = true;
|
|
|
|
_charset->setCurID(_string[0].charset);
|
|
|
|
_charset->_nextLeft = _string[0].xpos;
|
|
|
|
_charset->_nextTop = _string[0].ypos;
|
2002-10-06 06:09:32 +00:00
|
|
|
|
2002-10-06 07:23:08 +00:00
|
|
|
// Center text
|
2003-03-30 19:32:12 +00:00
|
|
|
_string[0].xpos -= _charset->getStringWidth(0, buffer) >> 1;
|
|
|
|
if (_string[0].xpos < 0) {
|
|
|
|
_string[0].xpos = 0;
|
|
|
|
}
|
2002-10-06 07:23:08 +00:00
|
|
|
|
2002-10-06 06:09:32 +00:00
|
|
|
_talkDelay = 1;
|
|
|
|
|
2003-03-30 19:03:12 +00:00
|
|
|
if (_string[0].ypos + _charset->getFontHeight() > 0)
|
2003-05-10 21:49:59 +00:00
|
|
|
restoreBG(0, _string[0].ypos, _screenWidth - 1, _string[0].ypos + _charset->getFontHeight());
|
2003-03-30 19:03:12 +00:00
|
|
|
|
|
|
|
_charset->_nextLeft = _string[0].xpos;
|
|
|
|
_charset->_nextTop = _string[0].ypos;
|
2002-10-06 06:09:32 +00:00
|
|
|
|
2002-10-06 07:23:08 +00:00
|
|
|
do {
|
|
|
|
c = *buf++;
|
2003-01-16 00:40:19 +00:00
|
|
|
if (c != 0 && c != 0xFF) {
|
2002-12-25 21:04:47 +00:00
|
|
|
_charset->_left = _charset->_nextLeft;
|
|
|
|
_charset->_top = _charset->_nextTop;
|
|
|
|
_charset->printChar(c);
|
|
|
|
_charset->_nextLeft = _charset->_left;
|
|
|
|
_charset->_nextTop = _charset->_top;
|
2002-10-06 07:23:08 +00:00
|
|
|
}
|
2003-01-16 00:40:19 +00:00
|
|
|
} while (c);
|
|
|
|
_haveMsg = 1;
|
2002-10-06 06:09:32 +00:00
|
|
|
|
2003-03-30 19:32:12 +00:00
|
|
|
// hack: more 8 pixels at width and height while redraw
|
2003-03-29 15:48:25 +00:00
|
|
|
// for proper description redraw while scrolling room
|
|
|
|
gdi._mask_left = _charset->_strLeft - 8;
|
|
|
|
gdi._mask_right = _charset->_strRight + 8;
|
2003-03-30 19:32:12 +00:00
|
|
|
gdi._mask_top = _charset->_strTop - 8;
|
|
|
|
gdi._mask_bottom = _charset->_strBottom + 8;
|
2002-10-06 06:09:32 +00:00
|
|
|
}
|
|
|
|
|
2003-03-06 17:58:13 +00:00
|
|
|
void Scumm::drawString(int a) {
|
2001-10-09 14:30:12 +00:00
|
|
|
byte buf[256];
|
2002-12-04 15:00:35 +00:00
|
|
|
byte *space;
|
2001-10-09 14:30:12 +00:00
|
|
|
int i;
|
2002-11-29 18:27:35 +00:00
|
|
|
byte fontHeight = 0, chr;
|
2001-10-26 17:34:50 +00:00
|
|
|
uint color;
|
2002-04-11 17:19:16 +00:00
|
|
|
|
2001-10-09 14:30:12 +00:00
|
|
|
_msgPtrToAdd = buf;
|
|
|
|
_messagePtr = addMessageToStack(_messagePtr);
|
|
|
|
|
2002-12-25 21:04:47 +00:00
|
|
|
_charset->_top = _string[a].ypos;
|
|
|
|
_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
|
|
|
|
2003-05-14 13:30:52 +00:00
|
|
|
if (!(_features & GF_AFTER_V2 || _features & GF_AFTER_V3)) {
|
2002-04-11 17:19:16 +00:00
|
|
|
for (i = 0; i < 4; i++)
|
2002-12-26 00:21:19 +00:00
|
|
|
_charsetColorMap[i] = _charsetData[_charset->getCurID()][i];
|
2002-02-16 03:59:18 +00:00
|
|
|
}
|
2002-02-16 19:03:14 +00:00
|
|
|
|
2003-05-14 13:30:52 +00:00
|
|
|
fontHeight = _charset->getFontHeight();
|
|
|
|
|
2001-10-09 14:30:12 +00:00
|
|
|
_msgPtrToAdd = buf;
|
|
|
|
|
2002-12-04 21:46:05 +00:00
|
|
|
// trim from the right
|
2001-10-09 14:30:12 +00:00
|
|
|
space = NULL;
|
2002-04-11 17:19:16 +00:00
|
|
|
while (*_msgPtrToAdd) {
|
|
|
|
if (*_msgPtrToAdd == ' ') {
|
|
|
|
if (!space)
|
|
|
|
space = _msgPtrToAdd;
|
2001-10-09 14:30:12 +00:00
|
|
|
} else {
|
|
|
|
space = NULL;
|
|
|
|
}
|
|
|
|
_msgPtrToAdd++;
|
|
|
|
}
|
2002-04-11 17:19:16 +00:00
|
|
|
if (space)
|
|
|
|
*space = '\0';
|
2002-12-25 21:04:47 +00:00
|
|
|
if (_charset->_center) {
|
2002-12-25 21:42:22 +00:00
|
|
|
_charset->_left -= _charset->getStringWidth(a, buf) >> 1;
|
2001-10-09 14:30:12 +00:00
|
|
|
}
|
|
|
|
|
2002-10-06 06:47:01 +00:00
|
|
|
if (!(_features & GF_AFTER_V7))
|
2002-12-25 21:04:47 +00:00
|
|
|
_charset->_ignoreCharsetMask = true;
|
2002-10-06 06:09:32 +00:00
|
|
|
|
|
|
|
|
2002-10-06 15:39:38 +00:00
|
|
|
// In Full Throttle (and other games?), verb text should always mask
|
|
|
|
// and never time out. We can't do it blindly for all games, because
|
|
|
|
// it causes problem with the FOA intro.
|
|
|
|
|
2002-12-27 16:55:22 +00:00
|
|
|
if (_gameId == GID_FT && a == 4)
|
2002-10-03 07:38:03 +00:00
|
|
|
_talkDelay = -1;
|
2001-10-09 14:30:12 +00:00
|
|
|
|
|
|
|
if (!buf[0]) {
|
|
|
|
buf[0] = ' ';
|
|
|
|
buf[1] = 0;
|
|
|
|
}
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
for (i = 0; (chr = buf[i++]) != 0;) {
|
2002-12-28 01:57:19 +00:00
|
|
|
if (chr == 0xFE || chr == 0xFF) {
|
2001-10-09 14:30:12 +00:00
|
|
|
chr = buf[i++];
|
2002-04-11 17:19:16 +00:00
|
|
|
switch (chr) {
|
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
|
|
|
}
|
2002-12-25 21:04:47 +00:00
|
|
|
_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 {
|
2002-10-02 17:23:19 +00:00
|
|
|
if (a == 1 && (_features & GF_AFTER_V6)) {
|
2002-09-22 01:17:53 +00:00
|
|
|
if (_string[a].no_talk_anim == 0)
|
2002-12-25 21:04:47 +00:00
|
|
|
_charset->_blitAlso = true;
|
2002-10-02 17:23:19 +00:00
|
|
|
}
|
2002-12-25 21:57:01 +00:00
|
|
|
_charset->printChar(chr);
|
2002-12-25 21:04:47 +00:00
|
|
|
_charset->_blitAlso = false;
|
2001-10-09 14:30:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-12-25 21:04:47 +00:00
|
|
|
_charset->_ignoreCharsetMask = false;
|
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;
|
2002-10-02 17:23:19 +00:00
|
|
|
}
|
|
|
|
|
2002-11-03 15:56:52 +00:00
|
|
|
|
2002-12-25 21:04:47 +00:00
|
|
|
_string[a].xpos = _charset->_strRight + 8; // Indy3: Fixes Grail Diary text positioning
|
2002-11-03 15:56:52 +00:00
|
|
|
|
2002-10-02 17:23:19 +00:00
|
|
|
if (_features & GF_AFTER_V7) {
|
2002-12-25 21:04:47 +00:00
|
|
|
_charset->_hasMask = true;
|
2002-12-31 14:59:06 +00:00
|
|
|
// FIXME - how is this supposed to ever work, since gdi._mask_left is by default set
|
2002-12-27 23:18:06 +00:00
|
|
|
// to -1 to mark it as invalid. Hence this comparision will always leave it at -1,
|
|
|
|
// which implies that if the mask was marked invalid, it will always stay so.
|
|
|
|
// That seems odd and not at all to be the intended thing... or is it?
|
2002-12-25 21:04:47 +00:00
|
|
|
if (_charset->_strLeft < gdi._mask_left)
|
|
|
|
gdi._mask_left = _charset->_strLeft;
|
|
|
|
if (_charset->_strRight > gdi._mask_right)
|
|
|
|
gdi._mask_right = _charset->_strRight;
|
|
|
|
if (_charset->_strTop < gdi._mask_top)
|
|
|
|
gdi._mask_top = _charset->_strTop;
|
|
|
|
if (_charset->_strBottom > gdi._mask_bottom)
|
|
|
|
gdi._mask_bottom = _charset->_strBottom;
|
2002-10-02 17:23:19 +00:00
|
|
|
}
|
2001-10-09 14:30:12 +00:00
|
|
|
}
|
|
|
|
|
2003-03-06 17:58:13 +00:00
|
|
|
byte *Scumm::addMessageToStack(byte *msg) {
|
2001-10-09 14:30:12 +00:00
|
|
|
int num, numorg;
|
2002-09-21 Matt Hargett <matt@use.net>
* scumm.dsp, scummvm.dsp, simon.dsp: Turn on warning as errors. Generate
PDBs on all builds.
* gameDetector.cpp, newgui.cpp, widget.cpp, actor.cpp,
dialogs.cpp, resource.cpp, saveload.cpp, scumm_renderer.cpp:
Fix warnings where possible. One pragma added to eliminate
warning of unknown pragmas.
* string.cpp: If unknown escape sequence, print warning.
svn-id: r4998
2002-09-22 03:53:53 +00:00
|
|
|
unsigned char *ptr, chr;
|
2001-10-09 14:30:12 +00:00
|
|
|
|
|
|
|
numorg = num = _numInMsgStack;
|
2001-11-05 19:21:49 +00:00
|
|
|
ptr = getResourceAddress(rtTemp, 6);
|
2001-10-09 14:30:12 +00:00
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
if (ptr == NULL)
|
2001-10-09 14:30:12 +00:00
|
|
|
error("Message stack not allocated");
|
|
|
|
|
2002-07-01 02:18:01 +00:00
|
|
|
if (msg == NULL) {
|
|
|
|
warning("Bad message in addMessageToStack, ignoring");
|
|
|
|
return NULL;
|
|
|
|
}
|
2002-02-12 21:28:07 +00:00
|
|
|
|
2002-10-24 21:39:45 +00:00
|
|
|
while ((ptr[num++] = chr = *msg++) != 0) {
|
2002-09-16 23:48:42 +00:00
|
|
|
if (num >= 500)
|
2001-10-09 14:30:12 +00:00
|
|
|
error("Message stack overflow");
|
|
|
|
|
2002-09-16 23:48:42 +00:00
|
|
|
if (chr == 0xff) { // 0xff is an escape character
|
|
|
|
ptr[num++] = chr = *msg++; // followed by a "command" code
|
2002-04-11 17:19:16 +00:00
|
|
|
if (chr != 1 && chr != 2 && chr != 3 && chr != 8) {
|
2002-09-16 23:48:42 +00:00
|
|
|
ptr[num++] = *msg++; // and some commands are followed by parameters to the functions below
|
|
|
|
ptr[num++] = *msg++; // these are numbers of names, strings, verbs, variables, etc
|
2002-12-23 18:30:12 +00:00
|
|
|
if (_features & GF_AFTER_V8) {
|
|
|
|
ptr[num++] = *msg++;
|
|
|
|
ptr[num++] = *msg++;
|
|
|
|
}
|
2001-10-09 14:30:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2002-04-11 17:19:16 +00:00
|
|
|
|
2001-10-09 14:30:12 +00:00
|
|
|
_numInMsgStack = num;
|
|
|
|
num = numorg;
|
|
|
|
|
|
|
|
while (1) {
|
2001-11-05 19:21:49 +00:00
|
|
|
ptr = getResourceAddress(rtTemp, 6);
|
2001-10-09 14:30:12 +00:00
|
|
|
chr = ptr[num++];
|
2002-04-11 17:19:16 +00:00
|
|
|
if (chr == 0)
|
2001-10-09 14:30:12 +00:00
|
|
|
break;
|
|
|
|
if (chr == 0xFF) {
|
|
|
|
chr = ptr[num++];
|
2002-04-11 17:19:16 +00:00
|
|
|
switch (chr) {
|
2001-10-09 14:30:12 +00:00
|
|
|
case 4:
|
2002-12-23 18:30:12 +00:00
|
|
|
if (_features & GF_AFTER_V8) {
|
|
|
|
addIntToStack(READ_LE_UINT32(ptr + num));
|
|
|
|
num += 4;
|
|
|
|
} else {
|
|
|
|
addIntToStack(READ_LE_UINT16(ptr + num));
|
|
|
|
num += 2;
|
|
|
|
}
|
2001-10-09 14:30:12 +00:00
|
|
|
break;
|
|
|
|
case 5:
|
2002-12-23 18:30:12 +00:00
|
|
|
if (_features & GF_AFTER_V8) {
|
|
|
|
addVerbToStack(READ_LE_UINT32(ptr + num));
|
|
|
|
num += 4;
|
|
|
|
} else {
|
|
|
|
addVerbToStack(READ_LE_UINT16(ptr + num));
|
|
|
|
num += 2;
|
|
|
|
}
|
2001-10-09 14:30:12 +00:00
|
|
|
break;
|
|
|
|
case 6:
|
2002-12-23 18:30:12 +00:00
|
|
|
if (_features & GF_AFTER_V8) {
|
|
|
|
addNameToStack(READ_LE_UINT32(ptr + num));
|
|
|
|
num += 4;
|
|
|
|
} else {
|
|
|
|
addNameToStack(READ_LE_UINT16(ptr + num));
|
|
|
|
num += 2;
|
|
|
|
}
|
2001-10-09 14:30:12 +00:00
|
|
|
break;
|
|
|
|
case 7:
|
2002-12-23 18:30:12 +00:00
|
|
|
if (_features & GF_AFTER_V8) {
|
|
|
|
addStringToStack(READ_LE_UINT32(ptr + num));
|
|
|
|
num += 4;
|
|
|
|
} else {
|
|
|
|
addStringToStack(READ_LE_UINT16(ptr + num));
|
|
|
|
num += 2;
|
|
|
|
}
|
2001-10-09 14:30:12 +00:00
|
|
|
break;
|
2002-10-13 05:39:26 +00:00
|
|
|
case 3:
|
2002-04-11 17:19:16 +00:00
|
|
|
case 9:
|
2001-10-23 19:51:50 +00:00
|
|
|
//#if defined(DOTT)
|
2002-04-11 17:19:16 +00:00
|
|
|
case 10:
|
|
|
|
case 12:
|
|
|
|
case 13:
|
|
|
|
case 14:
|
2001-10-23 19:51:50 +00:00
|
|
|
//#endif
|
2001-10-09 14:30:12 +00:00
|
|
|
*_msgPtrToAdd++ = 0xFF;
|
|
|
|
*_msgPtrToAdd++ = chr;
|
2001-10-16 10:01:48 +00:00
|
|
|
*_msgPtrToAdd++ = ptr[num++];
|
|
|
|
*_msgPtrToAdd++ = ptr[num++];
|
2002-12-28 01:57:19 +00:00
|
|
|
if (_features & GF_AFTER_V8) {
|
|
|
|
// FIXME - is this right?!?
|
|
|
|
*_msgPtrToAdd++ = ptr[num++];
|
|
|
|
*_msgPtrToAdd++ = ptr[num++];
|
|
|
|
}
|
2001-10-09 14:30:12 +00:00
|
|
|
break;
|
2002-09-21 Matt Hargett <matt@use.net>
* scumm.dsp, scummvm.dsp, simon.dsp: Turn on warning as errors. Generate
PDBs on all builds.
* gameDetector.cpp, newgui.cpp, widget.cpp, actor.cpp,
dialogs.cpp, resource.cpp, saveload.cpp, scumm_renderer.cpp:
Fix warnings where possible. One pragma added to eliminate
warning of unknown pragmas.
* string.cpp: If unknown escape sequence, print warning.
svn-id: r4998
2002-09-22 03:53:53 +00:00
|
|
|
default:
|
2002-11-05 10:18:04 +00:00
|
|
|
debug(2, "addMessageToStack(): string escape sequence %d unknown", chr);
|
2001-10-09 14:30:12 +00:00
|
|
|
*_msgPtrToAdd++ = 0xFF;
|
|
|
|
*_msgPtrToAdd++ = chr;
|
2002-09-21 Matt Hargett <matt@use.net>
* scumm.dsp, scummvm.dsp, simon.dsp: Turn on warning as errors. Generate
PDBs on all builds.
* gameDetector.cpp, newgui.cpp, widget.cpp, actor.cpp,
dialogs.cpp, resource.cpp, saveload.cpp, scumm_renderer.cpp:
Fix warnings where possible. One pragma added to eliminate
warning of unknown pragmas.
* string.cpp: If unknown escape sequence, print warning.
svn-id: r4998
2002-09-22 03:53:53 +00:00
|
|
|
break;
|
2001-10-09 14:30:12 +00:00
|
|
|
}
|
|
|
|
} else {
|
2002-04-11 17:19:16 +00:00
|
|
|
if (chr != '@') {
|
2001-10-09 14:30:12 +00:00
|
|
|
*_msgPtrToAdd++ = chr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*_msgPtrToAdd = 0;
|
|
|
|
_numInMsgStack = numorg;
|
2002-04-11 17:19:16 +00:00
|
|
|
|
2001-10-09 14:30:12 +00:00
|
|
|
return msg;
|
|
|
|
}
|
|
|
|
|
2003-03-06 17:58:13 +00:00
|
|
|
void Scumm::addIntToStack(int var) {
|
2002-04-11 17:19:16 +00:00
|
|
|
int num, max;
|
2001-10-09 14:30:12 +00:00
|
|
|
byte flag;
|
2002-04-11 17:19:16 +00:00
|
|
|
|
2001-10-09 14:30:12 +00:00
|
|
|
num = readVar(var);
|
|
|
|
if (num < 0) {
|
|
|
|
*_msgPtrToAdd++ = '-';
|
|
|
|
num = -num;
|
|
|
|
}
|
|
|
|
|
|
|
|
flag = 0;
|
|
|
|
max = 10000;
|
|
|
|
do {
|
2002-04-11 17:19:16 +00:00
|
|
|
if (num >= max || flag) {
|
|
|
|
*_msgPtrToAdd++ = num / max + '0';
|
|
|
|
num -= (num / max) * max;
|
|
|
|
flag = 1;
|
2001-10-09 14:30:12 +00:00
|
|
|
}
|
2002-04-11 17:19:16 +00:00
|
|
|
max /= 10;
|
|
|
|
if (max == 1)
|
|
|
|
flag = 1;
|
2001-10-09 14:30:12 +00:00
|
|
|
} while (max);
|
|
|
|
}
|
|
|
|
|
2002-09-16 23:48:42 +00:00
|
|
|
void Scumm::addVerbToStack(int var)
|
2002-04-11 17:19:16 +00:00
|
|
|
{
|
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) {
|
2002-12-29 19:51:27 +00:00
|
|
|
for (k = 1; k < _maxVerbs; k++) {
|
|
|
|
if (num == _verbs[k].verbid && !_verbs[k].type && !_verbs[k].saveid) {
|
|
|
|
byte *ptr = getResourceAddress(rtVerb, k);
|
|
|
|
if ((_features & GF_AFTER_V8) && (ptr[0] == '/')) {
|
|
|
|
char pointer[20];
|
|
|
|
int i, j;
|
|
|
|
|
|
|
|
translateText(ptr, _transText);
|
|
|
|
|
|
|
|
for (i = 0, j = 0; (ptr[i] != '/' || j == 0) && j < 19; i++) {
|
|
|
|
if (ptr[i] != '/')
|
|
|
|
pointer[j++] = ptr[i];
|
|
|
|
}
|
|
|
|
pointer[j] = 0;
|
|
|
|
_sound->_talkChannel = _sound->playBundleSound(pointer);
|
|
|
|
addMessageToStack(_transText);
|
|
|
|
} else {
|
|
|
|
addMessageToStack(ptr);
|
|
|
|
}
|
2001-10-09 14:30:12 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
2002-04-11 17:19:16 +00:00
|
|
|
addMessageToStack((byte *)"");
|
2001-10-09 14:30:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-09-16 23:48:42 +00:00
|
|
|
void Scumm::addNameToStack(int var)
|
2002-04-11 17:19:16 +00:00
|
|
|
{
|
2001-10-09 14:30:12 +00:00
|
|
|
int num;
|
|
|
|
|
|
|
|
num = readVar(var);
|
|
|
|
if (num) {
|
2003-01-16 11:27:02 +00:00
|
|
|
byte *ptr = getObjOrActorName(num);
|
|
|
|
if ((_features & GF_AFTER_V8) && (ptr[0] == '/')) {
|
|
|
|
char pointer[20];
|
|
|
|
int i, j;
|
|
|
|
|
|
|
|
translateText(ptr, _transText);
|
|
|
|
for (i = 0, j = 0; (ptr[i] != '/' || j == 0) && j < 19; i++) {
|
|
|
|
if (ptr[i] != '/')
|
|
|
|
pointer[j++] = ptr[i];
|
|
|
|
}
|
|
|
|
pointer[j] = 0;
|
|
|
|
|
|
|
|
addMessageToStack(_transText);
|
|
|
|
} else {
|
|
|
|
addMessageToStack(ptr);
|
|
|
|
}
|
2001-10-09 14:30:12 +00:00
|
|
|
} else {
|
2002-04-11 17:19:16 +00:00
|
|
|
addMessageToStack((byte *)"");
|
2001-10-09 14:30:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-03-06 17:58:13 +00:00
|
|
|
void Scumm::addStringToStack(int var) {
|
2001-10-09 14:30:12 +00:00
|
|
|
byte *ptr;
|
2001-10-24 20:12:52 +00:00
|
|
|
|
2002-07-12 21:36:20 +00:00
|
|
|
if (_features & GF_AFTER_V6 || _gameId == GID_INDY3_256)
|
|
|
|
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) {
|
2002-12-29 19:51:27 +00:00
|
|
|
if ((_features & GF_AFTER_V8) && (ptr[0] == '/')) {
|
|
|
|
char pointer[20];
|
|
|
|
int i, j;
|
2002-12-29 17:46:12 +00:00
|
|
|
|
2002-12-29 19:51:27 +00:00
|
|
|
translateText(ptr, _transText);
|
2002-12-29 17:46:12 +00:00
|
|
|
|
2002-12-29 19:51:27 +00:00
|
|
|
for (i = 0, j = 0; (ptr[i] != '/' || j == 0) && j < 19; i++) {
|
|
|
|
if (ptr[i] != '/')
|
|
|
|
pointer[j++] = ptr[i];
|
|
|
|
}
|
|
|
|
pointer[j] = 0;
|
2003-01-16 11:27:02 +00:00
|
|
|
|
2002-12-29 17:46:12 +00:00
|
|
|
addMessageToStack(_transText);
|
2002-12-29 19:51:27 +00:00
|
|
|
} else {
|
2002-12-29 17:46:12 +00:00
|
|
|
addMessageToStack(ptr);
|
|
|
|
}
|
2001-10-09 14:30:12 +00:00
|
|
|
}
|
2002-12-29 19:51:27 +00:00
|
|
|
} else
|
|
|
|
addMessageToStack((byte *)"");
|
2001-10-09 14:30:12 +00:00
|
|
|
}
|
|
|
|
|
2003-03-06 17:58:13 +00:00
|
|
|
void Scumm::initCharset(int charsetno) {
|
2001-10-09 14:30:12 +00:00
|
|
|
int i;
|
2002-03-19 14:39:02 +00:00
|
|
|
|
2003-04-29 10:26:35 +00:00
|
|
|
if (!getResourceAddress(rtCharset, charsetno))
|
2002-04-11 17:19:16 +00:00
|
|
|
loadCharset(charsetno);
|
2001-10-09 14:30:12 +00:00
|
|
|
|
2002-09-22 01:17:53 +00:00
|
|
|
_string[0].t_charset = charsetno;
|
|
|
|
_string[1].t_charset = charsetno;
|
2001-10-09 14:30:12 +00:00
|
|
|
|
2002-11-29 18:27:35 +00:00
|
|
|
for (i = 0; i < 16; i++)
|
2002-12-26 00:21:19 +00:00
|
|
|
_charsetColorMap[i] = _charsetData[_charset->getCurID()][i];
|
2001-10-09 14:30:12 +00:00
|
|
|
}
|
2002-12-25 21:42:22 +00:00
|
|
|
|
2003-03-06 17:58:13 +00:00
|
|
|
int indexCompare(const void *p1, const void *p2) {
|
2003-02-14 16:01:55 +00:00
|
|
|
struct langIndexNode *i1 = (struct langIndexNode *) p1;
|
|
|
|
struct langIndexNode *i2 = (struct langIndexNode *) p2;
|
|
|
|
|
|
|
|
return strcmp(i1->tag, i2->tag);
|
|
|
|
}
|
|
|
|
|
2002-09-17 09:18:47 +00:00
|
|
|
void Scumm::loadLanguageBundle() {
|
|
|
|
File file;
|
2003-02-14 16:01:55 +00:00
|
|
|
int32 size;
|
2002-09-17 09:18:47 +00:00
|
|
|
|
2003-01-30 08:10:16 +00:00
|
|
|
if (_gameId == GID_DIG) {
|
|
|
|
file.open("language.bnd", _gameDataPath);
|
|
|
|
} else if (_gameId == GID_CMI) {
|
|
|
|
file.open("language.tab", _gameDataPath);
|
|
|
|
} else {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2002-09-17 09:18:47 +00:00
|
|
|
if(file.isOpen() == false) {
|
|
|
|
_existLanguageFile = false;
|
|
|
|
return;
|
|
|
|
}
|
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
|
|
|
|
|
|
|
// Create an index of the language file.
|
|
|
|
// FIXME: Extend this mechanism to also cover The Dig?
|
|
|
|
|
|
|
|
if (_gameId == GID_CMI) {
|
|
|
|
int32 i;
|
|
|
|
char *ptr = _languageBuffer;
|
|
|
|
|
|
|
|
// Count the number of lines in the language file.
|
|
|
|
|
|
|
|
_languageStrCount = 0;
|
|
|
|
|
|
|
|
for (;;) {
|
|
|
|
ptr = strpbrk(ptr, "\n\r");
|
|
|
|
if (ptr == NULL)
|
|
|
|
break;
|
|
|
|
while (*ptr == '\n' || *ptr == '\r')
|
|
|
|
ptr++;
|
|
|
|
_languageStrCount++;
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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.
|
|
|
|
|
|
|
|
_languageIndex = (struct langIndexNode *) malloc(_languageStrCount * sizeof(struct langIndexNode));
|
|
|
|
|
|
|
|
ptr = _languageBuffer;
|
|
|
|
|
|
|
|
for (i = 0; i < _languageStrCount; i++) {
|
|
|
|
int j;
|
|
|
|
|
|
|
|
for (j = 0; j < 8 && !isspace(ptr[j]); j++)
|
|
|
|
_languageIndex[i].tag[j] = toupper(ptr[j]);
|
|
|
|
_languageIndex[i].tag[j] = 0;
|
|
|
|
ptr += (j + 1);
|
|
|
|
_languageIndex[i].offset = ptr - _languageBuffer;
|
|
|
|
ptr = strpbrk(ptr, "\n\r");
|
|
|
|
if (ptr == NULL)
|
|
|
|
break;
|
|
|
|
while (*ptr == '\n' || *ptr == '\r')
|
|
|
|
ptr++;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Conceptually, it may be more elegant to construct the
|
|
|
|
// index so that it is sorted, or otherwise ordered, from the
|
|
|
|
// start. However, this is less error-prone and likely to be
|
|
|
|
// much more optimized than anything I might implement.
|
|
|
|
|
|
|
|
qsort(_languageIndex, _languageStrCount, sizeof(struct langIndexNode), indexCompare);
|
|
|
|
free(_languageBuffer);
|
|
|
|
}
|
|
|
|
|
2002-09-17 09:18:47 +00:00
|
|
|
_existLanguageFile = true;
|
|
|
|
}
|
|
|
|
|
2002-11-06 14:19:50 +00:00
|
|
|
void Scumm::translateText(byte *text, byte *trans_buff) {
|
2003-03-12 19:53:02 +00:00
|
|
|
char name[20], tmp[500], tmp2[20], num_s[20], number[4], enc;
|
|
|
|
int32 num, l, j, k, r, pos = 0;
|
|
|
|
char *buf = _languageBuffer;
|
2002-09-17 09:18:47 +00:00
|
|
|
|
2003-03-12 19:53:02 +00:00
|
|
|
if (_gameId == GID_CMI) {
|
|
|
|
if ((text[0] == '/') && (_existLanguageFile == true)) {
|
2003-02-14 16:01:55 +00:00
|
|
|
struct langIndexNode target;
|
2003-04-07 16:04:30 +00:00
|
|
|
struct langIndexNode *found = NULL;
|
2003-02-14 16:01:55 +00:00
|
|
|
|
2003-01-30 08:10:16 +00:00
|
|
|
// copy name from text /..../
|
2003-02-14 16:01:55 +00:00
|
|
|
for (l = 0; (l < 8) && (text[l + 1] != '/'); l++)
|
|
|
|
target.tag[l] = toupper(text[l + 1]);
|
|
|
|
target.tag[l] = 0;
|
|
|
|
|
2003-04-07 16:04:30 +00:00
|
|
|
// HACK: These are used for the object line when
|
|
|
|
// 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.
|
2003-02-14 16:01:55 +00:00
|
|
|
|
2003-04-07 16:04:30 +00:00
|
|
|
if (strcmp(target.tag, "PU_M001") != 0 && strcmp(target.tag, "PU_M002") != 0)
|
|
|
|
found = (struct langIndexNode *)bsearch(&target, _languageIndex, _languageStrCount, sizeof(struct langIndexNode), indexCompare);
|
2003-02-14 16:01:55 +00:00
|
|
|
if (found != NULL) {
|
|
|
|
File file;
|
|
|
|
|
|
|
|
file.open("language.tab", _gameDataPath);
|
|
|
|
if (file.isOpen()) {
|
|
|
|
byte *ptr = trans_buff;
|
|
|
|
byte c;
|
|
|
|
|
|
|
|
file.seek(found->offset, SEEK_SET);
|
|
|
|
for (;;) {
|
|
|
|
c = file.readByte();
|
|
|
|
if (c == 10 || c == 13) {
|
|
|
|
*ptr = 0;
|
|
|
|
break;
|
|
|
|
} else
|
|
|
|
*ptr++ = c;
|
|
|
|
}
|
|
|
|
file.close();
|
2003-01-30 08:10:16 +00:00
|
|
|
return;
|
2003-03-12 19:53:02 +00:00
|
|
|
} else {
|
|
|
|
// Some evil person removed the language file?
|
|
|
|
_existLanguageFile = false;
|
2003-01-30 08:10:16 +00:00
|
|
|
}
|
|
|
|
}
|
2003-03-12 19:53:02 +00:00
|
|
|
}
|
|
|
|
byte *pointer = (byte *)strchr((char *)text + 1, '/');
|
|
|
|
if (pointer != NULL) {
|
|
|
|
pointer++;
|
|
|
|
memcpy(trans_buff, pointer, resStrLen(pointer) + 1);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
} else if (_gameId == GID_DIG) {
|
|
|
|
if ((text[0] == '/') && (_existLanguageFile == true)) {
|
2003-01-30 08:10:16 +00:00
|
|
|
// copy name from text /..../
|
|
|
|
for (l = 0; (l < 20) && (text[l + 1] != '.'); l++) {
|
|
|
|
name[l] = text[l + 1];
|
|
|
|
}
|
|
|
|
name[l] = 0;
|
|
|
|
l++;
|
|
|
|
// get number from text /..../
|
|
|
|
number[0] = text[l + 1];
|
|
|
|
number[1] = text[l + 2];
|
|
|
|
number[2] = text[l + 3];
|
|
|
|
number[3] = 0;
|
|
|
|
num = atol(number);
|
|
|
|
sprintf(num_s, "%d", num);
|
|
|
|
|
|
|
|
// determine is file encoded
|
|
|
|
if (buf[pos] == 'e') {
|
|
|
|
enc = 0x13;
|
|
|
|
pos += 3;
|
|
|
|
} else {
|
|
|
|
enc = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// skip translation if flag 'h' exist
|
|
|
|
if (buf[pos] == 'h') {
|
|
|
|
pos += 3;
|
2003-03-06 17:58:13 +00:00
|
|
|
byte *pointer = (byte *)strchr((char *)text + 1, '/');
|
2003-01-30 08:10:16 +00:00
|
|
|
if (pointer != NULL)
|
|
|
|
memcpy(trans_buff, pointer + 1, resStrLen(pointer + 1) + 1);
|
|
|
|
else
|
|
|
|
trans_buff[0] = '\0';
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
for(;;) {
|
|
|
|
// search char @
|
|
|
|
if (buf[pos++] == '@') {
|
|
|
|
// copy name after @ to endline
|
2002-09-17 09:18:47 +00:00
|
|
|
l = 0;
|
2003-01-30 08:10:16 +00:00
|
|
|
do {
|
|
|
|
tmp[l++] = buf[pos++];
|
|
|
|
} while((buf[pos] != 0x0d) && (buf[pos + 1] != 0x0a) && (l < 19));
|
|
|
|
tmp[l] = 0;
|
|
|
|
pos += 2;
|
|
|
|
// compare 'name' with above name
|
|
|
|
if (strcmp(tmp, name) == 0) {
|
|
|
|
// get number lines of 'name' after '#'
|
|
|
|
l = 0;
|
|
|
|
if (buf[pos++] == '#') {
|
2002-09-17 09:18:47 +00:00
|
|
|
do {
|
2003-01-30 08:10:16 +00:00
|
|
|
tmp[l++] = buf[pos++];
|
|
|
|
} while((buf[pos] != 0x0d) && (buf[pos + 1] != 0x0a) && (l < 19));
|
|
|
|
tmp[l] = 0;
|
|
|
|
pos += 2;
|
|
|
|
l = atol(tmp);
|
|
|
|
// get number of line
|
|
|
|
for(r = 0; r < l; r++) {
|
|
|
|
j = 0;
|
2002-09-17 09:18:47 +00:00
|
|
|
do {
|
2003-01-30 08:10:16 +00:00
|
|
|
tmp2[j++] = buf[pos++];
|
|
|
|
} while(buf[pos] != '/');
|
|
|
|
tmp2[j] = 0;
|
|
|
|
// compare if is right line
|
|
|
|
if (strcmp(tmp2, num_s) == 0) {
|
|
|
|
k = 0;
|
|
|
|
pos++;
|
|
|
|
// copy translated text to tran_buffer
|
|
|
|
do {
|
|
|
|
trans_buff[k++] = (buf[pos++]) ^ enc;
|
|
|
|
} while((buf[pos] != 0x0d) && (buf[pos + 1] != 0x0a));
|
|
|
|
trans_buff[k] = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// goto next line
|
|
|
|
do {
|
|
|
|
pos++;
|
|
|
|
} while((buf[pos] != 0x0d) && (buf[pos + 1] != 0x0a));
|
|
|
|
pos += 2;
|
2002-09-17 09:18:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2003-03-06 17:58:13 +00:00
|
|
|
byte *pointer = (byte *)strchr((char *)text + 1, '/');
|
2003-03-08 17:39:18 +00:00
|
|
|
if (pointer != NULL) {
|
|
|
|
pointer++;
|
2003-03-12 19:53:02 +00:00
|
|
|
l = 0;
|
2003-03-08 17:39:18 +00:00
|
|
|
while (*pointer != '/' && *pointer != 0xff && *pointer != 0) {
|
|
|
|
trans_buff[l++] = *pointer++;
|
|
|
|
}
|
|
|
|
trans_buff[l] = '\0';
|
2003-03-12 19:53:02 +00:00
|
|
|
return;
|
2003-03-08 17:39:18 +00:00
|
|
|
}
|
2002-09-17 09:18:47 +00:00
|
|
|
}
|
2002-12-28 15:16:26 +00:00
|
|
|
memcpy(trans_buff, text, resStrLen(text) + 1);
|
2002-09-17 09:18:47 +00:00
|
|
|
}
|
|
|
|
|