2012-09-26 23:34:10 +10:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
|
|
|
*
|
|
|
|
* ScummVM is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
|
|
* file distributed with this source distribution.
|
|
|
|
*
|
|
|
|
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "common/system.h"
|
2012-09-27 23:05:09 +10:00
|
|
|
#include "common/endian.h"
|
|
|
|
#include "common/file.h"
|
2012-09-26 23:34:10 +10:00
|
|
|
#include "common/textconsole.h"
|
|
|
|
#include "hopkins/talk.h"
|
|
|
|
#include "hopkins/files.h"
|
|
|
|
#include "hopkins/globals.h"
|
|
|
|
#include "hopkins/graphics.h"
|
|
|
|
#include "hopkins/hopkins.h"
|
|
|
|
#include "hopkins/objects.h"
|
|
|
|
|
|
|
|
namespace Hopkins {
|
|
|
|
|
2012-10-25 08:34:37 +11:00
|
|
|
TalkManager::TalkManager() {
|
2012-12-19 08:00:22 +01:00
|
|
|
_characterBuffer = NULL;
|
|
|
|
_characterPalette = NULL;
|
2012-12-17 08:01:29 +01:00
|
|
|
_characterSprite = NULL;
|
2012-12-27 07:52:37 +01:00
|
|
|
_characterAnim = NULL;
|
2012-12-19 08:00:22 +01:00
|
|
|
_characterSize = 0;
|
2013-01-16 21:15:30 +01:00
|
|
|
STATI = false;
|
2013-01-20 00:56:19 +01:00
|
|
|
_dialogueMesgId1 = _dialogueMesgId2 = _dialogueMesgId3 = _dialogueMesgId4 = 0;
|
2012-12-27 07:52:37 +01:00
|
|
|
_paletteBufferIdx = 0;
|
2012-10-25 08:34:37 +11:00
|
|
|
}
|
|
|
|
|
2012-09-26 23:34:10 +10:00
|
|
|
void TalkManager::setParent(HopkinsEngine *vm) {
|
|
|
|
_vm = vm;
|
|
|
|
}
|
|
|
|
|
2012-09-28 22:15:59 +10:00
|
|
|
void TalkManager::PARLER_PERSO(const Common::String &filename) {
|
2012-12-26 21:30:51 +01:00
|
|
|
Common::String spriteFilename;
|
2012-09-28 22:15:59 +10:00
|
|
|
|
2012-12-12 00:22:18 +01:00
|
|
|
_vm->_fontManager.hideText(5);
|
|
|
|
_vm->_fontManager.hideText(9);
|
2012-09-28 22:15:59 +10:00
|
|
|
_vm->_eventsManager.VBL();
|
2013-01-20 00:56:19 +01:00
|
|
|
_vm->_graphicsManager._scrollStatus = 1;
|
2012-12-10 23:57:59 +01:00
|
|
|
bool oldDisableInventFl = _vm->_globals._disableInventFl;
|
|
|
|
_vm->_globals._disableInventFl = true;
|
2012-12-19 08:00:22 +01:00
|
|
|
_characterBuffer = _vm->_fileManager.searchCat(filename, 5);
|
|
|
|
_characterSize = _vm->_globals._catalogSize;
|
|
|
|
if (_characterBuffer == g_PTRNUL) {
|
2013-01-07 23:56:39 +01:00
|
|
|
_characterBuffer = _vm->_fileManager.loadFile(filename);
|
|
|
|
_characterSize = _vm->_fileManager.fileSize(filename);
|
2012-09-28 22:15:59 +10:00
|
|
|
}
|
2013-01-21 18:59:17 +01:00
|
|
|
_vm->_globals._saveData->_data[svField4] = 0;
|
2012-12-26 21:30:51 +01:00
|
|
|
getStringFromBuffer(40, spriteFilename, (const char *)_characterBuffer);
|
|
|
|
getStringFromBuffer(0, _questionsFilename, (const char *)_characterBuffer);
|
|
|
|
getStringFromBuffer(20, _answersFilename, (const char *)_characterBuffer);
|
2012-12-24 11:36:53 +01:00
|
|
|
if (_vm->_globals._language == LANG_FR) {
|
2012-12-19 08:00:22 +01:00
|
|
|
_answersFilename = _questionsFilename = "RUE.TXT";
|
2012-12-24 11:36:53 +01:00
|
|
|
} else if (_vm->_globals._language == LANG_EN) {
|
2012-12-19 08:00:22 +01:00
|
|
|
_answersFilename = _questionsFilename = "RUEAN.TXT";
|
2012-12-24 11:36:53 +01:00
|
|
|
} else if (_vm->_globals._language == LANG_SP) {
|
2012-12-19 08:00:22 +01:00
|
|
|
_answersFilename = _questionsFilename = "RUEES.TXT";
|
2012-09-28 22:15:59 +10:00
|
|
|
}
|
2013-01-20 00:56:19 +01:00
|
|
|
_dialogueMesgId1 = (int16)READ_LE_UINT16((uint16 *)_characterBuffer + 40);
|
2012-12-27 07:52:37 +01:00
|
|
|
_paletteBufferIdx = 20 * (int16)READ_LE_UINT16((uint16 *)_characterBuffer + 42) + 110;
|
2012-12-26 21:30:51 +01:00
|
|
|
_characterSprite = _vm->_fileManager.searchCat(spriteFilename, 7);
|
2012-12-17 08:01:29 +01:00
|
|
|
if (_characterSprite) {
|
2013-01-07 23:56:39 +01:00
|
|
|
_characterSprite = _vm->_objectsManager.loadSprite(spriteFilename);
|
2012-09-28 22:15:59 +10:00
|
|
|
} else {
|
2013-01-07 23:56:39 +01:00
|
|
|
_characterSprite = _vm->_objectsManager.loadSprite("RES_SAN.RES");
|
2012-09-28 22:15:59 +10:00
|
|
|
}
|
2012-10-24 22:49:32 +11:00
|
|
|
|
2012-12-19 08:00:22 +01:00
|
|
|
if (_vm->_graphicsManager._lineNbr == SCREEN_WIDTH)
|
2013-01-07 23:56:39 +01:00
|
|
|
_vm->_saveLoadManager.saveFile("TEMP.SCR", _vm->_graphicsManager._vesaScreen, 307200);
|
2012-12-19 08:00:22 +01:00
|
|
|
else if (_vm->_graphicsManager._lineNbr == (SCREEN_WIDTH * 2))
|
2013-01-07 23:56:39 +01:00
|
|
|
_vm->_saveLoadManager.saveFile("TEMP.SCR", _vm->_graphicsManager._vesaScreen, 614400);
|
2012-10-24 22:49:32 +11:00
|
|
|
|
2012-12-19 08:00:22 +01:00
|
|
|
if (!_vm->_graphicsManager._lineNbr)
|
2013-01-01 13:53:07 +01:00
|
|
|
_vm->_graphicsManager._scrollOffset = 0;
|
2013-01-07 13:24:04 +02:00
|
|
|
_vm->_graphicsManager.NB_SCREEN(true);
|
2012-10-29 23:08:23 +01:00
|
|
|
_vm->_objectsManager.PERSO_ON = true;
|
2012-12-27 07:52:37 +01:00
|
|
|
searchCharacterPalette(_paletteBufferIdx, false);
|
|
|
|
startCharacterAnim0(_paletteBufferIdx, false);
|
2012-12-17 08:01:29 +01:00
|
|
|
initCharacterAnim();
|
2013-01-20 00:56:19 +01:00
|
|
|
_dialogueMesgId2 = _dialogueMesgId1 + 1;
|
|
|
|
_dialogueMesgId3 = _dialogueMesgId1 + 2;
|
|
|
|
_dialogueMesgId4 = _dialogueMesgId1 + 3;
|
2013-01-23 01:38:34 +01:00
|
|
|
int oldMouseCursorId = _vm->_eventsManager._mouseCursorId;
|
2012-12-11 08:31:07 +01:00
|
|
|
_vm->_eventsManager._mouseCursorId = 4;
|
2012-12-11 01:53:50 +01:00
|
|
|
_vm->_eventsManager.changeMouseCursor(0);
|
2013-01-23 01:38:34 +01:00
|
|
|
if (!_vm->_globals._introSpeechOffFl) {
|
|
|
|
int answer = 0;
|
|
|
|
int dlgAnswer;
|
2012-09-28 22:15:59 +10:00
|
|
|
do {
|
2013-01-23 01:38:34 +01:00
|
|
|
dlgAnswer = dialogQuestion();
|
|
|
|
if (dlgAnswer != _dialogueMesgId4)
|
|
|
|
answer = dialogAnswer(dlgAnswer);
|
2012-12-26 21:30:51 +01:00
|
|
|
if (answer == -1)
|
2013-01-23 01:38:34 +01:00
|
|
|
dlgAnswer = _dialogueMesgId4;
|
2012-09-28 22:15:59 +10:00
|
|
|
_vm->_eventsManager.VBL();
|
2013-01-23 01:38:34 +01:00
|
|
|
} while (dlgAnswer != _dialogueMesgId4);
|
2012-09-28 22:15:59 +10:00
|
|
|
}
|
2013-01-23 01:38:34 +01:00
|
|
|
if (_vm->_globals._introSpeechOffFl) {
|
|
|
|
int idx = 1;
|
|
|
|
int answer;
|
2012-09-28 22:15:59 +10:00
|
|
|
do
|
2013-01-23 01:38:34 +01:00
|
|
|
answer = dialogAnswer(idx++);
|
|
|
|
while (answer != -1);
|
2012-09-28 22:15:59 +10:00
|
|
|
}
|
2012-12-09 22:35:59 +01:00
|
|
|
clearCharacterAnim();
|
2013-01-23 01:38:34 +01:00
|
|
|
_vm->_globals._introSpeechOffFl = false;
|
2012-12-19 08:00:22 +01:00
|
|
|
_characterBuffer = _vm->_globals.freeMemory(_characterBuffer);
|
2012-12-17 08:01:29 +01:00
|
|
|
_characterSprite = _vm->_globals.freeMemory(_characterSprite);
|
2013-01-07 13:24:04 +02:00
|
|
|
_vm->_graphicsManager.NB_SCREEN(false);
|
2012-10-24 23:20:26 +11:00
|
|
|
|
2012-12-20 00:30:01 +01:00
|
|
|
_vm->_saveLoadManager.load("TEMP.SCR", _vm->_graphicsManager._vesaScreen);
|
2012-10-28 18:04:06 +11:00
|
|
|
g_system->getSavefileManager()->removeSavefile("TEMP.SCR");
|
2012-10-24 23:20:26 +11:00
|
|
|
|
2012-10-29 23:08:23 +01:00
|
|
|
_vm->_objectsManager.PERSO_ON = false;
|
2013-01-23 01:38:34 +01:00
|
|
|
_vm->_eventsManager._mouseCursorId = oldMouseCursorId;
|
2012-12-14 01:49:22 +01:00
|
|
|
|
2013-01-23 01:38:34 +01:00
|
|
|
_vm->_eventsManager.changeMouseCursor(oldMouseCursorId);
|
2012-09-28 22:15:59 +10:00
|
|
|
_vm->_graphicsManager.SETCOLOR3(253, 100, 100, 100);
|
2012-10-31 22:15:09 +01:00
|
|
|
|
|
|
|
if (_vm->getIsDemo() == false)
|
|
|
|
_vm->_graphicsManager.SETCOLOR3(254, 0, 0, 0);
|
|
|
|
|
2012-12-23 20:36:08 +01:00
|
|
|
_vm->_graphicsManager.initColorTable(145, 150, _vm->_graphicsManager._palette);
|
2013-01-07 08:33:55 +01:00
|
|
|
_vm->_graphicsManager.setPaletteVGA256(_vm->_graphicsManager._palette);
|
2012-12-19 02:15:32 +01:00
|
|
|
_vm->_graphicsManager.lockScreen();
|
|
|
|
_vm->_graphicsManager.m_scroll16(_vm->_graphicsManager._vesaScreen, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
|
|
|
|
_vm->_graphicsManager.unlockScreen();
|
2013-01-01 21:03:24 +01:00
|
|
|
memcpy(_vm->_graphicsManager._vesaBuffer, _vm->_graphicsManager._vesaScreen, 614399);
|
2012-12-10 23:57:59 +01:00
|
|
|
_vm->_globals._disableInventFl = oldDisableInventFl;
|
2012-09-28 22:15:59 +10:00
|
|
|
_vm->_graphicsManager.DD_VBL();
|
2012-12-17 08:01:29 +01:00
|
|
|
for (int i = 0; i <= 4; i++)
|
2012-09-28 22:15:59 +10:00
|
|
|
_vm->_eventsManager.VBL();
|
2013-01-20 00:56:19 +01:00
|
|
|
_vm->_graphicsManager._scrollStatus = 0;
|
2012-09-28 22:15:59 +10:00
|
|
|
}
|
|
|
|
|
2012-09-26 23:34:10 +10:00
|
|
|
void TalkManager::PARLER_PERSO2(const Common::String &filename) {
|
2013-01-07 19:59:38 +02:00
|
|
|
// TODO: The original disables the mouse cursor here
|
2013-01-16 21:15:30 +01:00
|
|
|
STATI = true;
|
2013-01-23 01:38:34 +01:00
|
|
|
bool oldDisableInventFl = _vm->_globals._disableInventFl;
|
2012-12-10 23:57:59 +01:00
|
|
|
_vm->_globals._disableInventFl = true;
|
2012-12-19 08:00:22 +01:00
|
|
|
_characterBuffer = _vm->_fileManager.searchCat(filename, 5);
|
|
|
|
_characterSize = _vm->_globals._catalogSize;
|
|
|
|
if (_characterBuffer == g_PTRNUL) {
|
2013-01-07 23:56:39 +01:00
|
|
|
_characterBuffer = _vm->_fileManager.loadFile(filename);
|
|
|
|
_characterSize = _vm->_fileManager.fileSize(filename);
|
2012-09-26 23:34:10 +10:00
|
|
|
}
|
|
|
|
|
2013-01-21 18:59:17 +01:00
|
|
|
_vm->_globals._saveData->_data[svField4] = 0;
|
2012-12-26 21:30:51 +01:00
|
|
|
getStringFromBuffer(0, _questionsFilename, (const char *)_characterBuffer);
|
|
|
|
getStringFromBuffer(20, _answersFilename, (const char *)_characterBuffer);
|
2012-09-26 23:34:10 +10:00
|
|
|
|
2012-12-24 11:36:53 +01:00
|
|
|
switch (_vm->_globals._language) {
|
|
|
|
case LANG_EN:
|
2012-12-19 08:00:22 +01:00
|
|
|
_questionsFilename = "RUEAN.TXT";
|
|
|
|
_answersFilename = "RUEAN.TXT";
|
2012-09-26 23:34:10 +10:00
|
|
|
break;
|
2012-12-24 11:36:53 +01:00
|
|
|
case LANG_FR:
|
2012-12-19 08:00:22 +01:00
|
|
|
_questionsFilename = "RUE.TXT";
|
|
|
|
_answersFilename = "RUE.TXT";
|
2012-09-26 23:34:10 +10:00
|
|
|
break;
|
2012-12-24 11:36:53 +01:00
|
|
|
case LANG_SP:
|
2012-12-19 08:00:22 +01:00
|
|
|
_questionsFilename = "RUEES.TXT";
|
|
|
|
_answersFilename = "RUEES.TXT";
|
2012-09-26 23:34:10 +10:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2013-01-20 00:56:19 +01:00
|
|
|
_dialogueMesgId1 = (int16)READ_LE_UINT16((uint16 *)_characterBuffer + 40);
|
2012-12-27 07:52:37 +01:00
|
|
|
_paletteBufferIdx = 20 * (int16)READ_LE_UINT16((uint16 *)_characterBuffer + 42) + 110;
|
|
|
|
searchCharacterPalette(_paletteBufferIdx, false);
|
2013-01-20 00:56:19 +01:00
|
|
|
_dialogueMesgId2 = _dialogueMesgId1 + 1;
|
|
|
|
_dialogueMesgId3 = _dialogueMesgId1 + 2;
|
|
|
|
_dialogueMesgId4 = _dialogueMesgId1 + 3;
|
2013-01-16 21:15:30 +01:00
|
|
|
int oldMouseCursorId = _vm->_eventsManager._mouseCursorId;
|
2012-12-11 08:31:07 +01:00
|
|
|
_vm->_eventsManager._mouseCursorId = 4;
|
2012-12-11 01:53:50 +01:00
|
|
|
_vm->_eventsManager.changeMouseCursor(0);
|
2012-12-14 01:49:22 +01:00
|
|
|
|
2013-01-23 01:38:34 +01:00
|
|
|
if (!_vm->_globals._introSpeechOffFl) {
|
|
|
|
int answer;
|
2012-09-26 23:34:10 +10:00
|
|
|
do {
|
2013-01-23 01:38:34 +01:00
|
|
|
answer = dialogQuestion();
|
|
|
|
if (answer != _dialogueMesgId4) {
|
|
|
|
if (dialogAnswer(answer) == -1)
|
|
|
|
answer = _dialogueMesgId4;
|
2012-11-27 22:33:51 +01:00
|
|
|
}
|
2013-01-23 01:38:34 +01:00
|
|
|
} while (answer != _dialogueMesgId4);
|
2012-09-26 23:34:10 +10:00
|
|
|
}
|
|
|
|
|
2013-01-23 01:38:34 +01:00
|
|
|
if (_vm->_globals._introSpeechOffFl) {
|
|
|
|
int idx = 1;
|
|
|
|
int answer;
|
2013-01-24 00:05:36 +01:00
|
|
|
do
|
2013-01-23 01:38:34 +01:00
|
|
|
answer = dialogAnswer(idx++);
|
|
|
|
while (answer != -1);
|
2012-09-26 23:34:10 +10:00
|
|
|
}
|
|
|
|
|
2012-12-19 08:00:22 +01:00
|
|
|
_characterBuffer = _vm->_globals.freeMemory(_characterBuffer);
|
2013-01-16 21:15:30 +01:00
|
|
|
_vm->_eventsManager._mouseCursorId = oldMouseCursorId;
|
2012-09-26 23:34:10 +10:00
|
|
|
|
2013-01-16 21:15:30 +01:00
|
|
|
_vm->_eventsManager.changeMouseCursor(oldMouseCursorId);
|
2012-12-23 20:36:08 +01:00
|
|
|
_vm->_graphicsManager.initColorTable(145, 150, _vm->_graphicsManager._palette);
|
2013-01-07 08:33:55 +01:00
|
|
|
_vm->_graphicsManager.setPaletteVGA256(_vm->_graphicsManager._palette);
|
2013-01-07 19:59:38 +02:00
|
|
|
// TODO: The original reenables the mouse cursor here
|
2013-01-23 01:38:34 +01:00
|
|
|
_vm->_globals._disableInventFl = oldDisableInventFl;
|
2013-01-16 21:15:30 +01:00
|
|
|
STATI = false;
|
2012-09-26 23:34:10 +10:00
|
|
|
}
|
|
|
|
|
2012-12-26 21:30:51 +01:00
|
|
|
void TalkManager::getStringFromBuffer(int srcStart, Common::String &dest, const char *srcData) {
|
2012-09-26 23:34:10 +10:00
|
|
|
dest = Common::String(srcData + srcStart);
|
|
|
|
}
|
|
|
|
|
2013-01-23 01:38:34 +01:00
|
|
|
int TalkManager::dialogQuestion() {
|
2012-09-27 23:05:09 +10:00
|
|
|
if (STATI) {
|
2013-01-16 21:15:30 +01:00
|
|
|
uint16 *bufPtr = (uint16 *)_characterBuffer + 48;
|
|
|
|
int curVal = (int16)READ_LE_UINT16(bufPtr);
|
|
|
|
if (curVal != 0)
|
|
|
|
_vm->_objectsManager.setBobAnimation(curVal);
|
|
|
|
if (curVal != 1)
|
|
|
|
_vm->_objectsManager.setBobAnimation((int16)READ_LE_UINT16(bufPtr + 1));
|
|
|
|
if (curVal != 2)
|
|
|
|
_vm->_objectsManager.setBobAnimation((int16)READ_LE_UINT16(bufPtr + 2));
|
|
|
|
if (curVal != 3)
|
|
|
|
_vm->_objectsManager.setBobAnimation((int16)READ_LE_UINT16(bufPtr + 3));
|
|
|
|
if (curVal != 4)
|
|
|
|
_vm->_objectsManager.setBobAnimation((int16)READ_LE_UINT16(bufPtr + 4));
|
2012-09-27 23:05:09 +10:00
|
|
|
} else {
|
2012-12-27 18:41:52 +01:00
|
|
|
dialogWait();
|
2012-09-27 23:05:09 +10:00
|
|
|
}
|
2012-12-14 01:49:22 +01:00
|
|
|
|
2013-01-20 00:56:19 +01:00
|
|
|
int sentence1LineNumb = VERIF_BOITE(_dialogueMesgId1, _questionsFilename, 65);
|
|
|
|
int sentence2LineNumb = VERIF_BOITE(_dialogueMesgId2, _questionsFilename, 65);
|
|
|
|
int sentence3LineNumb = VERIF_BOITE(_dialogueMesgId3, _questionsFilename, 65);
|
|
|
|
int sentence4LineNumb = VERIF_BOITE(_dialogueMesgId4, _questionsFilename, 65);
|
2013-01-16 23:38:03 +01:00
|
|
|
|
|
|
|
int sentence4PosY = 420 - 20 * sentence4LineNumb;
|
|
|
|
int sentence3PosY = sentence4PosY - 20 * sentence3LineNumb;
|
|
|
|
int sentence2PosY = sentence3PosY - 20 * sentence2LineNumb;
|
|
|
|
int sentence1PosY = sentence2PosY - 20 * sentence1LineNumb;
|
|
|
|
|
2013-01-20 00:56:19 +01:00
|
|
|
_vm->_fontManager.initTextBuffers(5, _dialogueMesgId1, _questionsFilename, 5, sentence1PosY, 0, 65, 255);
|
|
|
|
_vm->_fontManager.initTextBuffers(6, _dialogueMesgId2, _questionsFilename, 5, sentence2PosY, 0, 65, 255);
|
|
|
|
_vm->_fontManager.initTextBuffers(7, _dialogueMesgId3, _questionsFilename, 5, sentence3PosY, 0, 65, 255);
|
|
|
|
_vm->_fontManager.initTextBuffers(8, _dialogueMesgId4, _questionsFilename, 5, sentence4PosY, 0, 65, 255);
|
2012-12-12 00:22:18 +01:00
|
|
|
_vm->_fontManager.showText(5);
|
|
|
|
_vm->_fontManager.showText(6);
|
|
|
|
_vm->_fontManager.showText(7);
|
|
|
|
_vm->_fontManager.showText(8);
|
2012-09-27 23:05:09 +10:00
|
|
|
|
2013-01-16 21:15:30 +01:00
|
|
|
int retVal = -1;
|
2013-01-23 01:38:34 +01:00
|
|
|
bool loopCond = false;
|
2012-09-27 23:05:09 +10:00
|
|
|
do {
|
2013-01-16 21:15:30 +01:00
|
|
|
int mousePosY = _vm->_eventsManager.getMouseY();
|
2013-01-16 23:38:03 +01:00
|
|
|
if (sentence1PosY < mousePosY && mousePosY < (sentence2PosY - 1)) {
|
2012-12-12 00:22:18 +01:00
|
|
|
_vm->_fontManager.setOptimalColor(6, 7, 8, 5);
|
2013-01-20 00:56:19 +01:00
|
|
|
retVal = _dialogueMesgId1;
|
2012-09-27 23:05:09 +10:00
|
|
|
}
|
2013-01-16 23:38:03 +01:00
|
|
|
if (sentence2PosY < mousePosY && mousePosY < (sentence3PosY - 1)) {
|
2012-12-12 00:22:18 +01:00
|
|
|
_vm->_fontManager.setOptimalColor(5, 7, 8, 6);
|
2013-01-20 00:56:19 +01:00
|
|
|
retVal = _dialogueMesgId2;
|
2012-09-27 23:05:09 +10:00
|
|
|
}
|
2013-01-16 23:38:03 +01:00
|
|
|
if (sentence3PosY < mousePosY && mousePosY < (sentence4PosY - 1)) {
|
2012-12-12 00:22:18 +01:00
|
|
|
_vm->_fontManager.setOptimalColor(5, 6, 8, 7);
|
2013-01-20 00:56:19 +01:00
|
|
|
retVal = _dialogueMesgId3;
|
2012-09-27 23:05:09 +10:00
|
|
|
}
|
2013-01-16 23:38:03 +01:00
|
|
|
if (sentence4PosY < mousePosY && mousePosY < 419) {
|
2012-12-12 00:22:18 +01:00
|
|
|
_vm->_fontManager.setOptimalColor(5, 6, 7, 8);
|
2013-01-20 00:56:19 +01:00
|
|
|
retVal = _dialogueMesgId4;
|
2012-09-27 23:05:09 +10:00
|
|
|
}
|
2012-12-14 01:49:22 +01:00
|
|
|
|
2012-09-27 23:05:09 +10:00
|
|
|
_vm->_eventsManager.VBL();
|
2012-12-11 01:53:50 +01:00
|
|
|
if (_vm->_eventsManager.getMouseButton())
|
2013-01-23 01:38:34 +01:00
|
|
|
loopCond = true;
|
2013-01-16 21:15:30 +01:00
|
|
|
if (retVal == -1)
|
2013-01-23 01:38:34 +01:00
|
|
|
loopCond = false;
|
|
|
|
} while (!_vm->shouldQuit() && !loopCond);
|
2012-12-14 01:49:22 +01:00
|
|
|
|
2013-01-16 21:15:30 +01:00
|
|
|
_vm->_soundManager.mixVoice(retVal, 1);
|
2012-12-12 00:22:18 +01:00
|
|
|
_vm->_fontManager.hideText(5);
|
|
|
|
_vm->_fontManager.hideText(6);
|
|
|
|
_vm->_fontManager.hideText(7);
|
|
|
|
_vm->_fontManager.hideText(8);
|
2012-12-14 01:49:22 +01:00
|
|
|
|
2012-09-27 23:05:09 +10:00
|
|
|
if (STATI) {
|
2013-01-16 21:15:30 +01:00
|
|
|
uint16 *bufPtr = (uint16 *)_characterBuffer + 48;
|
|
|
|
|
|
|
|
int curVal = (int16)READ_LE_UINT16(bufPtr);
|
|
|
|
if (curVal != 0)
|
|
|
|
_vm->_objectsManager.stopBobAnimation(curVal);
|
|
|
|
|
|
|
|
curVal = (int16)READ_LE_UINT16(bufPtr + 1);
|
|
|
|
if (curVal != 1)
|
|
|
|
_vm->_objectsManager.stopBobAnimation(curVal);
|
|
|
|
|
|
|
|
curVal = (int16)READ_LE_UINT16(bufPtr + 2);
|
|
|
|
if (curVal != 2)
|
|
|
|
_vm->_objectsManager.stopBobAnimation(curVal);
|
|
|
|
|
|
|
|
curVal = (int16)READ_LE_UINT16(bufPtr + 3);
|
|
|
|
if (curVal != 3)
|
|
|
|
_vm->_objectsManager.stopBobAnimation(curVal);
|
|
|
|
|
|
|
|
curVal = (int16)READ_LE_UINT16(bufPtr + 4);
|
|
|
|
if (curVal != 4)
|
|
|
|
_vm->_objectsManager.stopBobAnimation(curVal);
|
2012-09-27 23:05:09 +10:00
|
|
|
} else {
|
2012-12-27 18:41:52 +01:00
|
|
|
dialogTalk();
|
2012-09-27 23:05:09 +10:00
|
|
|
}
|
2012-12-14 01:49:22 +01:00
|
|
|
|
2012-09-27 23:05:09 +10:00
|
|
|
_vm->_eventsManager.VBL();
|
2013-01-16 21:15:30 +01:00
|
|
|
return retVal;
|
2012-09-26 23:34:10 +10:00
|
|
|
}
|
|
|
|
|
2013-01-23 01:38:34 +01:00
|
|
|
int TalkManager::dialogAnswer(int idx) {
|
|
|
|
int charIdx;
|
|
|
|
byte *charBuf;
|
|
|
|
for (charBuf = _characterBuffer + 110, charIdx = 0; (int16)READ_LE_UINT16(charBuf) != idx; charBuf += 20) {
|
|
|
|
++charIdx;
|
|
|
|
if ((int16)READ_LE_UINT16((uint16 *)_characterBuffer + 42) < charIdx)
|
2012-09-27 23:05:09 +10:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2013-01-23 01:38:34 +01:00
|
|
|
int mesgId = (int16)READ_LE_UINT16((uint16 *)charBuf + 1);
|
|
|
|
int mesgPosX = (int16)READ_LE_UINT16((uint16 *)charBuf + 2);
|
|
|
|
int mesgPosY = (int16)READ_LE_UINT16((uint16 *)charBuf + 3);
|
|
|
|
int mesgLength = (int16)READ_LE_UINT16((uint16 *)charBuf + 4);
|
|
|
|
_dialogueMesgId1 = (int16)READ_LE_UINT16((uint16 *)charBuf + 5);
|
|
|
|
_dialogueMesgId2 = (int16)READ_LE_UINT16((uint16 *)charBuf + 6);
|
|
|
|
_dialogueMesgId3 = (int16)READ_LE_UINT16((uint16 *)charBuf + 7);
|
|
|
|
int v6 = (int16)READ_LE_UINT16((uint16 *)charBuf + 8);
|
|
|
|
int v7 = (int16)READ_LE_UINT16((uint16 *)charBuf + 9);
|
2012-12-14 01:49:22 +01:00
|
|
|
|
2012-09-27 23:05:09 +10:00
|
|
|
if (v7)
|
2013-01-21 18:59:17 +01:00
|
|
|
_vm->_globals._saveData->_data[svField4] = v7;
|
2012-09-27 23:05:09 +10:00
|
|
|
|
|
|
|
if (!v6)
|
|
|
|
v6 = 10;
|
|
|
|
if (STATI) {
|
2013-01-16 21:15:30 +01:00
|
|
|
uint16 *bufPtr = (uint16 *)_characterBuffer + 43;
|
|
|
|
int curVal = (int16)READ_LE_UINT16(bufPtr);
|
|
|
|
if (curVal)
|
|
|
|
_vm->_objectsManager.stopBobAnimation(curVal);
|
|
|
|
|
|
|
|
curVal = (int16)READ_LE_UINT16(bufPtr + 1);
|
|
|
|
if (curVal)
|
|
|
|
_vm->_objectsManager.stopBobAnimation(curVal);
|
|
|
|
|
|
|
|
curVal = (int16)READ_LE_UINT16(bufPtr + 2);
|
|
|
|
if (curVal)
|
|
|
|
_vm->_objectsManager.stopBobAnimation(curVal);
|
|
|
|
|
|
|
|
curVal = (int16)READ_LE_UINT16(bufPtr + 3);
|
|
|
|
if (curVal)
|
|
|
|
_vm->_objectsManager.stopBobAnimation(curVal);
|
|
|
|
|
|
|
|
curVal = (int16)READ_LE_UINT16(bufPtr + 4);
|
|
|
|
if (curVal)
|
|
|
|
_vm->_objectsManager.stopBobAnimation(curVal);
|
2012-09-27 23:05:09 +10:00
|
|
|
} else {
|
|
|
|
VISU_PARLE();
|
|
|
|
}
|
|
|
|
|
2012-12-24 11:36:53 +01:00
|
|
|
if (!_vm->_soundManager._textOffFl) {
|
2013-01-23 01:38:34 +01:00
|
|
|
_vm->_fontManager.initTextBuffers(9, mesgId, _answersFilename, mesgPosX, mesgPosY, 5, mesgLength, 252);
|
2012-12-12 00:22:18 +01:00
|
|
|
_vm->_fontManager.showText(9);
|
2012-09-27 23:05:09 +10:00
|
|
|
}
|
2013-01-23 01:38:34 +01:00
|
|
|
if (!_vm->_soundManager.mixVoice(mesgId, 1)) {
|
2012-12-11 08:31:07 +01:00
|
|
|
_vm->_eventsManager._curMouseButton = 0;
|
|
|
|
_vm->_eventsManager._mouseButton = 0;
|
2012-09-27 23:05:09 +10:00
|
|
|
|
2012-11-15 13:34:15 +01:00
|
|
|
if (_vm->getIsDemo()) {
|
2013-01-16 21:15:30 +01:00
|
|
|
for (int i = 0; i < v6; i++) {
|
2012-11-15 13:34:15 +01:00
|
|
|
_vm->_eventsManager.VBL();
|
2013-01-16 21:15:30 +01:00
|
|
|
}
|
2012-11-15 13:34:15 +01:00
|
|
|
} else {
|
2013-01-16 21:15:30 +01:00
|
|
|
for (int i = 0; i < v6; i++) {
|
2012-11-15 13:34:15 +01:00
|
|
|
_vm->_eventsManager.VBL();
|
2012-12-11 08:31:07 +01:00
|
|
|
if (_vm->_eventsManager._mouseButton || _vm->_eventsManager._curMouseButton)
|
2013-01-16 21:15:30 +01:00
|
|
|
break;
|
|
|
|
if (_vm->_eventsManager.getMouseButton() && i + 1 > abs(v6 / 5))
|
|
|
|
break;
|
|
|
|
}
|
2012-11-15 13:34:15 +01:00
|
|
|
}
|
2012-09-27 23:05:09 +10:00
|
|
|
}
|
|
|
|
|
2012-12-24 11:36:53 +01:00
|
|
|
if (!_vm->_soundManager._textOffFl)
|
2012-12-12 00:22:18 +01:00
|
|
|
_vm->_fontManager.hideText(9);
|
2012-09-27 23:05:09 +10:00
|
|
|
if (STATI) {
|
2013-01-16 21:15:30 +01:00
|
|
|
uint16 *bufPtr = (uint16 *)_characterBuffer + 43;
|
|
|
|
int curVal = (int16)READ_LE_UINT16(bufPtr);
|
|
|
|
if (curVal)
|
|
|
|
_vm->_objectsManager.stopBobAnimation(curVal);
|
|
|
|
|
|
|
|
curVal = (int16)READ_LE_UINT16(bufPtr + 1);
|
|
|
|
if (curVal)
|
|
|
|
_vm->_objectsManager.stopBobAnimation(curVal);
|
|
|
|
|
|
|
|
curVal = (int16)READ_LE_UINT16(bufPtr + 2);
|
|
|
|
if (curVal)
|
|
|
|
_vm->_objectsManager.stopBobAnimation(curVal);
|
|
|
|
|
|
|
|
curVal = (int16)READ_LE_UINT16(bufPtr + 3);
|
|
|
|
if (curVal)
|
|
|
|
_vm->_objectsManager.stopBobAnimation(curVal);
|
|
|
|
|
|
|
|
curVal = (int16)READ_LE_UINT16(bufPtr + 4);
|
|
|
|
if (curVal)
|
|
|
|
_vm->_objectsManager.stopBobAnimation(curVal);
|
2012-09-27 23:05:09 +10:00
|
|
|
} else {
|
2012-12-27 18:41:52 +01:00
|
|
|
dialogEndTalk();
|
2012-09-27 23:05:09 +10:00
|
|
|
}
|
2013-01-23 01:38:34 +01:00
|
|
|
int result = 0;
|
2013-01-20 00:56:19 +01:00
|
|
|
if (!_dialogueMesgId1)
|
2013-01-23 01:38:34 +01:00
|
|
|
result = -1;
|
2012-09-27 23:05:09 +10:00
|
|
|
|
2013-01-23 01:38:34 +01:00
|
|
|
return result;
|
2012-09-26 23:34:10 +10:00
|
|
|
}
|
|
|
|
|
2012-12-27 07:52:37 +01:00
|
|
|
void TalkManager::searchCharacterPalette(int startIdx, bool dark) {
|
|
|
|
int palettePos = 0;
|
|
|
|
size_t curIdx = startIdx;
|
2012-09-27 23:05:09 +10:00
|
|
|
for (;;) {
|
2013-01-30 08:31:32 +01:00
|
|
|
if (READ_BE_UINT24(&_characterBuffer[curIdx]) == MKTAG24('P', 'A', 'L')) {
|
2012-12-27 07:52:37 +01:00
|
|
|
palettePos = curIdx;
|
2012-09-27 23:05:09 +10:00
|
|
|
break;
|
2012-12-27 07:52:37 +01:00
|
|
|
}
|
|
|
|
++curIdx;
|
|
|
|
if (_characterSize == curIdx)
|
2012-09-27 23:05:09 +10:00
|
|
|
return;
|
|
|
|
}
|
2012-12-14 01:49:22 +01:00
|
|
|
|
2012-12-27 07:52:37 +01:00
|
|
|
_characterPalette = _characterBuffer + palettePos + 5;
|
|
|
|
_characterPalette[0] = 0;
|
|
|
|
_characterPalette[1] = 0;
|
|
|
|
_characterPalette[2] = 0;
|
|
|
|
_characterPalette[759] = 255;
|
|
|
|
_characterPalette[760] = 255;
|
|
|
|
_characterPalette[762] = 0;
|
|
|
|
_characterPalette[763] = 0;
|
|
|
|
_characterPalette[764] = 0;
|
|
|
|
_characterPalette[765] = 224;
|
|
|
|
_characterPalette[766] = 224;
|
|
|
|
_characterPalette[767] = 255;
|
|
|
|
|
|
|
|
if (!dark)
|
|
|
|
_characterPalette[761] = 86;
|
|
|
|
else
|
|
|
|
_characterPalette[761] = 255;
|
2012-12-14 01:49:22 +01:00
|
|
|
|
2013-01-07 08:33:55 +01:00
|
|
|
_vm->_graphicsManager.setPaletteVGA256(_characterPalette);
|
2012-12-27 07:52:37 +01:00
|
|
|
_vm->_graphicsManager.initColorTable(145, 150, _characterPalette);
|
2012-09-27 23:05:09 +10:00
|
|
|
}
|
|
|
|
|
2012-12-27 18:41:52 +01:00
|
|
|
void TalkManager::dialogWait() {
|
2012-09-27 23:05:09 +10:00
|
|
|
for (int idx = 26; idx <= 30; ++idx) {
|
2012-12-29 14:20:34 +01:00
|
|
|
if (_vm->_globals.Bqe_Anim[idx]._enabledFl)
|
2012-09-27 23:05:09 +10:00
|
|
|
BOB_VISU_PARLE(idx);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-12-27 18:41:52 +01:00
|
|
|
void TalkManager::dialogTalk() {
|
2012-09-27 23:05:09 +10:00
|
|
|
for (int idx = 26; idx <= 30; ++idx) {
|
2012-12-29 14:20:34 +01:00
|
|
|
if (_vm->_globals.Bqe_Anim[idx]._enabledFl)
|
2012-09-27 23:05:09 +10:00
|
|
|
_vm->_objectsManager.BOB_OFF(idx);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int idx = 26; idx <= 30; ++idx) {
|
2012-12-29 14:20:34 +01:00
|
|
|
if (_vm->_globals.Bqe_Anim[idx]._enabledFl)
|
2013-02-05 00:12:42 +01:00
|
|
|
_vm->_objectsManager.resetBob(idx);
|
2012-09-27 23:05:09 +10:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-12-27 18:41:52 +01:00
|
|
|
void TalkManager::dialogEndTalk() {
|
2012-09-27 23:05:09 +10:00
|
|
|
for (int idx = 21; idx <= 25; ++idx) {
|
2012-12-29 14:20:34 +01:00
|
|
|
if (_vm->_globals.Bqe_Anim[idx]._enabledFl)
|
2012-09-27 23:05:09 +10:00
|
|
|
_vm->_objectsManager.BOB_OFF(idx);
|
|
|
|
}
|
2012-12-14 01:49:22 +01:00
|
|
|
|
2012-09-27 23:05:09 +10:00
|
|
|
_vm->_eventsManager.VBL();
|
|
|
|
_vm->_eventsManager.VBL();
|
2012-12-14 01:49:22 +01:00
|
|
|
|
2012-09-27 23:05:09 +10:00
|
|
|
for (int idx = 21; idx <= 25; ++idx) {
|
2012-12-29 14:20:34 +01:00
|
|
|
if (_vm->_globals.Bqe_Anim[idx]._enabledFl)
|
2013-02-05 00:12:42 +01:00
|
|
|
_vm->_objectsManager.resetBob(idx);
|
2012-09-27 23:05:09 +10:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-09-28 22:49:43 +10:00
|
|
|
int TalkManager::VERIF_BOITE(int idx, const Common::String &file, int a3) {
|
2012-09-27 23:05:09 +10:00
|
|
|
int v9;
|
|
|
|
int v10;
|
2012-12-14 01:49:22 +01:00
|
|
|
char v11;
|
|
|
|
char v13;
|
2012-09-30 21:21:09 +10:00
|
|
|
int v15;
|
2012-12-14 01:49:22 +01:00
|
|
|
byte *ptr;
|
2012-09-27 23:05:09 +10:00
|
|
|
int v17;
|
2012-12-14 01:49:22 +01:00
|
|
|
byte *v19;
|
2012-10-24 23:20:26 +11:00
|
|
|
uint32 indexData[4047];
|
2012-09-27 23:05:09 +10:00
|
|
|
Common::String filename;
|
|
|
|
Common::String dest;
|
|
|
|
Common::File f;
|
|
|
|
int filesize;
|
|
|
|
|
2013-02-07 21:56:10 +01:00
|
|
|
_vm->_fontManager._fontFixedWidth = 11;
|
2012-12-14 01:49:22 +01:00
|
|
|
|
2012-10-24 23:20:26 +11:00
|
|
|
// Build up the filename
|
2013-01-07 23:56:39 +01:00
|
|
|
filename = dest = file;
|
2012-10-24 23:20:26 +11:00
|
|
|
while (filename.lastChar() != '.')
|
|
|
|
filename.deleteLastChar();
|
2012-09-27 23:05:09 +10:00
|
|
|
filename += "IND";
|
|
|
|
|
|
|
|
if (!f.open(filename))
|
|
|
|
error("Could not open file - %s", filename.c_str());
|
|
|
|
filesize = f.size();
|
2012-12-14 01:49:22 +01:00
|
|
|
assert(filesize < 16188);
|
2012-09-27 23:05:09 +10:00
|
|
|
|
2012-10-24 23:20:26 +11:00
|
|
|
for (int i = 0; i < (filesize / 4); ++i)
|
|
|
|
indexData[i] = f.readUint32LE();
|
2012-09-27 23:05:09 +10:00
|
|
|
f.close();
|
|
|
|
|
|
|
|
if (!f.open(dest))
|
|
|
|
error("Error opening file - %s", dest.c_str());
|
2012-09-26 23:34:10 +10:00
|
|
|
|
2012-10-24 23:20:26 +11:00
|
|
|
f.seek(indexData[idx]);
|
2012-12-12 08:05:04 +01:00
|
|
|
ptr = _vm->_globals.allocMemory(2058);
|
2012-10-10 21:03:29 +11:00
|
|
|
if (ptr == g_PTRNUL)
|
2012-09-27 23:05:09 +10:00
|
|
|
error("temporary TEXT");
|
|
|
|
f.read(ptr, 2048);
|
|
|
|
f.close();
|
|
|
|
|
|
|
|
v19 = ptr;
|
2012-12-17 08:01:29 +01:00
|
|
|
for (int i = 0; i < 2048; i++) {
|
2012-09-27 23:05:09 +10:00
|
|
|
v13 = *v19;
|
2012-12-21 01:26:11 +01:00
|
|
|
if ((byte)(*v19 + 46) > 27) {
|
|
|
|
if ((byte)(v13 + 80) > 27) {
|
|
|
|
if ((byte)(v13 - 65) <= 25 || (byte)(v13 - 97) <= 25)
|
2012-09-27 23:05:09 +10:00
|
|
|
v13 = 32;
|
|
|
|
} else {
|
|
|
|
v13 -= 79;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
v13 = *v19 + 111;
|
|
|
|
}
|
|
|
|
*v19 = v13;
|
2013-01-16 23:38:03 +01:00
|
|
|
v19++;
|
2012-12-17 08:01:29 +01:00
|
|
|
}
|
2012-12-14 01:49:22 +01:00
|
|
|
|
2012-12-17 08:01:29 +01:00
|
|
|
for (int i = 0; i < 2048; i++) {
|
2013-01-16 23:38:03 +01:00
|
|
|
if ( ptr[i] == 10 || ptr[i] == 13 )
|
2012-12-17 08:01:29 +01:00
|
|
|
ptr[i] = 0;
|
|
|
|
}
|
2012-09-27 23:05:09 +10:00
|
|
|
|
|
|
|
v9 = 0;
|
2012-09-28 22:49:43 +10:00
|
|
|
v15 = (11 * a3) - 4;
|
2013-01-16 23:38:03 +01:00
|
|
|
int lineCount = 0;
|
2012-09-27 23:05:09 +10:00
|
|
|
do {
|
|
|
|
v10 = 0;
|
|
|
|
for (;;) {
|
|
|
|
v17 = v10;
|
|
|
|
do {
|
2013-01-01 21:03:24 +01:00
|
|
|
v11 = ptr[v9 + v10];
|
2012-09-27 23:05:09 +10:00
|
|
|
++v10;
|
2013-01-01 21:03:24 +01:00
|
|
|
} while (v11 != ' ' && v11 != '%');
|
2012-12-17 08:01:29 +01:00
|
|
|
|
2013-02-07 21:56:10 +01:00
|
|
|
if (v10 >= v15 / _vm->_fontManager._fontFixedWidth) {
|
2013-01-16 23:38:03 +01:00
|
|
|
if (v11 == '%')
|
|
|
|
v11 = ' ';
|
2012-09-27 23:05:09 +10:00
|
|
|
break;
|
2013-01-16 23:38:03 +01:00
|
|
|
}
|
|
|
|
|
2013-01-01 21:03:24 +01:00
|
|
|
if (v11 == '%') {
|
2013-01-16 23:38:03 +01:00
|
|
|
v17 = v10;
|
2012-09-27 23:05:09 +10:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2013-01-16 23:38:03 +01:00
|
|
|
++lineCount;
|
2012-09-27 23:05:09 +10:00
|
|
|
v9 += v17;
|
2013-01-16 23:38:03 +01:00
|
|
|
} while (v11 != '%');
|
2012-09-27 23:05:09 +10:00
|
|
|
free(ptr);
|
2013-01-16 23:38:03 +01:00
|
|
|
return lineCount;
|
2012-09-27 23:05:09 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
void TalkManager::VISU_PARLE() {
|
|
|
|
for (int idx = 21; idx <= 25; ++idx) {
|
2012-12-29 14:20:34 +01:00
|
|
|
if (_vm->_globals.Bqe_Anim[idx]._enabledFl)
|
2012-09-27 23:05:09 +10:00
|
|
|
BOB_VISU_PARLE(idx);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void TalkManager::BOB_VISU_PARLE(int idx) {
|
|
|
|
int v4;
|
|
|
|
byte *v5;
|
|
|
|
|
2012-12-16 09:56:50 +01:00
|
|
|
_vm->_objectsManager._priorityFl = true;
|
2012-12-20 08:35:11 +01:00
|
|
|
if (!_vm->_globals._bob[idx].field0) {
|
2013-02-05 00:12:42 +01:00
|
|
|
_vm->_objectsManager.resetBob(idx);
|
2012-12-17 00:16:49 +01:00
|
|
|
v5 = _vm->_globals.Bqe_Anim[idx]._data;
|
2012-10-11 22:58:04 +11:00
|
|
|
v4 = (int16)READ_LE_UINT16(v5 + 2);
|
2012-09-27 23:05:09 +10:00
|
|
|
if (!v4)
|
|
|
|
v4 = 1;
|
2012-10-11 22:58:04 +11:00
|
|
|
if ((int16)READ_LE_UINT16(v5 + 24)) {
|
2012-12-20 08:35:11 +01:00
|
|
|
_vm->_globals._bob[idx]._isSpriteFl = true;
|
2013-01-22 18:59:01 +01:00
|
|
|
_vm->_globals._bob[idx]._zoomFactor = 0;
|
2013-01-21 22:25:12 +01:00
|
|
|
_vm->_globals._bob[idx]._flipFl = false;
|
2012-12-20 08:35:11 +01:00
|
|
|
_vm->_globals._bob[idx]._animData = _vm->_globals.Bqe_Anim[idx]._data;
|
|
|
|
_vm->_globals._bob[idx].field0 = 10;
|
2012-12-17 08:01:29 +01:00
|
|
|
v5 = _characterSprite;
|
2012-12-20 08:35:11 +01:00
|
|
|
_vm->_globals._bob[idx]._spriteData = _characterSprite;
|
|
|
|
_vm->_globals._bob[idx].field1E = v4;
|
|
|
|
_vm->_globals._bob[idx].field20 = -1;
|
|
|
|
_vm->_globals._bob[idx].field22 = 0;
|
|
|
|
_vm->_globals._bob[idx]._offsetY = 0;
|
2012-09-27 23:05:09 +10:00
|
|
|
}
|
|
|
|
}
|
2012-09-26 23:34:10 +10:00
|
|
|
}
|
|
|
|
|
2012-12-27 07:52:37 +01:00
|
|
|
void TalkManager::startCharacterAnim0(int startIdx, bool readOnlyFl) {
|
|
|
|
int animIdx = 0;
|
|
|
|
size_t curIdx = startIdx;
|
2012-12-04 21:36:53 +01:00
|
|
|
for (;;) {
|
2013-01-30 00:17:08 +01:00
|
|
|
if (READ_BE_UINT32(&_characterBuffer[curIdx]) == MKTAG('A', 'N', 'I', 'M') && _characterBuffer[curIdx + 4] == 1) {
|
2012-12-27 07:52:37 +01:00
|
|
|
animIdx = curIdx;
|
2012-09-28 22:49:43 +10:00
|
|
|
break;
|
2012-12-27 07:52:37 +01:00
|
|
|
}
|
|
|
|
++curIdx;
|
|
|
|
if (_characterSize == curIdx)
|
2012-09-28 22:49:43 +10:00
|
|
|
return;
|
|
|
|
}
|
2012-12-27 07:52:37 +01:00
|
|
|
_characterAnim = _characterBuffer + animIdx + 25;
|
|
|
|
if (!readOnlyFl) {
|
|
|
|
int idx = 0;
|
|
|
|
int v7;
|
2012-09-28 22:49:43 +10:00
|
|
|
do {
|
2012-12-27 07:52:37 +01:00
|
|
|
v7 = (int16)READ_LE_UINT16(&_characterAnim[2 * idx + 4]);
|
2012-12-17 08:01:29 +01:00
|
|
|
if (v7 && _vm->_globals._speed != 501)
|
2012-12-27 07:52:37 +01:00
|
|
|
_vm->_graphicsManager.fastDisplay(_characterSprite, _vm->_eventsManager._startPos.x + (int16)READ_LE_UINT16(&_characterAnim[2 * idx]),
|
|
|
|
(int16)READ_LE_UINT16(&_characterAnim[2 * idx + 2]), _characterAnim[2 * idx + 8]);
|
|
|
|
idx += 5;
|
2012-12-17 08:01:29 +01:00
|
|
|
} while (_vm->_globals._speed != 501 && v7);
|
2012-09-28 22:49:43 +10:00
|
|
|
}
|
2012-09-28 22:15:59 +10:00
|
|
|
}
|
|
|
|
|
2012-12-17 08:01:29 +01:00
|
|
|
/**
|
|
|
|
* Initialize character animation
|
|
|
|
*/
|
|
|
|
void TalkManager::initCharacterAnim() {
|
2013-01-16 23:38:03 +01:00
|
|
|
uint16 *bufPtr = (uint16 *)_characterBuffer + 43;
|
|
|
|
byte *animPtr = _characterBuffer + 110;
|
|
|
|
int curVal = (int16)READ_LE_UINT16(bufPtr);
|
|
|
|
if (curVal)
|
|
|
|
searchCharacterAnim(21, animPtr, curVal, _characterSize);
|
|
|
|
|
|
|
|
curVal = (int16)READ_LE_UINT16(bufPtr + 1);
|
|
|
|
if (curVal)
|
|
|
|
searchCharacterAnim(22, animPtr, curVal, _characterSize);
|
|
|
|
|
|
|
|
curVal = (int16)READ_LE_UINT16(bufPtr + 2);
|
|
|
|
if (curVal)
|
|
|
|
searchCharacterAnim(23, animPtr, curVal, _characterSize);
|
|
|
|
|
|
|
|
curVal = (int16)READ_LE_UINT16(bufPtr + 3);
|
|
|
|
if (curVal)
|
|
|
|
searchCharacterAnim(24, animPtr, curVal, _characterSize);
|
|
|
|
|
|
|
|
curVal = (int16)READ_LE_UINT16(bufPtr + 4);
|
|
|
|
if (curVal)
|
|
|
|
searchCharacterAnim(25, animPtr, curVal, _characterSize);
|
|
|
|
|
|
|
|
curVal = (int16)READ_LE_UINT16(bufPtr + 5);
|
|
|
|
if (curVal)
|
|
|
|
searchCharacterAnim(26, animPtr, curVal, _characterSize);
|
|
|
|
|
|
|
|
curVal = (int16)READ_LE_UINT16(bufPtr + 6);
|
|
|
|
if (curVal)
|
|
|
|
searchCharacterAnim(27, animPtr, curVal, _characterSize);
|
|
|
|
|
|
|
|
curVal = (int16)READ_LE_UINT16(bufPtr + 7);
|
|
|
|
if (curVal)
|
|
|
|
searchCharacterAnim(28, animPtr, curVal, _characterSize);
|
|
|
|
|
|
|
|
curVal = (int16)READ_LE_UINT16(bufPtr + 8);
|
|
|
|
if (curVal)
|
|
|
|
searchCharacterAnim(29, animPtr, curVal, _characterSize);
|
|
|
|
|
|
|
|
curVal = (int16)READ_LE_UINT16(bufPtr + 9);
|
|
|
|
if (curVal)
|
|
|
|
searchCharacterAnim(30, animPtr, curVal, _characterSize);
|
2012-09-28 22:15:59 +10:00
|
|
|
}
|
|
|
|
|
2012-12-09 22:35:59 +01:00
|
|
|
void TalkManager::clearCharacterAnim() {
|
2012-09-28 22:49:43 +10:00
|
|
|
for (int idx = 21; idx <= 34; ++idx) {
|
2012-12-17 00:16:49 +01:00
|
|
|
_vm->_globals.Bqe_Anim[idx]._data = _vm->_globals.freeMemory(_vm->_globals.Bqe_Anim[idx]._data);
|
2012-12-29 14:20:34 +01:00
|
|
|
_vm->_globals.Bqe_Anim[idx]._enabledFl = false;
|
2012-09-28 22:49:43 +10:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-29 23:59:25 +01:00
|
|
|
bool TalkManager::searchCharacterAnim(int idx, const byte *bufPerso, int animId, int bufferSize) {
|
|
|
|
bool result = false;
|
|
|
|
|
|
|
|
for (int bufPos = 0; bufPos <= bufferSize; bufPos++) {
|
|
|
|
if (READ_BE_UINT32(bufPerso + bufPos) == MKTAG('A', 'N', 'I', 'M') && bufPerso[bufPos + 4] == animId) {
|
|
|
|
int bufIndx = bufPos + 5;
|
|
|
|
const byte *curPtr = bufPerso + bufIndx;
|
|
|
|
int animLength = 0;
|
|
|
|
bool loopCond = false;
|
2012-09-28 22:49:43 +10:00
|
|
|
do {
|
2013-01-30 08:31:32 +01:00
|
|
|
if (READ_BE_UINT32(curPtr) == MKTAG('A', 'N', 'I', 'M') || READ_BE_UINT24(curPtr) == MKTAG24('F', 'I', 'N'))
|
2013-01-29 23:59:25 +01:00
|
|
|
loopCond = true;
|
|
|
|
if (bufIndx > bufferSize) {
|
2012-12-29 14:20:34 +01:00
|
|
|
_vm->_globals.Bqe_Anim[idx]._enabledFl = false;
|
|
|
|
_vm->_globals.Bqe_Anim[idx]._data = g_PTRNUL;
|
2013-01-29 23:59:25 +01:00
|
|
|
return false;
|
2012-09-28 22:49:43 +10:00
|
|
|
}
|
2013-01-29 23:59:25 +01:00
|
|
|
++bufIndx;
|
|
|
|
++animLength;
|
|
|
|
++curPtr;
|
|
|
|
} while (!loopCond);
|
|
|
|
_vm->_globals.Bqe_Anim[idx]._data = _vm->_globals.allocMemory(animLength + 50);
|
2012-12-29 14:20:34 +01:00
|
|
|
_vm->_globals.Bqe_Anim[idx]._enabledFl = true;
|
2013-01-29 23:59:25 +01:00
|
|
|
memcpy(_vm->_globals.Bqe_Anim[idx]._data, (const byte *)(bufPerso + bufPos + 5), 20);
|
|
|
|
int v23 = (int16)READ_LE_UINT16(bufPos + bufPerso + 29);
|
|
|
|
WRITE_LE_UINT16(_vm->_globals.Bqe_Anim[idx]._data + 20, (int16)READ_LE_UINT16(bufPos + bufPerso + 25));
|
|
|
|
WRITE_LE_UINT16(_vm->_globals.Bqe_Anim[idx]._data + 22, (int16)READ_LE_UINT16(bufPos + bufPerso + 27));
|
|
|
|
WRITE_LE_UINT16(_vm->_globals.Bqe_Anim[idx]._data + 24, v23);
|
|
|
|
WRITE_LE_UINT16(_vm->_globals.Bqe_Anim[idx]._data + 26, (int16)READ_LE_UINT16(bufPos + bufPerso + 31));
|
|
|
|
_vm->_globals.Bqe_Anim[idx]._data[28] = bufPerso[bufPos + 33];
|
|
|
|
_vm->_globals.Bqe_Anim[idx]._data[29] = bufPerso[bufPos + 34];
|
|
|
|
byte *bqeCurData = _vm->_globals.Bqe_Anim[idx]._data + 20;
|
|
|
|
const byte *curBufPerso = bufPos + bufPerso + 25;
|
2012-12-17 08:01:29 +01:00
|
|
|
for (int i = 1; i < 5000; i++) {
|
2013-01-29 23:59:25 +01:00
|
|
|
bqeCurData += 10;
|
|
|
|
curBufPerso += 10;
|
2012-09-28 22:49:43 +10:00
|
|
|
if (!v23)
|
|
|
|
break;
|
2013-01-29 23:59:25 +01:00
|
|
|
v23 = (int16)READ_LE_UINT16(curBufPerso + 4);
|
|
|
|
WRITE_LE_UINT16(bqeCurData, (int16)READ_LE_UINT16(curBufPerso));
|
|
|
|
WRITE_LE_UINT16(bqeCurData + 2, (int16)READ_LE_UINT16(curBufPerso + 2));
|
|
|
|
WRITE_LE_UINT16(bqeCurData + 4, v23);
|
|
|
|
WRITE_LE_UINT16(bqeCurData + 6, (int16)READ_LE_UINT16(curBufPerso + 6));
|
|
|
|
bqeCurData[8] = curBufPerso[8];
|
|
|
|
bqeCurData[9] = curBufPerso[9];
|
2012-12-17 08:01:29 +01:00
|
|
|
}
|
2012-12-29 14:20:34 +01:00
|
|
|
result = true;
|
2012-09-28 22:49:43 +10:00
|
|
|
}
|
2013-01-30 08:31:32 +01:00
|
|
|
if (READ_BE_UINT24(&bufPerso[bufPos]) == MKTAG24('F', 'I', 'N'))
|
2012-09-28 22:49:43 +10:00
|
|
|
result = true;
|
2013-01-29 23:59:25 +01:00
|
|
|
|
|
|
|
if (result)
|
|
|
|
break;
|
|
|
|
}
|
2012-09-28 22:49:43 +10:00
|
|
|
|
|
|
|
return result;
|
2012-09-28 22:15:59 +10:00
|
|
|
}
|
|
|
|
|
2013-01-18 18:52:19 +01:00
|
|
|
void TalkManager::REPONSE(int zone, int verb) {
|
2012-12-14 01:49:22 +01:00
|
|
|
uint16 v7;
|
|
|
|
byte *v8;
|
2013-02-06 21:44:32 +01:00
|
|
|
int opcodeType;
|
2012-12-14 01:49:22 +01:00
|
|
|
uint16 v11;
|
|
|
|
int v12;
|
2013-02-06 21:44:32 +01:00
|
|
|
int lastOpcodeResult;
|
2013-01-27 01:25:46 +01:00
|
|
|
bool tagFound;
|
2013-01-16 23:48:09 +01:00
|
|
|
bool v16;
|
2013-02-06 21:59:13 +01:00
|
|
|
bool innerLoopCond;
|
2012-12-14 01:49:22 +01:00
|
|
|
byte *ptr;
|
2012-10-04 07:27:34 +10:00
|
|
|
|
2013-01-18 18:52:19 +01:00
|
|
|
byte zoneObj = zone;
|
|
|
|
byte verbObj = verb;
|
2013-02-06 21:59:13 +01:00
|
|
|
|
|
|
|
bool outerLoopFl;
|
2013-01-27 01:25:46 +01:00
|
|
|
do {
|
2013-02-06 21:59:13 +01:00
|
|
|
outerLoopFl = false;
|
|
|
|
tagFound = false;
|
|
|
|
if (_vm->_globals._answerBuffer == g_PTRNUL)
|
2013-01-27 01:25:46 +01:00
|
|
|
return;
|
|
|
|
|
2013-02-06 21:59:13 +01:00
|
|
|
byte *curAnswerBuf = _vm->_globals._answerBuffer;
|
|
|
|
for (;;) {
|
|
|
|
if (READ_BE_UINT24(curAnswerBuf) == MKTAG24('F', 'I', 'N'))
|
|
|
|
return;
|
|
|
|
if (READ_BE_UINT24(curAnswerBuf) == MKTAG24('C', 'O', 'D')) {
|
|
|
|
if (curAnswerBuf[3] == zoneObj && curAnswerBuf[4] == verbObj)
|
|
|
|
tagFound = true;
|
|
|
|
}
|
|
|
|
if (!tagFound)
|
|
|
|
curAnswerBuf++;
|
|
|
|
else
|
|
|
|
break;
|
2013-01-27 01:25:46 +01:00
|
|
|
}
|
2013-02-06 21:59:13 +01:00
|
|
|
|
|
|
|
// 'COD' tag found
|
|
|
|
curAnswerBuf += 5;
|
|
|
|
ptr = _vm->_globals.allocMemory(620);
|
|
|
|
assert(ptr != g_PTRNUL);
|
|
|
|
memset(ptr, 0, 620);
|
|
|
|
v7 = 0;
|
|
|
|
v12 = 0;
|
|
|
|
innerLoopCond = false;
|
|
|
|
do {
|
|
|
|
v16 = false;
|
|
|
|
if (READ_BE_UINT16(&curAnswerBuf[v7]) == MKTAG16('F', 'C')) {
|
|
|
|
++v12;
|
|
|
|
assert(v12 < (620 / 20));
|
|
|
|
|
|
|
|
v8 = (ptr + 20 * v12);
|
|
|
|
v11 = 0;
|
|
|
|
do {
|
|
|
|
assert(v11 < 20);
|
|
|
|
v8[v11++] = curAnswerBuf[v7++];
|
|
|
|
if (READ_BE_UINT16(&curAnswerBuf[v7]) == MKTAG16('F', 'F')) {
|
|
|
|
v16 = true;
|
|
|
|
v8[v11] = 'F';
|
|
|
|
v8[v11 + 1] = 'F';
|
|
|
|
++v7;
|
|
|
|
}
|
|
|
|
} while (!v16);
|
|
|
|
}
|
|
|
|
if (!v16) {
|
|
|
|
uint32 signature24 = READ_BE_UINT24(&curAnswerBuf[v7]);
|
|
|
|
if (signature24 == MKTAG24('C', 'O', 'D') || signature24 == MKTAG24('F', 'I', 'N'))
|
|
|
|
innerLoopCond = true;
|
|
|
|
}
|
|
|
|
curAnswerBuf += v7 + 1;
|
|
|
|
v7 = 0;
|
|
|
|
} while (!innerLoopCond);
|
|
|
|
innerLoopCond = false;
|
|
|
|
lastOpcodeResult = 1;
|
|
|
|
do {
|
|
|
|
opcodeType = _vm->_scriptManager.handleOpcode(ptr + 20 * lastOpcodeResult);
|
|
|
|
if (_vm->shouldQuit())
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (opcodeType == 2)
|
|
|
|
// GOTO
|
|
|
|
lastOpcodeResult = _vm->_scriptManager.handleGoto(ptr + 20 * lastOpcodeResult);
|
|
|
|
else if (opcodeType == 3)
|
|
|
|
// IF
|
|
|
|
lastOpcodeResult = _vm->_scriptManager.handleIf(ptr, lastOpcodeResult);
|
|
|
|
|
|
|
|
if (lastOpcodeResult == -1)
|
|
|
|
error("Invalid IFF function");
|
|
|
|
|
|
|
|
if (opcodeType == 1 || opcodeType == 4)
|
|
|
|
// Already handled opcode or END IF
|
|
|
|
++lastOpcodeResult;
|
|
|
|
else if (!opcodeType || opcodeType == 5)
|
|
|
|
// EXIT
|
|
|
|
innerLoopCond = true;
|
|
|
|
else if (opcodeType == 6) {
|
|
|
|
// JUMP
|
|
|
|
_vm->_globals.freeMemory(ptr);
|
|
|
|
zoneObj = _vm->_objectsManager._jumpZone;
|
|
|
|
verbObj = _vm->_objectsManager._jumpVerb;
|
|
|
|
outerLoopFl = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} while (!innerLoopCond);
|
|
|
|
} while (outerLoopFl);
|
2013-01-27 01:25:46 +01:00
|
|
|
_vm->_globals.freeMemory(ptr);
|
|
|
|
_vm->_globals._saveData->_data[svField2] = 0;
|
|
|
|
return;
|
2012-09-29 09:33:42 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
void TalkManager::REPONSE2(int a1, int a2) {
|
2012-12-20 00:30:01 +01:00
|
|
|
int indx = 0;
|
2013-01-21 18:59:17 +01:00
|
|
|
if (a2 != 5 || _vm->_globals._saveData->_data[svField3] != 4)
|
2013-01-18 18:52:19 +01:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (a1 == 22 || a1 == 23) {
|
|
|
|
_vm->_objectsManager.setFlipSprite(0, false);
|
|
|
|
_vm->_objectsManager.setSpriteIndex(0, 62);
|
2013-02-07 22:30:40 +01:00
|
|
|
_vm->_objectsManager.SPACTION(_vm->_objectsManager._forestSprite, "2,3,4,5,6,7,8,9,10,11,12,-1,", 0, 0, 4, false);
|
2013-01-18 18:52:19 +01:00
|
|
|
if (a1 == 22) {
|
|
|
|
_vm->_objectsManager.lockAnimX(6, _vm->_objectsManager.getBobPosX(3));
|
|
|
|
_vm->_objectsManager.lockAnimX(8, _vm->_objectsManager.getBobPosX(3));
|
|
|
|
} else { // a1 == 23
|
|
|
|
_vm->_objectsManager.lockAnimX(6, _vm->_objectsManager.getBobPosX(4));
|
|
|
|
_vm->_objectsManager.lockAnimX(8, _vm->_objectsManager.getBobPosX(4));
|
|
|
|
}
|
|
|
|
_vm->_objectsManager.stopBobAnimation(3);
|
|
|
|
_vm->_objectsManager.stopBobAnimation(4);
|
|
|
|
_vm->_objectsManager.setBobAnimation(6);
|
|
|
|
_vm->_soundManager.PLAY_SAMPLE2(1);
|
2013-02-07 22:30:40 +01:00
|
|
|
_vm->_objectsManager.SPACTION1(_vm->_objectsManager._forestSprite, "13,14,15,14,13,12,13,14,15,16,-1,", 0, 0, 4);
|
2013-01-18 18:52:19 +01:00
|
|
|
do
|
|
|
|
_vm->_eventsManager.VBL();
|
2013-02-05 07:52:46 +01:00
|
|
|
while (_vm->_objectsManager.getBobAnimDataIdx(6) < 12);
|
2013-01-18 18:52:19 +01:00
|
|
|
_vm->_objectsManager.stopBobAnimation(6);
|
|
|
|
_vm->_objectsManager.setBobAnimation(8);
|
|
|
|
|
|
|
|
switch (_vm->_globals._screenId) {
|
|
|
|
case 35:
|
|
|
|
indx = 201;
|
|
|
|
break;
|
|
|
|
case 36:
|
|
|
|
indx = 203;
|
|
|
|
break;
|
|
|
|
case 37:
|
|
|
|
indx = 205;
|
|
|
|
break;
|
|
|
|
case 38:
|
|
|
|
indx = 207;
|
|
|
|
break;
|
|
|
|
case 39:
|
|
|
|
indx = 209;
|
|
|
|
break;
|
|
|
|
case 40:
|
|
|
|
indx = 211;
|
|
|
|
break;
|
|
|
|
case 41:
|
|
|
|
indx = 213;
|
|
|
|
break;
|
|
|
|
}
|
2013-01-21 18:59:17 +01:00
|
|
|
_vm->_globals._saveData->_data[indx] = 2;
|
2013-01-18 18:52:19 +01:00
|
|
|
_vm->_objectsManager.disableZone(22);
|
|
|
|
_vm->_objectsManager.disableZone(23);
|
|
|
|
} else if (a1 == 20 || a1 == 21) {
|
|
|
|
_vm->_objectsManager.setFlipSprite(0, true);
|
|
|
|
_vm->_objectsManager.setSpriteIndex(0, 62);
|
2013-02-07 22:30:40 +01:00
|
|
|
_vm->_objectsManager.SPACTION(_vm->_objectsManager._forestSprite, "2,3,4,5,6,7,8,9,10,11,12,-1,", 0, 0, 4, true);
|
2013-01-18 18:52:19 +01:00
|
|
|
if (a1 == 20) {
|
|
|
|
_vm->_objectsManager.lockAnimX(5, _vm->_objectsManager.getBobPosX(1));
|
|
|
|
_vm->_objectsManager.lockAnimX(7, _vm->_objectsManager.getBobPosX(1));
|
|
|
|
} else { // a1 == 21
|
|
|
|
_vm->_objectsManager.lockAnimX(5, _vm->_objectsManager.getBobPosX(2));
|
|
|
|
_vm->_objectsManager.lockAnimX(7, _vm->_objectsManager.getBobPosX(2));
|
|
|
|
}
|
|
|
|
_vm->_objectsManager.stopBobAnimation(1);
|
|
|
|
_vm->_objectsManager.stopBobAnimation(2);
|
|
|
|
_vm->_objectsManager.setBobAnimation(5);
|
|
|
|
_vm->_soundManager.PLAY_SAMPLE2(1);
|
2013-02-07 22:30:40 +01:00
|
|
|
_vm->_objectsManager.SPACTION1(_vm->_objectsManager._forestSprite, "13,14,15,14,13,12,13,14,15,16,-1,", 0, 0, 4);
|
2013-01-18 18:52:19 +01:00
|
|
|
do
|
|
|
|
_vm->_eventsManager.VBL();
|
2013-02-05 07:52:46 +01:00
|
|
|
while (_vm->_objectsManager.getBobAnimDataIdx(5) < 12);
|
2013-01-18 18:52:19 +01:00
|
|
|
_vm->_objectsManager.stopBobAnimation(5);
|
|
|
|
_vm->_objectsManager.setBobAnimation(7);
|
|
|
|
switch (_vm->_globals._screenId) {
|
|
|
|
case 35:
|
|
|
|
indx = 200;
|
|
|
|
break;
|
|
|
|
case 36:
|
|
|
|
indx = 202;
|
|
|
|
break;
|
|
|
|
case 37:
|
|
|
|
indx = 204;
|
|
|
|
break;
|
|
|
|
case 38:
|
|
|
|
indx = 206;
|
|
|
|
break;
|
|
|
|
case 39:
|
|
|
|
indx = 208;
|
|
|
|
break;
|
|
|
|
case 40:
|
|
|
|
indx = 210;
|
|
|
|
break;
|
|
|
|
case 41:
|
|
|
|
indx = 212;
|
|
|
|
break;
|
2012-10-04 07:27:34 +10:00
|
|
|
}
|
2013-01-21 18:59:17 +01:00
|
|
|
_vm->_globals._saveData->_data[indx] = 2;
|
2013-01-18 18:52:19 +01:00
|
|
|
_vm->_objectsManager.disableZone(21);
|
|
|
|
_vm->_objectsManager.disableZone(20);
|
2012-10-04 07:27:34 +10:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void TalkManager::OBJET_VIVANT(const Common::String &a2) {
|
2012-12-14 01:49:22 +01:00
|
|
|
byte *v11;
|
2012-10-04 07:27:34 +10:00
|
|
|
Common::String s;
|
2012-12-14 01:49:22 +01:00
|
|
|
Common::String v20;
|
|
|
|
Common::String v22;
|
|
|
|
Common::String v23;
|
2012-10-04 07:27:34 +10:00
|
|
|
|
2012-12-12 00:22:18 +01:00
|
|
|
_vm->_fontManager.hideText(5);
|
|
|
|
_vm->_fontManager.hideText(9);
|
2012-10-04 07:27:34 +10:00
|
|
|
_vm->_eventsManager.VBL();
|
2013-01-20 00:56:19 +01:00
|
|
|
_vm->_graphicsManager._scrollStatus = 1;
|
2013-01-11 01:50:29 +01:00
|
|
|
_vm->_linesManager.clearAllZones();
|
2013-01-10 22:09:37 +01:00
|
|
|
_vm->_linesManager.resetLines();
|
2013-01-02 00:57:00 +01:00
|
|
|
_vm->_globals.resetCache();
|
2012-12-17 08:01:29 +01:00
|
|
|
|
|
|
|
for (int i = 0; i <= 44; i++)
|
|
|
|
_vm->_globals.BOBZONE[i] = 0;
|
|
|
|
|
2013-01-12 11:55:44 +01:00
|
|
|
_vm->_objectsManager._zoneNum = -1;
|
2012-12-11 08:31:07 +01:00
|
|
|
_vm->_eventsManager._mouseCursorId = 4;
|
2012-12-11 01:53:50 +01:00
|
|
|
_vm->_eventsManager.changeMouseCursor(0);
|
2012-12-19 08:00:22 +01:00
|
|
|
_characterBuffer = _vm->_fileManager.searchCat(a2, 5);
|
|
|
|
_characterSize = _vm->_globals._catalogSize;
|
|
|
|
if (_characterBuffer == g_PTRNUL) {
|
2013-01-07 23:56:39 +01:00
|
|
|
_characterBuffer = _vm->_fileManager.loadFile(a2);
|
|
|
|
_characterSize = _vm->_fileManager.fileSize(a2);
|
2012-10-04 07:27:34 +10:00
|
|
|
}
|
2012-12-26 21:30:51 +01:00
|
|
|
getStringFromBuffer(40, v23, (const char *)_characterBuffer);
|
|
|
|
getStringFromBuffer(0, v22, (const char *)_characterBuffer);
|
|
|
|
getStringFromBuffer(20, v20, (const char *)_characterBuffer);
|
2012-10-04 07:27:34 +10:00
|
|
|
|
2012-12-19 08:00:22 +01:00
|
|
|
if (v20 == "NULL")
|
2012-12-24 13:32:39 +01:00
|
|
|
v20 = Common::String::format("IM%d", _vm->_globals._screenId);
|
2012-12-19 08:00:22 +01:00
|
|
|
|
2012-12-17 08:01:29 +01:00
|
|
|
_characterSprite = _vm->_fileManager.searchCat(v23, 7);
|
2012-12-19 08:00:22 +01:00
|
|
|
if (_characterSprite)
|
2013-01-07 23:56:39 +01:00
|
|
|
_characterSprite = _vm->_objectsManager.loadSprite(v23);
|
2012-12-19 08:00:22 +01:00
|
|
|
else
|
2013-01-07 23:56:39 +01:00
|
|
|
_characterSprite = _vm->_objectsManager.loadSprite("RES_SAN.RES");
|
2012-12-19 08:00:22 +01:00
|
|
|
|
|
|
|
if (_vm->_graphicsManager._lineNbr == SCREEN_WIDTH)
|
2013-01-07 23:56:39 +01:00
|
|
|
_vm->_saveLoadManager.saveFile("TEMP.SCR", _vm->_graphicsManager._vesaScreen, 307200);
|
2012-12-19 08:00:22 +01:00
|
|
|
else if (_vm->_graphicsManager._lineNbr == (SCREEN_WIDTH * 2))
|
2013-01-07 23:56:39 +01:00
|
|
|
_vm->_saveLoadManager.saveFile("TEMP.SCR", _vm->_graphicsManager._vesaScreen, 614400);
|
2012-10-28 18:04:06 +11:00
|
|
|
|
2012-12-19 08:00:22 +01:00
|
|
|
if (!_vm->_graphicsManager._lineNbr)
|
2013-01-01 13:53:07 +01:00
|
|
|
_vm->_graphicsManager._scrollOffset = 0;
|
2013-01-07 13:24:04 +02:00
|
|
|
_vm->_graphicsManager.NB_SCREEN(true);
|
2012-12-27 07:52:37 +01:00
|
|
|
_paletteBufferIdx = 20 * (int16)READ_LE_UINT16((uint16 *)_characterBuffer + 42) + 110;
|
2013-01-07 13:24:04 +02:00
|
|
|
_vm->_graphicsManager.NB_SCREEN(true);
|
2012-10-29 23:08:23 +01:00
|
|
|
_vm->_objectsManager.PERSO_ON = true;
|
2012-12-27 07:52:37 +01:00
|
|
|
searchCharacterPalette(_paletteBufferIdx, true);
|
|
|
|
startCharacterAnim0(_paletteBufferIdx, false);
|
2013-01-27 01:25:46 +01:00
|
|
|
v11 = _vm->_globals._answerBuffer;
|
|
|
|
_vm->_globals._answerBuffer = g_PTRNUL;
|
2012-10-28 22:38:34 +01:00
|
|
|
_vm->_globals.NOMARCHE = true;
|
2012-10-04 07:27:34 +10:00
|
|
|
_vm->_objectsManager.INILINK(v22);
|
2012-10-29 23:08:23 +01:00
|
|
|
_vm->_objectsManager.PERSO_ON = true;
|
2012-12-19 02:15:32 +01:00
|
|
|
_vm->_globals.GOACTION = false;
|
2013-01-12 11:55:44 +01:00
|
|
|
_vm->_objectsManager._zoneNum = -1;
|
2012-12-17 08:01:29 +01:00
|
|
|
initCharacterAnim();
|
2012-10-04 07:27:34 +10:00
|
|
|
VISU_PARLE();
|
2012-12-27 18:41:52 +01:00
|
|
|
dialogWait();
|
2013-01-07 19:43:24 +02:00
|
|
|
_vm->_graphicsManager.INI_ECRAN2(v22, true);
|
2012-10-28 22:38:34 +01:00
|
|
|
_vm->_globals.NOMARCHE = true;
|
2012-12-16 09:56:50 +01:00
|
|
|
_vm->_objectsManager._forceZoneFl = true;
|
2013-01-12 11:55:44 +01:00
|
|
|
_vm->_objectsManager._zoneNum = -1;
|
2012-10-04 07:27:34 +10:00
|
|
|
do {
|
2012-12-26 21:30:51 +01:00
|
|
|
int mouseButton = _vm->_eventsManager.getMouseButton();
|
|
|
|
if (mouseButton == 1)
|
2012-12-19 02:15:32 +01:00
|
|
|
_vm->_objectsManager.handleLeftButton();
|
2012-12-26 21:30:51 +01:00
|
|
|
else if (mouseButton == 2)
|
2012-12-19 02:15:32 +01:00
|
|
|
_vm->_objectsManager.handleRightButton();
|
2012-12-26 21:30:51 +01:00
|
|
|
|
2012-12-26 07:56:26 +01:00
|
|
|
_vm->_objectsManager.checkZone();
|
2012-12-19 02:15:32 +01:00
|
|
|
if (_vm->_globals.GOACTION)
|
2012-10-04 07:27:34 +10:00
|
|
|
_vm->_objectsManager.PARADISE();
|
|
|
|
_vm->_eventsManager.VBL();
|
2012-12-24 13:32:39 +01:00
|
|
|
} while (!_vm->_globals._exitId);
|
2012-12-27 18:41:52 +01:00
|
|
|
dialogEndTalk();
|
|
|
|
dialogTalk();
|
2012-12-09 22:35:59 +01:00
|
|
|
clearCharacterAnim();
|
|
|
|
clearCharacterAnim();
|
2013-01-23 01:38:34 +01:00
|
|
|
_vm->_globals._introSpeechOffFl = false;
|
2012-12-19 08:00:22 +01:00
|
|
|
_characterBuffer = _vm->_globals.freeMemory(_characterBuffer);
|
2012-12-17 08:01:29 +01:00
|
|
|
_characterSprite = _vm->_globals.freeMemory(_characterSprite);
|
2013-01-07 13:24:04 +02:00
|
|
|
_vm->_graphicsManager.NB_SCREEN(false);
|
2013-01-11 01:50:29 +01:00
|
|
|
_vm->_linesManager.clearAllZones();
|
2013-01-10 22:09:37 +01:00
|
|
|
_vm->_linesManager.resetLines();
|
2013-01-02 00:57:00 +01:00
|
|
|
_vm->_globals.resetCache();
|
2012-12-17 08:01:29 +01:00
|
|
|
for (int i = 0; i <= 44; i++)
|
|
|
|
_vm->_globals.BOBZONE[i] = 0;
|
|
|
|
|
2013-01-27 01:25:46 +01:00
|
|
|
_vm->_globals.freeMemory(_vm->_globals._answerBuffer);
|
|
|
|
_vm->_globals._answerBuffer = v11;
|
2012-12-24 18:43:49 +01:00
|
|
|
_vm->_objectsManager._disableFl = true;
|
2012-10-04 07:27:34 +10:00
|
|
|
_vm->_objectsManager.INILINK(v20);
|
2013-01-07 19:43:24 +02:00
|
|
|
_vm->_graphicsManager.INI_ECRAN2(v20, true);
|
2012-12-24 18:43:49 +01:00
|
|
|
_vm->_objectsManager._disableFl = false;
|
2012-10-28 22:38:34 +01:00
|
|
|
_vm->_globals.NOMARCHE = false;
|
2012-12-24 13:32:39 +01:00
|
|
|
if (_vm->_globals._exitId == 101)
|
|
|
|
_vm->_globals._exitId = 0;
|
2012-10-28 18:04:06 +11:00
|
|
|
|
2012-12-20 00:30:01 +01:00
|
|
|
_vm->_saveLoadManager.load("TEMP.SCR", _vm->_graphicsManager._vesaScreen);
|
2012-10-28 18:04:06 +11:00
|
|
|
g_system->getSavefileManager()->removeSavefile("TEMP.SCR");
|
|
|
|
|
2012-10-29 23:08:23 +01:00
|
|
|
_vm->_objectsManager.PERSO_ON = false;
|
2012-12-11 08:31:07 +01:00
|
|
|
_vm->_eventsManager._mouseCursorId = 4;
|
2012-12-11 01:53:50 +01:00
|
|
|
_vm->_eventsManager.changeMouseCursor(4);
|
2012-10-04 07:27:34 +10:00
|
|
|
_vm->_graphicsManager.SETCOLOR3(253, 100, 100, 100);
|
2012-11-15 13:34:15 +01:00
|
|
|
|
|
|
|
if (!_vm->getIsDemo())
|
|
|
|
_vm->_graphicsManager.SETCOLOR3(254, 0, 0, 0);
|
|
|
|
|
2012-12-23 20:36:08 +01:00
|
|
|
_vm->_graphicsManager.initColorTable(145, 150, _vm->_graphicsManager._palette);
|
2013-01-07 08:33:55 +01:00
|
|
|
_vm->_graphicsManager.setPaletteVGA256(_vm->_graphicsManager._palette);
|
2012-12-19 02:15:32 +01:00
|
|
|
_vm->_graphicsManager.lockScreen();
|
|
|
|
_vm->_graphicsManager.m_scroll16(_vm->_graphicsManager._vesaScreen, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
|
|
|
|
_vm->_graphicsManager.unlockScreen();
|
2013-01-07 08:33:55 +01:00
|
|
|
_vm->_graphicsManager.setPaletteVGA256(_vm->_graphicsManager._palette);
|
2013-01-01 21:03:24 +01:00
|
|
|
memcpy(_vm->_graphicsManager._vesaBuffer, _vm->_graphicsManager._vesaScreen, 614399);
|
2012-12-10 23:57:59 +01:00
|
|
|
_vm->_globals._disableInventFl = false;
|
2012-10-04 07:27:34 +10:00
|
|
|
_vm->_graphicsManager.DD_VBL();
|
2012-12-17 08:01:29 +01:00
|
|
|
for (int i = 0; i <= 4; i++)
|
2012-10-04 07:27:34 +10:00
|
|
|
_vm->_eventsManager.VBL();
|
2013-01-20 00:56:19 +01:00
|
|
|
_vm->_graphicsManager._scrollStatus = 0;
|
2012-09-29 09:33:42 +10:00
|
|
|
}
|
|
|
|
|
2012-09-26 23:34:10 +10:00
|
|
|
} // End of namespace Hopkins
|