2007-05-30 21:56:52 +00: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.
|
2007-04-15 13:44:49 +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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
* $URL$
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2008-05-11 23:16:50 +00:00
|
|
|
#include "kyra/kyra_v1.h"
|
2008-05-02 14:46:30 +00:00
|
|
|
#include "kyra/kyra_mr.h"
|
|
|
|
#include "kyra/screen_mr.h"
|
2007-04-15 13:44:49 +00:00
|
|
|
#include "kyra/wsamovie.h"
|
|
|
|
#include "kyra/sound.h"
|
2008-05-02 14:46:30 +00:00
|
|
|
#include "kyra/text_mr.h"
|
2007-04-15 13:44:49 +00:00
|
|
|
#include "kyra/vqa.h"
|
2008-04-12 23:17:21 +00:00
|
|
|
#include "kyra/gui.h"
|
2008-04-16 23:09:07 +00:00
|
|
|
#include "kyra/timer.h"
|
2008-04-25 16:02:20 +00:00
|
|
|
#include "kyra/debugger.h"
|
2008-05-04 15:18:46 +00:00
|
|
|
#include "kyra/gui_mr.h"
|
2008-05-02 14:46:30 +00:00
|
|
|
#include "kyra/resource.h"
|
2007-04-15 13:44:49 +00:00
|
|
|
|
|
|
|
#include "common/system.h"
|
|
|
|
#include "common/config-manager.h"
|
|
|
|
|
|
|
|
namespace Kyra {
|
2008-05-03 19:23:45 +00:00
|
|
|
|
2008-05-03 19:32:45 +00:00
|
|
|
const KyraEngine_v2::EngineDesc KyraEngine_MR::_mrEngineDesc = {
|
|
|
|
// Generic shape related
|
2008-05-03 19:23:45 +00:00
|
|
|
248,
|
2008-05-03 19:32:45 +00:00
|
|
|
KyraEngine_MR::_characterFrameTable,
|
2008-05-03 19:23:45 +00:00
|
|
|
|
2008-05-03 19:32:45 +00:00
|
|
|
// Scene script
|
2008-05-03 19:23:45 +00:00
|
|
|
9,
|
|
|
|
|
2008-05-03 19:32:45 +00:00
|
|
|
// Animation script specific
|
2008-05-06 20:55:33 +00:00
|
|
|
9,
|
|
|
|
|
|
|
|
// Item specific
|
|
|
|
71
|
2008-05-03 19:23:45 +00:00
|
|
|
};
|
|
|
|
|
2008-05-03 19:32:45 +00:00
|
|
|
KyraEngine_MR::KyraEngine_MR(OSystem *system, const GameFlags &flags) : KyraEngine_v2(system, flags, _mrEngineDesc) {
|
2007-04-15 13:44:49 +00:00
|
|
|
_soundDigital = 0;
|
|
|
|
_musicSoundChannel = -1;
|
2008-06-03 18:12:21 +00:00
|
|
|
_menuAudioFile = "TITLE1";
|
2008-04-27 00:42:17 +00:00
|
|
|
_lastMusicCommand = -1;
|
2007-04-15 13:44:49 +00:00
|
|
|
_itemBuffer1 = _itemBuffer2 = 0;
|
|
|
|
_scoreFile = 0;
|
|
|
|
_cCodeFile = 0;
|
2008-04-14 20:20:51 +00:00
|
|
|
_scenesFile = 0;
|
|
|
|
_itemFile = 0;
|
|
|
|
_gamePlayBuffer = 0;
|
|
|
|
_interface = _interfaceCommandLine = 0;
|
|
|
|
_costPalBuffer = 0;
|
|
|
|
memset(_sceneShapes, 0, sizeof(_sceneShapes));
|
|
|
|
memset(_sceneAnimMovie, 0, sizeof(_sceneAnimMovie));
|
|
|
|
_gfxBackUpRect = 0;
|
|
|
|
_paletteOverlay = 0;
|
|
|
|
_sceneList = 0;
|
|
|
|
_mainCharacter.sceneId = 9;
|
2008-04-19 22:22:00 +00:00
|
|
|
_mainCharacter.height = 0x4C;
|
2008-04-14 20:20:51 +00:00
|
|
|
_mainCharacter.facing = 5;
|
2008-04-17 11:59:20 +00:00
|
|
|
_mainCharacter.animFrame = 0x57;
|
2008-04-14 20:20:51 +00:00
|
|
|
_mainCharacter.walkspeed = 5;
|
2008-05-10 14:12:48 +00:00
|
|
|
memset(_activeItemAnim, 0, sizeof(_activeItemAnim));
|
|
|
|
_nextAnimItem = 0;
|
2008-04-16 20:28:27 +00:00
|
|
|
_text = 0;
|
|
|
|
_commandLineY = 189;
|
|
|
|
_inventoryState = false;
|
|
|
|
memset(_characterAnimTable, 0, sizeof(_characterAnimTable));
|
|
|
|
_overwriteSceneFacing = false;
|
|
|
|
_maskPageMinY = _maskPageMaxY = 0;
|
|
|
|
_sceneStrings = 0;
|
|
|
|
_enterNewSceneLock = 0;
|
|
|
|
_mainCharX = _mainCharY = -1;
|
|
|
|
_animList = 0;
|
|
|
|
_drawNoShapeFlag = false;
|
2008-05-05 16:14:45 +00:00
|
|
|
_wasPlayingVQA = false;
|
2008-04-16 20:28:27 +00:00
|
|
|
_lastCharPalLayer = -1;
|
|
|
|
_charPalUpdate = false;
|
|
|
|
_runFlag = false;
|
2008-04-17 14:26:50 +00:00
|
|
|
_unk5 = 0;
|
2008-04-16 20:28:27 +00:00
|
|
|
_unkSceneScreenFlag1 = false;
|
|
|
|
_noScriptEnter = true;
|
2010-10-22 02:10:22 +00:00
|
|
|
_itemInHand = _mouseState = kItemNone;
|
2010-10-22 02:08:26 +00:00
|
|
|
_savedMouseState = -1;
|
2008-04-16 20:28:27 +00:00
|
|
|
_unk4 = 0;
|
|
|
|
_loadingState = false;
|
|
|
|
_noStartupChat = false;
|
2008-04-17 15:39:34 +00:00
|
|
|
_pathfinderFlag = 0;
|
2008-04-19 22:22:00 +00:00
|
|
|
_talkObjectList = 0;
|
|
|
|
memset(&_chatScriptState, 0, sizeof(_chatScriptState));
|
|
|
|
memset(&_chatScriptData, 0, sizeof(_chatScriptData));
|
|
|
|
_voiceSoundChannel = -1;
|
|
|
|
_charBackUpWidth2 = _charBackUpHeight2 = -1;
|
|
|
|
_charBackUpWidth = _charBackUpHeight = -1;
|
|
|
|
_useActorBuffer = false;
|
|
|
|
_curStudioSFX = 283;
|
2008-04-20 00:11:42 +00:00
|
|
|
_badConscienceShown = false;
|
2008-04-27 00:42:17 +00:00
|
|
|
_currentChapter = 1;
|
2008-04-20 02:11:10 +00:00
|
|
|
_unkHandleSceneChangeFlag = false;
|
2008-04-20 13:44:44 +00:00
|
|
|
memset(_sceneShapeDescs, 0, sizeof(_sceneShapeDescs));
|
2008-04-22 22:36:09 +00:00
|
|
|
_cnvFile = _dlgBuffer = 0;
|
|
|
|
_curDlgChapter = _curDlgIndex = _curDlgLang = -1;
|
|
|
|
_isStartupDialog = 0;
|
|
|
|
_stringBuffer = 0;
|
|
|
|
_dialogSceneAnim = _dialogSceneScript = -1;
|
|
|
|
memset(&_dialogScriptData, 0, sizeof(_dialogScriptData));
|
|
|
|
memset(&_dialogScriptState, 0, sizeof(_dialogScriptState));
|
|
|
|
_dialogScriptFuncStart = _dialogScriptFuncProc = _dialogScriptFuncEnd = 0;
|
2008-04-23 21:07:58 +00:00
|
|
|
_malcolmsMood = 1;
|
2008-04-23 19:24:02 +00:00
|
|
|
_nextIdleAnim = 0;
|
|
|
|
_nextIdleType = false;
|
2008-04-23 20:50:31 +00:00
|
|
|
_inventoryScrollSpeed = -1;
|
2008-04-23 21:07:58 +00:00
|
|
|
_invWsa = 0;
|
|
|
|
_invWsaFrame = -1;
|
2008-04-24 21:11:55 +00:00
|
|
|
_score = 0;
|
|
|
|
memset(_scoreFlagTable, 0, sizeof(_scoreFlagTable));
|
2008-04-26 21:08:47 +00:00
|
|
|
_mainButtonData = 0;
|
|
|
|
_mainButtonList = 0;
|
|
|
|
_mainButtonListInitialized = false;
|
|
|
|
_enableInventory = true;
|
2008-04-28 20:45:22 +00:00
|
|
|
_goodConscienceShown = false;
|
|
|
|
_goodConscienceAnim = -1;
|
|
|
|
_goodConsciencePosition = false;
|
2008-05-05 16:05:56 +00:00
|
|
|
_menuDirectlyToLoad = false;
|
|
|
|
_optionsFile = 0;
|
2008-05-05 17:56:39 +00:00
|
|
|
_actorFile = 0;
|
2008-05-06 16:57:07 +00:00
|
|
|
_chatAltFlag = false;
|
2008-05-11 15:24:25 +00:00
|
|
|
_albumChatActive = false;
|
|
|
|
memset(&_album, 0, sizeof(_album));
|
2008-05-11 17:50:13 +00:00
|
|
|
_configHelium = false;
|
2008-05-12 17:23:28 +00:00
|
|
|
_fadeOutMusicChannel = -1;
|
2008-05-12 17:46:15 +00:00
|
|
|
memset(_scaleTable, 0, sizeof(_scaleTable));
|
2007-04-15 13:44:49 +00:00
|
|
|
}
|
|
|
|
|
2008-05-02 14:46:30 +00:00
|
|
|
KyraEngine_MR::~KyraEngine_MR() {
|
2008-04-14 20:20:51 +00:00
|
|
|
delete _screen;
|
2007-04-15 13:44:49 +00:00
|
|
|
delete _soundDigital;
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2008-05-05 16:05:56 +00:00
|
|
|
delete[] _itemBuffer1;
|
|
|
|
delete[] _itemBuffer2;
|
|
|
|
delete[] _scoreFile;
|
|
|
|
delete[] _cCodeFile;
|
|
|
|
delete[] _scenesFile;
|
|
|
|
delete[] _itemFile;
|
2008-05-06 16:57:07 +00:00
|
|
|
delete[] _actorFile;
|
2008-05-05 16:05:56 +00:00
|
|
|
delete[] _gamePlayBuffer;
|
|
|
|
delete[] _interface;
|
|
|
|
delete[] _interfaceCommandLine;
|
|
|
|
delete[] _costPalBuffer;
|
2008-04-14 20:20:51 +00:00
|
|
|
|
|
|
|
for (uint i = 0; i < ARRAYSIZE(_sceneShapes); ++i)
|
2008-05-05 16:05:56 +00:00
|
|
|
delete[] _sceneShapes[i];
|
2008-04-14 20:20:51 +00:00
|
|
|
|
|
|
|
for (uint i = 0; i < ARRAYSIZE(_sceneAnimMovie); ++i)
|
|
|
|
delete _sceneAnimMovie[i];
|
|
|
|
|
2008-05-05 16:05:56 +00:00
|
|
|
delete[] _gfxBackUpRect;
|
|
|
|
delete[] _paletteOverlay;
|
2008-04-14 20:20:51 +00:00
|
|
|
|
|
|
|
for (ShapeMap::iterator i = _gameShapes.begin(); i != _gameShapes.end(); ++i) {
|
2008-05-05 16:05:56 +00:00
|
|
|
delete[] i->_value;
|
2008-04-14 20:20:51 +00:00
|
|
|
i->_value = 0;
|
|
|
|
}
|
|
|
|
_gameShapes.clear();
|
2008-04-16 20:28:27 +00:00
|
|
|
|
2008-05-05 16:05:56 +00:00
|
|
|
delete[] _sceneStrings;
|
|
|
|
delete[] _talkObjectList;
|
2008-04-20 15:16:58 +00:00
|
|
|
|
2010-05-17 23:29:44 +00:00
|
|
|
for (Common::Array<const Opcode *>::iterator i = _opcodesDialog.begin(); i != _opcodesDialog.end(); ++i)
|
2008-04-22 22:36:09 +00:00
|
|
|
delete *i;
|
|
|
|
_opcodesDialog.clear();
|
|
|
|
|
|
|
|
delete _cnvFile;
|
|
|
|
delete _dlgBuffer;
|
2008-05-05 16:05:56 +00:00
|
|
|
delete[] _stringBuffer;
|
2008-04-23 21:07:58 +00:00
|
|
|
delete _invWsa;
|
2008-05-05 16:05:56 +00:00
|
|
|
delete[] _mainButtonData;
|
2008-04-26 21:08:47 +00:00
|
|
|
delete _gui;
|
2008-05-05 16:05:56 +00:00
|
|
|
delete[] _optionsFile;
|
2008-05-11 15:24:25 +00:00
|
|
|
|
|
|
|
delete _album.wsa;
|
|
|
|
delete _album.leftPage.wsa;
|
|
|
|
delete _album.rightPage.wsa;
|
2007-04-15 13:44:49 +00:00
|
|
|
}
|
|
|
|
|
2008-11-06 17:05:54 +00:00
|
|
|
Common::Error KyraEngine_MR::init() {
|
2008-05-02 14:46:30 +00:00
|
|
|
_screen = new Screen_MR(this, _system);
|
2007-09-23 22:29:05 +00:00
|
|
|
assert(_screen);
|
2008-04-26 10:15:54 +00:00
|
|
|
_screen->setResolution();
|
2007-09-23 22:29:05 +00:00
|
|
|
|
2008-05-11 23:16:50 +00:00
|
|
|
KyraEngine_v1::init();
|
2008-05-12 13:35:58 +00:00
|
|
|
initStaticResource();
|
2009-01-01 15:06:43 +00:00
|
|
|
|
2008-05-04 15:56:28 +00:00
|
|
|
_debugger = new Debugger_v2(this);
|
2008-04-25 16:02:20 +00:00
|
|
|
assert(_debugger);
|
2007-04-15 13:44:49 +00:00
|
|
|
|
|
|
|
_soundDigital = new SoundDigital(this, _mixer);
|
|
|
|
assert(_soundDigital);
|
|
|
|
if (!_soundDigital->init())
|
|
|
|
error("_soundDigital->init() failed");
|
2008-05-11 23:16:50 +00:00
|
|
|
KyraEngine_v1::_text = _text = new TextDisplayer_MR(this, _screen);
|
2008-04-16 20:28:27 +00:00
|
|
|
assert(_text);
|
2008-05-04 15:18:46 +00:00
|
|
|
_gui = new GUI_MR(this);
|
2008-04-26 21:08:47 +00:00
|
|
|
assert(_gui);
|
2008-05-05 16:05:56 +00:00
|
|
|
_gui->initStaticData();
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2007-04-15 13:44:49 +00:00
|
|
|
_screen->loadFont(Screen::FID_6_FNT, "6.FNT");
|
|
|
|
_screen->loadFont(Screen::FID_8_FNT, "8FAT.FNT");
|
|
|
|
_screen->loadFont(Screen::FID_BOOKFONT_FNT, "BOOKFONT.FNT");
|
2009-10-06 17:28:32 +00:00
|
|
|
_screen->setFont(Screen::FID_8_FNT);
|
2007-04-15 13:44:49 +00:00
|
|
|
_screen->setAnimBlockPtr(3500);
|
|
|
|
_screen->setScreenDim(0);
|
2009-01-01 15:06:43 +00:00
|
|
|
|
2009-06-25 19:53:55 +00:00
|
|
|
_screen->loadPalette("PALETTE.COL", _screen->getPalette(0));
|
2009-06-22 02:36:54 +00:00
|
|
|
_screen->setScreenPalette(_screen->getPalette(0));
|
2007-04-15 13:44:49 +00:00
|
|
|
|
2008-11-06 17:05:54 +00:00
|
|
|
return Common::kNoError;
|
2007-04-15 13:44:49 +00:00
|
|
|
}
|
|
|
|
|
2008-11-06 17:05:54 +00:00
|
|
|
Common::Error KyraEngine_MR::go() {
|
2007-04-15 13:44:49 +00:00
|
|
|
bool running = true;
|
2008-04-14 20:20:51 +00:00
|
|
|
preinit();
|
|
|
|
_screen->hideMouse();
|
2008-04-12 23:17:21 +00:00
|
|
|
initMainMenu();
|
2008-04-12 23:29:12 +00:00
|
|
|
|
|
|
|
_screen->clearPage(0);
|
|
|
|
_screen->clearPage(2);
|
|
|
|
|
2008-05-05 16:14:45 +00:00
|
|
|
const bool firstTimeGame = !saveFileLoadable(0);
|
|
|
|
|
|
|
|
if (firstTimeGame) {
|
|
|
|
playVQA("K3INTRO");
|
|
|
|
_wasPlayingVQA = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_gameToLoad != -1 || firstTimeGame) {
|
2008-05-05 16:18:54 +00:00
|
|
|
while (!_screen->isMouseVisible())
|
|
|
|
_screen->showMouse();
|
|
|
|
|
2008-05-05 16:05:56 +00:00
|
|
|
uninitMainMenu();
|
|
|
|
_musicSoundChannel = -1;
|
|
|
|
startup();
|
|
|
|
runLoop();
|
|
|
|
running = false;
|
|
|
|
}
|
|
|
|
|
2008-09-30 12:27:38 +00:00
|
|
|
while (running && !shouldQuit()) {
|
2007-04-15 13:44:49 +00:00
|
|
|
_screen->_curPage = 0;
|
|
|
|
_screen->clearPage(0);
|
|
|
|
|
2009-06-22 02:36:54 +00:00
|
|
|
_screen->setScreenPalette(_screen->getPalette(0));
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2007-04-15 13:44:49 +00:00
|
|
|
playMenuAudioFile();
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2008-09-30 12:27:38 +00:00
|
|
|
for (int i = 0; i < 64 && !shouldQuit(); ++i) {
|
2007-04-15 13:44:49 +00:00
|
|
|
uint32 nextRun = _system->getMillis() + 3 * _tickLength;
|
2009-06-09 11:26:15 +00:00
|
|
|
_menuAnim->displayFrame(i, 0, 0, 0, 0, 0, 0);
|
2007-04-15 13:44:49 +00:00
|
|
|
_screen->updateScreen();
|
|
|
|
delayUntil(nextRun);
|
|
|
|
}
|
|
|
|
|
2008-09-30 12:27:38 +00:00
|
|
|
for (int i = 64; i > 29 && !shouldQuit(); --i) {
|
2007-04-15 13:44:49 +00:00
|
|
|
uint32 nextRun = _system->getMillis() + 3 * _tickLength;
|
2009-06-09 11:26:15 +00:00
|
|
|
_menuAnim->displayFrame(i, 0, 0, 0, 0, 0, 0);
|
2007-04-15 13:44:49 +00:00
|
|
|
_screen->updateScreen();
|
|
|
|
delayUntil(nextRun);
|
|
|
|
}
|
|
|
|
|
2008-05-10 19:41:26 +00:00
|
|
|
_eventList.clear();
|
|
|
|
|
2008-04-12 23:17:21 +00:00
|
|
|
switch (_menu->handle(3)) {
|
2008-05-05 16:05:56 +00:00
|
|
|
case 2:
|
2008-05-05 16:18:54 +00:00
|
|
|
_menuDirectlyToLoad = true;
|
2008-05-05 16:14:45 +00:00
|
|
|
// fall through
|
2008-05-05 16:05:56 +00:00
|
|
|
|
2007-04-15 13:44:49 +00:00
|
|
|
case 0:
|
2008-04-12 23:17:21 +00:00
|
|
|
uninitMainMenu();
|
|
|
|
|
2008-04-19 15:04:59 +00:00
|
|
|
fadeOutMusic(60);
|
2008-05-05 16:14:45 +00:00
|
|
|
_screen->fadeToBlack(60);
|
2008-04-20 02:11:10 +00:00
|
|
|
_musicSoundChannel = -1;
|
2008-04-14 20:20:51 +00:00
|
|
|
startup();
|
2008-04-16 23:09:07 +00:00
|
|
|
runLoop();
|
2007-04-15 13:44:49 +00:00
|
|
|
running = false;
|
|
|
|
break;
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2007-04-15 13:44:49 +00:00
|
|
|
case 1:
|
|
|
|
playVQA("K3INTRO");
|
2008-05-05 16:14:45 +00:00
|
|
|
_wasPlayingVQA = false;
|
2008-04-14 20:20:51 +00:00
|
|
|
_screen->hideMouse();
|
2007-04-15 13:44:49 +00:00
|
|
|
break;
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2007-04-15 13:44:49 +00:00
|
|
|
case 3:
|
2008-04-16 21:13:52 +00:00
|
|
|
fadeOutMusic(60);
|
2008-05-05 16:14:45 +00:00
|
|
|
_screen->fadeToBlack(60);
|
2008-04-12 23:17:21 +00:00
|
|
|
uninitMainMenu();
|
|
|
|
quitGame();
|
|
|
|
running = false;
|
2009-07-06 16:17:03 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
2007-04-15 13:44:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-07-06 16:17:03 +00:00
|
|
|
if (_showOutro && !shouldQuit())
|
2008-04-28 21:32:23 +00:00
|
|
|
playVQA("CREDITS");
|
|
|
|
|
2008-11-06 17:05:54 +00:00
|
|
|
return Common::kNoError;
|
2007-04-15 13:44:49 +00:00
|
|
|
}
|
|
|
|
|
2008-05-02 14:46:30 +00:00
|
|
|
void KyraEngine_MR::initMainMenu() {
|
2009-06-09 11:26:15 +00:00
|
|
|
_menuAnim = new WSAMovie_v2(this);
|
2009-06-22 02:37:20 +00:00
|
|
|
_menuAnim->open("REVENGE.WSA", 1, &_screen->getPalette(0));
|
2009-06-29 16:49:53 +00:00
|
|
|
_screen->getPalette(0).fill(0, 1, 0);
|
2008-04-12 23:17:21 +00:00
|
|
|
|
|
|
|
_menu = new MainMenu(this);
|
|
|
|
MainMenu::StaticData data = {
|
2008-12-26 11:04:45 +00:00
|
|
|
{ _mainMenuStrings[_lang*4+0], _mainMenuStrings[_lang*4+1], _mainMenuStrings[_lang*4+2], _mainMenuStrings[_lang*4+3], 0 },
|
|
|
|
{ 0x01, 0x04, 0x0C, 0x04, 0x00, 0x80, 0xFF },
|
2008-04-12 23:17:21 +00:00
|
|
|
{ 0x16, 0x19, 0x1A, 0x16 },
|
2008-12-26 11:04:45 +00:00
|
|
|
Screen::FID_8_FNT, 240
|
2008-04-12 23:17:21 +00:00
|
|
|
};
|
|
|
|
|
2008-07-05 07:47:27 +00:00
|
|
|
if (_flags.lang == Common::ES_ESP) {
|
|
|
|
for (int i = 0; i < 4; ++i)
|
|
|
|
data.strings[i] = _mainMenuSpanishFan[i];
|
2008-07-05 08:20:10 +00:00
|
|
|
} else if (_flags.lang == Common::IT_ITA) {
|
|
|
|
for (int i = 0; i < 4; ++i)
|
|
|
|
data.strings[i] = _mainMenuItalianFan[i];
|
2008-07-05 07:47:27 +00:00
|
|
|
}
|
|
|
|
|
2008-04-12 23:17:21 +00:00
|
|
|
MainMenu::Animation anim;
|
|
|
|
anim.anim = _menuAnim;
|
|
|
|
anim.startFrame = 29;
|
|
|
|
anim.endFrame = 63;
|
|
|
|
anim.delay = 2;
|
|
|
|
|
|
|
|
_menu->init(data, anim);
|
|
|
|
}
|
|
|
|
|
2008-05-02 14:46:30 +00:00
|
|
|
void KyraEngine_MR::uninitMainMenu() {
|
2008-04-12 23:17:21 +00:00
|
|
|
delete _menuAnim;
|
|
|
|
_menuAnim = 0;
|
|
|
|
delete _menu;
|
|
|
|
_menu = 0;
|
|
|
|
}
|
|
|
|
|
2008-05-02 14:46:30 +00:00
|
|
|
void KyraEngine_MR::playVQA(const char *name) {
|
2007-04-15 13:44:49 +00:00
|
|
|
VQAMovie vqa(this, _system);
|
|
|
|
|
|
|
|
char filename[20];
|
2010-07-23 00:39:23 +00:00
|
|
|
snprintf(filename, sizeof(filename), "%s%d.VQA", name, _configVQAQuality);
|
2007-04-15 13:44:49 +00:00
|
|
|
|
|
|
|
if (vqa.open(filename)) {
|
2008-05-17 15:12:20 +00:00
|
|
|
for (int i = 0; i < 4; ++i) {
|
|
|
|
if (i != _musicSoundChannel)
|
|
|
|
_soundDigital->stopSound(i);
|
|
|
|
}
|
2007-04-15 13:44:49 +00:00
|
|
|
|
|
|
|
_screen->hideMouse();
|
2009-06-22 02:36:16 +00:00
|
|
|
_screen->copyPalette(1, 0);
|
2008-04-16 20:28:27 +00:00
|
|
|
fadeOutMusic(60);
|
2008-05-05 16:14:45 +00:00
|
|
|
_screen->fadeToBlack(60);
|
2008-04-16 20:28:27 +00:00
|
|
|
_screen->clearPage(0);
|
|
|
|
|
2007-04-15 13:44:49 +00:00
|
|
|
vqa.setDrawPage(0);
|
|
|
|
vqa.play();
|
|
|
|
vqa.close();
|
2008-04-16 20:28:27 +00:00
|
|
|
|
|
|
|
_soundDigital->stopAllSounds();
|
2007-04-15 13:44:49 +00:00
|
|
|
_screen->showMouse();
|
|
|
|
|
2008-04-19 15:37:59 +00:00
|
|
|
// Taken from original, it used '1' here too
|
2009-06-29 16:49:53 +00:00
|
|
|
_screen->getPalette(0).fill(0, 256, 1);
|
2009-06-22 02:36:54 +00:00
|
|
|
_screen->setScreenPalette(_screen->getPalette(0));
|
2008-04-16 20:28:27 +00:00
|
|
|
_screen->clearPage(0);
|
2009-06-22 02:36:16 +00:00
|
|
|
_screen->copyPalette(0, 1);
|
2008-05-05 16:14:45 +00:00
|
|
|
_wasPlayingVQA = true;
|
2007-04-15 13:44:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#pragma mark -
|
|
|
|
|
2008-05-02 14:46:30 +00:00
|
|
|
void KyraEngine_MR::playMenuAudioFile() {
|
2007-04-15 13:44:49 +00:00
|
|
|
if (_soundDigital->isPlaying(_musicSoundChannel))
|
|
|
|
return;
|
|
|
|
|
2008-05-17 13:22:12 +00:00
|
|
|
_musicSoundChannel = _soundDigital->playSound(_menuAudioFile, 0xFF, Audio::Mixer::kMusicSoundType, 255, true);
|
2007-04-15 13:44:49 +00:00
|
|
|
}
|
|
|
|
|
2008-05-02 14:46:30 +00:00
|
|
|
void KyraEngine_MR::snd_playWanderScoreViaMap(int track, int force) {
|
2007-04-15 16:41:20 +00:00
|
|
|
if (_musicSoundChannel != -1 && !_soundDigital->isPlaying(_musicSoundChannel))
|
2007-04-15 13:44:49 +00:00
|
|
|
force = 1;
|
2007-04-15 16:41:20 +00:00
|
|
|
else if (_musicSoundChannel == -1)
|
2007-04-15 13:44:49 +00:00
|
|
|
force = 1;
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2008-04-27 00:42:17 +00:00
|
|
|
if (track == _lastMusicCommand && !force)
|
2007-04-15 13:44:49 +00:00
|
|
|
return;
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2007-04-15 13:44:49 +00:00
|
|
|
stopMusicTrack();
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2007-04-15 13:44:49 +00:00
|
|
|
if (_musicSoundChannel == -1) {
|
|
|
|
assert(track < _soundListSize && track >= 0);
|
|
|
|
|
2008-05-12 13:35:58 +00:00
|
|
|
char file[13];
|
2008-06-03 18:12:21 +00:00
|
|
|
sprintf(file, "%s", _soundList[track]);
|
2008-05-12 13:35:58 +00:00
|
|
|
_musicSoundChannel = _soundDigital->playSound(file, 0xFF, Audio::Mixer::kMusicSoundType);
|
2007-04-15 13:44:49 +00:00
|
|
|
}
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2008-04-27 00:42:17 +00:00
|
|
|
_lastMusicCommand = track;
|
2007-04-15 13:44:49 +00:00
|
|
|
}
|
|
|
|
|
2008-05-02 14:46:30 +00:00
|
|
|
void KyraEngine_MR::stopMusicTrack() {
|
2008-02-07 23:27:08 +00:00
|
|
|
if (_musicSoundChannel != -1 && _soundDigital->isPlaying(_musicSoundChannel))
|
2007-04-15 13:44:49 +00:00
|
|
|
_soundDigital->stopSound(_musicSoundChannel);
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2008-04-27 00:42:17 +00:00
|
|
|
_lastMusicCommand = -1;
|
2007-04-15 13:44:49 +00:00
|
|
|
_musicSoundChannel = -1;
|
|
|
|
}
|
|
|
|
|
2008-05-02 14:46:30 +00:00
|
|
|
int KyraEngine_MR::musicUpdate(int forceRestart) {
|
2007-07-29 16:33:11 +00:00
|
|
|
static uint32 mTimer = 0;
|
2007-04-15 13:44:49 +00:00
|
|
|
static uint16 lock = 0;
|
|
|
|
|
2008-04-14 20:20:51 +00:00
|
|
|
if (ABS<int>(_system->getMillis() - mTimer) > (int)(0x0F * _tickLength))
|
2007-07-29 16:33:11 +00:00
|
|
|
mTimer = _system->getMillis();
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2008-04-14 20:20:51 +00:00
|
|
|
if (_system->getMillis() < mTimer && !forceRestart)
|
2007-04-15 13:44:49 +00:00
|
|
|
return 1;
|
|
|
|
|
|
|
|
if (!lock) {
|
|
|
|
lock = 1;
|
|
|
|
if (_musicSoundChannel >= 0) {
|
|
|
|
if (!_soundDigital->isPlaying(_musicSoundChannel)) {
|
2008-04-27 00:42:17 +00:00
|
|
|
if (_lastMusicCommand != -1)
|
2008-04-29 14:08:08 +00:00
|
|
|
snd_playWanderScoreViaMap(_lastMusicCommand, 1);
|
2007-04-15 13:44:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
lock = 0;
|
2007-07-29 16:33:11 +00:00
|
|
|
mTimer = _system->getMillis() + 0x0F * _tickLength;
|
2007-04-15 13:44:49 +00:00
|
|
|
}
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2007-04-15 13:44:49 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2008-05-02 14:46:30 +00:00
|
|
|
void KyraEngine_MR::fadeOutMusic(int ticks) {
|
2008-04-16 20:28:27 +00:00
|
|
|
if (_musicSoundChannel >= 0) {
|
|
|
|
_fadeOutMusicChannel = _musicSoundChannel;
|
|
|
|
_soundDigital->beginFadeOut(_musicSoundChannel, ticks);
|
2008-04-27 00:42:17 +00:00
|
|
|
_lastMusicCommand = -1;
|
2008-04-16 20:28:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-05-02 14:46:30 +00:00
|
|
|
void KyraEngine_MR::snd_playSoundEffect(int item, int volume) {
|
2008-04-17 17:46:39 +00:00
|
|
|
if (_sfxFileMap[item*2+0] != 0xFF) {
|
|
|
|
char filename[16];
|
2008-05-12 13:50:59 +00:00
|
|
|
assert(_sfxFileMap[item*2+0] < _sfxFileListSize);
|
2008-06-03 18:12:21 +00:00
|
|
|
snprintf(filename, 16, "%s", _sfxFileList[_sfxFileMap[item*2+0]]);
|
2008-04-20 14:25:37 +00:00
|
|
|
uint8 priority = _sfxFileMap[item*2+1];
|
2008-04-17 17:46:39 +00:00
|
|
|
|
2008-04-20 22:24:24 +00:00
|
|
|
_soundDigital->playSound(filename, priority, Audio::Mixer::kSFXSoundType, volume);
|
2008-04-17 17:46:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-05-02 14:46:30 +00:00
|
|
|
void KyraEngine_MR::playVoice(int high, int low) {
|
2008-04-19 22:22:00 +00:00
|
|
|
snd_playVoiceFile(high * 1000 + low);
|
|
|
|
}
|
|
|
|
|
2008-05-02 14:46:30 +00:00
|
|
|
void KyraEngine_MR::snd_playVoiceFile(int file) {
|
2008-04-19 22:22:00 +00:00
|
|
|
char filename[16];
|
2008-06-03 18:12:21 +00:00
|
|
|
snprintf(filename, 16, "%.08u", (uint)file);
|
2008-04-19 22:22:00 +00:00
|
|
|
|
2008-08-10 01:28:00 +00:00
|
|
|
if (speechEnabled())
|
|
|
|
_voiceSoundChannel = _soundDigital->playSound(filename, 0xFE, Audio::Mixer::kSpeechSoundType, 255);
|
2008-04-19 22:22:00 +00:00
|
|
|
}
|
|
|
|
|
2008-05-02 14:46:30 +00:00
|
|
|
bool KyraEngine_MR::snd_voiceIsPlaying() {
|
2008-04-19 22:22:00 +00:00
|
|
|
return _soundDigital->isPlaying(_voiceSoundChannel);
|
|
|
|
}
|
|
|
|
|
2008-05-02 14:46:30 +00:00
|
|
|
void KyraEngine_MR::snd_stopVoice() {
|
2008-04-20 13:44:44 +00:00
|
|
|
if (_voiceSoundChannel != -1)
|
|
|
|
_soundDigital->stopSound(_voiceSoundChannel);
|
2008-04-19 22:22:00 +00:00
|
|
|
}
|
|
|
|
|
2008-05-02 14:46:30 +00:00
|
|
|
void KyraEngine_MR::playStudioSFX(const char *str) {
|
2008-05-05 17:12:48 +00:00
|
|
|
if (!_configStudio)
|
|
|
|
return;
|
|
|
|
|
2008-04-19 22:22:00 +00:00
|
|
|
if (_rnd.getRandomNumberRng(1, 2) != 2)
|
|
|
|
return;
|
|
|
|
|
2008-04-20 00:32:39 +00:00
|
|
|
const int strSize = strlen(str) - 1;
|
|
|
|
if (str[strSize] != '?' && str[strSize] != '!')
|
|
|
|
return;
|
|
|
|
|
2008-04-29 14:08:08 +00:00
|
|
|
snd_playSoundEffect(_curStudioSFX++, 128);
|
2008-04-19 22:22:00 +00:00
|
|
|
|
|
|
|
if (_curStudioSFX > 291)
|
|
|
|
_curStudioSFX = 283;
|
|
|
|
}
|
|
|
|
|
2007-04-15 13:44:49 +00:00
|
|
|
#pragma mark -
|
|
|
|
|
2008-05-02 14:46:30 +00:00
|
|
|
void KyraEngine_MR::preinit() {
|
2008-04-20 12:34:16 +00:00
|
|
|
_itemBuffer1 = new int8[72];
|
|
|
|
_itemBuffer2 = new int8[144];
|
2008-04-14 20:20:51 +00:00
|
|
|
initMouseShapes();
|
|
|
|
initItems();
|
|
|
|
|
|
|
|
_screen->setMouseCursor(0, 0, _gameShapes[0]);
|
|
|
|
}
|
|
|
|
|
2008-05-02 14:46:30 +00:00
|
|
|
void KyraEngine_MR::initMouseShapes() {
|
2008-04-14 20:20:51 +00:00
|
|
|
uint8 *data = _res->fileData("MOUSE.SHP", 0);
|
|
|
|
assert(data);
|
|
|
|
for (int i = 0; i <= 6; ++i)
|
|
|
|
_gameShapes[i] = _screen->makeShapeCopy(data, i);
|
2008-05-07 14:20:37 +00:00
|
|
|
delete[] data;
|
2008-04-14 20:20:51 +00:00
|
|
|
}
|
2007-04-15 13:44:49 +00:00
|
|
|
|
2008-05-02 14:46:30 +00:00
|
|
|
void KyraEngine_MR::startup() {
|
2009-06-09 11:26:15 +00:00
|
|
|
_album.wsa = new WSAMovie_v2(this);
|
2008-05-11 15:24:25 +00:00
|
|
|
assert(_album.wsa);
|
2009-06-09 11:26:15 +00:00
|
|
|
_album.leftPage.wsa = new WSAMovie_v2(this);
|
2008-05-11 15:24:25 +00:00
|
|
|
assert(_album.leftPage.wsa);
|
2009-06-09 11:26:15 +00:00
|
|
|
_album.rightPage.wsa = new WSAMovie_v2(this);
|
2008-05-11 15:24:25 +00:00
|
|
|
assert(_album.rightPage.wsa);
|
2007-04-15 13:44:49 +00:00
|
|
|
musicUpdate(0);
|
|
|
|
|
2008-04-14 20:20:51 +00:00
|
|
|
_gamePlayBuffer = new uint8[64000];
|
2007-04-15 13:44:49 +00:00
|
|
|
musicUpdate(0);
|
|
|
|
musicUpdate(0);
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2008-04-14 20:20:51 +00:00
|
|
|
_interface = new uint8[17920];
|
|
|
|
_interfaceCommandLine = new uint8[3840];
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2009-10-06 17:28:32 +00:00
|
|
|
_screen->setFont(Screen::FID_8_FNT);
|
2007-04-15 13:44:49 +00:00
|
|
|
|
2009-01-01 15:06:43 +00:00
|
|
|
_stringBuffer = new char[500];
|
2008-04-14 20:20:51 +00:00
|
|
|
musicUpdate(0);
|
2008-05-02 17:14:59 +00:00
|
|
|
allocAnimObjects(1, 16, 50);
|
2007-04-15 13:44:49 +00:00
|
|
|
|
|
|
|
musicUpdate(0);
|
|
|
|
|
2008-04-14 20:20:51 +00:00
|
|
|
memset(_sceneShapes, 0, sizeof(_sceneShapes));
|
|
|
|
_screenBuffer = new uint8[64000];
|
2007-04-15 13:44:49 +00:00
|
|
|
|
|
|
|
musicUpdate(0);
|
|
|
|
musicUpdate(0);
|
|
|
|
|
2008-04-14 20:20:51 +00:00
|
|
|
if (!loadLanguageFile("ITEMS.", _itemFile))
|
2008-04-24 21:11:55 +00:00
|
|
|
error("Couldn't load ITEMS");
|
|
|
|
if (!loadLanguageFile("SCORE.", _scoreFile))
|
|
|
|
error("Couldn't load SCORE");
|
2007-04-15 13:44:49 +00:00
|
|
|
if (!loadLanguageFile("C_CODE.", _cCodeFile))
|
2008-04-24 21:11:55 +00:00
|
|
|
error("Couldn't load C_CODE");
|
2008-04-14 20:20:51 +00:00
|
|
|
if (!loadLanguageFile("SCENES.", _scenesFile))
|
2008-04-24 21:11:55 +00:00
|
|
|
error("Couldn't load SCENES");
|
2008-05-05 16:05:56 +00:00
|
|
|
if (!loadLanguageFile("OPTIONS.", _optionsFile))
|
|
|
|
error("Couldn't load OPTIONS");
|
2008-05-05 17:12:48 +00:00
|
|
|
if (!loadLanguageFile("_ACTOR.", _actorFile))
|
2008-04-14 20:20:51 +00:00
|
|
|
error("couldn't load _ACTOR");
|
|
|
|
|
|
|
|
musicUpdate(0);
|
|
|
|
openTalkFile(0);
|
|
|
|
musicUpdate(0);
|
|
|
|
_currentTalkFile = 0;
|
|
|
|
openTalkFile(1);
|
|
|
|
loadCostPal();
|
|
|
|
musicUpdate(0);
|
|
|
|
|
|
|
|
for (int i = 0; i < 16; ++i) {
|
|
|
|
_sceneAnims[i].flags = 0;
|
2009-06-09 11:26:15 +00:00
|
|
|
_sceneAnimMovie[i] = new WSAMovie_v2(this);
|
2008-04-14 20:20:51 +00:00
|
|
|
assert(_sceneAnimMovie[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
_screen->_curPage = 0;
|
|
|
|
|
2008-04-19 22:22:00 +00:00
|
|
|
_talkObjectList = new TalkObject[88];
|
|
|
|
memset(_talkObjectList, 0, sizeof(TalkObject)*88);
|
|
|
|
for (int i = 0; i < 88; ++i)
|
2008-04-23 19:24:02 +00:00
|
|
|
_talkObjectList[i].sceneId = 0xFF;
|
2007-04-15 13:44:49 +00:00
|
|
|
|
|
|
|
musicUpdate(0);
|
2008-04-14 20:20:51 +00:00
|
|
|
_gfxBackUpRect = new uint8[_screen->getRectSize(32, 32)];
|
2008-05-02 15:08:45 +00:00
|
|
|
initItemList(50);
|
2008-04-14 20:20:51 +00:00
|
|
|
resetItemList();
|
|
|
|
|
|
|
|
loadShadowShape();
|
|
|
|
musicUpdate(0);
|
|
|
|
loadExtrasShapes();
|
|
|
|
musicUpdate(0);
|
2008-05-02 15:21:51 +00:00
|
|
|
_characterShapeFile = 0;
|
|
|
|
loadCharacterShapes(_characterShapeFile);
|
2008-05-02 15:39:51 +00:00
|
|
|
updateMalcolmShapes();
|
2008-04-14 20:20:51 +00:00
|
|
|
musicUpdate(0);
|
2008-04-26 21:08:47 +00:00
|
|
|
initMainButtonList(true);
|
2008-05-05 16:05:56 +00:00
|
|
|
loadButtonShapes();
|
2008-04-14 20:20:51 +00:00
|
|
|
loadInterfaceShapes();
|
|
|
|
|
|
|
|
musicUpdate(0);
|
2009-06-25 19:53:55 +00:00
|
|
|
_screen->loadPalette("PALETTE.COL", _screen->getPalette(0));
|
2008-04-14 20:20:51 +00:00
|
|
|
_paletteOverlay = new uint8[256];
|
2009-06-25 19:57:06 +00:00
|
|
|
_screen->generateOverlay(_screen->getPalette(0), _paletteOverlay, 0xF0, 0x19);
|
2008-04-14 20:20:51 +00:00
|
|
|
|
|
|
|
loadInterface();
|
|
|
|
musicUpdate(0);
|
|
|
|
|
|
|
|
clearAnimObjects();
|
|
|
|
|
2008-04-24 21:11:55 +00:00
|
|
|
_scoreMax = 0;
|
|
|
|
for (int i = 0; i < _scoreTableSize; ++i) {
|
|
|
|
if (_scoreTable[i] > 0)
|
|
|
|
_scoreMax += _scoreTable[i];
|
|
|
|
}
|
2008-04-14 20:20:51 +00:00
|
|
|
|
|
|
|
musicUpdate(0);
|
2008-04-23 18:18:11 +00:00
|
|
|
|
|
|
|
memset(_newSceneDlgState, 0, sizeof(_newSceneDlgState));
|
|
|
|
memset(_conversationState, -1, sizeof(_conversationState));
|
2008-04-14 20:20:51 +00:00
|
|
|
|
|
|
|
_sceneList = new SceneDesc[98];
|
2008-05-01 22:42:05 +00:00
|
|
|
assert(_sceneList);
|
|
|
|
memset(_sceneList, 0, sizeof(SceneDesc)*98);
|
2008-04-25 16:02:20 +00:00
|
|
|
_sceneListSize = 98;
|
2009-01-01 15:06:43 +00:00
|
|
|
|
2008-04-14 20:20:51 +00:00
|
|
|
musicUpdate(0);
|
|
|
|
runStartupScript(1, 0);
|
2008-04-23 21:07:58 +00:00
|
|
|
_res->exists("MOODOMTR.WSA", true);
|
2009-06-09 11:26:15 +00:00
|
|
|
_invWsa = new WSAMovie_v2(this);
|
2008-04-23 21:07:58 +00:00
|
|
|
assert(_invWsa);
|
|
|
|
_invWsa->open("MOODOMTR.WSA", 1, 0);
|
|
|
|
_invWsaFrame = 6;
|
2008-11-09 13:00:40 +00:00
|
|
|
saveGameState(0, "New Game", 0);
|
2008-05-05 16:05:56 +00:00
|
|
|
if (_gameToLoad == -1)
|
|
|
|
enterNewScene(_mainCharacter.sceneId, _mainCharacter.facing, 0, 0, 1);
|
|
|
|
else
|
2008-11-09 13:12:38 +00:00
|
|
|
loadGameStateCheck(_gameToLoad);
|
2008-05-05 16:05:56 +00:00
|
|
|
|
|
|
|
if (_menuDirectlyToLoad)
|
|
|
|
(*_mainButtonData[0].buttonCallback)(&_mainButtonData[0]);
|
|
|
|
|
2008-04-16 20:28:27 +00:00
|
|
|
_screen->updateScreen();
|
2008-04-14 20:20:51 +00:00
|
|
|
musicUpdate(0);
|
|
|
|
_screen->showMouse();
|
2008-05-05 16:05:56 +00:00
|
|
|
|
|
|
|
setNextIdleAnimTimer();
|
|
|
|
setWalkspeed(_configWalkspeed);
|
2008-04-14 20:20:51 +00:00
|
|
|
}
|
|
|
|
|
2008-05-02 14:46:30 +00:00
|
|
|
void KyraEngine_MR::loadCostPal() {
|
2008-05-06 16:57:07 +00:00
|
|
|
_res->exists("_COSTPAL.DAT", true);
|
|
|
|
uint32 size = 0;
|
|
|
|
_costPalBuffer = _res->fileData("_COSTPAL.DAT", &size);
|
|
|
|
assert(_costPalBuffer);
|
|
|
|
assert(size == 864);
|
2008-04-14 20:20:51 +00:00
|
|
|
}
|
|
|
|
|
2008-05-02 14:46:30 +00:00
|
|
|
void KyraEngine_MR::loadShadowShape() {
|
2008-04-14 20:20:51 +00:00
|
|
|
_screen->loadBitmap("SHADOW.CSH", 3, 3, 0);
|
|
|
|
addShapeToPool(_screen->getCPagePtr(3), 421, 0);
|
|
|
|
}
|
|
|
|
|
2008-05-02 14:46:30 +00:00
|
|
|
void KyraEngine_MR::loadExtrasShapes() {
|
2008-04-14 20:20:51 +00:00
|
|
|
_screen->loadBitmap("EXTRAS.CSH", 3, 3, 0);
|
|
|
|
for (int i = 0; i < 20; ++i)
|
|
|
|
addShapeToPool(_screen->getCPagePtr(3), i+433, i);
|
|
|
|
addShapeToPool(_screen->getCPagePtr(3), 453, 20);
|
|
|
|
addShapeToPool(_screen->getCPagePtr(3), 454, 21);
|
2007-04-15 13:44:49 +00:00
|
|
|
}
|
|
|
|
|
2008-05-02 14:46:30 +00:00
|
|
|
void KyraEngine_MR::loadInterfaceShapes() {
|
2008-04-14 20:20:51 +00:00
|
|
|
_screen->loadBitmap("INTRFACE.CSH", 3, 3, 0);
|
|
|
|
for (int i = 422; i <= 432; ++i)
|
|
|
|
addShapeToPool(_screen->getCPagePtr(3), i, i-422);
|
|
|
|
}
|
|
|
|
|
2008-05-02 14:46:30 +00:00
|
|
|
void KyraEngine_MR::loadInterface() {
|
2008-04-14 20:20:51 +00:00
|
|
|
_screen->loadBitmap("INTRFACE.CPS", 3, 3, 0);
|
|
|
|
memcpy(_interface, _screen->getCPagePtr(3), 17920);
|
|
|
|
memcpy(_interfaceCommandLine, _screen->getCPagePtr(3), 3840);
|
|
|
|
}
|
2007-04-15 13:44:49 +00:00
|
|
|
|
2008-05-02 14:46:30 +00:00
|
|
|
void KyraEngine_MR::initItems() {
|
2007-04-15 13:44:49 +00:00
|
|
|
_screen->loadBitmap("ITEMS.CSH", 3, 3, 0);
|
|
|
|
|
2008-04-14 20:20:51 +00:00
|
|
|
for (int i = 248; i <= 319; ++i)
|
|
|
|
addShapeToPool(_screen->getCPagePtr(3), i, i-248);
|
2007-04-15 13:44:49 +00:00
|
|
|
|
|
|
|
_screen->loadBitmap("ITEMS2.CSH", 3, 3, 0);
|
|
|
|
|
2008-04-14 20:20:51 +00:00
|
|
|
for (int i = 320; i <= 397; ++i)
|
|
|
|
addShapeToPool(_screen->getCPagePtr(3), i, i-320);
|
2007-04-15 13:44:49 +00:00
|
|
|
|
|
|
|
uint32 size = 0;
|
|
|
|
uint8 *itemsDat = _res->fileData("_ITEMS.DAT", &size);
|
|
|
|
|
|
|
|
assert(size >= 72+144);
|
|
|
|
|
|
|
|
memcpy(_itemBuffer1, itemsDat , 72);
|
|
|
|
memcpy(_itemBuffer2, itemsDat+72, 144);
|
|
|
|
|
2008-05-07 14:20:37 +00:00
|
|
|
delete[] itemsDat;
|
2007-04-15 13:44:49 +00:00
|
|
|
|
|
|
|
_screen->_curPage = 0;
|
|
|
|
}
|
|
|
|
|
2008-05-02 14:46:30 +00:00
|
|
|
void KyraEngine_MR::runStartupScript(int script, int unk1) {
|
2008-04-29 15:12:09 +00:00
|
|
|
EMCState state;
|
|
|
|
EMCData data;
|
2008-04-14 20:20:51 +00:00
|
|
|
memset(&state, 0, sizeof(state));
|
|
|
|
memset(&data, 0, sizeof(data));
|
|
|
|
char filename[13];
|
|
|
|
strcpy(filename, "_START0X.EMC");
|
|
|
|
filename[7] = (script % 10) + '0';
|
|
|
|
|
2008-04-29 15:12:09 +00:00
|
|
|
_emc->load(filename, &data, &_opcodes);
|
|
|
|
_emc->init(&state, &data);
|
|
|
|
_emc->start(&state, 0);
|
2008-04-14 20:20:51 +00:00
|
|
|
state.regs[6] = unk1;
|
|
|
|
|
2008-04-29 15:12:09 +00:00
|
|
|
while (_emc->isValid(&state))
|
|
|
|
_emc->run(&state);
|
2008-04-17 11:59:20 +00:00
|
|
|
|
2008-04-29 15:12:09 +00:00
|
|
|
_emc->unload(&data);
|
2008-04-14 20:20:51 +00:00
|
|
|
}
|
|
|
|
|
2008-05-02 14:46:30 +00:00
|
|
|
void KyraEngine_MR::openTalkFile(int file) {
|
2008-04-14 20:20:51 +00:00
|
|
|
char talkFilename[16];
|
|
|
|
|
|
|
|
if (file == 0) {
|
|
|
|
strcpy(talkFilename, "ANYTALK.TLK");
|
|
|
|
} else {
|
2008-04-18 19:33:06 +00:00
|
|
|
if (_currentTalkFile > 0) {
|
2008-04-14 20:20:51 +00:00
|
|
|
sprintf(talkFilename, "CH%dTALK.TLK", _currentTalkFile);
|
2008-04-18 19:33:06 +00:00
|
|
|
_res->unloadPakFile(talkFilename);
|
|
|
|
}
|
2008-04-14 20:20:51 +00:00
|
|
|
sprintf(talkFilename, "CH%dTALK.TLK", file);
|
|
|
|
}
|
|
|
|
|
|
|
|
_currentTalkFile = file;
|
2008-08-10 01:28:00 +00:00
|
|
|
if (!_res->loadPakFile(talkFilename)) {
|
|
|
|
if (speechEnabled()) {
|
2009-01-13 18:11:11 +00:00
|
|
|
warning("Couldn't load voice file '%s', falling back to text only mode", talkFilename);
|
2008-08-10 01:28:00 +00:00
|
|
|
_configVoice = 0;
|
2009-01-13 18:11:11 +00:00
|
|
|
|
|
|
|
// Sync the config manager with the new settings
|
|
|
|
writeSettings();
|
2008-08-10 01:28:00 +00:00
|
|
|
}
|
|
|
|
}
|
2008-04-14 20:20:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#pragma mark -
|
|
|
|
|
2008-05-02 15:21:51 +00:00
|
|
|
void KyraEngine_MR::loadCharacterShapes(int newShapes) {
|
2008-04-14 20:20:51 +00:00
|
|
|
static const uint8 numberOffset[] = { 3, 3, 4, 4, 3, 3 };
|
|
|
|
static const uint8 startShape[] = { 0x32, 0x58, 0x78, 0x98, 0xB8, 0xD8 };
|
|
|
|
static const uint8 endShape[] = { 0x57, 0x77, 0x97, 0xB7, 0xD7, 0xF7 };
|
|
|
|
static const char * const filenames[] = {
|
|
|
|
"MSW##.SHP",
|
|
|
|
"MTA##.SHP",
|
|
|
|
"MTFL##.SHP",
|
|
|
|
"MTFR##.SHP",
|
|
|
|
"MTL##.SHP",
|
2008-04-24 15:04:12 +00:00
|
|
|
"MTR##.SHP"
|
2008-04-14 20:20:51 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
for (int i = 50; i <= 247; ++i) {
|
|
|
|
if (i == 87)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
ShapeMap::iterator iter = _gameShapes.find(i);
|
|
|
|
if (iter != _gameShapes.end()) {
|
2008-05-12 17:23:28 +00:00
|
|
|
delete[] iter->_value;
|
2008-04-14 20:20:51 +00:00
|
|
|
iter->_value = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const char lowNum = (newShapes % 10) + '0';
|
|
|
|
const char highNum = (newShapes / 10) + '0';
|
|
|
|
|
|
|
|
for (int i = 0; i < 6; ++i) {
|
|
|
|
char filename[16];
|
|
|
|
strcpy(filename, filenames[i]);
|
|
|
|
filename[numberOffset[i]+0] = highNum;
|
|
|
|
filename[numberOffset[i]+1] = lowNum;
|
2008-04-24 15:04:12 +00:00
|
|
|
_res->exists(filename, true);
|
2008-04-14 20:20:51 +00:00
|
|
|
_res->loadFileToBuf(filename, _screenBuffer, 64000);
|
2008-04-26 21:52:15 +00:00
|
|
|
for (int j = startShape[i]; j <= endShape[i]; ++j) {
|
2008-04-14 20:20:51 +00:00
|
|
|
if (j == 87)
|
|
|
|
continue;
|
|
|
|
addShapeToPool(_screenBuffer, j, j-startShape[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-05-02 15:21:51 +00:00
|
|
|
_characterShapeFile = newShapes;
|
2008-04-14 20:20:51 +00:00
|
|
|
updateMalcolmShapes();
|
|
|
|
}
|
|
|
|
|
2008-05-02 14:46:30 +00:00
|
|
|
void KyraEngine_MR::updateMalcolmShapes() {
|
2008-05-02 15:21:51 +00:00
|
|
|
assert(_characterShapeFile >= 0 && _characterShapeFile < _shapeDescsSize);
|
|
|
|
_malcolmShapeXOffset = _shapeDescs[_characterShapeFile].xOffset;
|
|
|
|
_malcolmShapeYOffset = _shapeDescs[_characterShapeFile].yOffset;
|
|
|
|
_animObjects[0].width = _shapeDescs[_characterShapeFile].width;
|
|
|
|
_animObjects[0].height = _shapeDescs[_characterShapeFile].height;
|
2008-04-14 20:20:51 +00:00
|
|
|
}
|
|
|
|
|
2007-04-15 13:44:49 +00:00
|
|
|
#pragma mark -
|
|
|
|
|
2008-05-02 15:39:51 +00:00
|
|
|
int KyraEngine_MR::getCharacterWalkspeed() const {
|
|
|
|
return _mainCharacter.walkspeed;
|
2008-04-16 20:28:27 +00:00
|
|
|
}
|
|
|
|
|
2008-05-02 14:46:30 +00:00
|
|
|
void KyraEngine_MR::updateCharAnimFrame(int character, int *table) {
|
2008-04-16 20:28:27 +00:00
|
|
|
++_mainCharacter.animFrame;
|
|
|
|
int facing = _mainCharacter.facing;
|
|
|
|
|
|
|
|
if (table) {
|
|
|
|
if (table[0] != table[-1] && table[1] == table[-1]) {
|
|
|
|
facing = getOppositeFacingDirection(table[-1]);
|
|
|
|
table[0] = table[-1];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (facing) {
|
|
|
|
if (facing == 7 || facing == 1) {
|
|
|
|
if (_characterAnimTable[0] > 2)
|
|
|
|
facing = 0;
|
|
|
|
memset(_characterAnimTable, 0, sizeof(_characterAnimTable));
|
|
|
|
} else if (facing == 4) {
|
|
|
|
++_characterAnimTable[1];
|
|
|
|
} else if (facing == 5 || facing == 3) {
|
|
|
|
if (_characterAnimTable[1] > 2)
|
|
|
|
facing = 4;
|
|
|
|
memset(_characterAnimTable, 0, sizeof(_characterAnimTable));
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
++_characterAnimTable[0];
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (facing) {
|
|
|
|
case 0:
|
|
|
|
if (_mainCharacter.animFrame < 79 || _mainCharacter.animFrame > 86)
|
|
|
|
_mainCharacter.animFrame = 79;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1: case 2: case 3:
|
|
|
|
if (_mainCharacter.animFrame < 71 || _mainCharacter.animFrame > 78)
|
|
|
|
_mainCharacter.animFrame = 71;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 4:
|
|
|
|
if (_mainCharacter.animFrame < 55 || _mainCharacter.animFrame > 62)
|
|
|
|
_mainCharacter.animFrame = 55;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 5: case 6: case 7:
|
|
|
|
if (_mainCharacter.animFrame < 63 || _mainCharacter.animFrame > 70)
|
|
|
|
_mainCharacter.animFrame = 63;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
updateCharacterAnim(0);
|
|
|
|
}
|
|
|
|
|
2008-05-02 14:46:30 +00:00
|
|
|
void KyraEngine_MR::updateCharPal(int unk1) {
|
2008-04-16 20:28:27 +00:00
|
|
|
int layer = _screen->getLayer(_mainCharacter.x1, _mainCharacter.y1) - 1;
|
2008-05-02 15:21:51 +00:00
|
|
|
const uint8 *src = _costPalBuffer + _characterShapeFile * 72;
|
2009-06-29 16:08:39 +00:00
|
|
|
Palette &dst = _screen->getPalette(0);
|
2008-04-16 20:28:27 +00:00
|
|
|
const int8 *sceneDatPal = &_sceneDatPalette[layer * 3];
|
|
|
|
|
|
|
|
if (layer != _lastCharPalLayer && unk1) {
|
2009-06-29 16:08:39 +00:00
|
|
|
for (int i = 144; i < 168; ++i) {
|
|
|
|
for (int j = 0; j < 3; ++j) {
|
|
|
|
uint8 col = dst[i * 3 + j];
|
2009-06-29 18:49:28 +00:00
|
|
|
int subCol = src[(i - 144) * 3 + j] + sceneDatPal[j];
|
|
|
|
subCol = CLIP(subCol, 0, 63);
|
|
|
|
subCol = (col - subCol) / 2;
|
2009-06-29 16:08:39 +00:00
|
|
|
dst[i * 3 + j] -= subCol;
|
2008-04-16 20:28:27 +00:00
|
|
|
}
|
|
|
|
}
|
2009-06-29 16:08:39 +00:00
|
|
|
|
2008-04-16 20:28:27 +00:00
|
|
|
_charPalUpdate = true;
|
2009-06-22 02:36:54 +00:00
|
|
|
_screen->setScreenPalette(_screen->getPalette(0));
|
2008-04-16 20:28:27 +00:00
|
|
|
_lastCharPalLayer = layer;
|
|
|
|
} else if (_charPalUpdate || !unk1) {
|
2009-06-29 16:08:39 +00:00
|
|
|
dst.copy(_costPalBuffer, _characterShapeFile * 24, 24, 144);
|
|
|
|
|
|
|
|
for (int i = 144; i < 168; ++i) {
|
|
|
|
for (int j = 0; j < 3; ++j) {
|
2009-06-29 18:49:28 +00:00
|
|
|
int col = dst[i * 3 + j] + sceneDatPal[j];
|
|
|
|
dst[i * 3 + j] = CLIP(col, 0, 63);
|
2008-04-16 20:28:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-06-22 02:36:54 +00:00
|
|
|
_screen->setScreenPalette(_screen->getPalette(0));
|
2008-04-16 20:28:27 +00:00
|
|
|
_charPalUpdate = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-05-02 14:46:30 +00:00
|
|
|
bool KyraEngine_MR::checkCharCollision(int x, int y) {
|
2008-04-20 02:11:10 +00:00
|
|
|
int scale = getScale(_mainCharacter.x1, _mainCharacter.y1);
|
|
|
|
int width = (scale * 37) >> 8;
|
|
|
|
int height = (scale * 76) >> 8;
|
|
|
|
|
|
|
|
int x1 = _mainCharacter.x1 - width/2;
|
2008-04-24 13:14:39 +00:00
|
|
|
int x2 = _mainCharacter.x1 + width/2;
|
2008-04-20 02:11:10 +00:00
|
|
|
int y1 = _mainCharacter.y1 - height;
|
2008-04-24 13:14:39 +00:00
|
|
|
int y2 = _mainCharacter.y1;
|
2008-04-20 02:11:10 +00:00
|
|
|
|
|
|
|
if (x >= x1 && x <= x2 && y >= y1 && y <= y2)
|
|
|
|
return true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2008-04-16 20:28:27 +00:00
|
|
|
#pragma mark -
|
|
|
|
|
2008-05-02 14:46:30 +00:00
|
|
|
void KyraEngine_MR::runLoop() {
|
2008-05-05 16:18:54 +00:00
|
|
|
_eventList.clear();
|
|
|
|
|
2008-04-16 23:09:07 +00:00
|
|
|
_runFlag = true;
|
2008-09-30 12:27:38 +00:00
|
|
|
while (_runFlag && !shouldQuit()) {
|
2008-04-27 00:50:13 +00:00
|
|
|
if (_deathHandler >= 0) {
|
2008-05-05 16:05:56 +00:00
|
|
|
removeHandItem();
|
|
|
|
delay(5);
|
|
|
|
_drawNoShapeFlag = 0;
|
|
|
|
_gui->optionsButton(0);
|
|
|
|
_deathHandler = -1;
|
2008-09-14 19:48:40 +00:00
|
|
|
|
2009-01-31 12:00:20 +00:00
|
|
|
if (!_runFlag || shouldQuit())
|
2008-09-14 19:48:40 +00:00
|
|
|
break;
|
2008-04-27 00:50:13 +00:00
|
|
|
}
|
2008-09-14 19:48:40 +00:00
|
|
|
|
2008-04-23 19:24:02 +00:00
|
|
|
if (_system->getMillis() >= _nextIdleAnim)
|
|
|
|
showIdleAnim();
|
|
|
|
|
2008-04-27 00:38:01 +00:00
|
|
|
int inputFlag = checkInput(_mainButtonList, true);
|
2008-04-16 23:09:07 +00:00
|
|
|
removeInputTop();
|
|
|
|
|
|
|
|
update();
|
|
|
|
_timer->update();
|
|
|
|
|
|
|
|
if (inputFlag == 198 || inputFlag == 199) {
|
2010-10-22 02:08:26 +00:00
|
|
|
_savedMouseState = _mouseState;
|
2008-04-16 23:09:07 +00:00
|
|
|
Common::Point mouse = getMousePos();
|
|
|
|
handleInput(mouse.x, mouse.y);
|
|
|
|
}
|
|
|
|
|
|
|
|
_system->delayMillis(10);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-05-02 14:46:30 +00:00
|
|
|
void KyraEngine_MR::handleInput(int x, int y) {
|
2008-04-20 02:11:10 +00:00
|
|
|
if (_inventoryState)
|
|
|
|
return;
|
2008-04-23 19:24:02 +00:00
|
|
|
setNextIdleAnimTimer();
|
2008-04-20 02:11:10 +00:00
|
|
|
|
|
|
|
if (_unk5) {
|
|
|
|
_unk5 = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!_screen->isMouseVisible())
|
|
|
|
return;
|
|
|
|
|
2010-10-22 02:08:26 +00:00
|
|
|
if (_savedMouseState == -3) {
|
2008-04-29 14:08:08 +00:00
|
|
|
snd_playSoundEffect(0x0D, 0x80);
|
2008-04-20 02:11:10 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-04-23 19:24:02 +00:00
|
|
|
setNextIdleAnimTimer();
|
2009-01-01 15:06:43 +00:00
|
|
|
|
2008-04-20 02:11:10 +00:00
|
|
|
int skip = 0;
|
|
|
|
|
2010-10-22 02:08:26 +00:00
|
|
|
if (checkCharCollision(x, y) && _savedMouseState >= -1 && runSceneScript2()) {
|
2008-04-20 02:11:10 +00:00
|
|
|
return;
|
2008-04-24 13:14:39 +00:00
|
|
|
} else if (_itemInHand != 27 && pickUpItem(x, y, 1)) {
|
2008-04-20 02:11:10 +00:00
|
|
|
return;
|
|
|
|
} else if (checkItemCollision(x, y) == -1) {
|
|
|
|
resetGameFlag(1);
|
|
|
|
skip = runSceneScript1(x, y);
|
|
|
|
|
|
|
|
if (queryGameFlag(1)) {
|
|
|
|
resetGameFlag(1);
|
|
|
|
return;
|
|
|
|
} else if (_unk5) {
|
|
|
|
_unk5 = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_deathHandler >= 0)
|
|
|
|
skip = 1;
|
|
|
|
|
|
|
|
if (skip)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (checkCharCollision(x, y)) {
|
|
|
|
if (runSceneScript2())
|
|
|
|
return;
|
2010-10-22 02:08:26 +00:00
|
|
|
} else if (_itemInHand >= 0 && _savedMouseState >= 0) {
|
2008-04-23 22:53:19 +00:00
|
|
|
if (_itemInHand == 27) {
|
|
|
|
makeCharFacingMouse();
|
|
|
|
} else if (y <= 187) {
|
|
|
|
if (_itemInHand == 43)
|
|
|
|
removeHandItem();
|
|
|
|
else
|
|
|
|
dropItem(0, _itemInHand, x, y, 1);
|
|
|
|
}
|
2008-04-20 02:11:10 +00:00
|
|
|
return;
|
2010-10-22 02:08:26 +00:00
|
|
|
} else if (_savedMouseState == -3) {
|
2008-04-22 22:36:09 +00:00
|
|
|
return;
|
|
|
|
} else {
|
2010-10-22 02:08:26 +00:00
|
|
|
if (y > 187 && _savedMouseState > -4)
|
2008-04-20 02:11:10 +00:00
|
|
|
return;
|
|
|
|
if (_unk5) {
|
|
|
|
_unk5 = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
inputSceneChange(x, y, 1, 1);
|
|
|
|
}
|
|
|
|
|
2008-05-02 14:46:30 +00:00
|
|
|
int KyraEngine_MR::inputSceneChange(int x, int y, int unk1, int unk2) {
|
2008-04-20 02:11:10 +00:00
|
|
|
uint16 curScene = _mainCharacter.sceneId;
|
|
|
|
_pathfinderFlag = 15;
|
|
|
|
|
|
|
|
if (!_unkHandleSceneChangeFlag) {
|
2010-10-22 02:08:26 +00:00
|
|
|
if (_savedMouseState == -4) {
|
2008-04-20 02:11:10 +00:00
|
|
|
if (_sceneList[curScene].exit4 != 0xFFFF) {
|
|
|
|
x = 4;
|
|
|
|
y = _sceneEnterY4;
|
|
|
|
_pathfinderFlag = 7;
|
|
|
|
}
|
2010-10-22 02:08:26 +00:00
|
|
|
} else if (_savedMouseState == -6) {
|
2008-04-20 02:11:10 +00:00
|
|
|
if (_sceneList[curScene].exit2 != 0xFFFF) {
|
|
|
|
x = 316;
|
|
|
|
y = _sceneEnterY2;
|
|
|
|
_pathfinderFlag = 7;
|
|
|
|
}
|
2010-10-22 02:08:26 +00:00
|
|
|
} else if (_savedMouseState == -7) {
|
2008-04-20 02:11:10 +00:00
|
|
|
if (_sceneList[curScene].exit1 != 0xFFFF) {
|
|
|
|
x = _sceneEnterX1;
|
|
|
|
y = _sceneEnterY1 - 2;
|
|
|
|
_pathfinderFlag = 14;
|
|
|
|
}
|
2010-10-22 02:08:26 +00:00
|
|
|
} else if (_savedMouseState == -5) {
|
2008-04-20 02:11:10 +00:00
|
|
|
if (_sceneList[curScene].exit3 != 0xFFFF) {
|
|
|
|
x = _sceneEnterX3;
|
|
|
|
y = 191;
|
|
|
|
_pathfinderFlag = 11;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ABS(_mainCharacter.x1 - x) < 4 && ABS(_mainCharacter.y1 - y) < 2) {
|
|
|
|
_pathfinderFlag = 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int x1 = _mainCharacter.x1 & (~3);
|
|
|
|
int y1 = _mainCharacter.y1 & (~1);
|
|
|
|
x &= ~3;
|
|
|
|
y &= ~1;
|
|
|
|
|
2008-05-02 14:46:30 +00:00
|
|
|
int size = findWay(x1, y1, x, y, _movFacingTable, 600);
|
2008-04-20 02:11:10 +00:00
|
|
|
_pathfinderFlag = 0;
|
|
|
|
|
|
|
|
if (!size || size == 0x7D00)
|
|
|
|
return 0;
|
|
|
|
|
2008-05-02 14:46:30 +00:00
|
|
|
return trySceneChange(_movFacingTable, unk1, unk2);
|
2008-04-16 23:09:07 +00:00
|
|
|
}
|
|
|
|
|
2008-05-02 14:46:30 +00:00
|
|
|
void KyraEngine_MR::update() {
|
2008-04-16 23:09:07 +00:00
|
|
|
updateInput();
|
|
|
|
|
|
|
|
musicUpdate(0);
|
|
|
|
refreshAnimObjectsIfNeed();
|
|
|
|
musicUpdate(0);
|
2008-04-17 15:29:10 +00:00
|
|
|
updateMouse();
|
2008-04-16 23:09:07 +00:00
|
|
|
updateSpecialSceneScripts();
|
2008-04-17 14:26:50 +00:00
|
|
|
updateCommandLine();
|
2008-05-10 14:12:48 +00:00
|
|
|
updateItemAnimations();
|
2008-04-16 23:09:07 +00:00
|
|
|
musicUpdate(0);
|
2008-04-16 20:28:27 +00:00
|
|
|
|
|
|
|
_screen->updateScreen();
|
|
|
|
}
|
|
|
|
|
2008-05-02 14:46:30 +00:00
|
|
|
void KyraEngine_MR::updateWithText() {
|
2008-04-19 22:22:00 +00:00
|
|
|
updateInput();
|
|
|
|
|
|
|
|
musicUpdate(0);
|
|
|
|
updateMouse();
|
2008-05-10 14:12:48 +00:00
|
|
|
updateItemAnimations();
|
2008-04-19 22:22:00 +00:00
|
|
|
updateSpecialSceneScripts();
|
|
|
|
updateCommandLine();
|
|
|
|
musicUpdate(0);
|
|
|
|
|
|
|
|
restorePage3();
|
|
|
|
drawAnimObjects();
|
2010-08-05 14:41:00 +00:00
|
|
|
if (_chatTextEnabled && _chatText) {
|
2008-04-19 22:22:00 +00:00
|
|
|
int curPage = _screen->_curPage;
|
|
|
|
_screen->_curPage = 2;
|
|
|
|
objectChatPrintText(_chatText, _chatObject);
|
|
|
|
_screen->_curPage = curPage;
|
|
|
|
}
|
|
|
|
refreshAnimObjects(0);
|
|
|
|
|
|
|
|
_screen->updateScreen();
|
|
|
|
}
|
|
|
|
|
2008-05-02 14:46:30 +00:00
|
|
|
void KyraEngine_MR::updateMouse() {
|
2008-04-17 15:29:10 +00:00
|
|
|
int shape = 0, offsetX = 0, offsetY = 0;
|
|
|
|
Common::Point mouse = getMousePos();
|
|
|
|
bool hasItemCollision = checkItemCollision(mouse.x, mouse.y) != -1;
|
|
|
|
|
|
|
|
if (mouse.y > 187) {
|
|
|
|
bool setItemCursor = false;
|
2008-05-12 12:42:10 +00:00
|
|
|
if (_mouseState == -6) {
|
2008-04-17 15:29:10 +00:00
|
|
|
if (mouse.x < 311)
|
|
|
|
setItemCursor = true;
|
2008-05-12 12:42:10 +00:00
|
|
|
} else if (_mouseState == -5) {
|
2008-04-17 15:29:10 +00:00
|
|
|
if (mouse.x < _sceneMinX || mouse.x > _sceneMaxX)
|
|
|
|
setItemCursor = true;
|
2008-05-12 12:42:10 +00:00
|
|
|
} else if (_mouseState == -4) {
|
2008-04-17 15:29:10 +00:00
|
|
|
if (mouse.x > 8)
|
|
|
|
setItemCursor = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (setItemCursor) {
|
|
|
|
setItemMouseCursor();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_inventoryState) {
|
|
|
|
if (mouse.y >= 144)
|
|
|
|
return;
|
2008-04-23 20:50:31 +00:00
|
|
|
hideInventory();
|
2008-04-17 15:29:10 +00:00
|
|
|
}
|
|
|
|
|
2008-05-12 12:42:10 +00:00
|
|
|
if (hasItemCollision && _mouseState < -1 && _itemInHand < 0) {
|
2010-10-22 02:10:22 +00:00
|
|
|
_mouseState = kItemNone;
|
|
|
|
_itemInHand = kItemNone;
|
2008-04-17 15:29:10 +00:00
|
|
|
_screen->setMouseCursor(0, 0, _gameShapes[0]);
|
|
|
|
}
|
|
|
|
|
|
|
|
int type = 0;
|
|
|
|
if (mouse.y <= 199) {
|
|
|
|
if (mouse.x <= 8) {
|
|
|
|
if (_sceneExit4 != 0xFFFF) {
|
|
|
|
type = -4;
|
|
|
|
shape = 4;
|
|
|
|
offsetX = 0;
|
|
|
|
offsetY = 0;
|
|
|
|
}
|
|
|
|
} else if (mouse.x >= 311) {
|
|
|
|
if (_sceneExit2 != 0xFFFF) {
|
|
|
|
type = -6;
|
|
|
|
shape = 2;
|
|
|
|
offsetX = 13;
|
|
|
|
offsetY = 8;
|
|
|
|
}
|
|
|
|
} else if (mouse.y >= 171) {
|
|
|
|
if (_sceneExit3 != 0xFFFF) {
|
|
|
|
if (mouse.x >= _sceneMinX && mouse.x <= _sceneMaxX) {
|
|
|
|
type = -5;
|
|
|
|
shape = 3;
|
|
|
|
offsetX = 8;
|
|
|
|
offsetY = 13;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (mouse.y <= 8) {
|
|
|
|
if (_sceneExit1 != 0xFFFF) {
|
|
|
|
type = -7;
|
|
|
|
shape = 1;
|
|
|
|
offsetX = 8;
|
|
|
|
offsetY = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int i = 0; i < _specialExitCount; ++i) {
|
|
|
|
if (checkSpecialSceneExit(i, mouse.x, mouse.y)) {
|
|
|
|
switch (_specialExitTable[20+i]) {
|
|
|
|
case 0:
|
|
|
|
type = -7;
|
|
|
|
shape = 1;
|
|
|
|
offsetX = 8;
|
|
|
|
offsetY = 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
type = -6;
|
|
|
|
shape = 2;
|
|
|
|
offsetX = 13;
|
|
|
|
offsetY = 8;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 4:
|
|
|
|
type = -5;
|
|
|
|
shape = 3;
|
|
|
|
offsetX = 8;
|
|
|
|
offsetY = 13;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 6:
|
|
|
|
type = -4;
|
|
|
|
shape = 4;
|
|
|
|
offsetX = 0;
|
|
|
|
offsetY = 8;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-05-12 12:42:10 +00:00
|
|
|
if (type != 0 && type != _mouseState && !hasItemCollision) {
|
|
|
|
_mouseState = type;
|
2008-04-17 15:29:10 +00:00
|
|
|
_screen->setMouseCursor(offsetX, offsetY, _gameShapes[shape]);
|
2008-05-12 12:42:10 +00:00
|
|
|
} else if (type == 0 && _mouseState != _itemInHand && mouse.x > 8 && mouse.x < 311 && mouse.y < 171 && mouse.y > 8) {
|
2008-04-17 15:29:10 +00:00
|
|
|
setItemMouseCursor();
|
2008-05-12 12:42:10 +00:00
|
|
|
} else if (mouse.y > 187 && _mouseState > -4 && type == 0 && !_inventoryState) {
|
2008-04-23 20:50:31 +00:00
|
|
|
showInventory();
|
2008-04-17 15:29:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-04-16 20:28:27 +00:00
|
|
|
#pragma mark -
|
|
|
|
|
2008-05-02 14:46:30 +00:00
|
|
|
void KyraEngine_MR::makeCharFacingMouse() {
|
2008-04-23 22:53:19 +00:00
|
|
|
if (_mainCharacter.x1 > _mouseX)
|
|
|
|
_mainCharacter.facing = 5;
|
|
|
|
else
|
|
|
|
_mainCharacter.facing = 3;
|
|
|
|
_mainCharacter.animFrame = _characterFrameTable[_mainCharacter.facing];
|
|
|
|
updateCharacterAnim(0);
|
|
|
|
refreshAnimObjectsIfNeed();
|
|
|
|
}
|
|
|
|
|
2008-04-16 23:09:07 +00:00
|
|
|
#pragma mark -
|
|
|
|
|
2008-05-02 14:46:30 +00:00
|
|
|
int KyraEngine_MR::getDrawLayer(int x, int y) {
|
2008-04-16 20:28:27 +00:00
|
|
|
int layer = _screen->getLayer(x, y) - 1;
|
|
|
|
layer = _sceneDatLayerTable[layer];
|
|
|
|
return MAX(0, MIN(layer, 6));
|
|
|
|
}
|
|
|
|
|
2008-05-02 14:46:30 +00:00
|
|
|
int KyraEngine_MR::getScale(int x, int y) {
|
2008-04-16 20:28:27 +00:00
|
|
|
return _scaleTable[_screen->getLayer(x, y) - 1];
|
|
|
|
}
|
|
|
|
|
|
|
|
#pragma mark -
|
|
|
|
|
2008-05-02 14:46:30 +00:00
|
|
|
void KyraEngine_MR::backUpGfxRect32x32(int x, int y) {
|
2008-04-22 18:08:56 +00:00
|
|
|
_screen->copyRegionToBuffer(_screen->_curPage, x, y, 32, 32, _gfxBackUpRect);
|
|
|
|
}
|
|
|
|
|
2008-05-02 14:46:30 +00:00
|
|
|
void KyraEngine_MR::restoreGfxRect32x32(int x, int y) {
|
2008-04-22 18:08:56 +00:00
|
|
|
_screen->copyBlockToPage(_screen->_curPage, x, y, 32, 32, _gfxBackUpRect);
|
|
|
|
}
|
|
|
|
|
|
|
|
#pragma mark -
|
|
|
|
|
2008-05-02 14:46:30 +00:00
|
|
|
char *KyraEngine_MR::appendLanguage(char *buf, int lang, int bufSize) {
|
2007-04-15 13:44:49 +00:00
|
|
|
assert(lang < _languageExtensionSize);
|
|
|
|
|
2010-05-05 17:53:30 +00:00
|
|
|
const int size = Common::strlcat(buf, _languageExtension[lang], bufSize);
|
|
|
|
if (size >= bufSize) {
|
2007-04-15 13:44:49 +00:00
|
|
|
warning("buffer too small to append language extension");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
2008-05-02 14:46:30 +00:00
|
|
|
int KyraEngine_MR::loadLanguageFile(const char *file, uint8 *&buffer) {
|
2009-01-01 15:06:43 +00:00
|
|
|
delete[] buffer;
|
2008-05-05 17:12:48 +00:00
|
|
|
buffer = 0;
|
|
|
|
|
2007-04-15 13:44:49 +00:00
|
|
|
uint32 size = 0;
|
|
|
|
char nBuf[32];
|
2010-05-05 17:53:30 +00:00
|
|
|
Common::strlcpy(nBuf, file, sizeof(nBuf));
|
2007-04-15 13:44:49 +00:00
|
|
|
buffer = _res->fileData(appendLanguage(nBuf, _lang, sizeof(nBuf)), &size);
|
|
|
|
|
2008-04-14 20:20:51 +00:00
|
|
|
return buffer ? size : 0 ;
|
2007-04-15 13:44:49 +00:00
|
|
|
}
|
|
|
|
|
2008-05-02 14:46:30 +00:00
|
|
|
uint8 *KyraEngine_MR::getTableEntry(uint8 *buffer, int id) {
|
2008-04-17 13:38:44 +00:00
|
|
|
uint16 tableEntries = READ_LE_UINT16(buffer);
|
2010-05-17 23:29:44 +00:00
|
|
|
const uint16 *indexTable = (const uint16 *)(buffer + 2);
|
2008-04-17 13:38:44 +00:00
|
|
|
const uint16 *offsetTable = indexTable + tableEntries;
|
|
|
|
|
|
|
|
int num = 0;
|
|
|
|
while (id != READ_LE_UINT16(indexTable)) {
|
|
|
|
++indexTable;
|
|
|
|
++num;
|
|
|
|
}
|
|
|
|
|
|
|
|
return buffer + READ_LE_UINT16(offsetTable + num);
|
|
|
|
}
|
|
|
|
|
2008-05-02 14:46:30 +00:00
|
|
|
void KyraEngine_MR::getTableEntry(Common::SeekableReadStream *stream, int id, char *dst) {
|
2008-04-22 22:36:09 +00:00
|
|
|
stream->seek(0, SEEK_SET);
|
|
|
|
uint16 tableEntries = stream->readUint16LE();
|
|
|
|
|
|
|
|
int num = 0;
|
|
|
|
while (id != stream->readUint16LE())
|
|
|
|
++num;
|
|
|
|
|
|
|
|
stream->seek(2+tableEntries*2+num*2, SEEK_SET);
|
|
|
|
stream->seek(stream->readUint16LE(), SEEK_SET);
|
|
|
|
char c = 0;
|
|
|
|
while ((c = stream->readByte()) != 0)
|
|
|
|
*dst++ = c;
|
|
|
|
*dst = 0;
|
|
|
|
}
|
|
|
|
|
2008-04-17 13:38:44 +00:00
|
|
|
#pragma mark -
|
|
|
|
|
2008-05-02 14:46:30 +00:00
|
|
|
bool KyraEngine_MR::talkObjectsInCurScene() {
|
2008-04-23 19:24:02 +00:00
|
|
|
for (int i = 0; i < 88; ++i) {
|
|
|
|
if (_talkObjectList[i].sceneId == _mainCharacter.sceneId)
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
#pragma mark -
|
|
|
|
|
2008-05-02 14:46:30 +00:00
|
|
|
bool KyraEngine_MR::updateScore(int scoreId, int strId) {
|
2008-04-24 21:11:55 +00:00
|
|
|
int scoreIndex = (scoreId >> 3);
|
|
|
|
int scoreBit = scoreId & 7;
|
|
|
|
if ((_scoreFlagTable[scoreIndex] & (1 << scoreBit)) != 0)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
setNextIdleAnimTimer();
|
|
|
|
_scoreFlagTable[scoreIndex] |= (1 << scoreBit);
|
|
|
|
|
|
|
|
_screen->hideMouse();
|
2009-05-29 12:52:03 +00:00
|
|
|
strcpy(_stringBuffer, (const char *)getTableEntry(_scoreFile, strId));
|
2008-04-24 21:11:55 +00:00
|
|
|
strcat(_stringBuffer, ": ");
|
|
|
|
|
|
|
|
assert(scoreId < _scoreTableSize);
|
|
|
|
|
|
|
|
int count = _scoreTable[scoreId];
|
|
|
|
if (count > 0)
|
|
|
|
scoreIncrease(count, _stringBuffer);
|
|
|
|
|
|
|
|
_screen->showMouse();
|
|
|
|
setNextIdleAnimTimer();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2008-05-02 14:46:30 +00:00
|
|
|
void KyraEngine_MR::scoreIncrease(int count, const char *str) {
|
2008-04-24 21:11:55 +00:00
|
|
|
int drawOld = 1;
|
|
|
|
_screen->hideMouse();
|
|
|
|
|
|
|
|
showMessage(str, 0xFF, 0xF0);
|
|
|
|
const int x = getScoreX(str);
|
|
|
|
|
|
|
|
for (int i = 0; i < count; ++i) {
|
|
|
|
int oldScore = _score;
|
|
|
|
int newScore = ++_score;
|
|
|
|
|
|
|
|
if (newScore > _scoreMax) {
|
|
|
|
_score = _scoreMax;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
drawScoreCounting(oldScore, newScore, drawOld, x);
|
|
|
|
if (_inventoryState)
|
|
|
|
drawScore(0, 215, 191);
|
|
|
|
_screen->updateScreen();
|
|
|
|
delay(20, true);
|
2009-01-01 15:06:43 +00:00
|
|
|
|
2008-04-29 14:08:08 +00:00
|
|
|
snd_playSoundEffect(0x0E, 0xC8);
|
2008-04-24 21:11:55 +00:00
|
|
|
drawOld = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
_screen->showMouse();
|
|
|
|
}
|
|
|
|
|
2008-04-23 19:24:02 +00:00
|
|
|
#pragma mark -
|
|
|
|
|
2008-05-02 14:46:30 +00:00
|
|
|
void KyraEngine_MR::changeChapter(int newChapter, int sceneId, int malcolmShapes, int facing) {
|
2008-04-26 22:22:21 +00:00
|
|
|
resetItemList();
|
|
|
|
|
2008-04-27 00:42:17 +00:00
|
|
|
_currentChapter = newChapter;
|
2008-04-26 22:22:21 +00:00
|
|
|
runStartupScript(newChapter, 0);
|
|
|
|
_mainCharacter.dlgIndex = 0;
|
|
|
|
|
|
|
|
_malcolmsMood = 1;
|
|
|
|
memset(_newSceneDlgState, 0, sizeof(_newSceneDlgState));
|
|
|
|
|
|
|
|
if (malcolmShapes >= 0)
|
2008-05-02 15:21:51 +00:00
|
|
|
loadCharacterShapes(malcolmShapes);
|
2008-04-26 22:22:21 +00:00
|
|
|
|
|
|
|
enterNewScene(sceneId, facing, 0, 0, 0);
|
|
|
|
}
|
|
|
|
|
2008-05-05 17:12:48 +00:00
|
|
|
#pragma mark -
|
|
|
|
|
|
|
|
bool KyraEngine_MR::skipFlag() const {
|
|
|
|
if (!_configSkip)
|
|
|
|
return false;
|
|
|
|
return KyraEngine_v2::skipFlag();
|
|
|
|
}
|
|
|
|
|
|
|
|
void KyraEngine_MR::resetSkipFlag(bool removeEvent) {
|
|
|
|
if (!_configSkip) {
|
|
|
|
if (removeEvent)
|
|
|
|
_eventList.clear();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
KyraEngine_v2::resetSkipFlag(removeEvent);
|
|
|
|
}
|
|
|
|
|
|
|
|
#pragma mark -
|
|
|
|
|
|
|
|
void KyraEngine_MR::registerDefaultSettings() {
|
2008-05-11 23:16:50 +00:00
|
|
|
KyraEngine_v1::registerDefaultSettings();
|
2008-05-05 17:12:48 +00:00
|
|
|
|
|
|
|
// Most settings already have sensible defaults. This one, however, is
|
|
|
|
// specific to the Kyra engine.
|
|
|
|
ConfMan.registerDefault("walkspeed", 5);
|
|
|
|
ConfMan.registerDefault("studio_audience", true);
|
|
|
|
ConfMan.registerDefault("skip_support", true);
|
2008-05-11 17:50:13 +00:00
|
|
|
ConfMan.registerDefault("helium_mode", false);
|
2010-07-23 00:39:23 +00:00
|
|
|
// 0 - best, 1 - mid, 2 - low
|
|
|
|
ConfMan.registerDefault("video_quality", 0);
|
2008-05-05 17:12:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void KyraEngine_MR::writeSettings() {
|
|
|
|
switch (_lang) {
|
|
|
|
case 1:
|
|
|
|
_flags.lang = Common::FR_FRA;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
_flags.lang = Common::DE_DEU;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 0:
|
|
|
|
default:
|
|
|
|
_flags.lang = Common::EN_ANY;
|
|
|
|
}
|
|
|
|
|
2008-06-30 23:39:56 +00:00
|
|
|
if (_flags.lang == _flags.replacedLang && _flags.fanLang != Common::UNK_LANG)
|
|
|
|
_flags.lang = _flags.fanLang;
|
|
|
|
|
2008-05-05 17:12:48 +00:00
|
|
|
ConfMan.set("language", Common::getLanguageCode(_flags.lang));
|
|
|
|
|
|
|
|
ConfMan.setBool("studio_audience", _configStudio);
|
|
|
|
ConfMan.setBool("skip_support", _configSkip);
|
2008-05-11 17:50:13 +00:00
|
|
|
ConfMan.setBool("helium_mode", _configHelium);
|
2008-05-05 17:12:48 +00:00
|
|
|
|
2008-05-11 23:16:50 +00:00
|
|
|
KyraEngine_v1::writeSettings();
|
2008-05-05 17:12:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void KyraEngine_MR::readSettings() {
|
2010-08-05 14:41:00 +00:00
|
|
|
KyraEngine_v2::readSettings();
|
2008-05-05 17:12:48 +00:00
|
|
|
|
|
|
|
_configStudio = ConfMan.getBool("studio_audience");
|
|
|
|
_configSkip = ConfMan.getBool("skip_support");
|
2008-05-11 17:50:13 +00:00
|
|
|
_configHelium = ConfMan.getBool("helium_mode");
|
2010-07-23 00:39:23 +00:00
|
|
|
_configVQAQuality = CLIP(ConfMan.getInt("video_quality"), 0, 2);
|
2008-05-05 17:12:48 +00:00
|
|
|
}
|
|
|
|
|
2009-10-04 21:26:33 +00:00
|
|
|
} // End of namespace Kyra
|
2007-04-15 16:41:20 +00:00
|
|
|
|