2012-03-30 18:03:59 +02: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"
|
|
|
|
#include "common/random.h"
|
|
|
|
#include "common/error.h"
|
|
|
|
#include "common/debug-channels.h"
|
|
|
|
#include "common/config-manager.h"
|
|
|
|
#include "common/textconsole.h"
|
2012-04-04 00:03:41 +02:00
|
|
|
#include "common/memstream.h"
|
2012-04-10 10:06:50 +02:00
|
|
|
#include "common/events.h"
|
|
|
|
#include "engines/util.h"
|
2012-03-30 18:03:59 +02:00
|
|
|
|
|
|
|
#include "lilliput/lilliput.h"
|
|
|
|
#include "engines/util.h"
|
2012-04-04 00:03:41 +02:00
|
|
|
#include "lilliput/script.h"
|
2012-04-20 19:43:31 +02:00
|
|
|
#include "lilliput/sound.h"
|
2012-03-30 18:03:59 +02:00
|
|
|
|
|
|
|
namespace Lilliput {
|
|
|
|
|
|
|
|
LilliputEngine *LilliputEngine::s_Engine = 0;
|
2012-05-08 21:38:43 +02:00
|
|
|
|
2012-04-09 17:34:30 +02:00
|
|
|
static const byte _basisPalette[768] = {
|
|
|
|
0, 0, 0, 0, 0, 42, 0, 42, 0, 0, 42, 42,
|
|
|
|
42, 0, 0, 42, 0, 42, 42, 21, 0, 42, 42, 42,
|
|
|
|
21, 21, 21, 21, 21, 63, 21, 63, 21, 21, 63, 63,
|
|
|
|
63, 21, 21, 63, 21, 63, 63, 63, 21, 63, 63, 63,
|
|
|
|
63, 63, 63, 59, 59, 59, 54, 54, 54, 50, 50, 50,
|
|
|
|
46, 46, 46, 42, 42, 42, 38, 38, 38, 33, 33, 33,
|
|
|
|
29, 29, 29, 25, 25, 25, 21, 21, 21, 17, 17, 17,
|
|
|
|
13, 13, 13, 8, 8, 8, 4, 4, 4, 0, 0, 0,
|
|
|
|
63, 54, 54, 63, 46, 46, 63, 39, 39, 63, 31, 31,
|
|
|
|
63, 23, 23, 63, 16, 16, 63, 8, 8, 63, 0, 0,
|
|
|
|
57, 0, 0, 51, 0, 0, 45, 0, 0, 39, 0, 0,
|
|
|
|
33, 0, 0, 28, 0, 0, 22, 0, 0, 16, 0, 0,
|
|
|
|
63, 58, 54, 63, 54, 46, 63, 50, 39, 63, 46, 31,
|
|
|
|
63, 42, 23, 63, 38, 16, 63, 34, 8, 63, 30, 0,
|
|
|
|
57, 27, 0, 51, 24, 0, 45, 21, 0, 39, 19, 0,
|
|
|
|
33, 16, 0, 28, 14, 0, 22, 11, 0, 16, 8, 0,
|
|
|
|
63, 63, 54, 63, 63, 46, 63, 63, 39, 63, 63, 31,
|
|
|
|
63, 62, 23, 63, 61, 16, 63, 61, 8, 63, 61, 0,
|
|
|
|
57, 54, 0, 51, 49, 0, 45, 43, 0, 39, 39, 0,
|
|
|
|
33, 33, 0, 28, 27, 0, 22, 21, 0, 16, 16, 0,
|
|
|
|
62, 63, 54, 59, 61, 47, 56, 59, 42, 53, 58, 36,
|
|
|
|
50, 56, 32, 47, 54, 26, 44, 52, 22, 41, 50, 17,
|
|
|
|
36, 46, 14, 32, 42, 11, 28, 37, 8, 24, 33, 6,
|
|
|
|
20, 29, 4, 16, 25, 2, 13, 20, 1, 10, 16, 0,
|
|
|
|
54, 63, 54, 48, 61, 48, 43, 59, 43, 38, 58, 38,
|
|
|
|
33, 56, 33, 29, 54, 29, 25, 52, 24, 21, 50, 20,
|
|
|
|
16, 46, 16, 14, 42, 13, 10, 37, 9, 8, 33, 7,
|
|
|
|
6, 29, 4, 4, 25, 2, 2, 20, 1, 1, 16, 0,
|
|
|
|
59, 63, 63, 53, 63, 63, 47, 62, 63, 41, 61, 62,
|
|
|
|
35, 60, 62, 30, 59, 62, 24, 57, 62, 18, 55, 62,
|
|
|
|
20, 52, 56, 15, 47, 50, 11, 42, 45, 8, 37, 39,
|
|
|
|
5, 32, 33, 3, 27, 27, 1, 22, 22, 0, 16, 16,
|
|
|
|
54, 59, 63, 46, 56, 63, 39, 53, 63, 31, 50, 63,
|
|
|
|
23, 47, 63, 16, 44, 63, 8, 42, 63, 0, 39, 63,
|
|
|
|
0, 35, 57, 0, 31, 51, 0, 27, 45, 0, 23, 39,
|
|
|
|
0, 19, 33, 0, 16, 28, 0, 12, 22, 0, 9, 16,
|
|
|
|
54, 54, 63, 46, 47, 63, 39, 39, 63, 31, 32, 63,
|
|
|
|
23, 24, 63, 16, 16, 63, 8, 9, 63, 0, 1, 63,
|
|
|
|
0, 1, 57, 0, 1, 51, 0, 0, 45, 0, 0, 39,
|
|
|
|
0, 0, 33, 0, 0, 28, 0, 0, 22, 0, 0, 16,
|
|
|
|
54, 63, 54, 47, 63, 46, 39, 63, 39, 32, 63, 31,
|
|
|
|
24, 63, 23, 16, 63, 16, 8, 63, 8, 0, 63, 0,
|
|
|
|
0, 56, 0, 0, 49, 0, 0, 43, 0, 0, 36, 0,
|
|
|
|
0, 30, 0, 0, 23, 0, 0, 16, 0, 0, 10, 0,
|
|
|
|
63, 54, 63, 63, 46, 63, 63, 39, 63, 63, 31, 63,
|
|
|
|
63, 23, 63, 63, 16, 63, 63, 8, 63, 63, 0, 63,
|
|
|
|
56, 0, 57, 50, 0, 51, 45, 0, 45, 39, 0, 39,
|
|
|
|
33, 0, 33, 27, 0, 28, 22, 0, 22, 16, 0, 16,
|
|
|
|
63, 58, 55, 63, 56, 52, 63, 54, 49, 63, 53, 47,
|
|
|
|
63, 51, 44, 63, 49, 41, 63, 47, 39, 63, 46, 36,
|
|
|
|
63, 44, 32, 63, 41, 28, 63, 39, 24, 60, 37, 23,
|
|
|
|
58, 35, 22, 55, 34, 21, 52, 32, 20, 50, 31, 19,
|
|
|
|
47, 30, 18, 45, 28, 17, 42, 26, 16, 40, 25, 15,
|
|
|
|
39, 24, 14, 36, 23, 13, 34, 22, 12, 32, 20, 11,
|
|
|
|
29, 19, 10, 27, 18, 9, 23, 16, 8, 21, 15, 7,
|
|
|
|
18, 14, 6, 16, 12, 6, 14, 11, 5, 10, 8, 3,
|
|
|
|
63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
|
|
|
|
63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
|
|
|
|
63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
|
|
|
|
63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
|
|
|
|
63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
|
|
|
|
63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
|
|
|
|
63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
|
|
|
|
63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63
|
|
|
|
};
|
2012-03-30 18:03:59 +02:00
|
|
|
|
2012-05-21 22:22:06 +02:00
|
|
|
LilliputEngine::LilliputEngine(OSystem *syst, const LilliputGameDescription *gd) : Engine(syst), _gameDescription(gd) {
|
2012-03-30 18:03:59 +02:00
|
|
|
_system = syst;
|
|
|
|
DebugMan.addDebugChannel(kDebugEngine, "Engine", "Engine debug level");
|
2012-04-07 14:36:04 +02:00
|
|
|
DebugMan.addDebugChannel(kDebugScript, "Script", "Script debug level");
|
2012-05-08 18:36:01 +02:00
|
|
|
DebugMan.addDebugChannel(kDebugSound, "Sound", "Sound debug level");
|
|
|
|
DebugMan.addDebugChannel(kDebugEngineTBC, "EngineTBC", "Engine debug level");
|
|
|
|
DebugMan.addDebugChannel(kDebugScriptTBC, "ScriptTBC", "Script debug level");
|
2012-03-30 18:03:59 +02:00
|
|
|
|
|
|
|
_console = new LilliputConsole(this);
|
|
|
|
_rnd = 0;
|
2012-04-19 08:03:19 +02:00
|
|
|
_int8installed = false;
|
2012-05-05 18:16:03 +02:00
|
|
|
_mousePos = Common::Point(0, 0);
|
|
|
|
_oldMousePos = Common::Point(0, 0);
|
|
|
|
_mouseDisplayPos = Common::Point(0, 0);
|
2012-04-10 00:57:59 +02:00
|
|
|
_mouseButton = 0;
|
2012-06-01 23:57:25 +02:00
|
|
|
_mouseClicked = false;
|
2012-05-05 21:34:58 +02:00
|
|
|
_savedMousePosDivided = Common::Point(-1, -1);
|
2012-06-01 23:57:25 +02:00
|
|
|
_mousePreviousEventType = Common::EVENT_INVALID;
|
2012-04-15 23:20:30 +02:00
|
|
|
_skipDisplayFlag1 = 1;
|
|
|
|
_skipDisplayFlag2 = 0;
|
2012-06-01 08:18:33 +02:00
|
|
|
_displayMap = false;
|
2012-04-29 11:48:10 +02:00
|
|
|
_debugFlag = 0;
|
|
|
|
_byte14837 = 0;
|
2012-04-11 10:59:42 +02:00
|
|
|
|
2012-04-04 00:03:41 +02:00
|
|
|
_scriptHandler = new LilliputScript(this);
|
2012-04-20 19:43:31 +02:00
|
|
|
_soundHandler = new LilliputSound(this);
|
2012-04-04 00:03:41 +02:00
|
|
|
|
2012-06-23 18:01:01 +02:00
|
|
|
_handleOpcodeReturnCode = 0;
|
2012-07-01 00:59:06 +02:00
|
|
|
_delayedReactivationAction = false;
|
2012-06-17 14:09:52 +02:00
|
|
|
_selectedCharacterId = -1;
|
2012-04-25 00:13:32 +02:00
|
|
|
_numCharactersToDisplay = 0;
|
2012-05-08 18:36:01 +02:00
|
|
|
_nextDisplayCharacterPos = Common::Point(0, 0);
|
2012-05-11 17:01:00 +02:00
|
|
|
_animationTick = 0;
|
2012-06-23 18:01:01 +02:00
|
|
|
_byte12A05 = 10; // Used to trigger sound and animations in int8, 1 time out of 10
|
|
|
|
_byte12A06 = 2; // Used to switch _byte12A07 between true and false, 1 time our of 3
|
|
|
|
_byte12A07 = 0; // Set but never used
|
|
|
|
_byte12A08 = 0; // Used to avoid two executions of int8 at the same time. Useless in ScummVM
|
2012-05-22 22:12:09 +02:00
|
|
|
_refreshScreenFlag = false;
|
2012-04-20 08:34:41 +02:00
|
|
|
_byte16552 = 0;
|
2012-05-18 19:24:03 +02:00
|
|
|
_lastInterfaceHotspotIndex = -1;
|
|
|
|
_lastInterfaceHotspotButton = 0;
|
2012-05-11 17:01:00 +02:00
|
|
|
_lastAnimationTick = 0;
|
2012-04-11 10:59:42 +02:00
|
|
|
|
2012-05-01 23:32:44 +02:00
|
|
|
_currentScriptCharacter = 0;
|
2012-05-05 21:34:58 +02:00
|
|
|
_currentScriptCharacterPos = Common::Point(0, 0);
|
2012-04-11 10:59:42 +02:00
|
|
|
_word10804 = 0;
|
2012-05-19 14:25:30 +02:00
|
|
|
_nextCharacterIndex = 0;
|
2012-06-23 10:47:10 +02:00
|
|
|
_word16EFEh = -1;
|
|
|
|
_word16EFEl_characterId = -1;
|
2012-04-11 15:58:41 +02:00
|
|
|
_word1817B = 0;
|
2012-05-09 08:07:58 +02:00
|
|
|
_savedSurfaceUnderMousePos = Common::Point(0, 0);
|
2012-06-23 10:47:10 +02:00
|
|
|
_bool15AC2 = false;
|
2012-04-21 21:19:13 +02:00
|
|
|
_displayStringIndex = 0;
|
2012-04-22 22:54:50 +02:00
|
|
|
_word1289D = 0;
|
2012-05-03 19:35:53 +02:00
|
|
|
_numCharacters = 0;
|
2012-04-07 14:36:04 +02:00
|
|
|
|
2012-05-13 03:21:09 +02:00
|
|
|
_saveFlag = true;
|
2012-06-23 10:47:10 +02:00
|
|
|
_actionType = kActionNone;
|
2012-04-08 12:54:56 +02:00
|
|
|
|
2012-05-08 21:38:43 +02:00
|
|
|
_array16C54[0] = _array16C58[3] = 1;
|
|
|
|
_array16C54[1] = _array16C58[2] = 2;
|
|
|
|
_array16C54[2] = _array16C58[1] = 4;
|
|
|
|
_array16C54[3] = _array16C58[0] = 8;
|
2012-04-30 10:48:21 +02:00
|
|
|
|
2012-04-25 08:10:26 +02:00
|
|
|
for (int i = 0; i < 3; i++)
|
2012-06-23 10:47:10 +02:00
|
|
|
_codeEntered[i] = 0;
|
2012-04-25 08:10:26 +02:00
|
|
|
|
2012-05-02 22:01:20 +02:00
|
|
|
for (int i = 0; i < 4; i++)
|
|
|
|
_array1692B[i] = 0;
|
|
|
|
|
2012-04-07 14:36:04 +02:00
|
|
|
for (int i = 0; i < 40; i++) {
|
2012-05-06 10:04:09 +02:00
|
|
|
_array10999PosX[i] = 0;
|
|
|
|
_array109C1PosY[i] = 0;
|
2012-04-25 00:13:32 +02:00
|
|
|
_charactersToDisplay[i] = 0;
|
2012-05-06 22:32:23 +02:00
|
|
|
_characterRelativePositionX[i] = -1;
|
|
|
|
_characterRelativePositionY[i] = -1;
|
2012-04-25 01:41:31 +02:00
|
|
|
_characterDisplayX[i] = 0;
|
|
|
|
_characterDisplayY[i] = 0;
|
2012-05-29 22:54:02 +02:00
|
|
|
_array12299[i] = -1;
|
2012-05-06 22:32:23 +02:00
|
|
|
_array109E9PosX[i] = -1;
|
|
|
|
_array10A11PosY[i] = -1;
|
2012-04-22 22:54:50 +02:00
|
|
|
_array16E94[i] = 0;
|
2012-04-17 23:48:11 +02:00
|
|
|
|
2012-05-21 09:44:25 +02:00
|
|
|
_array11D49[i] = -1;
|
2012-05-06 22:32:23 +02:00
|
|
|
_characterPositionX[i] = -1;
|
|
|
|
_characterPositionY[i] = -1;
|
2012-05-01 14:35:19 +02:00
|
|
|
_characterPositionAltitude[i] = 0;
|
2012-04-30 17:57:23 +02:00
|
|
|
_characterFrameArray[i] = 0;
|
2012-05-26 17:59:38 +02:00
|
|
|
_rulesBuffer2_5[i] = -1;
|
2012-04-17 23:48:11 +02:00
|
|
|
_rulesBuffer2_6[i] = 4;
|
|
|
|
_rulesBuffer2_7[i] = 0;
|
2012-04-30 17:57:23 +02:00
|
|
|
_spriteSizeArray[i] = 20;
|
|
|
|
_characterDirectionArray[i] = 0;
|
2012-04-17 23:48:11 +02:00
|
|
|
_rulesBuffer2_10[i] = 0;
|
|
|
|
_rulesBuffer2_11[i] = 0;
|
|
|
|
_rulesBuffer2_12[i] = 0;
|
2012-05-18 16:48:49 +02:00
|
|
|
_rulesBuffer2_13_posX[i] = 0;
|
|
|
|
_rulesBuffer2_14_posY[i] = 0;
|
2012-05-21 09:44:25 +02:00
|
|
|
_array1289F[i] = -1;
|
2012-04-07 14:36:04 +02:00
|
|
|
}
|
|
|
|
|
2012-04-22 22:54:50 +02:00
|
|
|
for (int i = 0; i < 30; i++)
|
2012-05-20 17:53:09 +02:00
|
|
|
_array12861[i] = -1;
|
2012-04-22 22:54:50 +02:00
|
|
|
|
2012-04-15 23:20:30 +02:00
|
|
|
for (int i = 0; i < 256; i++)
|
2012-05-09 08:07:58 +02:00
|
|
|
_savedSurfaceUnderMouse[i] = 0;
|
2012-04-15 23:20:30 +02:00
|
|
|
|
2012-04-21 21:19:13 +02:00
|
|
|
for (int i = 0; i < 160; i++)
|
|
|
|
_displayStringBuf[i] = 0;
|
|
|
|
|
2012-05-04 23:13:43 +02:00
|
|
|
for (int i = 0; i < 1400 + 3120; i++) {
|
2012-05-26 02:06:12 +02:00
|
|
|
_characterVariables[i] = 0;
|
2012-05-04 23:13:43 +02:00
|
|
|
}
|
|
|
|
|
2012-05-01 14:35:19 +02:00
|
|
|
_currentCharacterVariables = NULL;
|
2012-04-16 23:16:01 +02:00
|
|
|
_bufferIdeogram = NULL;
|
|
|
|
_bufferMen = NULL;
|
|
|
|
_bufferMen2 = NULL;
|
|
|
|
_bufferIsoChars = NULL;
|
|
|
|
_bufferIsoMap = NULL;
|
|
|
|
_bufferCubegfx = NULL;
|
2012-03-30 18:03:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
LilliputEngine::~LilliputEngine() {
|
|
|
|
|
|
|
|
DebugMan.clearAllDebugChannels();
|
|
|
|
delete _console;
|
|
|
|
delete _rnd;
|
|
|
|
}
|
|
|
|
|
|
|
|
GUI::Debugger *LilliputEngine::getDebugger() {
|
|
|
|
return _console;
|
|
|
|
}
|
|
|
|
|
2012-04-19 08:03:19 +02:00
|
|
|
void LilliputEngine::update() {
|
2012-04-20 01:10:46 +02:00
|
|
|
// update every 20 ms.
|
|
|
|
int currentTime = _system->getMillis();
|
2012-05-16 20:58:41 +02:00
|
|
|
if (currentTime - _lastTime > 20) {
|
2012-04-20 01:15:36 +02:00
|
|
|
_lastTime += ((currentTime - _lastTime) / 20) * 20;
|
2012-04-20 01:10:46 +02:00
|
|
|
newInt8();
|
|
|
|
pollEvent();
|
|
|
|
}
|
2012-04-19 08:03:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void LilliputEngine::newInt8() {
|
|
|
|
|
|
|
|
if (_byte12A06 == 0) {
|
|
|
|
_byte12A06 = 2;
|
|
|
|
_byte12A07 ^= 1;
|
|
|
|
}
|
|
|
|
--_byte12A06;
|
|
|
|
// TODO: check 'out 20h, 20h'
|
2012-05-22 22:12:09 +02:00
|
|
|
|
|
|
|
if (!_int8installed)
|
|
|
|
return;
|
2012-04-19 08:03:19 +02:00
|
|
|
|
|
|
|
// if (_soundEnabled)
|
2012-04-20 19:43:31 +02:00
|
|
|
_soundHandler->contentFct1();
|
2012-04-19 08:03:19 +02:00
|
|
|
|
|
|
|
if (_byte12A08 != 1) {
|
|
|
|
_byte12A08 = 1;
|
|
|
|
if (_byte12A05 != 0)
|
|
|
|
--_byte12A05;
|
|
|
|
else {
|
|
|
|
_byte12A05 = 10;
|
|
|
|
if (_sound_byte16F06 != 0)
|
|
|
|
--_sound_byte16F06;
|
|
|
|
|
2012-05-11 17:01:00 +02:00
|
|
|
_animationTick ^= 1;
|
2012-05-22 22:12:09 +02:00
|
|
|
if (!_refreshScreenFlag)
|
|
|
|
displayRefreshScreen();
|
2012-04-19 08:03:19 +02:00
|
|
|
}
|
|
|
|
_byte12A08 = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-30 18:03:59 +02:00
|
|
|
bool LilliputEngine::hasFeature(EngineFeature f) const {
|
|
|
|
return (f == kSupportsRTL) || (f == kSupportsLoadingDuringRuntime) || (f == kSupportsSavingDuringRuntime);
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *LilliputEngine::getCopyrightString() const {
|
2012-05-17 11:59:54 +02:00
|
|
|
return "copyright S.L.Grand, Brainware, 1991 - 1992";
|
2012-03-30 18:03:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
GameType LilliputEngine::getGameType() const {
|
|
|
|
return _gameType;
|
|
|
|
}
|
|
|
|
|
|
|
|
Common::Platform LilliputEngine::getPlatform() const {
|
|
|
|
return _platform;
|
|
|
|
}
|
|
|
|
|
2012-05-08 18:36:01 +02:00
|
|
|
void LilliputEngine::displayCharacter(int index, Common::Point pos, int flags) {
|
2012-05-17 11:59:54 +02:00
|
|
|
debugC(2, kDebugEngine, "displayCharacter(%d, %d - %d, %d)", index, pos.x, pos.y, flags);
|
2012-04-24 01:20:29 +02:00
|
|
|
|
2012-05-17 11:59:54 +02:00
|
|
|
byte *buf = _savedSurfaceGameArea1 + (pos.y * 256) + pos.x;
|
2012-04-24 01:20:29 +02:00
|
|
|
|
2012-04-27 08:18:59 +02:00
|
|
|
byte *src = _bufferMen;
|
2012-04-24 01:20:29 +02:00
|
|
|
if (index < 0) {
|
|
|
|
src = _bufferIdeogram;
|
|
|
|
index = -index;
|
2012-04-24 23:17:10 +02:00
|
|
|
} else if (index >= 0xF0) {
|
2012-04-24 01:20:29 +02:00
|
|
|
src = _bufferMen2;
|
|
|
|
index -= 0xF0;
|
|
|
|
}
|
|
|
|
|
2012-05-17 11:59:54 +02:00
|
|
|
src += (index * 256);
|
2012-04-24 01:20:29 +02:00
|
|
|
|
2012-05-16 20:58:41 +02:00
|
|
|
if ((flags & 2) == 0) {
|
2012-04-24 01:20:29 +02:00
|
|
|
for (int y = 0; y < 16; y++) {
|
|
|
|
for (int x = 0; x < 16; x++) {
|
|
|
|
if (src[x] != 0)
|
|
|
|
buf[x] = src[x];
|
|
|
|
}
|
|
|
|
src += 16;
|
|
|
|
buf += 256;
|
|
|
|
}
|
|
|
|
} else {
|
2012-04-30 17:57:23 +02:00
|
|
|
// Sprite mirror
|
2012-04-24 01:20:29 +02:00
|
|
|
for (int y = 0; y < 16; y++) {
|
|
|
|
for (int x = 0; x < 16; x++) {
|
2012-05-22 22:12:09 +02:00
|
|
|
// May need a hack of 1 pixel
|
2012-04-30 14:17:03 +02:00
|
|
|
if (src[15 - x] != 0)
|
|
|
|
buf[x] = src[15 - x];
|
2012-04-24 01:20:29 +02:00
|
|
|
}
|
2012-04-30 14:17:03 +02:00
|
|
|
src += 16;
|
2012-04-24 01:20:29 +02:00
|
|
|
buf += 256;
|
|
|
|
}
|
2012-04-25 01:41:31 +02:00
|
|
|
}
|
2012-04-24 01:20:29 +02:00
|
|
|
}
|
|
|
|
|
2012-05-28 18:22:51 +02:00
|
|
|
void LilliputEngine::display16x16IndexedBuf(byte *buf, int index, Common::Point pos, bool transparent, bool updateScreen) {
|
2012-05-18 19:24:03 +02:00
|
|
|
debugC(2, kDebugEngine, "display16x16IndexedBuf(buf, %d, %d - %d)", index, pos.x, pos.y);
|
2012-04-15 23:20:30 +02:00
|
|
|
|
2012-05-17 11:59:54 +02:00
|
|
|
int index1 = index * 16 * 16;
|
2012-04-15 23:20:30 +02:00
|
|
|
byte *newBuf = &buf[index1];
|
|
|
|
|
2012-05-24 21:11:00 +02:00
|
|
|
int vgaIndex = pos.x + (pos.y * 320);
|
2012-04-15 23:20:30 +02:00
|
|
|
|
|
|
|
for (int i = 0; i < 16; i++) {
|
2012-05-24 20:12:21 +02:00
|
|
|
// clip on y
|
|
|
|
if (pos.y + i < 200) {
|
|
|
|
for (int j = 0; j < 16; j++) {
|
|
|
|
// clip on x
|
2012-05-28 18:22:51 +02:00
|
|
|
if ((newBuf[j] != 0 || !transparent) && (pos.x + j < 320))
|
2012-05-24 21:11:00 +02:00
|
|
|
((byte *)_mainSurface->getPixels())[vgaIndex + j] = newBuf[j];
|
2012-05-24 20:12:21 +02:00
|
|
|
}
|
2012-04-25 21:28:03 +02:00
|
|
|
}
|
2012-05-24 21:11:00 +02:00
|
|
|
vgaIndex += 320;
|
2012-04-25 21:28:03 +02:00
|
|
|
newBuf += 16;
|
2012-04-15 23:20:30 +02:00
|
|
|
}
|
2012-05-28 18:22:51 +02:00
|
|
|
|
|
|
|
if (updateScreen) {
|
|
|
|
_system->copyRectToScreen((byte *)_mainSurface->getPixels(), 320, 0, 0, 320, 200);
|
|
|
|
_system->updateScreen();
|
|
|
|
}
|
2012-04-15 23:20:30 +02:00
|
|
|
}
|
|
|
|
|
2012-05-28 18:22:51 +02:00
|
|
|
void LilliputEngine::display16x16Buf(byte *buf, Common::Point pos, bool transparent, bool updateScreen) {
|
2012-05-09 23:13:15 +02:00
|
|
|
debugC(2, kDebugEngine, "display16x16Buf(buf, %d, %d)", pos.x, pos.y);
|
2012-04-15 23:20:30 +02:00
|
|
|
|
2012-05-28 18:22:51 +02:00
|
|
|
display16x16IndexedBuf(buf, 0, pos, transparent, updateScreen);
|
2012-04-15 23:20:30 +02:00
|
|
|
}
|
|
|
|
|
2012-05-09 08:07:58 +02:00
|
|
|
void LilliputEngine::SaveSurfaceUnderMouseCursor(byte *buf, Common::Point pos) {
|
|
|
|
debugC(2, kDebugEngine, "SaveSurfaceUnderMouseCursor(buf, %d, %d)", pos.x, pos.y);
|
2012-04-16 07:43:49 +02:00
|
|
|
|
2012-05-17 11:59:54 +02:00
|
|
|
int index2 = pos.x + (pos.y * 320);
|
2012-04-16 07:43:49 +02:00
|
|
|
|
|
|
|
for (int i = 0; i < 16; i++) {
|
|
|
|
for (int j = 0; j < 16; j++) {
|
|
|
|
buf[(i * 16) + j] = ((byte *)_mainSurface->getPixels())[index2 + j];
|
|
|
|
}
|
|
|
|
index2 += 320;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-17 11:59:54 +02:00
|
|
|
void LilliputEngine::fill16x16Rect(byte col, Common::Point pos) {
|
|
|
|
debugC(2, kDebugEngineTBC, "fill16x16Rect(%d, %d - %d)", col, pos.x, pos.y);
|
2012-04-18 08:16:39 +02:00
|
|
|
|
2012-05-17 11:59:54 +02:00
|
|
|
int index = pos.x + (pos.y * 320);
|
2012-04-18 08:16:39 +02:00
|
|
|
for (int i = 0; i < 16; i++) {
|
|
|
|
for (int j = 0; j < 16; j++) {
|
|
|
|
((byte *)_mainSurface->getPixels())[index + j] = col;
|
|
|
|
}
|
|
|
|
index += 320;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-09 08:07:58 +02:00
|
|
|
void LilliputEngine::displayMousePointer() {
|
|
|
|
debugC(2, kDebugEngine, "displayMousePointer()");
|
2012-04-16 00:24:02 +02:00
|
|
|
|
|
|
|
if ((_skipDisplayFlag1 != 1) && (_skipDisplayFlag2 != 1)) {
|
|
|
|
_skipDisplayFlag2 = 1;
|
|
|
|
|
2012-05-09 08:07:58 +02:00
|
|
|
_savedSurfaceUnderMousePos = _mouseDisplayPos;
|
|
|
|
SaveSurfaceUnderMouseCursor(_savedSurfaceUnderMouse, _mouseDisplayPos);
|
2012-06-23 10:47:10 +02:00
|
|
|
display16x16IndexedBuf(_bufferIdeogram, _bool15AC2 ? 81 : 80, _mouseDisplayPos);
|
2012-04-16 00:24:02 +02:00
|
|
|
|
|
|
|
_skipDisplayFlag1 = 1;
|
|
|
|
_skipDisplayFlag2 = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-09 08:07:58 +02:00
|
|
|
void LilliputEngine::restoreSurfaceUnderMousePointer() {
|
|
|
|
debugC(2, kDebugEngine, "restoreSurfaceUnderMousePointer()");
|
2012-04-15 23:20:30 +02:00
|
|
|
|
|
|
|
if ((_skipDisplayFlag1 != 0) && (_skipDisplayFlag2 != 1)) {
|
|
|
|
_skipDisplayFlag2 = 1;
|
2012-05-28 18:22:51 +02:00
|
|
|
display16x16Buf(_savedSurfaceUnderMouse, _savedSurfaceUnderMousePos, false, false);
|
2012-04-15 23:20:30 +02:00
|
|
|
_skipDisplayFlag1 = 0;
|
|
|
|
_skipDisplayFlag2 = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-11 08:06:19 +02:00
|
|
|
void LilliputEngine::saveSurfaceGameArea() {
|
2012-05-17 11:59:54 +02:00
|
|
|
debugC(2, kDebugEngine, "saveSurfaceGameArea()");
|
2012-04-16 23:16:01 +02:00
|
|
|
|
2012-05-09 08:07:58 +02:00
|
|
|
restoreSurfaceUnderMousePointer();
|
2012-04-16 23:16:01 +02:00
|
|
|
|
2012-05-11 08:06:19 +02:00
|
|
|
int index = (16 * 320) + 64; // 5184
|
2012-04-16 23:16:01 +02:00
|
|
|
for (int i = 0; i < 176; i++) {
|
|
|
|
for (int j = 0; j < 256; j++)
|
2012-05-11 08:06:19 +02:00
|
|
|
_savedSurfaceGameArea3[(i * 256) + j] = ((byte *)_mainSurface->getPixels())[index + j];
|
2012-04-16 23:16:01 +02:00
|
|
|
index += 320;
|
|
|
|
}
|
|
|
|
|
2012-05-09 08:07:58 +02:00
|
|
|
displayMousePointer();
|
2012-04-16 23:16:01 +02:00
|
|
|
}
|
|
|
|
|
2012-05-11 08:06:19 +02:00
|
|
|
void LilliputEngine::saveSurfaceSpeech() {
|
|
|
|
debugC(2, kDebugEngine, "saveSurfaceSpeech()");
|
2012-04-17 23:48:11 +02:00
|
|
|
|
2012-05-09 08:07:58 +02:00
|
|
|
restoreSurfaceUnderMousePointer();
|
2012-04-17 23:48:11 +02:00
|
|
|
|
|
|
|
int index = 66;
|
|
|
|
for (int i = 0; i < 16; i++) {
|
|
|
|
for (int j = 0; j < 252; j++)
|
2012-05-11 08:06:19 +02:00
|
|
|
_savedSurfaceSpeech[(i * 252) + j] = ((byte *)_mainSurface->getPixels())[index + j];
|
2012-04-17 23:48:11 +02:00
|
|
|
index += 320;
|
|
|
|
}
|
|
|
|
|
2012-05-09 08:07:58 +02:00
|
|
|
displayMousePointer();
|
2012-04-17 23:48:11 +02:00
|
|
|
}
|
|
|
|
|
2012-05-11 08:06:19 +02:00
|
|
|
void LilliputEngine::restoreSurfaceSpeech() {
|
|
|
|
debugC(2, kDebugEngine, "restoreSurfaceSpeech()");
|
|
|
|
|
|
|
|
restoreSurfaceUnderMousePointer();
|
|
|
|
|
|
|
|
int index = 66;
|
|
|
|
for (int i = 0; i < 16; i++) {
|
|
|
|
for (int j = 0; j < 252; j++)
|
|
|
|
((byte *)_mainSurface->getPixels())[index + j] = _savedSurfaceSpeech[(i * 252) + j];
|
|
|
|
index += 320;
|
|
|
|
}
|
|
|
|
|
|
|
|
displayMousePointer();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-05-05 18:16:03 +02:00
|
|
|
void LilliputEngine::displayInterfaceHotspots() {
|
2012-05-17 11:59:54 +02:00
|
|
|
debugC(2, kDebugEngine, "displayInterfaceHotspots()");
|
2012-04-17 23:48:11 +02:00
|
|
|
|
2012-06-01 08:18:33 +02:00
|
|
|
if (_displayMap)
|
2012-04-17 23:48:11 +02:00
|
|
|
return;
|
|
|
|
|
2012-05-09 08:07:58 +02:00
|
|
|
restoreSurfaceUnderMousePointer();
|
2012-04-17 23:48:11 +02:00
|
|
|
|
|
|
|
int tmpVal;
|
2012-05-18 19:24:03 +02:00
|
|
|
for (int index = 0; index < _interfaceHotspotNumb; index++) {
|
|
|
|
tmpVal = _scriptHandler->_interfaceHotspotStatus[index] * 20;
|
2012-05-09 23:13:15 +02:00
|
|
|
display16x16IndexedBuf(_bufferIdeogram, tmpVal + index, Common::Point(_interfaceHotspotsX[index], _interfaceHotspotsY[index]));
|
2012-04-17 23:48:11 +02:00
|
|
|
}
|
|
|
|
|
2012-05-09 08:07:58 +02:00
|
|
|
displayMousePointer();
|
2012-04-17 23:48:11 +02:00
|
|
|
}
|
|
|
|
|
2012-05-10 08:11:45 +02:00
|
|
|
void LilliputEngine::displayLandscape() {
|
|
|
|
debugC(2, kDebugEngine, "displayLandscape()");
|
2012-04-17 23:48:11 +02:00
|
|
|
|
2012-05-11 08:06:19 +02:00
|
|
|
memcpy(_savedSurfaceGameArea2, _savedSurfaceGameArea3, 176 * 256); // 45056
|
2012-04-17 23:48:11 +02:00
|
|
|
|
2012-05-24 20:12:21 +02:00
|
|
|
int index = (_scriptHandler->_viewportPos.y * 64 + _scriptHandler->_viewportPos.x) * 4;
|
2012-04-17 23:48:11 +02:00
|
|
|
|
2012-05-24 20:12:21 +02:00
|
|
|
for (int posY = 0; posY < 8; posY++) {
|
|
|
|
for (int posX = 0; posX < 8 ; posX++) {
|
|
|
|
assert (index < 16384);
|
|
|
|
displayIsometricBlock(_savedSurfaceGameArea2, _bufferIsoMap[index], posX, posY, 0);
|
2012-04-17 23:48:11 +02:00
|
|
|
index += 4;
|
|
|
|
}
|
|
|
|
index += 224;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-04-19 08:03:19 +02:00
|
|
|
// Display dialog bubble
|
2012-05-21 22:03:40 +02:00
|
|
|
void LilliputEngine::displaySpeechBubble() {
|
|
|
|
debugC(2, kDebugEngine, "displaySpeechBubble()");
|
2012-04-18 08:16:39 +02:00
|
|
|
static const byte _array15976[16] = {244, 248, 250, 250, 252, 252, 252, 252, 252, 252, 252, 252, 250, 250, 248, 244};
|
|
|
|
|
2012-05-09 08:07:58 +02:00
|
|
|
restoreSurfaceUnderMousePointer();
|
2012-04-18 08:16:39 +02:00
|
|
|
|
|
|
|
int index = 192;
|
|
|
|
int tmpIndex;
|
|
|
|
int var3;
|
|
|
|
|
|
|
|
for (int i = 0; i < 16; i++) {
|
|
|
|
var3 = _array15976[i];
|
|
|
|
tmpIndex = index - (var3 / 2);
|
2012-04-19 08:03:19 +02:00
|
|
|
var3 &= 0xFE;
|
|
|
|
for (int j = 0; j < var3; j++) {
|
2012-04-18 08:16:39 +02:00
|
|
|
((byte *)_mainSurface->getPixels())[tmpIndex + j] = 17;
|
|
|
|
}
|
|
|
|
index += 320;
|
|
|
|
}
|
|
|
|
|
2012-05-09 08:07:58 +02:00
|
|
|
displayMousePointer();
|
2012-04-18 08:16:39 +02:00
|
|
|
}
|
|
|
|
|
2012-05-21 09:44:25 +02:00
|
|
|
void LilliputEngine::displaySpeechLine(int vgaIndex, byte *srcBuf, int &bufIndex) {
|
2012-05-21 22:03:40 +02:00
|
|
|
debugC(2, kDebugEngine, "displaySpeechLine()");
|
2012-04-29 00:35:44 +02:00
|
|
|
|
|
|
|
int var3 = 0;
|
|
|
|
int var1;
|
|
|
|
int bckIndex = bufIndex;
|
|
|
|
|
|
|
|
for (;;) {
|
|
|
|
var1 = srcBuf[bufIndex];
|
|
|
|
if ((var1 == 0) || (var1 == '|'))
|
|
|
|
break;
|
|
|
|
|
|
|
|
++bufIndex;
|
|
|
|
++var3;
|
|
|
|
}
|
|
|
|
|
2012-05-13 03:21:09 +02:00
|
|
|
var1 = (0x3D - var3) << 1;
|
2012-04-29 00:35:44 +02:00
|
|
|
vgaIndex += var1;
|
|
|
|
|
|
|
|
bufIndex = bckIndex;
|
|
|
|
for (;;) {
|
|
|
|
var1 = srcBuf[bufIndex];
|
|
|
|
++bufIndex;
|
|
|
|
if ((var1 == 0) || (var1 == '|'))
|
|
|
|
break;
|
|
|
|
|
2012-05-13 03:21:09 +02:00
|
|
|
displayChar(vgaIndex, var1);
|
2012-04-29 00:35:44 +02:00
|
|
|
vgaIndex += 4;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-21 09:44:25 +02:00
|
|
|
void LilliputEngine::displaySpeech(byte *buf) {
|
|
|
|
debugC(2, kDebugEngine, "displaySpeech(%s)", buf);
|
2012-04-29 00:35:44 +02:00
|
|
|
|
2012-05-09 08:07:58 +02:00
|
|
|
restoreSurfaceUnderMousePointer();
|
2012-04-29 00:35:44 +02:00
|
|
|
|
|
|
|
int vgaIndex = 70;
|
|
|
|
int bufIndex = 0;
|
|
|
|
|
2012-05-21 09:44:25 +02:00
|
|
|
bool multiLineFlag = false;
|
|
|
|
byte var1;
|
2012-04-29 00:35:44 +02:00
|
|
|
|
|
|
|
for (;;) {
|
|
|
|
var1 = buf[bufIndex];
|
|
|
|
++bufIndex;
|
|
|
|
if (var1 == 0) {
|
|
|
|
vgaIndex += (4 * 320);
|
|
|
|
break;
|
2012-05-21 09:44:25 +02:00
|
|
|
} else if (var1 == '|') {
|
|
|
|
multiLineFlag = true;
|
2012-04-29 00:35:44 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bufIndex = 0;
|
2012-05-21 09:44:25 +02:00
|
|
|
displaySpeechLine(vgaIndex, buf, bufIndex);
|
|
|
|
if (multiLineFlag) {
|
2012-04-29 00:35:44 +02:00
|
|
|
vgaIndex += (8 * 320);
|
2012-05-21 09:44:25 +02:00
|
|
|
displaySpeechLine(vgaIndex, buf, bufIndex);
|
2012-04-29 00:35:44 +02:00
|
|
|
}
|
|
|
|
|
2012-05-09 08:07:58 +02:00
|
|
|
displayMousePointer();
|
2012-04-29 00:35:44 +02:00
|
|
|
}
|
|
|
|
|
2012-05-17 11:59:54 +02:00
|
|
|
void LilliputEngine::initGameAreaDisplay() {
|
|
|
|
debugC(1, kDebugEngine, "initGameAreaDisplay()");
|
2012-04-16 23:16:01 +02:00
|
|
|
|
2012-05-09 08:07:58 +02:00
|
|
|
restoreSurfaceUnderMousePointer();
|
2012-04-16 23:16:01 +02:00
|
|
|
|
2012-05-17 11:59:54 +02:00
|
|
|
// display background
|
2012-05-11 08:06:19 +02:00
|
|
|
byte *tmpBuf = loadVGA("SCREEN.GFX", 320 * 200, true);
|
|
|
|
memcpy(_mainSurface->getPixels(), tmpBuf, 320 * 200);
|
2012-04-16 23:16:01 +02:00
|
|
|
_system->copyRectToScreen((byte *)_mainSurface->getPixels(), 320, 0, 0, 320, 200);
|
|
|
|
_system->updateScreen();
|
|
|
|
|
2012-05-17 11:59:54 +02:00
|
|
|
// display game area on top of background
|
2012-05-11 08:06:19 +02:00
|
|
|
saveSurfaceGameArea();
|
|
|
|
saveSurfaceSpeech();
|
2012-05-05 18:16:03 +02:00
|
|
|
displayInterfaceHotspots();
|
2012-05-10 08:11:45 +02:00
|
|
|
displayLandscape();
|
2012-05-11 20:47:17 +02:00
|
|
|
prepareGameArea();
|
2012-05-11 08:06:19 +02:00
|
|
|
displayGameArea();
|
2012-04-16 23:16:01 +02:00
|
|
|
|
2012-05-17 11:59:54 +02:00
|
|
|
// display mouse pointer on top of the rest
|
2012-05-09 08:07:58 +02:00
|
|
|
displayMousePointer();
|
2012-04-16 23:16:01 +02:00
|
|
|
free(tmpBuf);
|
|
|
|
}
|
|
|
|
|
2012-05-24 20:12:21 +02:00
|
|
|
void LilliputEngine::displayIsometricBlock(byte *buf, int var1, int posX, int posY, int var3) {
|
|
|
|
debugC(1, kDebugEngine, "displayIsometricBlock(buf, %d, %d - %d, %d)", var1, posX, posY, var3);
|
2012-05-10 08:11:45 +02:00
|
|
|
|
2012-05-24 20:12:21 +02:00
|
|
|
byte tmpByte1 = ((7 + posX - posY) << 4) & 0xFF;
|
|
|
|
byte tmpByte2 = ((4 + posX + posY - (var3 >> 7)) << 3) & 0xFF;
|
2012-04-17 23:48:11 +02:00
|
|
|
|
|
|
|
int index = (tmpByte2 << 8) + tmpByte1;
|
2012-04-18 00:47:50 +02:00
|
|
|
int index2 = var1 << 10;
|
2012-04-17 23:48:11 +02:00
|
|
|
|
|
|
|
for (int i = 0; i < 32; i++) {
|
|
|
|
for (int j = 0; j < 32; j++) {
|
|
|
|
if (_bufferCubegfx[index2 + j] != 0)
|
2012-04-18 00:01:23 +02:00
|
|
|
buf[index + j] = _bufferCubegfx[index2 + j];
|
2012-04-17 23:48:11 +02:00
|
|
|
}
|
2012-04-18 00:01:23 +02:00
|
|
|
index2 += 32;
|
2012-04-17 23:48:11 +02:00
|
|
|
index += 256;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-11 08:06:19 +02:00
|
|
|
void LilliputEngine::displayGameArea() {
|
|
|
|
debugC(2, kDebugEngine, "displayGameArea()");
|
2012-04-17 23:48:11 +02:00
|
|
|
|
2012-06-01 08:18:33 +02:00
|
|
|
if (_displayMap)
|
2012-04-17 23:48:11 +02:00
|
|
|
return;
|
|
|
|
|
2012-05-05 18:16:03 +02:00
|
|
|
if (_mouseDisplayPos.x > 48)
|
2012-05-09 08:07:58 +02:00
|
|
|
restoreSurfaceUnderMousePointer();
|
2012-04-17 23:48:11 +02:00
|
|
|
|
2012-05-11 08:06:19 +02:00
|
|
|
int index = (16 * 320) + 64; // 5184
|
2012-04-17 23:48:11 +02:00
|
|
|
for (int i = 0; i < 176; i++) {
|
|
|
|
for (int j = 0; j < 256; j++)
|
2012-05-11 08:06:19 +02:00
|
|
|
((byte *)_mainSurface->getPixels())[index + j] = _savedSurfaceGameArea1[(i * 256) + j];
|
2012-04-17 23:48:11 +02:00
|
|
|
index += 320;
|
|
|
|
}
|
|
|
|
|
|
|
|
_system->copyRectToScreen((byte *)_mainSurface->getPixels(), 320, 0, 0, 320, 200);
|
|
|
|
_system->updateScreen();
|
|
|
|
|
2012-05-09 08:07:58 +02:00
|
|
|
displayMousePointer();
|
2012-04-27 08:18:59 +02:00
|
|
|
}
|
2012-04-17 23:48:11 +02:00
|
|
|
|
2012-04-24 00:31:34 +02:00
|
|
|
void LilliputEngine::restoreMapPoints() {
|
2012-06-21 07:33:00 +02:00
|
|
|
debugC(2, kDebugEngine, "restoreMapPoints()");
|
2012-04-29 10:47:50 +02:00
|
|
|
|
2012-05-09 08:07:58 +02:00
|
|
|
restoreSurfaceUnderMousePointer();
|
2012-04-24 00:31:34 +02:00
|
|
|
|
2012-04-27 08:18:59 +02:00
|
|
|
byte *buf = (byte *)_mainSurface->getPixels();
|
2012-05-26 15:40:09 +02:00
|
|
|
for (byte index = 0; index < _numCharacters; index++) {
|
2012-06-20 01:35:57 +02:00
|
|
|
buf[_mapSavedPixelIndex[index]] = _mapSavedPixel[index];
|
2012-04-24 00:31:34 +02:00
|
|
|
}
|
|
|
|
|
2012-05-09 08:07:58 +02:00
|
|
|
displayMousePointer();
|
2012-04-24 00:31:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void LilliputEngine::displayCharactersOnMap() {
|
2012-05-08 18:36:01 +02:00
|
|
|
debugC(2, kDebugEngineTBC, "displayCharactersOnMap()");
|
2012-04-29 10:47:50 +02:00
|
|
|
|
2012-05-10 19:26:16 +02:00
|
|
|
moveCharacters();
|
2012-05-09 08:07:58 +02:00
|
|
|
restoreSurfaceUnderMousePointer();
|
2012-04-24 00:31:34 +02:00
|
|
|
|
2012-04-27 08:18:59 +02:00
|
|
|
byte *buf = (byte *)_mainSurface->getPixels();
|
2012-05-23 07:40:05 +02:00
|
|
|
for (int index = _numCharacters - 1; index >= 0; index--) {
|
2012-06-20 07:49:21 +02:00
|
|
|
if (((_rulesBuffer2_11[index] & 2) == 0) && (_scriptHandler->_characterTilePosY[index] != -1)) {
|
2012-06-20 01:35:57 +02:00
|
|
|
// FIXME: This is still wrong, but less. The values in both arrays should be verified now!
|
2012-06-20 07:49:21 +02:00
|
|
|
int pixIndex = 320 + ((15 * _scriptHandler->_characterTilePosY[index]) / 4) + (_scriptHandler->_characterTilePosX[index] * 4) + 1;
|
2012-04-24 00:31:34 +02:00
|
|
|
|
2012-06-20 01:35:57 +02:00
|
|
|
_mapSavedPixelIndex[index] = pixIndex;
|
|
|
|
_mapSavedPixel[index] = buf[pixIndex];
|
|
|
|
buf[pixIndex] = _scriptHandler->_characterMapPixelColor[index];
|
2012-04-24 00:31:34 +02:00
|
|
|
}
|
|
|
|
}
|
2012-05-09 08:07:58 +02:00
|
|
|
displayMousePointer();
|
2012-04-24 00:31:34 +02:00
|
|
|
}
|
|
|
|
|
2012-05-10 19:26:16 +02:00
|
|
|
void LilliputEngine::moveCharacters() {
|
|
|
|
debugC(2, kDebugEngine, "moveCharacters()");
|
2012-04-17 23:48:11 +02:00
|
|
|
|
2012-04-25 00:13:32 +02:00
|
|
|
_numCharactersToDisplay = 0;
|
2012-05-26 15:40:09 +02:00
|
|
|
byte index = _numCharacters - 1;
|
2012-05-05 18:16:03 +02:00
|
|
|
Common::Point _pos16213 = Common::Point(_scriptHandler->_viewportPos.x << 3, _scriptHandler->_viewportPos.y << 3);
|
2012-04-17 23:48:11 +02:00
|
|
|
|
|
|
|
for (int i = index; i >= 0; i--) {
|
2012-05-26 17:59:38 +02:00
|
|
|
if (_rulesBuffer2_5[i] != -1) {
|
2012-04-17 23:48:11 +02:00
|
|
|
int index2 = _rulesBuffer2_5[i];
|
2012-05-01 14:35:19 +02:00
|
|
|
_characterPositionAltitude[i] = _characterPositionAltitude[index2] + _rulesBuffer2_7[i];
|
2012-05-26 17:59:38 +02:00
|
|
|
int8 tmpVal = _rulesBuffer2_6[i];
|
2012-04-30 17:57:23 +02:00
|
|
|
_characterDirectionArray[i] = _characterDirectionArray[index2];
|
2012-04-25 01:41:31 +02:00
|
|
|
int var3 = _characterPositionX[index2];
|
|
|
|
int var4 = _characterPositionY[index2];
|
2012-04-17 23:48:11 +02:00
|
|
|
|
2012-04-30 17:57:23 +02:00
|
|
|
switch (_characterDirectionArray[i]) {
|
2012-04-17 23:48:11 +02:00
|
|
|
case 0:
|
|
|
|
var3 -= tmpVal;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
var4 += tmpVal;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
var4 -= tmpVal;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
var3 += tmpVal;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2012-04-25 01:41:31 +02:00
|
|
|
_characterPositionX[i] = var3;
|
|
|
|
_characterPositionY[i] = var4;
|
2012-04-17 23:48:11 +02:00
|
|
|
}
|
|
|
|
|
2012-06-20 07:49:21 +02:00
|
|
|
_scriptHandler->_characterTilePosX[i] = (_characterPositionX[i] >> 3);
|
|
|
|
_scriptHandler->_characterTilePosY[i] = (_characterPositionY[i] >> 3);
|
2012-06-21 07:33:00 +02:00
|
|
|
_characterRelativePositionX[i] = -1;
|
|
|
|
_characterRelativePositionY[i] = -1;
|
|
|
|
_characterDisplayX[i] = -1;
|
|
|
|
_characterDisplayY[i] = -1;
|
2012-04-17 23:48:11 +02:00
|
|
|
|
2012-05-05 18:16:03 +02:00
|
|
|
int tmpVal2 = (_characterPositionX[i] >> 3) - _scriptHandler->_viewportPos.x;
|
|
|
|
int tmpVal3 = (_characterPositionY[i] >> 3) - _scriptHandler->_viewportPos.y;
|
2012-04-17 23:48:11 +02:00
|
|
|
if ((tmpVal2 >= 0) && (tmpVal2 <= 7) && (tmpVal3 >= 0) && (tmpVal3 <= 7)) {
|
2012-04-25 01:41:31 +02:00
|
|
|
_characterRelativePositionX[i] = tmpVal2;
|
|
|
|
_characterRelativePositionY[i] = tmpVal3;
|
2012-05-05 18:16:03 +02:00
|
|
|
tmpVal2 = _characterPositionX[i] - _pos16213.x;
|
|
|
|
tmpVal3 = _characterPositionY[i] - _pos16213.y;
|
2012-05-01 14:35:19 +02:00
|
|
|
int tmpVal4 = _characterPositionAltitude[i];
|
2012-04-25 01:41:31 +02:00
|
|
|
_characterDisplayX[i] = ((60 + tmpVal2 - tmpVal3) * 2) & 0xFF;
|
|
|
|
_characterDisplayY[i] = (20 + tmpVal2 + tmpVal3 - tmpVal4) & 0xFF;
|
2012-04-25 00:13:32 +02:00
|
|
|
_charactersToDisplay[_numCharactersToDisplay] = i;
|
|
|
|
++_numCharactersToDisplay;
|
2012-05-22 22:12:09 +02:00
|
|
|
}
|
2012-04-17 23:48:11 +02:00
|
|
|
}
|
2012-04-18 00:01:23 +02:00
|
|
|
|
2012-04-25 00:13:32 +02:00
|
|
|
sortCharacters();
|
2012-04-17 23:48:11 +02:00
|
|
|
}
|
|
|
|
|
2012-04-25 21:28:03 +02:00
|
|
|
void LilliputEngine::setNextDisplayCharacter(int var1) {
|
2012-05-10 19:26:16 +02:00
|
|
|
debugC(2, kDebugEngine, "setNextDisplayCharacter(%d)", var1);
|
2012-04-17 23:48:11 +02:00
|
|
|
|
2012-04-25 21:28:03 +02:00
|
|
|
byte charNum = var1 & 0xFF;
|
2012-05-16 20:58:41 +02:00
|
|
|
if (charNum < _numCharactersToDisplay) {
|
2012-04-25 21:28:03 +02:00
|
|
|
int index = _charactersToDisplay[charNum];
|
2012-05-08 18:36:01 +02:00
|
|
|
_nextDisplayCharacterPos = Common::Point(_characterRelativePositionX[index], _characterRelativePositionY[index]);
|
2012-04-17 23:48:11 +02:00
|
|
|
} else {
|
2012-05-08 18:36:01 +02:00
|
|
|
_nextDisplayCharacterPos = Common::Point(-1, -1);
|
2012-04-17 23:48:11 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-11 20:47:17 +02:00
|
|
|
void LilliputEngine::prepareGameArea() {
|
2012-05-17 11:59:54 +02:00
|
|
|
debugC(2, kDebugEngine, "prepareGameArea()");
|
2012-04-17 23:48:11 +02:00
|
|
|
|
2012-05-10 19:26:16 +02:00
|
|
|
moveCharacters();
|
2012-04-25 01:41:31 +02:00
|
|
|
_currentDisplayCharacter = 0;
|
2012-04-25 21:28:03 +02:00
|
|
|
setNextDisplayCharacter(0);
|
2012-04-17 23:48:11 +02:00
|
|
|
|
2012-05-11 08:06:19 +02:00
|
|
|
memcpy(_savedSurfaceGameArea1, _savedSurfaceGameArea2, 176 * 256); // 45056;
|
2012-04-17 23:48:11 +02:00
|
|
|
|
2012-05-24 20:12:21 +02:00
|
|
|
int index1 = (_scriptHandler->_viewportPos.y * 64 + _scriptHandler->_viewportPos.x) * 4;
|
|
|
|
assert(index1 < 16384);
|
2012-04-17 23:48:11 +02:00
|
|
|
byte *map = &_bufferIsoMap[index1];
|
|
|
|
|
2012-05-24 20:12:21 +02:00
|
|
|
for (int posY = 0; posY < 8; posY++) {
|
|
|
|
for (int posX = 0; posX < 8; posX++) {
|
2012-04-17 23:48:11 +02:00
|
|
|
if (map[1] != 0xFF) {
|
|
|
|
int var1 = map[1];
|
2012-05-11 18:49:29 +02:00
|
|
|
if ((_rulesChunk9[var1] & 128) != 0)
|
2012-05-11 17:01:00 +02:00
|
|
|
var1 += _animationTick;
|
2012-05-24 20:12:21 +02:00
|
|
|
displayIsometricBlock(_savedSurfaceGameArea1, var1, posX, posY, 1 << 8);
|
2012-04-17 23:48:11 +02:00
|
|
|
}
|
2012-05-24 20:12:21 +02:00
|
|
|
renderCharacters(map, Common::Point(posX, posY));
|
2012-04-17 23:48:11 +02:00
|
|
|
|
|
|
|
if (map[2] != 0xFF) {
|
2012-04-18 00:47:50 +02:00
|
|
|
int var1 = map[2];
|
2012-05-11 18:49:29 +02:00
|
|
|
if ((_rulesChunk9[var1] & 128) != 0)
|
2012-05-11 17:01:00 +02:00
|
|
|
var1 += _animationTick;
|
2012-05-24 20:12:21 +02:00
|
|
|
displayIsometricBlock(_savedSurfaceGameArea1, var1, posX, posY, 2 << 8);
|
2012-04-17 23:48:11 +02:00
|
|
|
}
|
2012-04-18 00:47:50 +02:00
|
|
|
map += 4;
|
2012-04-17 23:48:11 +02:00
|
|
|
}
|
2012-04-18 00:47:50 +02:00
|
|
|
map += 224;
|
2012-04-17 23:48:11 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-22 22:12:09 +02:00
|
|
|
void LilliputEngine::displayRefreshScreen() {
|
2012-05-28 08:54:50 +02:00
|
|
|
debugC(2, kDebugEngine, "displayRefreshScreen()");
|
2012-04-19 08:03:19 +02:00
|
|
|
|
2012-06-01 08:18:33 +02:00
|
|
|
if (_displayMap) {
|
2012-04-29 10:04:15 +02:00
|
|
|
bool forceReturnFl = false;
|
2012-05-11 23:32:26 +02:00
|
|
|
checkMapClosing(forceReturnFl);
|
2012-04-29 10:04:15 +02:00
|
|
|
if (forceReturnFl)
|
|
|
|
return;
|
|
|
|
|
2012-04-24 00:31:34 +02:00
|
|
|
restoreMapPoints();
|
2012-04-20 08:34:41 +02:00
|
|
|
sub16626();
|
2012-04-22 11:48:35 +02:00
|
|
|
sub12F37();
|
2012-04-23 01:51:17 +02:00
|
|
|
sub16CA0();
|
2012-04-22 22:54:50 +02:00
|
|
|
sub16EBC();
|
|
|
|
sub171CF();
|
2012-04-24 00:31:34 +02:00
|
|
|
displayCharactersOnMap();
|
2012-04-19 08:03:19 +02:00
|
|
|
} else {
|
2012-04-25 01:41:31 +02:00
|
|
|
scrollToViewportCharacterTarget();
|
2012-05-11 23:32:26 +02:00
|
|
|
checkSpeechClosing();
|
2012-05-11 20:47:17 +02:00
|
|
|
prepareGameArea();
|
2012-05-11 08:06:19 +02:00
|
|
|
displayGameArea();
|
2012-04-20 08:34:41 +02:00
|
|
|
sub16626();
|
2012-04-22 11:48:35 +02:00
|
|
|
sub12F37();
|
2012-04-23 01:51:17 +02:00
|
|
|
sub16CA0();
|
2012-04-22 22:54:50 +02:00
|
|
|
sub16EBC();
|
|
|
|
sub171CF();
|
2012-06-23 10:47:10 +02:00
|
|
|
handleGameMouseClick();
|
2012-07-01 01:58:15 +02:00
|
|
|
checkInterfaceActivationDelay();
|
2012-04-22 22:54:50 +02:00
|
|
|
displayHeroismIndicator();
|
2012-04-19 08:03:19 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-11 17:01:00 +02:00
|
|
|
void LilliputEngine::resetSmallAnims() {
|
|
|
|
debugC(2, kDebugEngine, "resetSmallAnims()");
|
2012-05-11 08:06:19 +02:00
|
|
|
|
2012-05-11 17:01:00 +02:00
|
|
|
_smallAnims[0]._active = false;
|
|
|
|
_smallAnims[1]._active = false;
|
|
|
|
_smallAnims[2]._active = false;
|
|
|
|
_smallAnims[3]._active = false;
|
|
|
|
_smallAnimsFrameIndex = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void LilliputEngine::displaySmallIndexedAnim(byte index, byte subIndex) {
|
|
|
|
debugC(2, kDebugEngine, "displaySmallIndexedAnim(%d, %d)", index, subIndex);
|
|
|
|
|
|
|
|
if (!_smallAnims[index]._active)
|
|
|
|
return;
|
|
|
|
|
2012-05-28 18:22:51 +02:00
|
|
|
display16x16IndexedBuf(_bufferIdeogram, _smallAnims[index]._frameIndex[subIndex], _smallAnims[index]._pos, false);
|
2012-05-11 17:01:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void LilliputEngine::displaySmallAnims() {
|
2012-05-12 22:21:02 +02:00
|
|
|
debugC(2, kDebugEngine, "displaySmallAnims()");
|
2012-05-11 17:01:00 +02:00
|
|
|
|
|
|
|
if (_animationTick == _lastAnimationTick)
|
|
|
|
return;
|
|
|
|
|
2012-05-28 18:22:51 +02:00
|
|
|
restoreSurfaceUnderMousePointer();
|
|
|
|
|
2012-05-11 17:01:00 +02:00
|
|
|
_lastAnimationTick = _animationTick;
|
2012-05-22 22:12:09 +02:00
|
|
|
|
2012-05-11 17:01:00 +02:00
|
|
|
assert(_smallAnimsFrameIndex < 8);
|
|
|
|
int subIndex = _smallAnimsFrameIndex;
|
|
|
|
displaySmallIndexedAnim(0, subIndex);
|
|
|
|
displaySmallIndexedAnim(1, subIndex);
|
|
|
|
displaySmallIndexedAnim(2, subIndex);
|
|
|
|
displaySmallIndexedAnim(3, subIndex);
|
|
|
|
|
|
|
|
++subIndex;
|
|
|
|
if (subIndex == 8)
|
|
|
|
subIndex = 0;
|
|
|
|
|
|
|
|
_smallAnimsFrameIndex = subIndex;
|
2012-05-28 18:22:51 +02:00
|
|
|
|
|
|
|
displayMousePointer();
|
2012-04-29 10:04:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void LilliputEngine::paletteFadeOut() {
|
2012-05-09 08:07:58 +02:00
|
|
|
debugC(2, kDebugEngine, "paletteFadeOut()");
|
2012-04-29 10:04:15 +02:00
|
|
|
|
2012-05-11 17:01:00 +02:00
|
|
|
resetSmallAnims();
|
2012-04-29 10:04:15 +02:00
|
|
|
byte palette[768];
|
2012-05-21 22:22:06 +02:00
|
|
|
for (int fade = 256; fade >= 0; fade -= 8) {
|
2012-04-29 10:04:15 +02:00
|
|
|
for (int i = 0; i < 768; i++) {
|
|
|
|
palette[i] = (_curPalette[i] * fade) >> 8;
|
|
|
|
}
|
|
|
|
_system->getPaletteManager()->setPalette(palette, 0, 256);
|
|
|
|
_system->updateScreen();
|
|
|
|
_system->delayMillis(20);
|
2012-05-28 18:22:51 +02:00
|
|
|
pollEvent();
|
2012-04-29 10:04:15 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void LilliputEngine::paletteFadeIn() {
|
2012-05-09 23:13:15 +02:00
|
|
|
debugC(2, kDebugEngine, "paletteFadeIn()");
|
2012-04-29 10:04:15 +02:00
|
|
|
|
|
|
|
byte palette[768];
|
2012-05-21 22:22:06 +02:00
|
|
|
for (int fade = 8; fade <= 256; fade += 8) {
|
2012-04-29 10:04:15 +02:00
|
|
|
for (int i = 0; i < 768; i++) {
|
|
|
|
palette[i] = (_curPalette[i] * fade) >> 8;
|
|
|
|
}
|
|
|
|
_system->getPaletteManager()->setPalette(palette, 0, 256);
|
|
|
|
_system->updateScreen();
|
|
|
|
_system->delayMillis(20);
|
2012-05-28 18:22:51 +02:00
|
|
|
pollEvent();
|
2012-04-29 10:04:15 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-27 10:45:43 +02:00
|
|
|
int16 LilliputEngine::sub16DD5(int x1, int y1, int x2, int y2) {
|
|
|
|
debugC(2, kDebugEngine, "sub16DD5(%d, %d, %d, %d)", x1, y1, x2, y2);
|
2012-04-29 10:04:15 +02:00
|
|
|
|
2012-06-04 07:51:48 +02:00
|
|
|
int index = ((y1 * 64) + x1) * 4;
|
|
|
|
assert((index > 0) && (index <= 16380));
|
2012-05-29 08:30:34 +02:00
|
|
|
byte *isoMap = &_bufferIsoMap[index + 1];
|
2012-04-23 23:31:10 +02:00
|
|
|
|
2012-05-27 10:45:43 +02:00
|
|
|
int16 dx = x2 - x1;
|
|
|
|
int16 dy = y2 - y1;
|
2012-04-23 23:31:10 +02:00
|
|
|
|
2012-05-21 22:22:06 +02:00
|
|
|
int16 tmpMapMoveX = 0;
|
2012-05-20 22:57:03 +02:00
|
|
|
int16 tmpMapMoveY = 0;
|
|
|
|
int16 mapMoveY = 0;
|
|
|
|
int16 mapMoveX = 0;
|
2012-04-23 23:31:10 +02:00
|
|
|
|
2012-05-27 10:45:43 +02:00
|
|
|
int16 byte16DD4 = 0;
|
|
|
|
int16 byte16DD3 = 0;
|
2012-04-23 23:31:10 +02:00
|
|
|
|
2012-05-16 20:58:41 +02:00
|
|
|
if (dx < 0) {
|
2012-04-23 23:31:10 +02:00
|
|
|
dx = -dx;
|
2012-05-20 22:57:03 +02:00
|
|
|
tmpMapMoveX = -4;
|
2012-04-23 23:31:10 +02:00
|
|
|
} else {
|
2012-05-20 22:57:03 +02:00
|
|
|
tmpMapMoveX = 4;
|
2012-04-23 23:31:10 +02:00
|
|
|
}
|
|
|
|
|
2012-05-16 20:58:41 +02:00
|
|
|
if (dy < 0) {
|
2012-04-23 23:31:10 +02:00
|
|
|
dy = -dy;
|
2012-05-20 22:57:03 +02:00
|
|
|
tmpMapMoveY = -256;
|
2012-04-23 23:31:10 +02:00
|
|
|
} else {
|
2012-05-20 22:57:03 +02:00
|
|
|
tmpMapMoveY = 256;
|
2012-04-23 23:31:10 +02:00
|
|
|
}
|
|
|
|
|
2012-05-20 22:57:03 +02:00
|
|
|
if (dx >= dy) {
|
|
|
|
mapMoveY = 0;
|
|
|
|
mapMoveX = tmpMapMoveX;
|
2012-04-23 23:31:10 +02:00
|
|
|
} else {
|
2012-05-27 10:45:43 +02:00
|
|
|
int16 tmp = dy;
|
2012-04-23 23:31:10 +02:00
|
|
|
dy = dx;
|
|
|
|
dx = tmp;
|
2012-05-20 22:57:03 +02:00
|
|
|
mapMoveX = 0;
|
|
|
|
mapMoveY = tmpMapMoveY;
|
2012-04-23 23:31:10 +02:00
|
|
|
}
|
|
|
|
|
2012-05-27 10:45:43 +02:00
|
|
|
byte16DD4 = dy * 2;
|
|
|
|
int16 var1 = byte16DD4 - dx;
|
2012-05-20 22:57:03 +02:00
|
|
|
byte16DD3 = byte16DD4 - (dx * 2);
|
|
|
|
|
|
|
|
mapMoveX += mapMoveY;
|
|
|
|
tmpMapMoveX += tmpMapMoveY;
|
2012-04-23 23:31:10 +02:00
|
|
|
|
2012-05-21 22:22:06 +02:00
|
|
|
int count = 0;
|
2012-04-23 23:31:10 +02:00
|
|
|
|
2012-05-16 20:58:41 +02:00
|
|
|
while (*isoMap == 0xFF) {
|
2012-05-20 22:57:03 +02:00
|
|
|
if (var1 >= 0) {
|
|
|
|
isoMap += tmpMapMoveX;
|
2012-04-23 23:31:10 +02:00
|
|
|
var1 += byte16DD3;
|
|
|
|
} else {
|
2012-05-20 22:57:03 +02:00
|
|
|
isoMap += mapMoveX;
|
2012-04-23 23:31:10 +02:00
|
|
|
var1 += byte16DD4;
|
|
|
|
}
|
2012-05-21 22:22:06 +02:00
|
|
|
|
2012-04-23 23:31:10 +02:00
|
|
|
count++;
|
2012-05-20 22:57:03 +02:00
|
|
|
if (count > dx) {
|
2012-04-23 23:31:10 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
2012-05-27 10:45:43 +02:00
|
|
|
return tmpMapMoveY;
|
2012-04-23 01:51:17 +02:00
|
|
|
}
|
|
|
|
|
2012-04-29 10:04:15 +02:00
|
|
|
void LilliputEngine::sub15F75() {
|
2012-05-08 18:36:01 +02:00
|
|
|
debugC(2, kDebugEngineTBC, "sub15F75()");
|
2012-04-29 10:04:15 +02:00
|
|
|
|
2012-06-17 14:09:52 +02:00
|
|
|
_selectedCharacterId = -1;
|
2012-05-05 21:34:58 +02:00
|
|
|
_savedMousePosDivided = Common::Point(-1, -1);
|
2012-06-17 14:09:52 +02:00
|
|
|
byte newX = _mousePos.x / 4;
|
2012-05-05 18:16:03 +02:00
|
|
|
byte newY = _mousePos.y / 3;
|
2012-04-29 10:04:15 +02:00
|
|
|
|
|
|
|
if ((newX >= 64) || (newY >= 64))
|
|
|
|
return;
|
2012-05-21 22:22:06 +02:00
|
|
|
|
2012-05-05 21:34:58 +02:00
|
|
|
_savedMousePosDivided = Common::Point(newX, newY);
|
2012-06-23 18:56:08 +02:00
|
|
|
_actionType = 5;
|
2012-04-29 10:04:15 +02:00
|
|
|
}
|
|
|
|
|
2012-05-18 19:24:03 +02:00
|
|
|
void LilliputEngine::unselectInterfaceHotspots() {
|
|
|
|
debugC(2, kDebugEngine, "unselectInterfaceHotspots()");
|
2012-04-29 10:04:15 +02:00
|
|
|
|
2012-05-18 19:24:03 +02:00
|
|
|
for (int index = 0; index < _interfaceHotspotNumb; index++) {
|
|
|
|
if (_scriptHandler->_interfaceHotspotStatus[index] == kHotspotSelected)
|
|
|
|
_scriptHandler->_interfaceHotspotStatus[index] = kHotspotEnabled;
|
2012-04-29 10:04:15 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-11 23:32:26 +02:00
|
|
|
void LilliputEngine::checkMapClosing(bool &forceReturnFl) {
|
|
|
|
debugC(2, kDebugEngineTBC, "checkMapClosing()");
|
2012-04-29 10:04:15 +02:00
|
|
|
|
|
|
|
forceReturnFl = false;
|
2012-06-01 18:11:41 +02:00
|
|
|
if (!_displayMap)
|
2012-04-29 10:04:15 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
pollEvent();
|
2012-06-20 22:58:38 +02:00
|
|
|
if (!_keyboard_checkKeyboard()) {
|
2012-06-01 08:18:33 +02:00
|
|
|
_keyboard_getch();
|
|
|
|
} else {
|
2012-06-01 23:57:25 +02:00
|
|
|
if (_mouseButton != 1)
|
2012-06-01 08:18:33 +02:00
|
|
|
return;
|
2012-04-29 10:04:15 +02:00
|
|
|
|
2012-06-01 08:18:33 +02:00
|
|
|
_mouseButton = 0;
|
|
|
|
sub15F75();
|
|
|
|
}
|
2012-05-21 22:22:06 +02:00
|
|
|
|
2012-06-01 08:18:33 +02:00
|
|
|
_displayMap = false;
|
2012-04-29 10:04:15 +02:00
|
|
|
paletteFadeOut();
|
2012-06-23 10:47:10 +02:00
|
|
|
_bool15AC2 = false;
|
2012-05-18 19:24:03 +02:00
|
|
|
unselectInterfaceHotspots();
|
2012-05-17 11:59:54 +02:00
|
|
|
initGameAreaDisplay();
|
2012-04-29 10:04:15 +02:00
|
|
|
_scriptHandler->_heroismLevel = 0;
|
2012-05-10 19:26:16 +02:00
|
|
|
moveCharacters();
|
2012-04-29 10:04:15 +02:00
|
|
|
paletteFadeIn();
|
|
|
|
forceReturnFl = true;
|
|
|
|
}
|
|
|
|
|
2012-04-23 01:51:17 +02:00
|
|
|
void LilliputEngine::sub16CA0() {
|
2012-05-29 08:30:34 +02:00
|
|
|
debugC(2, kDebugEngine, "sub16CA0()");
|
2012-04-23 01:51:17 +02:00
|
|
|
|
2012-04-28 02:59:43 +02:00
|
|
|
for (int index = _numCharacters - 1; index >= 0; index--) {
|
2012-04-23 01:51:17 +02:00
|
|
|
if (_rulesBuffer2_11[index] & 1)
|
|
|
|
continue;
|
2012-04-23 20:36:18 +02:00
|
|
|
|
2012-06-20 07:49:21 +02:00
|
|
|
int c1 = _scriptHandler->_characterTilePosX[index];
|
|
|
|
int c2 = _scriptHandler->_characterTilePosY[index];
|
2012-04-23 01:51:17 +02:00
|
|
|
|
2012-06-04 07:51:48 +02:00
|
|
|
// Hack: Skip if disabled (c2 negative)
|
|
|
|
if (c2 == -1)
|
|
|
|
continue;
|
|
|
|
//
|
|
|
|
|
2012-04-28 02:59:43 +02:00
|
|
|
for (int index2 = _numCharacters - 1; index2 >= 0; index2--) {
|
2012-06-04 07:51:48 +02:00
|
|
|
byte byte16C9F = 0;
|
2012-05-21 22:22:06 +02:00
|
|
|
if ((index != index2) &&
|
|
|
|
(_rulesBuffer2_5[index] != index2) &&
|
|
|
|
(_rulesBuffer2_5[index2] != index) &&
|
|
|
|
(_rulesBuffer2_11[index2] & 2) == 0) {
|
2012-06-20 07:49:21 +02:00
|
|
|
int d1 = _scriptHandler->_characterTilePosX[index2];
|
|
|
|
int d2 = _scriptHandler->_characterTilePosY[index2];
|
2012-05-21 22:22:06 +02:00
|
|
|
|
2012-05-20 22:57:03 +02:00
|
|
|
if (d1 != -1) {
|
2012-04-23 01:51:17 +02:00
|
|
|
int x = c1 - d1;
|
2012-04-23 20:36:18 +02:00
|
|
|
if ((x > -6) && (x < 6)) {
|
2012-04-23 01:51:17 +02:00
|
|
|
int y = c2 - d2;
|
2012-04-23 20:36:18 +02:00
|
|
|
if ((y > -6) && (y < 6)) {
|
2012-06-04 07:51:48 +02:00
|
|
|
byte16C9F = 1;
|
2012-05-21 22:22:06 +02:00
|
|
|
|
2012-04-23 20:36:18 +02:00
|
|
|
if ((c1 == d1) && (c2 == d2)) {
|
2012-06-04 07:51:48 +02:00
|
|
|
byte16C9F = 4;
|
2012-05-16 20:58:41 +02:00
|
|
|
} else if ((_rulesBuffer2_11[index] & 4) != 0) {
|
2012-06-04 07:51:48 +02:00
|
|
|
byte16C9F = 0;
|
2012-04-23 20:36:18 +02:00
|
|
|
} else {
|
2012-05-29 08:30:34 +02:00
|
|
|
switch (_characterDirectionArray[index]) {
|
|
|
|
case 0:
|
2012-04-23 20:36:18 +02:00
|
|
|
if (d1 > c1) {
|
2012-06-04 07:51:48 +02:00
|
|
|
byte16C9F = 2;
|
2012-04-23 20:36:18 +02:00
|
|
|
|
|
|
|
if (d2 == c2)
|
2012-06-04 07:51:48 +02:00
|
|
|
byte16C9F = 3;
|
2012-04-23 20:36:18 +02:00
|
|
|
|
2012-05-29 08:30:34 +02:00
|
|
|
if (sub16DD5(c1, c2, d1, d2) != 0)
|
2012-06-04 07:51:48 +02:00
|
|
|
byte16C9F = 1;
|
2012-04-23 01:51:17 +02:00
|
|
|
}
|
2012-05-29 08:30:34 +02:00
|
|
|
break;
|
|
|
|
case 1:
|
2012-04-23 20:36:18 +02:00
|
|
|
if (d2 < c2) {
|
2012-06-04 07:51:48 +02:00
|
|
|
byte16C9F = 2;
|
2012-04-23 20:36:18 +02:00
|
|
|
|
2012-05-16 20:58:41 +02:00
|
|
|
if (d1 == c1)
|
2012-06-04 07:51:48 +02:00
|
|
|
byte16C9F = 3;
|
2012-04-23 20:36:18 +02:00
|
|
|
|
2012-05-29 08:30:34 +02:00
|
|
|
if (sub16DD5(c1, c2, d1, d2) != 0)
|
2012-06-04 07:51:48 +02:00
|
|
|
byte16C9F = 1;
|
2012-04-23 01:51:17 +02:00
|
|
|
}
|
2012-05-29 08:30:34 +02:00
|
|
|
break;
|
|
|
|
case 2:
|
2012-04-23 20:36:18 +02:00
|
|
|
if (d2 > c2) {
|
2012-06-04 07:51:48 +02:00
|
|
|
byte16C9F = 2;
|
2012-04-23 20:36:18 +02:00
|
|
|
|
2012-05-16 20:58:41 +02:00
|
|
|
if (d1 == c1)
|
2012-06-04 07:51:48 +02:00
|
|
|
byte16C9F = 3;
|
2012-04-23 20:36:18 +02:00
|
|
|
|
2012-05-29 08:30:34 +02:00
|
|
|
if (sub16DD5(c1, c2, d1, d2) != 0)
|
2012-06-04 07:51:48 +02:00
|
|
|
byte16C9F = 1;
|
2012-04-23 01:51:17 +02:00
|
|
|
}
|
2012-05-29 08:30:34 +02:00
|
|
|
break;
|
|
|
|
default:
|
2012-04-23 20:36:18 +02:00
|
|
|
if (d1 < c1) {
|
2012-06-04 07:51:48 +02:00
|
|
|
byte16C9F = 2;
|
2012-04-23 01:51:17 +02:00
|
|
|
|
2012-04-23 20:36:18 +02:00
|
|
|
if (d2 == c2)
|
2012-06-04 07:51:48 +02:00
|
|
|
byte16C9F = 3;
|
2012-04-23 20:36:18 +02:00
|
|
|
|
2012-05-29 08:30:34 +02:00
|
|
|
if (sub16DD5(c1, c2, d1, d2) != 0)
|
2012-06-04 07:51:48 +02:00
|
|
|
byte16C9F = 1;
|
2012-04-23 20:36:18 +02:00
|
|
|
}
|
2012-05-29 08:30:34 +02:00
|
|
|
break;
|
2012-04-23 01:51:17 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-29 08:30:34 +02:00
|
|
|
int8 v2 = _scriptHandler->_array10B51[index2 + (index * 40)] & 0xFF;
|
|
|
|
int8 v1 = v2;
|
|
|
|
|
2012-06-04 07:51:48 +02:00
|
|
|
if (v2 != byte16C9F) {
|
2012-04-28 02:59:43 +02:00
|
|
|
_scriptHandler->_characterScriptEnabled[index] = 1;
|
2012-06-04 07:51:48 +02:00
|
|
|
v2 = byte16C9F;
|
2012-04-23 20:36:18 +02:00
|
|
|
}
|
2012-05-29 08:30:34 +02:00
|
|
|
_scriptHandler->_array10B51[index2 + (index * 40)] = (v1 << 8) + v2;
|
2012-04-23 01:51:17 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-23 07:57:16 +02:00
|
|
|
void LilliputEngine::displayCharacterStatBar(int8 type, int16 averagePosX, int8 score, int16 posY) {
|
|
|
|
debugC(2, kDebugEngine, "displayCharacterStatBar(%d, %d, %d, %d)", type, averagePosX, score, posY);
|
2012-05-21 22:22:06 +02:00
|
|
|
|
2012-05-09 08:07:58 +02:00
|
|
|
restoreSurfaceUnderMousePointer();
|
2012-05-21 22:22:06 +02:00
|
|
|
|
2012-05-23 07:57:16 +02:00
|
|
|
int16 posX = averagePosX;
|
2012-05-21 22:22:06 +02:00
|
|
|
|
2012-05-23 07:57:16 +02:00
|
|
|
// If var equals 45 ('-'), score bar from -x to +x. If not (usually 43 '+'), score bar from 0 to x.
|
|
|
|
if (type == 45) {
|
|
|
|
posX += 35;
|
|
|
|
score -= 35;
|
|
|
|
|
|
|
|
if (score < 0) {
|
|
|
|
posX += score;
|
|
|
|
score = -score;
|
2012-05-03 19:08:44 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
byte *vgaBuf = (byte *)_mainSurface->getPixels();
|
2012-05-23 07:57:16 +02:00
|
|
|
int vgaIndex = posX + (320 * posY);
|
2012-05-21 22:22:06 +02:00
|
|
|
|
2012-05-23 07:57:16 +02:00
|
|
|
if (score == 0)
|
|
|
|
++score;
|
2012-05-21 22:22:06 +02:00
|
|
|
|
2012-05-24 00:54:34 +02:00
|
|
|
// Draw bar, color green, high = 4, width = score
|
2012-05-03 19:08:44 +02:00
|
|
|
for (int i = 0; i < 4; i++) {
|
2012-05-23 07:57:16 +02:00
|
|
|
for (int j = 0; j < score; j++) {
|
2012-05-03 19:08:44 +02:00
|
|
|
vgaBuf[vgaIndex + j] = 2;
|
|
|
|
}
|
|
|
|
vgaIndex += 320;
|
|
|
|
}
|
2012-05-21 22:22:06 +02:00
|
|
|
|
2012-05-09 08:07:58 +02:00
|
|
|
displayMousePointer();
|
2012-05-03 19:08:44 +02:00
|
|
|
}
|
|
|
|
|
2012-05-16 20:44:47 +02:00
|
|
|
void LilliputEngine::displayString(byte *buf, Common::Point pos) {
|
2012-05-18 16:48:49 +02:00
|
|
|
debugC(2, kDebugEngine, "displayString(%s, %d - %d)", buf, pos.x, pos.y);
|
2012-04-21 21:19:13 +02:00
|
|
|
|
2012-05-16 20:44:47 +02:00
|
|
|
int index = (pos.y * 320) + pos.x;
|
2012-04-21 21:19:13 +02:00
|
|
|
|
|
|
|
int i = 0;
|
|
|
|
while (buf[i] != 0) {
|
|
|
|
displayChar(index, buf[i]);
|
|
|
|
++i;
|
|
|
|
index += 4;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void LilliputEngine::displayChar(int index, int var1) {
|
2012-05-18 16:48:49 +02:00
|
|
|
debugC(2, kDebugEngine, "displayChar(%d, %d)", index, var1);
|
2012-04-21 21:19:13 +02:00
|
|
|
|
|
|
|
int indexVga = index;
|
|
|
|
int indexChar = var1 << 5;
|
|
|
|
|
|
|
|
for (int i = 0; i < 8; i++) {
|
|
|
|
for (int j = 0; j < 4; j++)
|
|
|
|
((byte *)_mainSurface->getPixels())[indexVga + j] = _bufferIsoChars[indexChar + j];
|
|
|
|
indexVga += 320;
|
|
|
|
indexChar += 4;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2012-04-25 00:13:32 +02:00
|
|
|
void LilliputEngine::sortCharacters() {
|
2012-05-10 19:26:16 +02:00
|
|
|
debugC(2, kDebugEngine, "sortCharacters()");
|
2012-04-21 10:56:47 +02:00
|
|
|
|
2012-04-25 00:13:32 +02:00
|
|
|
if (_numCharactersToDisplay <= 1)
|
2012-04-21 10:56:47 +02:00
|
|
|
return;
|
|
|
|
|
2012-05-10 19:26:16 +02:00
|
|
|
for (int var4 = _numCharactersToDisplay - 1; var4 > 0; var4--) {
|
|
|
|
bool found = false;
|
2012-04-21 10:56:47 +02:00
|
|
|
|
|
|
|
for (int var2 = 0; var2 < var4; var2++) {
|
2012-04-25 00:13:32 +02:00
|
|
|
int index1 = _charactersToDisplay[var2];
|
|
|
|
int index2 = _charactersToDisplay[var2 + 1];
|
2012-05-21 22:22:06 +02:00
|
|
|
|
|
|
|
if (_characterRelativePositionY[index1] < _characterRelativePositionY[index2])
|
2012-04-21 10:56:47 +02:00
|
|
|
continue;
|
|
|
|
|
2012-04-25 01:41:31 +02:00
|
|
|
if (_characterRelativePositionY[index1] == _characterRelativePositionY[index2]) {
|
|
|
|
if (_characterRelativePositionX[index1] < _characterRelativePositionX[index2])
|
2012-04-21 10:56:47 +02:00
|
|
|
continue;
|
|
|
|
|
2012-04-25 01:41:31 +02:00
|
|
|
if (_characterRelativePositionX[index1] == _characterRelativePositionX[index2]) {
|
2012-05-01 14:35:19 +02:00
|
|
|
if (_characterPositionAltitude[index1] < _characterPositionAltitude[index2])
|
2012-04-21 10:56:47 +02:00
|
|
|
continue;
|
|
|
|
|
2012-05-01 14:35:19 +02:00
|
|
|
if (_characterPositionAltitude[index1] == _characterPositionAltitude[index2]) {
|
2012-04-25 01:41:31 +02:00
|
|
|
if (_characterDisplayY[index1] < _characterDisplayY[index2])
|
2012-04-21 10:56:47 +02:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-04-25 00:13:32 +02:00
|
|
|
byte tmpVal = _charactersToDisplay[var2];
|
|
|
|
_charactersToDisplay[var2] = _charactersToDisplay[var2 + 1];
|
|
|
|
_charactersToDisplay[var2 + 1] = tmpVal;
|
2012-05-10 19:26:16 +02:00
|
|
|
found = true;
|
2012-04-21 10:56:47 +02:00
|
|
|
}
|
|
|
|
|
2012-05-10 19:26:16 +02:00
|
|
|
if (!found)
|
2012-04-21 10:56:47 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-04-25 01:41:31 +02:00
|
|
|
void LilliputEngine::scrollToViewportCharacterTarget() {
|
2012-05-20 15:09:32 +02:00
|
|
|
debugC(2, kDebugEngine, "scrollToViewportCharacterTarget()");
|
2012-04-19 08:03:19 +02:00
|
|
|
|
2012-05-11 20:47:17 +02:00
|
|
|
if (_scriptHandler->_viewportCharacterTarget == -1)
|
2012-04-19 08:03:19 +02:00
|
|
|
return;
|
|
|
|
|
2012-05-05 18:16:03 +02:00
|
|
|
int var2 = (_characterPositionX[_scriptHandler->_viewportCharacterTarget] >> 3) - _scriptHandler->_viewportPos.x;
|
|
|
|
int var4 = (_characterPositionY[_scriptHandler->_viewportCharacterTarget] >> 3) - _scriptHandler->_viewportPos.y;
|
2012-05-05 21:34:58 +02:00
|
|
|
Common::Point newPos = _scriptHandler->_viewportPos;
|
2012-04-19 08:03:19 +02:00
|
|
|
|
|
|
|
if (var2 >= 1) {
|
2012-05-20 15:09:32 +02:00
|
|
|
if (var2 > 6) {
|
2012-05-05 21:34:58 +02:00
|
|
|
newPos.x += 4;
|
|
|
|
if (newPos.x > 56)
|
|
|
|
newPos.x = 56;
|
2012-04-19 08:03:19 +02:00
|
|
|
}
|
|
|
|
} else {
|
2012-05-05 21:34:58 +02:00
|
|
|
newPos.x -= 4;
|
|
|
|
if (newPos.x < 0)
|
|
|
|
newPos.x = 0;
|
2012-04-19 08:03:19 +02:00
|
|
|
}
|
|
|
|
|
2012-05-20 15:09:32 +02:00
|
|
|
if ((var4 < 1) && (newPos.y < 4))
|
|
|
|
newPos.y = 0;
|
|
|
|
else {
|
|
|
|
if (var4 < 1)
|
|
|
|
newPos.y -= 4;
|
|
|
|
|
2012-04-19 08:03:19 +02:00
|
|
|
if (var4 > 6) {
|
2012-05-05 21:34:58 +02:00
|
|
|
newPos.y += 4;
|
|
|
|
if (newPos.y >= 56)
|
|
|
|
newPos.y = 56;
|
2012-04-19 08:03:19 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-05 21:34:58 +02:00
|
|
|
viewportScrollTo(newPos);
|
2012-04-19 08:03:19 +02:00
|
|
|
}
|
|
|
|
|
2012-05-05 21:34:58 +02:00
|
|
|
void LilliputEngine::viewportScrollTo(Common::Point goalPos) {
|
2012-05-26 11:07:15 +02:00
|
|
|
debugC(2, kDebugEngine, "viewportScrollTo(%d, %d)", goalPos.x, goalPos.y);
|
2012-04-19 08:03:19 +02:00
|
|
|
|
2012-05-05 21:34:58 +02:00
|
|
|
if (goalPos == _scriptHandler->_viewportPos)
|
2012-04-19 08:03:19 +02:00
|
|
|
return;
|
|
|
|
|
2012-05-26 11:07:15 +02:00
|
|
|
int16 dx = 0;
|
2012-05-05 21:34:58 +02:00
|
|
|
if (goalPos.x != _scriptHandler->_viewportPos.x) {
|
|
|
|
if (goalPos.x < _scriptHandler->_viewportPos.x)
|
2012-04-25 01:41:31 +02:00
|
|
|
--dx;
|
2012-04-19 08:03:19 +02:00
|
|
|
else
|
2012-04-25 01:41:31 +02:00
|
|
|
++dx;
|
2012-04-19 08:03:19 +02:00
|
|
|
}
|
|
|
|
|
2012-05-26 11:07:15 +02:00
|
|
|
int16 dy = 0;
|
2012-05-21 22:22:06 +02:00
|
|
|
if (goalPos.y != _scriptHandler->_viewportPos.y) {
|
2012-05-05 21:34:58 +02:00
|
|
|
if (goalPos.y < _scriptHandler->_viewportPos.y)
|
2012-04-25 01:41:31 +02:00
|
|
|
--dy;
|
2012-04-19 08:03:19 +02:00
|
|
|
else
|
2012-04-25 01:41:31 +02:00
|
|
|
++dy;
|
2012-04-19 08:03:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
do {
|
2012-05-05 18:16:03 +02:00
|
|
|
_scriptHandler->_viewportPos.x += dx;
|
|
|
|
_scriptHandler->_viewportPos.y += dy;
|
2012-05-21 22:22:06 +02:00
|
|
|
|
2012-05-10 08:11:45 +02:00
|
|
|
displayLandscape();
|
2012-05-11 20:47:17 +02:00
|
|
|
prepareGameArea();
|
2012-05-11 08:06:19 +02:00
|
|
|
displayGameArea();
|
2012-04-19 08:03:19 +02:00
|
|
|
|
2012-05-05 21:34:58 +02:00
|
|
|
if (goalPos.x == _scriptHandler->_viewportPos.x)
|
2012-04-25 01:41:31 +02:00
|
|
|
dx = 0;
|
2012-04-19 08:03:19 +02:00
|
|
|
|
2012-05-05 21:34:58 +02:00
|
|
|
if (goalPos.y == _scriptHandler->_viewportPos.y)
|
2012-04-25 01:41:31 +02:00
|
|
|
dy = 0;
|
2012-05-26 11:07:15 +02:00
|
|
|
} while ((dx != 0) || (dy != 0));
|
2012-04-19 08:03:19 +02:00
|
|
|
|
2012-04-20 19:43:31 +02:00
|
|
|
_soundHandler->contentFct5();
|
2012-04-19 08:03:19 +02:00
|
|
|
}
|
|
|
|
|
2012-05-08 18:36:01 +02:00
|
|
|
void LilliputEngine::renderCharacters(byte *buf, Common::Point pos) {
|
2012-05-17 11:59:54 +02:00
|
|
|
debugC(2, kDebugEngine, "renderCharacters(buf, %d - %d)", pos.x, pos.y);
|
2012-04-20 08:34:41 +02:00
|
|
|
|
2012-05-08 18:36:01 +02:00
|
|
|
if (_nextDisplayCharacterPos != pos)
|
2012-04-20 08:34:41 +02:00
|
|
|
return;
|
|
|
|
|
2012-05-02 18:52:15 +02:00
|
|
|
_byte16552 = 0;
|
2012-04-20 08:34:41 +02:00
|
|
|
|
|
|
|
if (buf[1] != 0xFF) {
|
|
|
|
int tmpIndex = buf[1];
|
2012-04-30 14:17:03 +02:00
|
|
|
if ((_rulesChunk9[tmpIndex] & 16) == 0)
|
2012-04-20 08:34:41 +02:00
|
|
|
++_byte16552;
|
|
|
|
}
|
|
|
|
|
2012-04-25 01:41:31 +02:00
|
|
|
int index = _charactersToDisplay[_currentDisplayCharacter];
|
2012-05-10 08:11:45 +02:00
|
|
|
Common::Point characterPos = Common::Point(_characterDisplayX[index], _characterDisplayY[index]);
|
2012-04-20 08:34:41 +02:00
|
|
|
|
2012-05-11 23:32:26 +02:00
|
|
|
if (index == _scriptHandler->_talkingCharacter)
|
2012-05-28 08:54:50 +02:00
|
|
|
displaySpeechBubbleTail(characterPos);
|
2012-04-20 08:34:41 +02:00
|
|
|
|
|
|
|
if (_byte16552 != 1) {
|
2012-05-10 08:11:45 +02:00
|
|
|
byte flag = _characterDirectionArray[index];
|
|
|
|
int16 frame = _characterFrameArray[index];
|
2012-04-20 08:34:41 +02:00
|
|
|
|
2012-05-10 08:11:45 +02:00
|
|
|
if (frame != -1) {
|
2012-04-25 01:41:31 +02:00
|
|
|
frame += _scriptHandler->_array10AB1[index];
|
2012-04-30 14:17:03 +02:00
|
|
|
if ((flag & 1) == 1)
|
2012-04-30 17:57:23 +02:00
|
|
|
frame += _spriteSizeArray[index];
|
2012-05-21 22:22:06 +02:00
|
|
|
|
2012-05-29 22:54:02 +02:00
|
|
|
if (_array12299[index] != -1) {
|
2012-04-25 01:41:31 +02:00
|
|
|
frame = _array12299[index] + 82;
|
2012-04-20 08:34:41 +02:00
|
|
|
--_array12299[index];
|
2012-04-25 01:41:31 +02:00
|
|
|
frame = -frame;
|
2012-04-20 08:34:41 +02:00
|
|
|
}
|
|
|
|
|
2012-05-10 08:11:45 +02:00
|
|
|
displayCharacter(frame, characterPos, flag);
|
2012-04-20 08:34:41 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-04-25 01:41:31 +02:00
|
|
|
++_currentDisplayCharacter;
|
2012-04-25 21:28:03 +02:00
|
|
|
setNextDisplayCharacter(_currentDisplayCharacter);
|
2012-04-20 08:34:41 +02:00
|
|
|
|
2012-05-08 18:36:01 +02:00
|
|
|
renderCharacters(buf, pos);
|
2012-04-20 08:34:41 +02:00
|
|
|
}
|
|
|
|
|
2012-05-28 08:54:50 +02:00
|
|
|
void LilliputEngine::displaySpeechBubbleTail(Common::Point displayPos) {
|
|
|
|
debugC(2, kDebugEngine, "displaySpeechBubbleTail(%d, %d)", displayPos.x, displayPos.y);
|
2012-05-21 22:22:06 +02:00
|
|
|
|
2012-05-10 08:11:45 +02:00
|
|
|
int orgX = displayPos.x + 8;
|
|
|
|
int orgY = displayPos.y;
|
2012-04-25 21:28:03 +02:00
|
|
|
int var2 = 0;
|
2012-05-21 22:22:06 +02:00
|
|
|
|
2012-04-25 21:28:03 +02:00
|
|
|
int x = orgX;
|
|
|
|
int y = orgY;
|
|
|
|
do {
|
2012-05-28 08:54:50 +02:00
|
|
|
displaySpeechBubbleTailLine(Common::Point(x, y), var2);
|
2012-04-25 21:28:03 +02:00
|
|
|
--x;
|
2012-05-28 08:54:50 +02:00
|
|
|
y /= 2;
|
2012-04-25 21:28:03 +02:00
|
|
|
} while (y != 0);
|
2012-05-21 22:22:06 +02:00
|
|
|
|
2012-04-25 21:28:03 +02:00
|
|
|
x = orgX + 1;
|
2012-05-28 08:54:50 +02:00
|
|
|
y = orgY / 2;
|
2012-05-21 22:22:06 +02:00
|
|
|
|
2012-04-25 21:28:03 +02:00
|
|
|
while (y != 0) {
|
2012-05-28 08:54:50 +02:00
|
|
|
displaySpeechBubbleTailLine(Common::Point(x, y), var2);
|
2012-04-25 21:28:03 +02:00
|
|
|
++x;
|
2012-05-28 08:54:50 +02:00
|
|
|
y /= 2;
|
2012-04-25 21:28:03 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-28 08:54:50 +02:00
|
|
|
void LilliputEngine::displaySpeechBubbleTailLine(Common::Point pos, int var2) {
|
|
|
|
debugC(2, kDebugEngine, "displaySpeechBubbleTailLine(%d - %d, %d)", pos.x, pos.y, var2);
|
2012-05-21 22:22:06 +02:00
|
|
|
|
2012-05-28 08:54:50 +02:00
|
|
|
int index = pos.x + (var2 * 256);
|
2012-05-11 23:32:26 +02:00
|
|
|
for (int i = 1 + pos.y - var2; i > 0; i--) {
|
2012-05-11 08:06:19 +02:00
|
|
|
_savedSurfaceGameArea1[index] = 17;
|
2012-04-25 21:28:03 +02:00
|
|
|
index += 256;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-11 23:32:26 +02:00
|
|
|
void LilliputEngine::checkSpeechClosing() {
|
2012-05-20 15:09:32 +02:00
|
|
|
debugC(2, kDebugEngine, "checkSpeechClosing()");
|
2012-04-20 08:34:41 +02:00
|
|
|
|
2012-05-11 23:32:26 +02:00
|
|
|
if (_scriptHandler->_speechTimer != 0) {
|
|
|
|
--_scriptHandler->_speechTimer;
|
|
|
|
if (_scriptHandler->_speechTimer == 0) {
|
2012-05-11 08:06:19 +02:00
|
|
|
restoreSurfaceSpeech();
|
2012-05-11 23:32:26 +02:00
|
|
|
_scriptHandler->_talkingCharacter = -1;
|
2012-04-20 08:34:41 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-20 17:53:09 +02:00
|
|
|
byte LilliputEngine::getDirection(Common::Point param1, Common::Point param2) {
|
|
|
|
debugC(2, kDebugEngine, "getDirection(%d - %d, %d - %d)", param1.x, param1.y, param2.x, param2.y);
|
2012-04-21 10:56:47 +02:00
|
|
|
|
2012-05-20 17:53:09 +02:00
|
|
|
static const byte _directionsArray[8] = {0, 2, 0, 1, 3, 2, 3, 1};
|
2012-04-21 10:56:47 +02:00
|
|
|
|
2012-05-05 21:34:58 +02:00
|
|
|
Common::Point var1 = param2;
|
|
|
|
Common::Point var2 = param1;
|
2012-04-21 10:56:47 +02:00
|
|
|
|
2012-05-05 21:34:58 +02:00
|
|
|
int8 var1h = var1.x - var2.x;
|
|
|
|
int8 var1l = var1.y - var2.y;
|
2012-04-21 10:56:47 +02:00
|
|
|
int8 var2l = 0;
|
|
|
|
|
2012-05-06 22:32:23 +02:00
|
|
|
if (var1h < 0) {
|
2012-04-21 10:56:47 +02:00
|
|
|
var2l |= 4;
|
|
|
|
var1h = -var1h;
|
|
|
|
}
|
|
|
|
|
2012-05-06 22:32:23 +02:00
|
|
|
if (var1l < 0) {
|
2012-04-21 10:56:47 +02:00
|
|
|
var2l |= 2;
|
|
|
|
var1l = -var1l;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (var1h < var1l)
|
|
|
|
var2l |= 1;
|
|
|
|
|
2012-05-06 22:32:23 +02:00
|
|
|
return _directionsArray[var2l];
|
2012-04-21 10:56:47 +02:00
|
|
|
}
|
|
|
|
|
2012-05-08 21:38:43 +02:00
|
|
|
byte LilliputEngine::sub16799(int index, Common::Point param1) {
|
2012-05-27 10:45:43 +02:00
|
|
|
debugC(2, kDebugEngine, "sub16799(%d, %d - %d)", index, param1.x, param1.y);
|
2012-04-21 10:56:47 +02:00
|
|
|
|
2012-05-06 22:32:23 +02:00
|
|
|
Common::Point var3 = Common::Point(_array109E9PosX[index], _array10A11PosY[index]);
|
2012-04-21 10:56:47 +02:00
|
|
|
|
2012-05-06 22:32:23 +02:00
|
|
|
if (var3.x != -1) {
|
2012-06-20 07:49:21 +02:00
|
|
|
if ((var3.x != _scriptHandler->_characterTilePosX[index]) || (var3.y != _scriptHandler->_characterTilePosY[index])) {
|
2012-05-28 08:54:50 +02:00
|
|
|
sub1693A_chooseDirections(index);
|
2012-05-08 21:38:43 +02:00
|
|
|
_scriptHandler->_array12811[index] -= (param1.x & 0x0F);
|
2012-04-21 10:56:47 +02:00
|
|
|
return 3;
|
|
|
|
}
|
|
|
|
|
2012-05-06 22:32:23 +02:00
|
|
|
if ((var3.x == _array10999PosX[index]) && (var3.y == _array109C1PosY[index]))
|
2012-04-21 10:56:47 +02:00
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
2012-05-03 19:08:44 +02:00
|
|
|
sub167EF(index);
|
|
|
|
|
2012-06-20 07:49:21 +02:00
|
|
|
Common::Point pos1 = Common::Point(_scriptHandler->_characterTilePosX[index], _scriptHandler->_characterTilePosY[index]);
|
2012-05-06 22:32:23 +02:00
|
|
|
Common::Point pos2 = Common::Point(_array109E9PosX[index], _array10A11PosY[index]);
|
2012-04-21 10:56:47 +02:00
|
|
|
|
2012-05-06 22:32:23 +02:00
|
|
|
_characterDirectionArray[index] = getDirection(pos1, pos2);
|
2012-04-21 10:56:47 +02:00
|
|
|
|
2012-05-28 08:54:50 +02:00
|
|
|
sub1693A_chooseDirections(index);
|
2012-05-08 21:38:43 +02:00
|
|
|
_scriptHandler->_array12811[index] -= (param1.x & 0x0F);
|
2012-04-21 10:56:47 +02:00
|
|
|
return 3;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2012-05-03 19:08:44 +02:00
|
|
|
void LilliputEngine::sub167EF(int index) {
|
2012-05-30 08:19:53 +02:00
|
|
|
debugC(2, kDebugEngine, "sub167EF(%d)", index);
|
2012-05-21 22:22:06 +02:00
|
|
|
|
2012-06-20 07:49:21 +02:00
|
|
|
int16 word167EB = findHotspot(Common::Point(_scriptHandler->_characterTilePosX[index], _scriptHandler->_characterTilePosY[index]));
|
2012-05-30 08:19:53 +02:00
|
|
|
int16 word167ED = findHotspot(Common::Point(_array10999PosX[index], _array109C1PosY[index]));
|
2012-05-21 22:22:06 +02:00
|
|
|
|
2012-05-03 19:08:44 +02:00
|
|
|
if (word167EB == word167ED) {
|
2012-05-06 22:32:23 +02:00
|
|
|
_array109E9PosX[index] = _array10999PosX[index];
|
|
|
|
_array10A11PosY[index] = _array109C1PosY[index];
|
2012-05-03 19:08:44 +02:00
|
|
|
return;
|
|
|
|
}
|
2012-05-21 22:22:06 +02:00
|
|
|
|
2012-05-07 07:51:28 +02:00
|
|
|
if (word167EB == -1) {
|
|
|
|
int tmpVal = reverseFindHotspot(Common::Point(_array10999PosX[index], _array109C1PosY[index]));
|
2012-05-06 23:38:13 +02:00
|
|
|
_array109E9PosX[index] = _rulesBuffer12Pos4[tmpVal].x;
|
|
|
|
_array10A11PosY[index] = _rulesBuffer12Pos4[tmpVal].y;
|
2012-05-03 19:08:44 +02:00
|
|
|
return;
|
|
|
|
}
|
2012-05-21 22:22:06 +02:00
|
|
|
|
|
|
|
if ((word167ED != -1) &&
|
|
|
|
(_array10999PosX[index] >= (_rectXMinMax[word167EB] >> 8)) &&
|
|
|
|
(_array10999PosX[index] <= (_rectXMinMax[word167EB] & 0xFF)) &&
|
|
|
|
(_array109C1PosY[index] >= (_rectYMinMax[word167EB] >> 8)) &&
|
|
|
|
(_array109C1PosY[index] <= (_rectYMinMax[word167EB] & 0xFF))) {
|
2012-05-06 23:38:13 +02:00
|
|
|
_array109E9PosX[index] = _rulesBuffer12Pos4[word167ED].x;
|
|
|
|
_array10A11PosY[index] = _rulesBuffer12Pos4[word167ED].y;
|
2012-05-03 19:08:44 +02:00
|
|
|
return;
|
|
|
|
}
|
2012-05-21 22:22:06 +02:00
|
|
|
|
2012-05-06 23:38:13 +02:00
|
|
|
_array109E9PosX[index] = _rulesBuffer12Pos4[word167EB].x;
|
|
|
|
_array10A11PosY[index] = _rulesBuffer12Pos4[word167EB].y;
|
2012-05-17 02:27:17 +02:00
|
|
|
int var4h = (_rectXMinMax[word167EB] >> 8);
|
|
|
|
int var4l = (_rectXMinMax[word167EB] & 0xFF);
|
2012-05-21 22:22:06 +02:00
|
|
|
|
2012-05-03 19:08:44 +02:00
|
|
|
if (var4h != var4l) {
|
2012-05-30 08:19:53 +02:00
|
|
|
if (_rulesBuffer12Pos4[word167EB].x == var4h) {
|
|
|
|
_array109E9PosX[index] = _rulesBuffer12Pos4[word167EB].x - 1;
|
|
|
|
_array10A11PosY[index] = _rulesBuffer12Pos4[word167EB].y;
|
2012-05-03 19:08:44 +02:00
|
|
|
return;
|
|
|
|
}
|
2012-05-21 22:22:06 +02:00
|
|
|
|
2012-05-30 08:19:53 +02:00
|
|
|
if (_rulesBuffer12Pos4[word167EB].x == var4l) {
|
|
|
|
_array109E9PosX[index] = _rulesBuffer12Pos4[word167EB].x + 1;
|
|
|
|
_array10A11PosY[index] = _rulesBuffer12Pos4[word167EB].y;
|
2012-05-03 19:08:44 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-05-17 02:27:17 +02:00
|
|
|
var4h = (_rectYMinMax[word167EB] >> 8);
|
|
|
|
var4l = (_rectYMinMax[word167EB] & 0xFF);
|
2012-05-03 19:08:44 +02:00
|
|
|
|
|
|
|
if (var4h != var4l) {
|
2012-05-30 08:19:53 +02:00
|
|
|
if (_rulesBuffer12Pos4[word167EB].y == var4h) {
|
|
|
|
_array109E9PosX[index] = _rulesBuffer12Pos4[word167EB].x;
|
|
|
|
_array10A11PosY[index] = _rulesBuffer12Pos4[word167EB].y - 1;
|
|
|
|
} else {
|
|
|
|
_array109E9PosX[index] = _rulesBuffer12Pos4[word167EB].x;
|
|
|
|
_array10A11PosY[index] = _rulesBuffer12Pos4[word167EB].y + 1;
|
|
|
|
}
|
2012-05-03 19:08:44 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2012-05-21 22:22:06 +02:00
|
|
|
|
2012-05-03 19:08:44 +02:00
|
|
|
// var4h == var4l
|
2012-05-30 08:19:53 +02:00
|
|
|
int mapIndex = (_rulesBuffer12Pos4[word167EB].y * 64 + _rulesBuffer12Pos4[word167EB].x) * 4;
|
2012-05-24 20:12:21 +02:00
|
|
|
assert(mapIndex < 16384);
|
|
|
|
|
2012-05-03 19:08:44 +02:00
|
|
|
int tmpVal = _bufferIsoMap[mapIndex + 3];
|
2012-05-30 08:19:53 +02:00
|
|
|
if ((tmpVal & 8) != 0) {
|
|
|
|
_array109E9PosX[index] = _rulesBuffer12Pos4[word167EB].x + 1;
|
|
|
|
_array10A11PosY[index] = _rulesBuffer12Pos4[word167EB].y;
|
|
|
|
} else if ((tmpVal & 4) != 0) {
|
|
|
|
_array109E9PosX[index] = _rulesBuffer12Pos4[word167EB].x;
|
|
|
|
_array10A11PosY[index] = _rulesBuffer12Pos4[word167EB].y - 1;
|
|
|
|
} else if ((tmpVal & 2) != 0) {
|
|
|
|
_array109E9PosX[index] = _rulesBuffer12Pos4[word167EB].x;
|
|
|
|
_array10A11PosY[index] = _rulesBuffer12Pos4[word167EB].y + 1;
|
|
|
|
} else {
|
|
|
|
_array109E9PosX[index] = _rulesBuffer12Pos4[word167EB].x - 1;
|
|
|
|
_array10A11PosY[index] = _rulesBuffer12Pos4[word167EB].y;
|
|
|
|
}
|
2012-05-03 19:08:44 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-05-28 08:54:50 +02:00
|
|
|
void LilliputEngine::sub1693A_chooseDirections(int index) {
|
|
|
|
debugC(2, kDebugEngine, "sub1693A_chooseDirections(%d)", index);
|
2012-05-17 02:27:17 +02:00
|
|
|
|
2012-05-16 17:56:46 +02:00
|
|
|
static const int16 mapArrayMove[4] = {4, -256, 256, -4};
|
2012-05-02 22:01:20 +02:00
|
|
|
|
2012-06-20 07:49:21 +02:00
|
|
|
_word16937Pos = Common::Point(_scriptHandler->_characterTilePosX[index], _scriptHandler->_characterTilePosY[index]);
|
2012-05-02 22:01:20 +02:00
|
|
|
|
|
|
|
sub16A08(index);
|
2012-05-21 22:22:06 +02:00
|
|
|
|
2012-05-02 22:01:20 +02:00
|
|
|
int var2 = (_characterDirectionArray[index] ^ 3);
|
2012-05-17 02:27:17 +02:00
|
|
|
// initialized by sub16A08, values: [0, 3[
|
|
|
|
_array1692B[var2] -= 8;
|
2012-05-16 17:56:46 +02:00
|
|
|
byte byte16939 = 0;
|
2012-05-21 22:22:06 +02:00
|
|
|
|
2012-05-28 08:54:50 +02:00
|
|
|
int mapIndex = ((_word16937Pos.y * 64) + _word16937Pos.x) * 4;
|
2012-05-16 17:56:46 +02:00
|
|
|
int mapIndexDiff = 0;
|
2012-05-02 22:01:20 +02:00
|
|
|
int retVal = 0;
|
|
|
|
for (int i = 3; i >= 0; i--) {
|
2012-05-16 17:56:46 +02:00
|
|
|
mapIndexDiff = mapArrayMove[i];
|
2012-05-24 20:12:21 +02:00
|
|
|
assert(mapIndex + mapIndexDiff + 3 < 16384);
|
2012-05-16 17:56:46 +02:00
|
|
|
if (((_bufferIsoMap[mapIndex + mapIndexDiff + 3] & _array16C54[i]) != 0) && ((_bufferIsoMap[mapIndex + 3] & _array16C58[i]) != 0)) {
|
2012-05-17 02:27:17 +02:00
|
|
|
if ((_bufferIsoMap[mapIndex + mapIndexDiff + 3] & 0x80) != 0 && (sub16A76(i, index) != 0)) {
|
|
|
|
_array1692B[i] -= 20;
|
2012-05-02 22:01:20 +02:00
|
|
|
}
|
2012-05-17 02:27:17 +02:00
|
|
|
|
|
|
|
int tmpVal = ((_rulesBuffer2_10[index] & 7) ^ 7);
|
|
|
|
retVal = _rulesChunk9[_bufferIsoMap[mapIndex + mapIndexDiff]];
|
|
|
|
tmpVal &= retVal;
|
|
|
|
if (tmpVal == 0)
|
|
|
|
continue;
|
2012-05-02 22:01:20 +02:00
|
|
|
}
|
2012-05-17 02:27:17 +02:00
|
|
|
_array1692B[i] = -98;
|
2012-05-16 17:56:46 +02:00
|
|
|
++byte16939;
|
2012-05-02 22:01:20 +02:00
|
|
|
}
|
|
|
|
|
2012-05-16 17:56:46 +02:00
|
|
|
if (byte16939 != 0)
|
2012-05-02 22:01:20 +02:00
|
|
|
_array1692B[_characterDirectionArray[index]] += 3;
|
|
|
|
|
2012-05-28 08:54:50 +02:00
|
|
|
int tmpVal = -99;
|
2012-05-02 22:01:20 +02:00
|
|
|
for (int i = 3; i >= 0; i--) {
|
|
|
|
if (tmpVal < _array1692B[i]) {
|
|
|
|
retVal = i;
|
|
|
|
tmpVal = _array1692B[i];
|
|
|
|
}
|
|
|
|
}
|
2012-05-21 22:22:06 +02:00
|
|
|
|
2012-05-02 22:01:20 +02:00
|
|
|
_characterDirectionArray[index] = retVal;
|
|
|
|
}
|
|
|
|
|
|
|
|
byte LilliputEngine::sub16A76(int indexb, int indexs) {
|
2012-05-27 10:45:43 +02:00
|
|
|
debugC(2, kDebugEngine, "sub16A76(%d, %d)", indexb, indexs);
|
2012-05-02 22:01:20 +02:00
|
|
|
|
2012-05-06 10:04:09 +02:00
|
|
|
static const char _array16A6C[4] = {1, 0, 0, -1};
|
|
|
|
static const char _array16A70[4] = {0, -1, 1, 0};
|
2012-05-21 22:22:06 +02:00
|
|
|
|
2012-05-06 23:38:13 +02:00
|
|
|
char var1h = _word16937Pos.x + _array16A6C[indexb];
|
2012-05-27 10:45:43 +02:00
|
|
|
char var1l = _word16937Pos.y + _array16A70[indexb];
|
2012-05-02 22:01:20 +02:00
|
|
|
|
2012-05-27 10:45:43 +02:00
|
|
|
int16 var2 = findHotspot(Common::Point(var1h, var1l));
|
2012-05-07 07:51:28 +02:00
|
|
|
if (var2 == -1)
|
2012-05-02 22:01:20 +02:00
|
|
|
return 1;
|
|
|
|
|
2012-05-10 08:11:45 +02:00
|
|
|
// int _word16A74 = var2; // useless?
|
2012-05-02 22:01:20 +02:00
|
|
|
|
2012-05-06 23:38:13 +02:00
|
|
|
var1h = _word16937Pos.x;
|
|
|
|
var1l = _word16937Pos.y;
|
2012-05-02 22:01:20 +02:00
|
|
|
|
2012-05-06 10:04:09 +02:00
|
|
|
if ((var1h >= (_rectXMinMax[var2] >> 8)) && (var1h <= (_rectXMinMax[var2] & 0xFF)) && (var1l >= (_rectYMinMax[var2] >> 8)) && (var1l <= (_rectYMinMax[var2] & 0xFF)))
|
2012-05-02 22:01:20 +02:00
|
|
|
return 0;
|
|
|
|
|
2012-05-06 22:32:23 +02:00
|
|
|
var1h = _array109E9PosX[indexs];
|
|
|
|
var1l = _array10A11PosY[indexs];
|
2012-05-02 22:01:20 +02:00
|
|
|
|
2012-05-06 10:04:09 +02:00
|
|
|
if ((var1h >= (_rectXMinMax[var2] >> 8)) && (var1h <= (_rectXMinMax[var2] & 0xFF)) && (var1l >= (_rectYMinMax[var2] >> 8)) && (var1l <= (_rectYMinMax[var2] & 0xFF)))
|
2012-05-02 22:01:20 +02:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2012-05-20 17:53:09 +02:00
|
|
|
int16 LilliputEngine::findHotspot(Common::Point pos) {
|
|
|
|
debugC(2, kDebugEngine, "findHotspot(%d, %d)", pos.x, pos.y);
|
2012-05-02 22:01:20 +02:00
|
|
|
|
2012-05-20 17:53:09 +02:00
|
|
|
for (int i = 0; i < _rectNumb; i++) {
|
2012-05-06 10:04:09 +02:00
|
|
|
if ((pos.x >= (_rectXMinMax[i] >> 8)) && (pos.x <= (_rectXMinMax[i] & 0xFF)) && (pos.y >= (_rectYMinMax[i] >> 8)) && (pos.y <= (_rectYMinMax[i] & 0xFF)))
|
2012-05-02 22:01:20 +02:00
|
|
|
return i;
|
|
|
|
}
|
2012-05-07 07:51:28 +02:00
|
|
|
return -1;
|
2012-05-02 22:01:20 +02:00
|
|
|
}
|
|
|
|
|
2012-05-20 17:53:09 +02:00
|
|
|
int16 LilliputEngine::reverseFindHotspot(Common::Point pos) {
|
|
|
|
debugC(2, kDebugEngine, "reverseFindHotspot(%d, %d)", pos.x, pos.y);
|
2012-05-03 00:54:08 +02:00
|
|
|
|
2012-05-20 17:53:09 +02:00
|
|
|
for (int i = _rectNumb - 1; i >= 0 ; i--) {
|
|
|
|
if ((pos.x >= (_rectXMinMax[i] >> 8)) && (pos.x <= (_rectXMinMax[i] & 0xFF)) && (pos.y >= (_rectYMinMax[i] >> 8)) && (pos.y <= (_rectYMinMax[i] & 0xFF)))
|
2012-05-03 00:54:08 +02:00
|
|
|
return i;
|
|
|
|
}
|
2012-05-07 07:51:28 +02:00
|
|
|
return -1;
|
2012-05-03 00:54:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-05-02 22:01:20 +02:00
|
|
|
void LilliputEngine::sub16A08(int index) {
|
2012-05-27 10:45:43 +02:00
|
|
|
debugC(2, kDebugEngine, "sub16A08(%d)", index);
|
2012-05-02 22:01:20 +02:00
|
|
|
|
2012-05-27 10:45:43 +02:00
|
|
|
static const int8 arrayMoveX[4] = {1, 0, 0, -1};
|
|
|
|
static const int8 arrayMoveY[4] = {0, -1, 1, 0};
|
2012-05-02 22:01:20 +02:00
|
|
|
|
2012-05-27 10:45:43 +02:00
|
|
|
int16 arrayDistance[4];
|
2012-05-02 22:01:20 +02:00
|
|
|
|
|
|
|
for (int i = 3; i >= 0; i--) {
|
2012-05-16 17:56:46 +02:00
|
|
|
int16 var1h = _word16937Pos.x + arrayMoveX[i] - _array109E9PosX[index];
|
|
|
|
int16 var1l = _word16937Pos.y + arrayMoveY[i] - _array10A11PosY[index];
|
|
|
|
arrayDistance[i] = (var1l * var1l) + (var1h * var1h);
|
2012-05-02 22:01:20 +02:00
|
|
|
}
|
2012-05-21 22:22:06 +02:00
|
|
|
|
2012-05-16 17:56:46 +02:00
|
|
|
for (int i = 0; i < 4; i++)
|
|
|
|
_array1692B[i] = 0;
|
2012-05-02 22:01:20 +02:00
|
|
|
|
2012-05-16 17:56:46 +02:00
|
|
|
int8 tmpIndex = 0;
|
2012-05-17 02:27:17 +02:00
|
|
|
for (int i = 3; i > 0; i--) {
|
2012-05-16 17:56:46 +02:00
|
|
|
int16 tmpVal = 0x7FFF;
|
2012-05-02 22:01:20 +02:00
|
|
|
for (int j = 0; j < 4; j++) {
|
2012-05-16 17:56:46 +02:00
|
|
|
if (tmpVal > arrayDistance[j]) {
|
|
|
|
tmpVal = arrayDistance[j];
|
2012-05-02 22:01:20 +02:00
|
|
|
tmpIndex = j;
|
|
|
|
}
|
|
|
|
}
|
2012-05-16 17:56:46 +02:00
|
|
|
arrayDistance[tmpIndex] = 0x7FFF;
|
2012-05-02 22:01:20 +02:00
|
|
|
_array1692B[tmpIndex] = i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-04-29 00:35:44 +02:00
|
|
|
void LilliputEngine::addCharToBuf(byte character) {
|
2012-05-18 16:48:49 +02:00
|
|
|
debugC(2, kDebugEngine, "addCharToBuf(%c)", character);
|
2012-04-21 21:19:13 +02:00
|
|
|
|
2012-04-29 00:35:44 +02:00
|
|
|
_displayStringBuf[_displayStringIndex] = character;
|
2012-04-21 21:19:13 +02:00
|
|
|
if (_displayStringIndex < 158)
|
|
|
|
++_displayStringIndex;
|
|
|
|
}
|
|
|
|
|
2012-05-18 16:48:49 +02:00
|
|
|
void LilliputEngine::numberToString(int param1) {
|
|
|
|
debugC(2, kDebugEngine, "numberToString(%d)", param1);
|
2012-05-21 22:22:06 +02:00
|
|
|
|
2012-04-21 21:19:13 +02:00
|
|
|
static const int _array18AE3[6] = {10000, 1000, 100, 10, 1};
|
|
|
|
|
|
|
|
int count;
|
|
|
|
int var1 = param1;
|
2012-04-22 00:05:02 +02:00
|
|
|
bool hideZeros = true;
|
2012-04-21 21:19:13 +02:00
|
|
|
for (int i = 0; i < 5; i++) {
|
|
|
|
count = 0;
|
|
|
|
while (var1 >= 0) {
|
|
|
|
++count;
|
|
|
|
var1 -= _array18AE3[i];
|
|
|
|
}
|
|
|
|
var1 += _array18AE3[i];
|
2012-04-22 00:05:02 +02:00
|
|
|
--count;
|
|
|
|
|
|
|
|
byte tmpVal = count + 0x30;
|
2012-05-21 22:22:06 +02:00
|
|
|
|
2012-04-21 21:19:13 +02:00
|
|
|
if (i == 4)
|
2012-04-29 00:35:44 +02:00
|
|
|
addCharToBuf(tmpVal);
|
2012-04-22 00:05:02 +02:00
|
|
|
else if ((count != 0) || (!hideZeros)) {
|
|
|
|
hideZeros = false;
|
2012-04-29 00:35:44 +02:00
|
|
|
addCharToBuf(tmpVal);
|
2012-04-21 21:19:13 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-04-20 08:34:41 +02:00
|
|
|
void LilliputEngine::sub16626() {
|
2012-05-28 08:54:50 +02:00
|
|
|
debugC(2, kDebugEngine, "sub16626()");
|
2012-04-20 08:34:41 +02:00
|
|
|
|
2012-04-28 02:59:43 +02:00
|
|
|
int index = _numCharacters - 1;
|
2012-05-03 08:08:05 +02:00
|
|
|
byte result;
|
2012-04-20 08:34:41 +02:00
|
|
|
while (index >= 0) {
|
2012-04-22 11:48:35 +02:00
|
|
|
result = 2;
|
|
|
|
while (result & 2) {
|
2012-05-26 15:40:09 +02:00
|
|
|
if (_scriptHandler->_array12811[index] == 16)
|
2012-04-20 08:34:41 +02:00
|
|
|
break;
|
2012-04-22 11:48:35 +02:00
|
|
|
|
2012-05-26 15:40:09 +02:00
|
|
|
uint16 index2 = _scriptHandler->_array12811[index] + (index * 16);
|
|
|
|
Common::Point var1 = _scriptHandler->_array12311[index2];
|
2012-04-20 08:34:41 +02:00
|
|
|
|
2012-05-28 08:54:50 +02:00
|
|
|
// /8, then /2 as the function array is a word array
|
|
|
|
int16 var2 = var1.x / 16;
|
2012-05-15 01:37:00 +02:00
|
|
|
|
2012-05-26 17:59:38 +02:00
|
|
|
switch (var2) {
|
2012-04-20 08:34:41 +02:00
|
|
|
case 0:
|
2012-05-20 22:57:03 +02:00
|
|
|
result = sub16675_moveCharacter(index, var1);
|
2012-04-20 08:34:41 +02:00
|
|
|
break;
|
|
|
|
case 1:
|
2012-04-22 23:54:45 +02:00
|
|
|
result = sub166DD(index, var1);
|
2012-04-20 08:34:41 +02:00
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
case 3:
|
|
|
|
case 4:
|
|
|
|
case 5:
|
|
|
|
case 6:
|
|
|
|
case 7:
|
|
|
|
case 8:
|
|
|
|
case 9:
|
2012-04-22 23:54:45 +02:00
|
|
|
result = 0;
|
2012-04-20 08:34:41 +02:00
|
|
|
break;
|
|
|
|
case 10:
|
2012-05-01 00:18:26 +02:00
|
|
|
result = sub1675D(index, var1);
|
2012-04-20 08:34:41 +02:00
|
|
|
break;
|
|
|
|
case 11:
|
2012-05-09 23:13:15 +02:00
|
|
|
result = sub16729(index, var1);
|
2012-04-20 08:34:41 +02:00
|
|
|
break;
|
|
|
|
case 12:
|
2012-05-03 08:08:05 +02:00
|
|
|
result = sub16799(index, var1);
|
2012-04-20 08:34:41 +02:00
|
|
|
break;
|
|
|
|
case 13:
|
2012-05-03 08:08:05 +02:00
|
|
|
result = sub16722(index, var1);
|
2012-04-20 08:34:41 +02:00
|
|
|
break;
|
|
|
|
case 14:
|
2012-05-26 15:40:09 +02:00
|
|
|
result = sub166F7(index, var1, index2);
|
2012-04-20 08:34:41 +02:00
|
|
|
break;
|
|
|
|
case 15:
|
2012-05-03 08:08:05 +02:00
|
|
|
result = sub166EA(index);
|
2012-04-20 08:34:41 +02:00
|
|
|
break;
|
|
|
|
default:
|
2012-05-26 17:59:38 +02:00
|
|
|
error("sub16626 - unexpected value %d", var2);
|
2012-04-20 08:34:41 +02:00
|
|
|
break;
|
|
|
|
}
|
2012-04-21 10:56:47 +02:00
|
|
|
|
2012-04-30 10:48:21 +02:00
|
|
|
if ((result & 1) == 0) {
|
2012-04-20 08:34:41 +02:00
|
|
|
++_scriptHandler->_array12811[index];
|
|
|
|
if (_scriptHandler->_array12811[index] == 16)
|
2012-04-28 02:59:43 +02:00
|
|
|
_scriptHandler->_characterScriptEnabled[index] = 1;
|
2012-04-20 08:34:41 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
--index;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-03 08:08:05 +02:00
|
|
|
byte LilliputEngine::sub166EA(int index) {
|
2012-05-20 22:57:03 +02:00
|
|
|
debugC(2, kDebugEngine, "sub166EA(%d)", index);
|
2012-05-03 08:08:05 +02:00
|
|
|
|
2012-05-20 22:57:03 +02:00
|
|
|
_scriptHandler->_array12811[index] = 16;
|
2012-05-03 08:08:05 +02:00
|
|
|
_scriptHandler->_characterScriptEnabled[index] = 1;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2012-05-06 22:32:23 +02:00
|
|
|
byte LilliputEngine::sub166F7(int index, Common::Point var1, int tmpVal) {
|
2012-05-20 22:57:03 +02:00
|
|
|
debugC(2, kDebugEngine, "sub166F7(%d, %d - %d, %d)", index, var1.x, var1.y, tmpVal);
|
2012-05-02 18:52:15 +02:00
|
|
|
|
2012-05-06 22:32:23 +02:00
|
|
|
byte a2 = var1.y;
|
2012-05-02 18:52:15 +02:00
|
|
|
if (a2 != 0) {
|
|
|
|
if ((a2 & 0xF0) == 0)
|
|
|
|
a2 |= (a2 << 4);
|
|
|
|
|
|
|
|
a2 -= 16;
|
2012-05-08 21:38:43 +02:00
|
|
|
_scriptHandler->_array12311[tmpVal] = Common::Point(var1.x, a2);
|
2012-05-02 18:52:15 +02:00
|
|
|
|
2012-05-08 21:38:43 +02:00
|
|
|
if ((a2 & 0xF0) == 0)
|
2012-05-02 18:52:15 +02:00
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
2012-05-06 22:32:23 +02:00
|
|
|
_scriptHandler->_array12811[index] -= (var1.x & 0x0F);
|
2012-05-02 18:52:15 +02:00
|
|
|
return 3;
|
|
|
|
}
|
2012-04-24 00:31:34 +02:00
|
|
|
|
2012-05-08 21:38:43 +02:00
|
|
|
byte LilliputEngine::sub166DD(int index, Common::Point var1) {
|
2012-05-20 22:57:03 +02:00
|
|
|
debugC(2, kDebugEngine, "sub166DD(%d, %d - %d)", index, var1.x, var1.y);
|
2012-05-21 22:22:06 +02:00
|
|
|
|
2012-05-20 22:57:03 +02:00
|
|
|
char var1h = var1.x & 3;
|
|
|
|
_characterDirectionArray[index] = var1h;
|
|
|
|
sub16685(index, Common::Point(var1h, var1.y));
|
2012-04-22 23:54:45 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-05-08 21:38:43 +02:00
|
|
|
byte LilliputEngine::sub16722(int index, Common::Point var1) {
|
|
|
|
debugC(2, kDebugEngineTBC, "sub16722(%d, %d - %d)", index, var1.x, var1.y);
|
2012-05-03 08:08:05 +02:00
|
|
|
|
2012-05-08 21:38:43 +02:00
|
|
|
_rulesBuffer2_10[index] = var1.y;
|
2012-05-03 08:08:05 +02:00
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
2012-05-09 23:13:15 +02:00
|
|
|
byte LilliputEngine::sub16729(int index, Common::Point var1) {
|
2012-05-29 22:54:02 +02:00
|
|
|
debugC(2, kDebugEngine, "sub16729(%d, %d - %d)", index, var1.x, var1.y);
|
2012-05-03 08:08:05 +02:00
|
|
|
|
2012-05-09 23:13:15 +02:00
|
|
|
int param4x = ((index | 0xFF00) >> 8);
|
|
|
|
int param1 = var1.y;
|
2012-06-20 07:49:21 +02:00
|
|
|
_soundHandler->contentFct2(param1, _scriptHandler->_viewportPos, Common::Point(_scriptHandler->_characterTilePosX[index], _scriptHandler->_characterTilePosY[index]), Common::Point(param4x, 0));
|
2012-05-03 00:54:08 +02:00
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
2012-05-08 21:38:43 +02:00
|
|
|
byte LilliputEngine::sub1675D(int index, Common::Point var1) {
|
2012-05-29 22:54:02 +02:00
|
|
|
debugC(2, kDebugEngine, "sub1675D(%d, %d - %d)", index, var1.x, var1.y);
|
2012-05-01 00:18:26 +02:00
|
|
|
|
2012-06-20 07:49:21 +02:00
|
|
|
int charIndex = _scriptHandler->_array10A39[index];
|
|
|
|
Common::Point charPos = Common::Point(_scriptHandler->_characterTilePosX[charIndex], _scriptHandler->_characterTilePosY[charIndex]);
|
2012-05-29 22:54:02 +02:00
|
|
|
|
|
|
|
if ((_array109E9PosX[index] != -1) && (_array109E9PosX[index] == _array10999PosX[index]) && (_array10A11PosY[index] == _array109C1PosY[index])) {
|
2012-06-20 07:49:21 +02:00
|
|
|
_array109E9PosX[index] = charPos.x;
|
|
|
|
_array10A11PosY[index] = charPos.y;
|
2012-05-01 00:18:26 +02:00
|
|
|
}
|
|
|
|
|
2012-06-20 07:49:21 +02:00
|
|
|
_array10999PosX[index] = charPos.x;
|
|
|
|
_array109C1PosY[index] = charPos.y;
|
2012-05-01 00:18:26 +02:00
|
|
|
|
|
|
|
return sub16799(index, var1);
|
|
|
|
}
|
|
|
|
|
2012-04-22 22:54:50 +02:00
|
|
|
void LilliputEngine::sub16EBC() {
|
2012-05-21 07:51:05 +02:00
|
|
|
debugC(2, kDebugEngine, "sub16EBC()");
|
2012-04-22 22:54:50 +02:00
|
|
|
|
2012-04-28 02:59:43 +02:00
|
|
|
for (int index1 = _numCharacters - 1; index1 >= 0; index1--) {
|
2012-06-04 07:51:48 +02:00
|
|
|
// Hack: The original doesn't check if it's disabled, which looks wrong
|
2012-06-20 07:49:21 +02:00
|
|
|
if ((_scriptHandler->_characterTilePosX[index1] == -1) || (_scriptHandler->_characterTilePosY[index1] == -1))
|
2012-06-04 07:51:48 +02:00
|
|
|
continue;
|
|
|
|
//
|
|
|
|
|
2012-06-20 07:49:21 +02:00
|
|
|
int mapIndex = 3 + (_scriptHandler->_characterTilePosY[index1] * 64 + _scriptHandler->_characterTilePosX[index1]) * 4;
|
2012-06-04 07:51:48 +02:00
|
|
|
assert((mapIndex >= 0) && (mapIndex < 16384));
|
|
|
|
byte var1 = _bufferIsoMap[mapIndex] & 0x40;
|
2012-04-22 22:54:50 +02:00
|
|
|
|
2012-06-04 07:51:48 +02:00
|
|
|
if (var1 == _array16E94[index1])
|
2012-04-22 22:54:50 +02:00
|
|
|
continue;
|
|
|
|
|
|
|
|
_array16E94[index1] = var1;
|
|
|
|
if (var1 != 0)
|
2012-04-28 02:59:43 +02:00
|
|
|
_scriptHandler->_characterScriptEnabled[index1] = 1;
|
2012-04-22 22:54:50 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-04-22 11:48:35 +02:00
|
|
|
void LilliputEngine::sub12F37() {
|
2012-05-21 07:51:05 +02:00
|
|
|
debugC(2, kDebugEngine, "sub12F37()");
|
2012-04-22 11:48:35 +02:00
|
|
|
|
2012-05-11 17:01:00 +02:00
|
|
|
int index1 = _animationTick + 2;
|
2012-04-22 11:48:35 +02:00
|
|
|
int index2 = 0;
|
|
|
|
|
2012-05-26 15:40:09 +02:00
|
|
|
for (byte i = 0; i < _numCharacters; i++) {
|
2012-05-04 23:13:43 +02:00
|
|
|
byte *varPtr = getCharacterVariablesPtr(index1);
|
2012-05-16 20:58:41 +02:00
|
|
|
if (varPtr[0] != 0) {
|
2012-05-04 23:13:43 +02:00
|
|
|
if (varPtr[0] == 1) {
|
|
|
|
varPtr[0] = 0;
|
2012-04-25 23:51:45 +02:00
|
|
|
} else {
|
2012-05-04 23:13:43 +02:00
|
|
|
--varPtr[0];
|
|
|
|
if (varPtr[0] == 1)
|
2012-04-28 02:59:43 +02:00
|
|
|
_scriptHandler->_characterScriptEnabled[index2] = 1;
|
2012-05-21 22:22:06 +02:00
|
|
|
}
|
2012-04-25 23:51:45 +02:00
|
|
|
}
|
2012-04-22 11:48:35 +02:00
|
|
|
|
|
|
|
index1 += 32;
|
|
|
|
++index2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-01 23:57:25 +02:00
|
|
|
void LilliputEngine::sub13156(bool &forceReturnFl) {
|
|
|
|
debugC(2, kDebugEngine, "sub13156()");
|
|
|
|
|
|
|
|
forceReturnFl = false;
|
|
|
|
|
|
|
|
if (!_keyboard_checkKeyboard())
|
|
|
|
return;
|
|
|
|
|
2012-06-03 11:57:07 +02:00
|
|
|
Common::Event event = _keyboard_getch();
|
2012-06-01 23:57:25 +02:00
|
|
|
|
2012-06-03 13:27:20 +02:00
|
|
|
int8 index = -1;
|
|
|
|
for (int8 i = 0; i < _interfaceHotspotNumb; i++) {
|
|
|
|
if (event.kbd.keycode == _keyboardMapping[i]) {
|
|
|
|
index = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2012-06-01 23:57:25 +02:00
|
|
|
|
2012-06-03 13:27:20 +02:00
|
|
|
if (index != -1) {
|
|
|
|
byte button = 1;
|
|
|
|
if (event.type == Common::EVENT_KEYUP)
|
|
|
|
button = 2;
|
|
|
|
sub1305C(index, button);
|
|
|
|
forceReturnFl = true;
|
|
|
|
}
|
2012-06-01 23:57:25 +02:00
|
|
|
}
|
|
|
|
|
2012-07-01 00:59:06 +02:00
|
|
|
void LilliputEngine::checkNumericCode() {
|
|
|
|
debugC(2, kDebugEngine, "checkNumericCode()");
|
2012-06-03 11:57:07 +02:00
|
|
|
|
|
|
|
static bool altKeyFl = false;
|
|
|
|
static int16 keyCount = 0;
|
|
|
|
|
|
|
|
if (_keyboard_oldIndex == _keyboard_nextIndex)
|
|
|
|
return;
|
|
|
|
|
|
|
|
Common::Event oldEvent = _keyboard_buffer[_keyboard_oldIndex];
|
|
|
|
if ((oldEvent.kbd.keycode == Common::KEYCODE_LALT) || (oldEvent.kbd.keycode == Common::KEYCODE_RALT)) {
|
|
|
|
if (oldEvent.type == Common::EVENT_KEYDOWN) {
|
|
|
|
altKeyFl = true;
|
|
|
|
keyCount = 0;
|
|
|
|
return;
|
|
|
|
} else if (oldEvent.type == Common::EVENT_KEYUP) {
|
|
|
|
altKeyFl = false;
|
|
|
|
if (keyCount == 3)
|
2012-06-23 10:47:10 +02:00
|
|
|
_actionType = kCodeEntered;
|
2012-06-03 11:57:07 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (keyCount >= 3)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if ((altKeyFl) && (oldEvent.type == Common::EVENT_KEYDOWN)) {
|
|
|
|
switch (oldEvent.kbd.keycode) {
|
|
|
|
case Common::KEYCODE_KP0:
|
|
|
|
case Common::KEYCODE_KP1:
|
|
|
|
case Common::KEYCODE_KP2:
|
|
|
|
case Common::KEYCODE_KP3:
|
|
|
|
case Common::KEYCODE_KP4:
|
|
|
|
case Common::KEYCODE_KP5:
|
|
|
|
case Common::KEYCODE_KP6:
|
|
|
|
case Common::KEYCODE_KP7:
|
|
|
|
case Common::KEYCODE_KP8:
|
|
|
|
case Common::KEYCODE_KP9:
|
|
|
|
case Common::KEYCODE_0:
|
|
|
|
case Common::KEYCODE_1:
|
|
|
|
case Common::KEYCODE_2:
|
|
|
|
case Common::KEYCODE_3:
|
|
|
|
case Common::KEYCODE_4:
|
|
|
|
case Common::KEYCODE_5:
|
|
|
|
case Common::KEYCODE_6:
|
|
|
|
case Common::KEYCODE_7:
|
|
|
|
case Common::KEYCODE_8:
|
|
|
|
case Common::KEYCODE_9:
|
2012-06-23 10:47:10 +02:00
|
|
|
_codeEntered[keyCount] = oldEvent.kbd.keycode - Common::KEYCODE_0;
|
2012-06-03 11:57:07 +02:00
|
|
|
++keyCount;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-23 10:47:10 +02:00
|
|
|
void LilliputEngine::handleGameMouseClick() {
|
|
|
|
debugC(2, kDebugEngine, "handleGameMouseClick()");
|
2012-04-24 00:21:20 +02:00
|
|
|
|
2012-07-01 00:59:06 +02:00
|
|
|
checkNumericCode();
|
2012-06-03 11:57:07 +02:00
|
|
|
|
2012-06-01 23:57:25 +02:00
|
|
|
bool forceReturnFl = false;
|
|
|
|
sub13156(forceReturnFl);
|
|
|
|
if (forceReturnFl)
|
2012-04-24 00:21:20 +02:00
|
|
|
return;
|
|
|
|
|
2012-06-01 23:57:25 +02:00
|
|
|
if (_mouseButton == 0) {
|
|
|
|
if (!_mouseClicked)
|
|
|
|
return;
|
|
|
|
_mouseClicked = false;
|
|
|
|
_mouseButton = 2;
|
|
|
|
}
|
|
|
|
|
2012-04-24 00:21:20 +02:00
|
|
|
int button = _mouseButton;
|
|
|
|
_mouseButton = 0;
|
|
|
|
|
2012-06-01 23:57:25 +02:00
|
|
|
if (button == 2) {
|
2012-05-18 19:24:03 +02:00
|
|
|
if (_lastInterfaceHotspotIndex != -1)
|
|
|
|
sub1305C(_lastInterfaceHotspotIndex, button);
|
2012-04-24 00:21:20 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-06-01 23:57:25 +02:00
|
|
|
forceReturnFl = false;
|
2012-05-05 18:16:03 +02:00
|
|
|
checkInterfaceHotspots(forceReturnFl);
|
2012-04-24 08:02:28 +02:00
|
|
|
if (forceReturnFl)
|
|
|
|
return;
|
|
|
|
|
2012-05-08 18:36:01 +02:00
|
|
|
Common::Point pos = Common::Point(_mousePos.x - 64, _mousePos.y - 16);
|
2012-04-24 00:21:20 +02:00
|
|
|
|
2012-05-08 18:36:01 +02:00
|
|
|
if ((pos.x < 0) || (pos.x > 255) || (pos.y < 0) || (pos.y > 176))
|
2012-04-24 00:21:20 +02:00
|
|
|
return;
|
|
|
|
|
2012-04-24 08:02:28 +02:00
|
|
|
forceReturnFl = false;
|
2012-06-17 14:09:52 +02:00
|
|
|
checkClickOnCharacter(pos, forceReturnFl);
|
2012-04-24 08:02:28 +02:00
|
|
|
if (forceReturnFl)
|
|
|
|
return;
|
|
|
|
|
2012-06-23 10:47:10 +02:00
|
|
|
checkClickOnGameArea(pos);
|
2012-04-24 08:02:28 +02:00
|
|
|
}
|
|
|
|
|
2012-06-23 10:47:10 +02:00
|
|
|
void LilliputEngine::checkClickOnGameArea(Common::Point pos) {
|
|
|
|
debugC(2, kDebugEngine, "checkClickOnGameArea(%d, %d)", pos.x, pos.y);
|
2012-04-24 08:02:28 +02:00
|
|
|
|
2012-05-08 18:36:01 +02:00
|
|
|
int x = pos.x - 8;
|
|
|
|
int y = pos.y - 4;
|
2012-04-24 08:02:28 +02:00
|
|
|
|
2012-06-23 10:47:10 +02:00
|
|
|
x = (x / 16) - 7;
|
|
|
|
y = (y / 8) - 4;
|
2012-04-24 08:02:28 +02:00
|
|
|
|
2012-06-23 10:47:10 +02:00
|
|
|
int arrowY = (y - x) >> 1;
|
|
|
|
int arrowX = y - arrowY;
|
2012-04-24 08:02:28 +02:00
|
|
|
|
2012-06-23 10:47:10 +02:00
|
|
|
if ((arrowX >= 0) && (arrowY >= 0) && (arrowX < 8) && (arrowY < 8)) {
|
|
|
|
arrowX += _scriptHandler->_viewportPos.x;
|
|
|
|
arrowY += _scriptHandler->_viewportPos.y;
|
|
|
|
_savedMousePosDivided = Common::Point(arrowX, arrowY);
|
2012-06-23 18:56:08 +02:00
|
|
|
_actionType = 5;
|
2012-04-24 08:02:28 +02:00
|
|
|
}
|
2012-04-24 00:21:20 +02:00
|
|
|
}
|
|
|
|
|
2012-06-17 14:09:52 +02:00
|
|
|
void LilliputEngine::checkClickOnCharacter(Common::Point pos, bool &forceReturnFl) {
|
|
|
|
debugC(2, kDebugEngine, "checkClickOnCharacter(%d, %d)", pos.x, pos.y);
|
2012-04-24 08:02:28 +02:00
|
|
|
|
|
|
|
forceReturnFl = false;
|
|
|
|
|
2012-05-28 23:51:53 +02:00
|
|
|
for (int8 i = 0; i < _numCharacters; i++) {
|
2012-06-23 10:47:10 +02:00
|
|
|
// check if position is over a character
|
2012-05-08 18:36:01 +02:00
|
|
|
if ((pos.x >= _characterDisplayX[i]) && (pos.x <= _characterDisplayX[i] + 17) && (pos.y >= _characterDisplayY[i]) && (pos.y <= _characterDisplayY[i] + 17) && (i != _word10804)) {
|
2012-06-17 14:09:52 +02:00
|
|
|
_selectedCharacterId = i;
|
2012-06-23 18:56:08 +02:00
|
|
|
_actionType = kActionGoto;
|
2012-07-01 00:59:06 +02:00
|
|
|
if (_delayedReactivationAction)
|
2012-06-23 18:56:08 +02:00
|
|
|
_actionType = kActionTalk;
|
2012-04-24 08:02:28 +02:00
|
|
|
|
2012-06-17 00:04:11 +02:00
|
|
|
forceReturnFl = true;
|
2012-04-24 08:02:28 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-05 18:16:03 +02:00
|
|
|
void LilliputEngine::checkInterfaceHotspots(bool &forceReturnFl) {
|
2012-05-24 20:12:21 +02:00
|
|
|
debugC(2, kDebugEngine, "checkInterfaceHotspots()");
|
2012-04-24 00:21:20 +02:00
|
|
|
|
2012-04-24 08:02:28 +02:00
|
|
|
forceReturnFl = false;
|
2012-05-18 19:24:03 +02:00
|
|
|
for (int index = _interfaceHotspotNumb - 1; index >= 0; index--) {
|
2012-05-24 20:12:21 +02:00
|
|
|
if (isMouseOverHotspot(_mousePos, Common::Point(_interfaceHotspotsX[index], _interfaceHotspotsY[index]))) {
|
2012-04-24 00:21:20 +02:00
|
|
|
sub1305C(index, 1);
|
2012-04-24 08:02:28 +02:00
|
|
|
forceReturnFl = true;
|
|
|
|
return;
|
2012-04-24 00:21:20 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-24 20:12:21 +02:00
|
|
|
bool LilliputEngine::isMouseOverHotspot(Common::Point mousePos, Common::Point hotspotPos) {
|
|
|
|
debugC(2, kDebugEngine, "isMouseOverHotspot(%d - %d, %d - %d)", mousePos.x, mousePos.y, hotspotPos.x, hotspotPos.y);
|
2012-04-24 00:21:20 +02:00
|
|
|
|
2012-05-24 20:12:21 +02:00
|
|
|
if ((mousePos.x < hotspotPos.x) || (mousePos.y < hotspotPos.y) || (mousePos.x > hotspotPos.x + 16) || (mousePos.y > hotspotPos.y + 16))
|
|
|
|
return false;
|
2012-04-24 00:21:20 +02:00
|
|
|
|
2012-05-24 20:12:21 +02:00
|
|
|
return true;
|
2012-04-24 00:21:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void LilliputEngine::sub1305C(byte index, byte button) {
|
2012-05-30 08:19:53 +02:00
|
|
|
debugC(2, kDebugEngine, "sub1305C(%d, %d)", index, button);
|
2012-04-24 00:21:20 +02:00
|
|
|
|
2012-05-18 19:24:03 +02:00
|
|
|
if (_scriptHandler->_interfaceHotspotStatus[index] < kHotspotEnabled)
|
2012-04-24 00:21:20 +02:00
|
|
|
return;
|
|
|
|
|
2012-05-18 19:24:03 +02:00
|
|
|
_lastInterfaceHotspotIndex = index;
|
|
|
|
_lastInterfaceHotspotButton = button;
|
2012-04-24 00:21:20 +02:00
|
|
|
|
2012-06-01 23:57:25 +02:00
|
|
|
if (button == 2) {
|
2012-07-01 00:59:06 +02:00
|
|
|
if (!_delayedReactivationAction) {
|
2012-05-18 19:24:03 +02:00
|
|
|
_scriptHandler->_interfaceHotspotStatus[index] = kHotspotEnabled;
|
2012-06-23 10:47:10 +02:00
|
|
|
_actionType = 2;
|
2012-05-05 18:16:03 +02:00
|
|
|
displayInterfaceHotspots();
|
2012-04-24 00:21:20 +02:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-07-01 00:59:06 +02:00
|
|
|
if (_delayedReactivationAction) {
|
2012-05-24 00:54:34 +02:00
|
|
|
unselectInterfaceButton();
|
2012-04-24 00:21:20 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-05-18 19:24:03 +02:00
|
|
|
unselectInterfaceHotspots();
|
|
|
|
_scriptHandler->_interfaceHotspotStatus[index] = kHotspotSelected;
|
2012-04-24 00:21:20 +02:00
|
|
|
if (_rulesBuffer13_1[index] == 1) {
|
2012-07-01 00:59:06 +02:00
|
|
|
_delayedReactivationAction = true;
|
2012-06-23 10:47:10 +02:00
|
|
|
_bool15AC2 = true;
|
2012-04-24 00:21:20 +02:00
|
|
|
} else {
|
2012-06-23 10:47:10 +02:00
|
|
|
_actionType = 1;
|
2012-04-24 00:21:20 +02:00
|
|
|
}
|
|
|
|
|
2012-05-05 18:16:03 +02:00
|
|
|
displayInterfaceHotspots();
|
2012-04-24 00:21:20 +02:00
|
|
|
}
|
|
|
|
|
2012-05-08 21:38:43 +02:00
|
|
|
void LilliputEngine::sub16685(int idx, Common::Point var1) {
|
2012-05-20 22:57:03 +02:00
|
|
|
debugC(2, kDebugEngine, "sub16685(%d, %d - %d)", idx, var1.x, var1.y);
|
2012-04-22 11:48:35 +02:00
|
|
|
|
2012-05-08 21:38:43 +02:00
|
|
|
int index = (idx << 5) + var1.y;
|
2012-04-30 11:57:57 +02:00
|
|
|
_scriptHandler->_array10AB1[idx] = _rulesBuffer2_16[index];
|
2012-04-22 11:48:35 +02:00
|
|
|
}
|
|
|
|
|
2012-05-20 22:57:03 +02:00
|
|
|
byte LilliputEngine::sub16675_moveCharacter(int idx, Common::Point var1) {
|
|
|
|
debugC(2, kDebugEngine, "sub16675_moveCharacter(%d, %d - %d)", idx, var1.x, var1.y);
|
2012-04-22 11:48:35 +02:00
|
|
|
|
2012-04-30 11:57:57 +02:00
|
|
|
sub16685(idx, var1);
|
2012-05-15 08:05:20 +02:00
|
|
|
|
2012-05-21 22:22:06 +02:00
|
|
|
int index = idx;
|
2012-05-08 21:38:43 +02:00
|
|
|
switch (var1.x) {
|
2012-04-22 11:48:35 +02:00
|
|
|
case 0:
|
|
|
|
break;
|
|
|
|
case 1:
|
2012-05-20 17:53:09 +02:00
|
|
|
moveCharacterSpeed2(index);
|
2012-04-22 11:48:35 +02:00
|
|
|
break;
|
|
|
|
case 2:
|
2012-05-20 17:53:09 +02:00
|
|
|
moveCharacterSpeed4(index);
|
2012-04-22 11:48:35 +02:00
|
|
|
break;
|
|
|
|
case 3:
|
2012-05-20 17:53:09 +02:00
|
|
|
moveCharacterBack2(index);
|
2012-04-22 11:48:35 +02:00
|
|
|
break;
|
|
|
|
case 4:
|
2012-05-20 22:57:03 +02:00
|
|
|
turnCharacter1(index);
|
2012-04-22 11:48:35 +02:00
|
|
|
break;
|
|
|
|
case 5:
|
2012-05-20 22:57:03 +02:00
|
|
|
turnCharacter2(index);
|
2012-04-22 11:48:35 +02:00
|
|
|
break;
|
|
|
|
case 6:
|
2012-05-20 17:53:09 +02:00
|
|
|
moveCharacterUp1(index);
|
2012-04-22 11:48:35 +02:00
|
|
|
break;
|
|
|
|
case 7:
|
2012-05-20 17:53:09 +02:00
|
|
|
moveCharacterUp2(index);
|
2012-04-22 11:48:35 +02:00
|
|
|
break;
|
|
|
|
case 8:
|
2012-05-20 17:53:09 +02:00
|
|
|
moveCharacterDown1(index);
|
2012-04-22 11:48:35 +02:00
|
|
|
break;
|
|
|
|
case 9:
|
2012-05-20 17:53:09 +02:00
|
|
|
moveCharacterDown2(index);
|
2012-04-22 11:48:35 +02:00
|
|
|
break;
|
|
|
|
case 10:
|
2012-05-20 17:53:09 +02:00
|
|
|
moveCharacterSpeed3(index);
|
2012-04-22 11:48:35 +02:00
|
|
|
break;
|
|
|
|
default:
|
2012-05-20 22:57:03 +02:00
|
|
|
warning("sub16675_moveCharacter - Unexpected value %d", var1.x);
|
2012-04-22 11:48:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-05-20 22:57:03 +02:00
|
|
|
void LilliputEngine::turnCharacter1(int index) {
|
|
|
|
debugC(2, kDebugEngine, "turnCharacter1(%d)", index);
|
2012-04-30 10:48:21 +02:00
|
|
|
|
2012-05-01 12:18:52 +02:00
|
|
|
static const byte nextDirection[4] = {1, 3, 0, 2};
|
|
|
|
_characterDirectionArray[index] = nextDirection[_characterDirectionArray[index]];
|
2012-04-30 10:48:21 +02:00
|
|
|
}
|
|
|
|
|
2012-05-20 22:57:03 +02:00
|
|
|
void LilliputEngine::turnCharacter2(int index) {
|
|
|
|
debugC(2, kDebugEngine, "turnCharacter2(%d)", index);
|
2012-04-30 10:48:21 +02:00
|
|
|
|
2012-05-01 12:18:52 +02:00
|
|
|
static const byte nextDirection[4] = {2, 0, 3, 1};
|
|
|
|
_characterDirectionArray[index] = nextDirection[_characterDirectionArray[index]];
|
2012-04-30 10:48:21 +02:00
|
|
|
}
|
|
|
|
|
2012-05-20 17:53:09 +02:00
|
|
|
void LilliputEngine::moveCharacterUp1(int index) {
|
|
|
|
debugC(2, kDebugEngine, "moveCharacterUp1(%d)", index);
|
2012-04-30 10:48:21 +02:00
|
|
|
|
2012-05-01 14:35:19 +02:00
|
|
|
_characterPositionAltitude[index] += 1;
|
2012-04-30 10:48:21 +02:00
|
|
|
}
|
|
|
|
|
2012-05-20 17:53:09 +02:00
|
|
|
void LilliputEngine::moveCharacterUp2(int index) {
|
|
|
|
debugC(2, kDebugEngine, "moveCharacterUp2(%d)", index);
|
2012-04-30 10:48:21 +02:00
|
|
|
|
2012-05-01 14:35:19 +02:00
|
|
|
_characterPositionAltitude[index] += 2;
|
2012-04-30 10:48:21 +02:00
|
|
|
}
|
|
|
|
|
2012-05-20 17:53:09 +02:00
|
|
|
void LilliputEngine::moveCharacterDown1(int index) {
|
|
|
|
debugC(2, kDebugEngine, "moveCharacterDown1(%d)", index);
|
2012-04-30 10:48:21 +02:00
|
|
|
|
2012-05-01 14:35:19 +02:00
|
|
|
_characterPositionAltitude[index] -= 1;
|
2012-04-30 10:48:21 +02:00
|
|
|
}
|
|
|
|
|
2012-05-20 17:53:09 +02:00
|
|
|
void LilliputEngine::moveCharacterDown2(int index) {
|
|
|
|
debugC(2, kDebugEngine, "moveCharacterDown2(%d)", index);
|
2012-04-30 10:48:21 +02:00
|
|
|
|
2012-05-01 14:35:19 +02:00
|
|
|
_characterPositionAltitude[index] -= 2;
|
2012-04-30 10:48:21 +02:00
|
|
|
}
|
|
|
|
|
2012-05-20 17:53:09 +02:00
|
|
|
void LilliputEngine::moveCharacterSpeed2(int index) {
|
|
|
|
debugC(2, kDebugEngine, "moveCharacterSpeed2(%d)", index);
|
2012-04-30 10:48:21 +02:00
|
|
|
|
2012-05-20 17:53:09 +02:00
|
|
|
sub16B31_moveCharacter(index, 2);
|
2012-04-30 10:48:21 +02:00
|
|
|
}
|
|
|
|
|
2012-05-20 17:53:09 +02:00
|
|
|
void LilliputEngine::moveCharacterSpeed4(int index) {
|
|
|
|
debugC(2, kDebugEngine, "moveCharacterSpeed4(%d)", index);
|
2012-04-30 10:48:21 +02:00
|
|
|
|
2012-05-20 17:53:09 +02:00
|
|
|
sub16B31_moveCharacter(index, 4);
|
2012-04-30 10:48:21 +02:00
|
|
|
}
|
|
|
|
|
2012-05-20 17:53:09 +02:00
|
|
|
void LilliputEngine::moveCharacterBack2(int index) {
|
|
|
|
debugC(2, kDebugEngine, "moveCharacterBack2(%d)", index);
|
2012-04-30 10:48:21 +02:00
|
|
|
|
2012-05-20 17:53:09 +02:00
|
|
|
sub16B31_moveCharacter(index, -2);
|
2012-04-30 10:48:21 +02:00
|
|
|
}
|
|
|
|
|
2012-05-20 17:53:09 +02:00
|
|
|
void LilliputEngine::moveCharacterSpeed3(int index) {
|
|
|
|
debugC(2, kDebugEngine, "moveCharacterSpeed3(%d)", index);
|
2012-04-30 10:48:21 +02:00
|
|
|
|
2012-05-20 17:53:09 +02:00
|
|
|
sub16B31_moveCharacter(index, 3);
|
2012-04-30 10:48:21 +02:00
|
|
|
}
|
|
|
|
|
2012-05-20 17:53:09 +02:00
|
|
|
void LilliputEngine::sub16B31_moveCharacter(int index, int16 speed) {
|
|
|
|
debugC(2, kDebugEngine, "sub16B31_moveCharacter(%d, %d)", index, speed);
|
2012-04-30 10:48:21 +02:00
|
|
|
|
2012-05-20 17:53:09 +02:00
|
|
|
int16 newX = _characterPositionX[index];
|
|
|
|
int16 newY = _characterPositionY[index];
|
2012-04-30 17:57:23 +02:00
|
|
|
switch (_characterDirectionArray[index]) {
|
2012-04-30 10:48:21 +02:00
|
|
|
case 0:
|
2012-05-20 17:53:09 +02:00
|
|
|
newX += speed;
|
2012-04-30 10:48:21 +02:00
|
|
|
break;
|
|
|
|
case 1:
|
2012-05-20 17:53:09 +02:00
|
|
|
newY -= speed;
|
2012-04-30 10:48:21 +02:00
|
|
|
break;
|
|
|
|
case 2:
|
2012-05-20 17:53:09 +02:00
|
|
|
newY += speed;
|
2012-04-30 10:48:21 +02:00
|
|
|
break;
|
|
|
|
default:
|
2012-05-20 17:53:09 +02:00
|
|
|
newX -= speed;
|
2012-04-30 10:48:21 +02:00
|
|
|
break;
|
|
|
|
}
|
2012-05-20 17:53:09 +02:00
|
|
|
sub16B8F_moveCharacter(index, Common::Point(newX, newY), _characterDirectionArray[index]);
|
2012-04-30 10:48:21 +02:00
|
|
|
}
|
|
|
|
|
2012-05-20 17:53:09 +02:00
|
|
|
void LilliputEngine::sub16B8F_moveCharacter(int index, Common::Point pos, int direction) {
|
|
|
|
debugC(2, kDebugEngine, "sub16B8F_moveCharacter(%d, %d - %d, %d)", index, pos.x, pos.y, direction);
|
2012-04-30 10:48:21 +02:00
|
|
|
|
2012-05-20 17:53:09 +02:00
|
|
|
int16 diffX = pos.x >> 3;
|
2012-06-20 07:49:21 +02:00
|
|
|
if (((diffX & 0xFF) == _scriptHandler->_characterTilePosX[index]) && ((pos.y >> 3) == _scriptHandler->_characterTilePosY[index])) {
|
2012-05-20 17:53:09 +02:00
|
|
|
_characterPositionX[index] = pos.x;
|
|
|
|
_characterPositionY[index] = pos.y;
|
|
|
|
return;
|
2012-04-30 10:48:21 +02:00
|
|
|
}
|
|
|
|
|
2012-05-20 17:53:09 +02:00
|
|
|
if ((pos.x < 0) || (pos.x >= 512) || (pos.y < 0) || (pos.y >= 512))
|
2012-04-30 10:48:21 +02:00
|
|
|
return;
|
|
|
|
|
2012-06-20 07:49:21 +02:00
|
|
|
int mapIndex = (_scriptHandler->_characterTilePosY[index] * 64 + _scriptHandler->_characterTilePosX[index]) * 4;
|
2012-05-24 20:12:21 +02:00
|
|
|
assert(mapIndex < 16384);
|
2012-04-30 10:48:21 +02:00
|
|
|
|
2012-05-20 17:53:09 +02:00
|
|
|
if ((_bufferIsoMap[mapIndex + 3] & _array16C58[direction]) == 0)
|
2012-04-30 10:48:21 +02:00
|
|
|
return;
|
|
|
|
|
2012-05-20 17:53:09 +02:00
|
|
|
mapIndex = ((pos.y & 0xFFF8) << 3) + diffX;
|
2012-04-30 10:48:21 +02:00
|
|
|
mapIndex <<= 2;
|
|
|
|
|
2012-05-20 17:53:09 +02:00
|
|
|
if ((_bufferIsoMap[mapIndex + 3] & _array16C54[direction]) == 0)
|
2012-04-30 10:48:21 +02:00
|
|
|
return;
|
|
|
|
|
2012-05-20 17:53:09 +02:00
|
|
|
byte var1 = _rulesBuffer2_10[index];
|
2012-04-30 10:48:21 +02:00
|
|
|
var1 &= 7;
|
|
|
|
var1 ^= 7;
|
|
|
|
|
|
|
|
if ((var1 & _rulesChunk9[_bufferIsoMap[mapIndex]]) != 0)
|
|
|
|
return;
|
|
|
|
|
2012-05-20 17:53:09 +02:00
|
|
|
_characterPositionX[index] = pos.x;
|
|
|
|
_characterPositionY[index] = pos.y;
|
2012-04-30 10:48:21 +02:00
|
|
|
}
|
|
|
|
|
2012-05-24 00:54:34 +02:00
|
|
|
void LilliputEngine::sub17224(byte type, byte index, int var4) {
|
|
|
|
debugC(2, kDebugEngine, "sub17224(%d, %d, %d)", type, index, var4);
|
2012-04-30 10:48:21 +02:00
|
|
|
|
|
|
|
if (type == 0) {
|
2012-05-24 00:54:34 +02:00
|
|
|
sub17264(index, var4);
|
2012-04-30 10:48:21 +02:00
|
|
|
return;
|
|
|
|
}
|
2012-05-21 22:22:06 +02:00
|
|
|
|
2012-04-30 10:48:21 +02:00
|
|
|
if (type == 3) {
|
|
|
|
for (int i = _numCharacters - 1; i >= 0; i--)
|
|
|
|
sub17264(i, var4);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-05-24 00:54:34 +02:00
|
|
|
int index2 = var4 & 0xFF;
|
2012-05-26 15:40:09 +02:00
|
|
|
for (byte i = 0; i < _numCharacters; i++) {
|
2012-05-24 00:54:34 +02:00
|
|
|
if ((_scriptHandler->_array10B51[index2] & 0xFF) >= type)
|
2012-04-30 10:48:21 +02:00
|
|
|
sub17264(i, var4);
|
2012-05-24 00:54:34 +02:00
|
|
|
index2 += 40;
|
2012-04-30 10:48:21 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-24 00:54:34 +02:00
|
|
|
void LilliputEngine::sub17264(byte index, int var4) {
|
2012-05-21 07:51:05 +02:00
|
|
|
debugC(2, kDebugEngine, "sub17264(%d, %d)", index, var4);
|
2012-04-30 10:48:21 +02:00
|
|
|
|
2012-05-21 07:51:05 +02:00
|
|
|
if (_array11D49[index] != -1) {
|
2012-04-30 10:48:21 +02:00
|
|
|
_array1289F[index] = var4;
|
|
|
|
} else {
|
|
|
|
_scriptHandler->_characterScriptEnabled[index] = 1;
|
|
|
|
_array11D49[index] = var4;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-04-22 22:54:50 +02:00
|
|
|
void LilliputEngine::sub171CF() {
|
2012-05-21 07:51:05 +02:00
|
|
|
debugC(2, kDebugEngine, "sub171CF()");
|
2012-04-22 22:54:50 +02:00
|
|
|
|
2012-05-26 15:40:09 +02:00
|
|
|
for (byte i = 0; i < _numCharacters; i++) {
|
2012-05-21 07:51:05 +02:00
|
|
|
if (_array1289F[i] != -1) {
|
2012-04-22 22:54:50 +02:00
|
|
|
_array11D49[i] = _array1289F[i];
|
2012-05-21 07:51:05 +02:00
|
|
|
_array1289F[i] = -1;
|
2012-04-28 02:59:43 +02:00
|
|
|
_scriptHandler->_characterScriptEnabled[i] = 1;
|
2012-04-22 22:54:50 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
++_word1289D;
|
|
|
|
|
|
|
|
for (int i = 0; i < 10; i++) {
|
2012-05-20 17:53:09 +02:00
|
|
|
if ((_array12861[(3 * i) + 1] != -1) && (_array12861[3 * i] == _word1289D)) {
|
2012-05-24 00:54:34 +02:00
|
|
|
int16 var1 = _array12861[(3 * i) + 1];
|
2012-04-22 22:54:50 +02:00
|
|
|
int var4 = _array12861[(3 * i) + 2];
|
2012-05-20 17:53:09 +02:00
|
|
|
_array12861[(3 * i) + 1] = -1;
|
2012-04-22 22:54:50 +02:00
|
|
|
|
2012-05-24 00:54:34 +02:00
|
|
|
byte type = var1 >> 8;
|
|
|
|
byte index = var1 & 0xFF;
|
|
|
|
|
|
|
|
sub17224(type, index, var4);
|
2012-04-22 22:54:50 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-01 01:58:15 +02:00
|
|
|
void LilliputEngine::checkInterfaceActivationDelay() {
|
|
|
|
debugC(2, kDebugEngine, "checkInterfaceActivationDelay()");
|
2012-04-22 22:54:50 +02:00
|
|
|
|
2012-05-11 17:01:00 +02:00
|
|
|
if (_animationTick != 1)
|
2012-04-22 22:54:50 +02:00
|
|
|
return;
|
|
|
|
|
2012-07-01 01:58:15 +02:00
|
|
|
bool needRedraw = false;
|
2012-05-18 19:24:03 +02:00
|
|
|
for (int i = 0; i < _interfaceHotspotNumb; i++) {
|
2012-07-01 01:58:15 +02:00
|
|
|
if (_scriptHandler->_interfaceButtonActivationDelay[i] != 0) {
|
|
|
|
--_scriptHandler->_interfaceButtonActivationDelay[i];
|
|
|
|
if (_scriptHandler->_interfaceButtonActivationDelay[i] == 0) {
|
2012-07-01 01:40:38 +02:00
|
|
|
_scriptHandler->_interfaceHotspotStatus[i] = kHotspotEnabled;
|
2012-07-01 01:58:15 +02:00
|
|
|
needRedraw = true;
|
2012-04-22 22:54:50 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-01 01:58:15 +02:00
|
|
|
if (needRedraw)
|
2012-05-05 18:16:03 +02:00
|
|
|
displayInterfaceHotspots();
|
2012-04-22 22:54:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void LilliputEngine::displayHeroismIndicator() {
|
2012-05-23 07:40:05 +02:00
|
|
|
debugC(2, kDebugEngine, "displayHeroismIndicator()");
|
2012-04-22 22:54:50 +02:00
|
|
|
|
|
|
|
if (_scriptHandler->_savedBuffer215Ptr == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
int var1 = (_scriptHandler->_savedBuffer215Ptr[0] * 25) >> 8;
|
|
|
|
|
2012-04-25 23:51:45 +02:00
|
|
|
if (var1 == _scriptHandler->_heroismLevel)
|
2012-04-22 22:54:50 +02:00
|
|
|
return;
|
|
|
|
|
2012-05-09 08:07:58 +02:00
|
|
|
restoreSurfaceUnderMousePointer();
|
2012-04-22 22:54:50 +02:00
|
|
|
int var2 = 1;
|
2012-04-25 23:51:45 +02:00
|
|
|
if (var1 > _scriptHandler->_heroismLevel)
|
2012-04-22 22:54:50 +02:00
|
|
|
var1 = 150;
|
|
|
|
else {
|
|
|
|
var2 = -1;
|
|
|
|
var1 = 40;
|
|
|
|
}
|
|
|
|
|
2012-04-25 23:51:45 +02:00
|
|
|
_scriptHandler->_heroismLevel += var2;
|
2012-05-21 22:22:06 +02:00
|
|
|
|
2012-05-23 07:40:05 +02:00
|
|
|
int index = _scriptHandler->_heroismBarX + (_scriptHandler->_heroismBarBottomY * 320);
|
2012-04-22 22:54:50 +02:00
|
|
|
|
2012-04-25 23:51:45 +02:00
|
|
|
var2 = _scriptHandler->_heroismLevel & 0xFF;
|
2012-04-24 23:17:10 +02:00
|
|
|
if (var2 != 0) {
|
2012-04-22 22:54:50 +02:00
|
|
|
// sub16064(var1, _scriptHandler->_byte15FFA);
|
2012-04-24 23:17:10 +02:00
|
|
|
for (int i = 0; i < (var2 << 2); i++) {
|
2012-04-25 01:41:31 +02:00
|
|
|
((byte *)_mainSurface->getPixels())[index] = var1;
|
|
|
|
((byte *)_mainSurface->getPixels())[index + 1] = var1;
|
|
|
|
((byte *)_mainSurface->getPixels())[index + 2] = var1;
|
|
|
|
index -= 320;
|
2012-04-22 22:54:50 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-04-25 23:51:45 +02:00
|
|
|
if (25 - _scriptHandler->_heroismLevel != 0) {
|
2012-04-22 22:54:50 +02:00
|
|
|
// sub16064(23, 25 - _scriptHandler->_byte15FFA);
|
2012-04-25 23:51:45 +02:00
|
|
|
var2 = (25 - _scriptHandler->_heroismLevel) << 2;
|
2012-04-22 22:54:50 +02:00
|
|
|
for (int i = 0; i < var2; i++) {
|
2012-04-25 01:41:31 +02:00
|
|
|
((byte *)_mainSurface->getPixels())[index] = 23;
|
|
|
|
((byte *)_mainSurface->getPixels())[index + 1] = 23;
|
|
|
|
((byte *)_mainSurface->getPixels())[index + 2] = 23;
|
|
|
|
index -= 320;
|
2012-04-22 22:54:50 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-09 08:07:58 +02:00
|
|
|
displayMousePointer();
|
2012-04-22 22:54:50 +02:00
|
|
|
}
|
|
|
|
|
2012-04-10 10:06:50 +02:00
|
|
|
void LilliputEngine::pollEvent() {
|
2012-05-09 23:13:15 +02:00
|
|
|
debugC(2, kDebugEngine, "pollEvent()");
|
2012-04-11 10:59:42 +02:00
|
|
|
|
2012-04-10 00:57:59 +02:00
|
|
|
Common::Event event;
|
2012-04-10 10:06:50 +02:00
|
|
|
while (_system->getEventManager()->pollEvent(event)) {
|
|
|
|
switch (event.type) {
|
|
|
|
case Common::EVENT_MOUSEMOVE:
|
2012-06-01 23:57:25 +02:00
|
|
|
case Common::EVENT_LBUTTONDOWN:
|
|
|
|
case Common::EVENT_LBUTTONUP: {
|
|
|
|
Common::Point newMousePos = Common::Point(CLIP<int>(event.mouse.x, 0, 304), CLIP<int>(event.mouse.y, 0, 184));
|
|
|
|
|
|
|
|
if (_mousePreviousEventType != event.type) {
|
|
|
|
_mousePreviousEventType = event.type;
|
|
|
|
if (_mouseButton != 1) {
|
|
|
|
_mouseButton = 2;
|
|
|
|
if (event.type != Common::EVENT_MOUSEMOVE) {
|
|
|
|
_mouseButton = 1;
|
|
|
|
_mousePos = Common::Point(newMousePos.x + 5, newMousePos.y + 1);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
_mouseClicked = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (newMousePos != _oldMousePos) {
|
|
|
|
_oldMousePos = newMousePos;
|
|
|
|
if (_skipDisplayFlag1 != 0) {
|
|
|
|
restoreSurfaceUnderMousePointer();
|
|
|
|
_mouseDisplayPos = newMousePos;
|
|
|
|
displayMousePointer();
|
|
|
|
} else {
|
|
|
|
_mouseDisplayPos = newMousePos;
|
|
|
|
}
|
|
|
|
}
|
2012-06-03 11:57:07 +02:00
|
|
|
_lastEventType = event.type;
|
2012-06-01 23:57:25 +02:00
|
|
|
}
|
2012-04-10 10:06:50 +02:00
|
|
|
break;
|
|
|
|
case Common::EVENT_QUIT:
|
|
|
|
_shouldQuit = true;
|
|
|
|
break;
|
2012-06-03 11:57:07 +02:00
|
|
|
case Common::EVENT_KEYUP:
|
2012-05-31 08:29:02 +02:00
|
|
|
case Common::EVENT_KEYDOWN: {
|
2012-06-03 11:57:07 +02:00
|
|
|
if ((event.type == _lastKeyPressed.type) && (event.kbd == _lastKeyPressed.kbd))
|
2012-05-31 08:29:02 +02:00
|
|
|
break;
|
|
|
|
|
2012-06-03 11:57:07 +02:00
|
|
|
_lastKeyPressed = event;
|
2012-05-31 08:29:02 +02:00
|
|
|
int nextIndex = (_keyboard_nextIndex + 1) % 8;
|
|
|
|
if (_keyboard_oldIndex != nextIndex) {
|
2012-06-03 11:57:07 +02:00
|
|
|
_keyboard_buffer[_keyboard_nextIndex] = event;
|
2012-05-31 08:29:02 +02:00
|
|
|
_keyboard_nextIndex = nextIndex;
|
|
|
|
}
|
2012-06-03 11:57:07 +02:00
|
|
|
|
|
|
|
_lastEventType = event.type;
|
2012-05-31 08:29:02 +02:00
|
|
|
}
|
|
|
|
break;
|
2012-04-10 10:06:50 +02:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2012-04-10 00:57:59 +02:00
|
|
|
}
|
|
|
|
|
2012-05-08 19:47:16 +02:00
|
|
|
byte *LilliputEngine::loadVGA(Common::String filename, int expectedSize, bool loadPal) {
|
|
|
|
debugC(1, kDebugEngine, "loadVGA(%s, %d, %d)", filename.c_str(), expectedSize, (loadPal) ? 1 : 0);
|
2012-04-11 10:59:42 +02:00
|
|
|
|
2012-04-04 00:03:41 +02:00
|
|
|
Common::File f;
|
|
|
|
|
|
|
|
if (!f.open(filename))
|
|
|
|
error("Missing game file %s", filename.c_str());
|
|
|
|
|
|
|
|
int remainingSize = f.size();
|
|
|
|
if (loadPal) {
|
|
|
|
for (int i = 0; i < 768; ++i)
|
2012-04-09 17:34:30 +02:00
|
|
|
_curPalette[i] = f.readByte();
|
2012-04-04 00:03:41 +02:00
|
|
|
remainingSize -= 768;
|
2012-04-11 10:59:42 +02:00
|
|
|
|
2012-04-09 17:34:30 +02:00
|
|
|
fixPaletteEntries(_curPalette, 256);
|
2012-04-04 00:03:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
uint8 curByte;
|
2012-05-08 19:47:16 +02:00
|
|
|
byte *decodeBuffer = (byte *)malloc(expectedSize);
|
2012-04-04 00:03:41 +02:00
|
|
|
int size = 0;
|
|
|
|
|
2012-05-21 22:22:06 +02:00
|
|
|
for (; (remainingSize > 0) && (size < expectedSize);) {
|
2012-04-04 00:03:41 +02:00
|
|
|
curByte = f.readByte();
|
|
|
|
--remainingSize;
|
|
|
|
|
|
|
|
if (curByte == 0xFF)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (curByte & 0x80) {
|
|
|
|
// Compressed
|
|
|
|
int compSize = (curByte & 0x7F);
|
|
|
|
curByte = f.readByte();
|
|
|
|
--remainingSize;
|
|
|
|
|
|
|
|
for (int i = 0; i < compSize; ++i) {
|
|
|
|
decodeBuffer[size] = curByte;
|
|
|
|
++size;
|
2012-05-08 19:47:16 +02:00
|
|
|
if (size == expectedSize)
|
|
|
|
break;
|
2012-04-04 00:03:41 +02:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Not compressed
|
2012-04-10 10:19:52 +02:00
|
|
|
int rawSize = (curByte & 0xFF);
|
2012-04-04 00:03:41 +02:00
|
|
|
for (int i = 0; i < rawSize; ++i) {
|
|
|
|
decodeBuffer[size] = f.readByte();
|
|
|
|
--remainingSize;
|
|
|
|
++size;
|
2012-05-08 19:47:16 +02:00
|
|
|
if (size == expectedSize)
|
|
|
|
break;
|
2012-04-04 00:03:41 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
f.close();
|
|
|
|
|
2012-05-08 19:47:16 +02:00
|
|
|
for (int i = size; i < expectedSize; i++)
|
|
|
|
decodeBuffer[i] = 0;
|
|
|
|
|
|
|
|
return decodeBuffer;
|
2012-04-04 00:03:41 +02:00
|
|
|
}
|
|
|
|
|
2012-05-24 20:12:21 +02:00
|
|
|
byte *LilliputEngine::loadRaw(Common::String filename, int filesize) {
|
2012-04-11 10:59:42 +02:00
|
|
|
debugC(1, kDebugEngine, "loadRaw(%s)", filename.c_str());
|
|
|
|
|
2012-04-04 00:03:41 +02:00
|
|
|
Common::File f;
|
|
|
|
|
|
|
|
if (!f.open(filename))
|
|
|
|
error("Missing game file %s", filename.c_str());
|
|
|
|
|
2012-05-24 20:12:21 +02:00
|
|
|
byte *res = (byte *)malloc(sizeof(byte) * filesize);
|
|
|
|
for (int i = 0; i < filesize; ++i)
|
2012-04-04 00:03:41 +02:00
|
|
|
res[i] = f.readByte();
|
|
|
|
|
|
|
|
f.close();
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
void LilliputEngine::loadRules() {
|
2012-04-11 10:59:42 +02:00
|
|
|
debugC(1, kDebugEngine, "loadRules()");
|
|
|
|
|
2012-07-01 00:59:06 +02:00
|
|
|
static const Common::KeyCode keybMappingArray[26] = {
|
2012-06-03 13:27:20 +02:00
|
|
|
Common::KEYCODE_a, Common::KEYCODE_b, Common::KEYCODE_c, Common::KEYCODE_d, Common::KEYCODE_e,
|
|
|
|
Common::KEYCODE_f, Common::KEYCODE_g, Common::KEYCODE_h, Common::KEYCODE_i, Common::KEYCODE_j,
|
|
|
|
Common::KEYCODE_k, Common::KEYCODE_l, Common::KEYCODE_m, Common::KEYCODE_n, Common::KEYCODE_o,
|
|
|
|
Common::KEYCODE_p, Common::KEYCODE_q, Common::KEYCODE_r, Common::KEYCODE_s, Common::KEYCODE_t,
|
|
|
|
Common::KEYCODE_u, Common::KEYCODE_v, Common::KEYCODE_w, Common::KEYCODE_x, Common::KEYCODE_y,
|
|
|
|
Common::KEYCODE_z};
|
2012-04-04 00:03:41 +02:00
|
|
|
Common::File f;
|
|
|
|
uint16 curWord;
|
|
|
|
|
2012-06-01 18:11:41 +02:00
|
|
|
Common::String filename = "ERULES.PRG";
|
|
|
|
Common::Language lang = Common::parseLanguage(ConfMan.get("language"));
|
|
|
|
|
|
|
|
switch (lang) {
|
2012-06-03 19:27:19 +02:00
|
|
|
case Common::EN_ANY:
|
|
|
|
break;
|
2012-06-01 18:11:41 +02:00
|
|
|
case Common::FR_FRA:
|
|
|
|
filename = "FRULES.PRG";
|
|
|
|
break;
|
|
|
|
case Common::IT_ITA:
|
|
|
|
filename = "IRULES.PRG";
|
|
|
|
break;
|
|
|
|
case Common::DE_DEU:
|
|
|
|
filename = "GRULES.PRG";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
warning("unsupported language, switching back to English");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!f.open(filename))
|
|
|
|
error("Missing game file %s", filename.c_str());
|
2012-04-04 00:03:41 +02:00
|
|
|
|
|
|
|
_word10800_ERULES = f.readUint16LE();
|
2012-05-21 22:22:06 +02:00
|
|
|
|
2012-04-04 00:03:41 +02:00
|
|
|
// Chunk 1
|
|
|
|
int size = f.readUint16LE();
|
|
|
|
_rulesChunk1 = (byte *)malloc(sizeof(byte) * size);
|
|
|
|
for (int i = 0; i < size; ++i)
|
|
|
|
_rulesChunk1[i] = f.readByte();
|
|
|
|
|
|
|
|
// Chunk 2
|
2012-05-26 15:40:09 +02:00
|
|
|
_numCharacters = (f.readUint16LE() & 0xFF);
|
2012-06-04 07:51:48 +02:00
|
|
|
assert(_numCharacters <= 40);
|
2012-04-04 00:03:41 +02:00
|
|
|
|
2012-04-28 02:59:43 +02:00
|
|
|
for (int i = _numCharacters, j = 0; i != 0; i--, j++) {
|
2012-04-04 00:03:41 +02:00
|
|
|
curWord = f.readUint16LE();
|
|
|
|
if (curWord != 0xFFFF)
|
|
|
|
curWord = (curWord << 3) + 4;
|
2012-04-25 01:41:31 +02:00
|
|
|
_characterPositionX[j] = curWord;
|
2012-04-04 00:03:41 +02:00
|
|
|
|
|
|
|
curWord = f.readUint16LE();
|
|
|
|
if (curWord != 0xFFFF)
|
|
|
|
curWord = (curWord << 3) + 4;
|
2012-04-25 01:41:31 +02:00
|
|
|
_characterPositionY[j] = curWord;
|
2012-04-04 00:03:41 +02:00
|
|
|
|
2012-05-01 14:35:19 +02:00
|
|
|
_characterPositionAltitude[j] = (f.readUint16LE() & 0xFF);
|
2012-04-30 17:57:23 +02:00
|
|
|
_characterFrameArray[j] = f.readUint16LE();
|
2012-05-26 17:59:38 +02:00
|
|
|
_rulesBuffer2_5[j] = (int8)f.readByte();
|
|
|
|
_rulesBuffer2_6[j] = (int8)f.readByte();
|
2012-04-04 00:03:41 +02:00
|
|
|
_rulesBuffer2_7[j] = f.readByte();
|
2012-04-30 17:57:23 +02:00
|
|
|
_spriteSizeArray[j] = f.readByte();
|
|
|
|
_characterDirectionArray[j] = f.readByte();
|
2012-04-04 00:03:41 +02:00
|
|
|
_rulesBuffer2_10[j] = f.readByte();
|
|
|
|
_rulesBuffer2_11[j] = f.readByte();
|
|
|
|
_rulesBuffer2_12[j] = f.readByte();
|
2012-05-18 16:48:49 +02:00
|
|
|
_rulesBuffer2_13_posX[j] = f.readByte();
|
|
|
|
_rulesBuffer2_14_posY[j] = f.readByte();
|
2012-04-04 00:03:41 +02:00
|
|
|
|
|
|
|
for (int k = 0; k < 32; k++)
|
2012-05-26 02:06:12 +02:00
|
|
|
_characterVariables[(j * 32) + k] = f.readByte();
|
2012-04-04 00:03:41 +02:00
|
|
|
|
|
|
|
for (int k = 0; k < 32; k++)
|
|
|
|
_rulesBuffer2_16[(j * 32) + k] = f.readByte();
|
|
|
|
}
|
|
|
|
|
2012-05-09 08:07:58 +02:00
|
|
|
// Chunk 3 & 4 : Packed strings & associated indexes
|
|
|
|
_packedStringNumb = f.readSint16LE();
|
2012-04-04 00:03:41 +02:00
|
|
|
curWord = f.readSint16LE();
|
|
|
|
|
2012-05-09 08:07:58 +02:00
|
|
|
_packedStringIndex = (int *)malloc(sizeof(int) * _packedStringNumb);
|
|
|
|
for (int i = 0; i < _packedStringNumb; ++i)
|
|
|
|
_packedStringIndex[i] = f.readUint16LE();
|
2012-04-04 00:03:41 +02:00
|
|
|
|
2012-05-09 08:07:58 +02:00
|
|
|
_packedStrings = (char *)malloc(curWord);
|
2012-04-04 00:03:41 +02:00
|
|
|
for (int i = 0; i < curWord; ++i)
|
2012-05-09 08:07:58 +02:00
|
|
|
_packedStrings[i] = f.readByte();
|
2012-04-04 00:03:41 +02:00
|
|
|
|
|
|
|
// Chunk 5: Scripts
|
|
|
|
// Use byte instead of int, therefore multiply by two the size.
|
2012-05-09 08:07:58 +02:00
|
|
|
// This is for converting it into a memory read stream
|
|
|
|
_initScriptSize = f.readUint16LE() * 2;
|
|
|
|
_initScript = (byte *)malloc(_initScriptSize);
|
|
|
|
for (int i = 0; i < _initScriptSize; ++i)
|
2012-04-11 10:59:42 +02:00
|
|
|
_initScript[i] = f.readByte();
|
2012-04-04 00:03:41 +02:00
|
|
|
|
2012-05-09 08:07:58 +02:00
|
|
|
// Chunk 6: Menu Script
|
|
|
|
_menuScriptSize = f.readUint16LE() * 2;
|
|
|
|
_menuScript = (byte *)malloc(sizeof(byte) * _menuScriptSize);
|
|
|
|
for (int i = 0; i < _menuScriptSize; ++i)
|
2012-04-11 10:59:42 +02:00
|
|
|
_menuScript[i] = f.readByte();
|
2012-04-04 00:03:41 +02:00
|
|
|
|
2012-05-09 08:07:58 +02:00
|
|
|
// Chunk 7 & 8: Game scripts and indexes
|
2012-04-11 15:58:41 +02:00
|
|
|
_gameScriptIndexSize = f.readUint16LE();
|
|
|
|
// Added one position to keep the total size too, as it's useful later
|
|
|
|
_arrayGameScriptIndex = (int *)malloc(sizeof(int) * (_gameScriptIndexSize + 1));
|
|
|
|
for (int i = 0; i < _gameScriptIndexSize; ++i)
|
|
|
|
_arrayGameScriptIndex[i] = f.readUint16LE();
|
2012-04-04 00:03:41 +02:00
|
|
|
|
|
|
|
curWord = f.readUint16LE();
|
2012-04-11 15:58:41 +02:00
|
|
|
_arrayGameScriptIndex[_gameScriptIndexSize] = curWord;
|
|
|
|
|
|
|
|
_arrayGameScripts = (byte *)malloc(sizeof(byte) * curWord);
|
2012-04-04 00:03:41 +02:00
|
|
|
for (int i = 0; i < curWord; ++i)
|
2012-04-11 15:58:41 +02:00
|
|
|
_arrayGameScripts[i] = f.readByte();
|
2012-04-04 00:03:41 +02:00
|
|
|
|
|
|
|
// Chunk 9
|
|
|
|
for (int i = 0; i < 60; i++)
|
|
|
|
_rulesChunk9[i] = f.readByte();
|
|
|
|
|
|
|
|
// Chunk 10 & 11
|
|
|
|
_rulesChunk10_size = f.readByte();
|
|
|
|
assert(_rulesChunk10_size <= 20);
|
|
|
|
|
|
|
|
if (_rulesChunk10_size != 0) {
|
2012-05-18 19:24:03 +02:00
|
|
|
_rulesChunk10 = (int16 *)malloc(sizeof(int16) * _rulesChunk10_size);
|
2012-04-04 00:03:41 +02:00
|
|
|
int totalSize = 0;
|
|
|
|
for (int i = 0; i < _rulesChunk10_size; ++i) {
|
|
|
|
_rulesChunk10[i] = totalSize;
|
|
|
|
totalSize += f.readByte();
|
|
|
|
}
|
|
|
|
if (totalSize != 0) {
|
|
|
|
_rulesChunk11 = (byte *)malloc(sizeof(byte) * totalSize);
|
|
|
|
for (int i = 0; i < totalSize; i++)
|
|
|
|
_rulesChunk11[i] = f.readByte();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Chunk 12
|
2012-05-20 17:53:09 +02:00
|
|
|
_rectNumb = f.readUint16LE();
|
|
|
|
assert(_rectNumb <= 40);
|
2012-05-06 22:32:23 +02:00
|
|
|
uint16 tmpVal;
|
2012-04-04 00:03:41 +02:00
|
|
|
|
2012-05-20 17:53:09 +02:00
|
|
|
for (int i = 0; i < _rectNumb; i++) {
|
2012-05-06 10:04:09 +02:00
|
|
|
_rectXMinMax[i] = f.readUint16LE();
|
|
|
|
_rectYMinMax[i] = f.readUint16LE();
|
2012-05-06 22:32:23 +02:00
|
|
|
tmpVal = f.readUint16LE();
|
2012-05-06 23:38:13 +02:00
|
|
|
_rulesBuffer12Pos3[i] = Common::Point(tmpVal >> 8, tmpVal & 0xFF);
|
|
|
|
tmpVal = f.readUint16LE();
|
|
|
|
_rulesBuffer12Pos4[i] = Common::Point(tmpVal >> 8, tmpVal & 0xFF);
|
2012-04-04 00:03:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Chunk 13
|
2012-05-18 19:24:03 +02:00
|
|
|
_interfaceHotspotNumb = f.readUint16LE();
|
2012-04-04 00:03:41 +02:00
|
|
|
for (int i = 0 ; i < 20; i++)
|
|
|
|
_rulesBuffer13_1[i] = f.readByte();
|
|
|
|
|
|
|
|
for (int i = 0 ; i < 20; i++)
|
2012-05-18 16:48:49 +02:00
|
|
|
_interfaceHotspotsX[i] = f.readSint16LE();
|
2012-04-04 00:03:41 +02:00
|
|
|
|
|
|
|
for (int i = 0 ; i < 20; i++)
|
2012-05-18 16:48:49 +02:00
|
|
|
_interfaceHotspotsY[i] = f.readSint16LE();
|
2012-04-04 00:03:41 +02:00
|
|
|
|
|
|
|
for (int i = 0; i < 20; i++) {
|
|
|
|
byte curByte = f.readByte();
|
|
|
|
|
|
|
|
if (curByte == 0x20)
|
2012-06-03 13:27:20 +02:00
|
|
|
_keyboardMapping[i] = Common::KEYCODE_SPACE;
|
2012-04-04 00:03:41 +02:00
|
|
|
else if (curByte == 0xD)
|
2012-06-03 13:27:20 +02:00
|
|
|
_keyboardMapping[i] = Common::KEYCODE_RETURN;
|
2012-04-04 00:03:41 +02:00
|
|
|
// Hack to avoid xlat out of bounds
|
|
|
|
else if (curByte == 0xFF)
|
2012-06-03 13:27:20 +02:00
|
|
|
_keyboardMapping[i] = Common::KEYCODE_INVALID; // 0x21; ?
|
2012-04-04 00:03:41 +02:00
|
|
|
// Hack to avoid xlat out of bounds
|
|
|
|
else if (curByte == 0x00)
|
2012-06-03 13:27:20 +02:00
|
|
|
_keyboardMapping[i] = Common::KEYCODE_INVALID; // 0xB4; ?
|
2012-04-04 00:03:41 +02:00
|
|
|
else {
|
|
|
|
assert((curByte > 0x40) && (curByte <= 0x41 + 26));
|
2012-07-01 00:59:06 +02:00
|
|
|
_keyboardMapping[i] = keybMappingArray[curByte - 0x41];
|
2012-04-04 00:03:41 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
f.close();
|
|
|
|
|
|
|
|
// Skipped: Load Savegame
|
|
|
|
}
|
|
|
|
|
2012-04-09 20:19:58 +02:00
|
|
|
void LilliputEngine::displayVGAFile(Common::String fileName) {
|
2012-05-09 08:07:58 +02:00
|
|
|
debugC(1, kDebugEngine, "displayVGAFile(%s)", fileName.c_str());
|
2012-04-16 00:24:02 +02:00
|
|
|
|
2012-05-28 18:22:51 +02:00
|
|
|
restoreSurfaceUnderMousePointer();
|
2012-04-09 20:19:58 +02:00
|
|
|
|
2012-05-08 19:47:16 +02:00
|
|
|
byte *buffer = loadVGA(fileName, 64000, true);
|
2012-04-09 20:19:58 +02:00
|
|
|
memcpy(_mainSurface->getPixels(), buffer, 320*200);
|
|
|
|
_system->copyRectToScreen((byte *)_mainSurface->getPixels(), 320, 0, 0, 320, 200);
|
|
|
|
_system->updateScreen();
|
2012-05-28 18:22:51 +02:00
|
|
|
|
|
|
|
displayMousePointer();
|
2012-04-09 20:19:58 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2012-04-09 17:34:30 +02:00
|
|
|
void LilliputEngine::fixPaletteEntries(uint8 *palette, int num) {
|
2012-04-11 10:59:42 +02:00
|
|
|
debugC(1, kDebugEngine, "fixPaletteEntries(palette, %d)", num);
|
2012-05-16 20:58:41 +02:00
|
|
|
// Color values are coded on 6bits (for old 6bits DAC)
|
2012-04-09 17:34:30 +02:00
|
|
|
for (int32 i = 0; i < num * 3; i++) {
|
|
|
|
int32 a = palette[i];
|
|
|
|
assert(a < 64);
|
|
|
|
|
2012-05-21 22:22:06 +02:00
|
|
|
a = (a << 2) | (a >> 4);
|
2012-04-09 17:34:30 +02:00
|
|
|
if (a > 255)
|
|
|
|
a = 255;
|
|
|
|
palette[i] = a;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void LilliputEngine::initPalette() {
|
2012-04-11 10:59:42 +02:00
|
|
|
debugC(1, kDebugEngine, "initPalette()");
|
|
|
|
|
2012-04-09 17:34:30 +02:00
|
|
|
for (int i = 0; i < 768; i++)
|
|
|
|
_curPalette[i] = _basisPalette[i];
|
|
|
|
|
|
|
|
fixPaletteEntries(_curPalette, 256);
|
|
|
|
_system->getPaletteManager()->setPalette(_curPalette, 0, 256);
|
|
|
|
}
|
|
|
|
|
2012-05-18 16:48:49 +02:00
|
|
|
void LilliputEngine::setCurrentCharacter(int index) {
|
|
|
|
debugC(1, kDebugEngine, "setCurrentCharacter(%d)", index);
|
2012-04-11 10:59:42 +02:00
|
|
|
|
2012-05-01 23:32:44 +02:00
|
|
|
_currentScriptCharacter = index;
|
2012-04-11 10:59:42 +02:00
|
|
|
|
2012-05-21 22:22:06 +02:00
|
|
|
assert(index < 40);
|
2012-05-18 16:48:49 +02:00
|
|
|
int posX = _characterPositionX[index];
|
|
|
|
int posY = _characterPositionY[index];
|
2012-04-11 10:59:42 +02:00
|
|
|
|
2012-05-18 16:48:49 +02:00
|
|
|
_currentScriptCharacterPos = Common::Point(posX >> 3, posY >> 3);
|
2012-05-04 23:13:43 +02:00
|
|
|
_currentCharacterVariables = getCharacterVariablesPtr(_currentScriptCharacter * 32);
|
2012-04-11 10:59:42 +02:00
|
|
|
}
|
|
|
|
|
2012-05-24 00:54:34 +02:00
|
|
|
void LilliputEngine::unselectInterfaceButton() {
|
|
|
|
debugC(1, kDebugEngine, "unselectInterfaceButton()");
|
|
|
|
|
2012-07-01 00:59:06 +02:00
|
|
|
_delayedReactivationAction = false;
|
2012-06-23 10:47:10 +02:00
|
|
|
_bool15AC2 = false;
|
2012-05-24 00:54:34 +02:00
|
|
|
_lastInterfaceHotspotButton = 0;
|
|
|
|
unselectInterfaceHotspots();
|
|
|
|
displayInterfaceHotspots();
|
2012-04-11 10:59:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void LilliputEngine::handleMenu() {
|
2012-05-19 14:25:30 +02:00
|
|
|
debugC(1, kDebugEngine, "handleMenu()");
|
2012-04-11 10:59:42 +02:00
|
|
|
|
2012-06-23 10:47:10 +02:00
|
|
|
if (_actionType == kActionNone)
|
2012-04-11 10:59:42 +02:00
|
|
|
return;
|
|
|
|
|
2012-07-01 00:59:06 +02:00
|
|
|
if (_delayedReactivationAction && (_actionType != kActionTalk))
|
2012-04-11 10:59:42 +02:00
|
|
|
return;
|
|
|
|
|
2012-05-18 16:48:49 +02:00
|
|
|
setCurrentCharacter(_word10804);
|
2012-05-08 18:36:01 +02:00
|
|
|
debugC(1, kDebugScriptTBC, "========================== Menu Script ==============================");
|
2012-05-09 08:07:58 +02:00
|
|
|
_scriptHandler->runMenuScript(ScriptStream(_menuScript, _menuScriptSize));
|
2012-05-08 18:36:01 +02:00
|
|
|
debugC(1, kDebugScriptTBC, "========================== End of Menu Script==============================");
|
2012-05-05 21:34:58 +02:00
|
|
|
_savedMousePosDivided = Common::Point(-1, -1);
|
2012-06-17 14:09:52 +02:00
|
|
|
_selectedCharacterId = -1;
|
2012-04-11 10:59:42 +02:00
|
|
|
|
2012-06-23 18:56:08 +02:00
|
|
|
if (_actionType == kActionTalk)
|
2012-05-24 00:54:34 +02:00
|
|
|
unselectInterfaceButton();
|
2012-04-11 10:59:42 +02:00
|
|
|
|
2012-06-23 10:47:10 +02:00
|
|
|
_actionType = kActionNone;
|
2012-04-11 10:59:42 +02:00
|
|
|
}
|
|
|
|
|
2012-04-11 18:23:17 +02:00
|
|
|
void LilliputEngine::handleGameScripts() {
|
2012-05-19 14:25:30 +02:00
|
|
|
debugC(1, kDebugEngine, "handleGameScripts()");
|
2012-04-11 18:23:17 +02:00
|
|
|
|
2012-05-19 14:25:30 +02:00
|
|
|
int index = _nextCharacterIndex;
|
2012-04-11 15:58:41 +02:00
|
|
|
int i;
|
2012-04-28 02:59:43 +02:00
|
|
|
for (i = 0; (_scriptHandler->_characterScriptEnabled[index] == 0) && (i < _numCharacters); i++) {
|
2012-04-11 15:58:41 +02:00
|
|
|
++index;
|
2012-04-28 02:59:43 +02:00
|
|
|
if (index >= _numCharacters)
|
2012-04-11 15:58:41 +02:00
|
|
|
index = 0;
|
|
|
|
}
|
|
|
|
|
2012-04-28 02:59:43 +02:00
|
|
|
if (i > _numCharacters)
|
2012-04-11 15:58:41 +02:00
|
|
|
return;
|
|
|
|
|
2012-05-19 14:25:30 +02:00
|
|
|
_nextCharacterIndex = (index + 1) % _numCharacters;
|
2012-04-28 02:59:43 +02:00
|
|
|
|
2012-04-11 15:58:41 +02:00
|
|
|
|
2012-04-28 02:59:43 +02:00
|
|
|
_scriptHandler->_characterScriptEnabled[index] = 0;
|
2012-05-18 16:48:49 +02:00
|
|
|
setCurrentCharacter(index);
|
2012-04-11 15:58:41 +02:00
|
|
|
|
2012-04-30 11:57:57 +02:00
|
|
|
|
2012-06-23 10:47:10 +02:00
|
|
|
_word16EFEh = _array11D49[index] >> 8;
|
|
|
|
_word16EFEl_characterId = _array11D49[index] & 0xFF;
|
2012-05-21 09:44:25 +02:00
|
|
|
_array11D49[index] = -1;
|
2012-04-11 15:58:41 +02:00
|
|
|
_word1817B = 0;
|
|
|
|
|
2012-04-28 02:59:43 +02:00
|
|
|
int tmpVal = _rulesBuffer2_12[index];
|
2012-04-11 15:58:41 +02:00
|
|
|
if (tmpVal == 0xFF)
|
|
|
|
return;
|
2012-05-12 18:04:07 +02:00
|
|
|
|
2012-05-21 22:22:06 +02:00
|
|
|
/* Decompiler follows
|
2012-05-13 03:21:09 +02:00
|
|
|
|
2012-05-21 22:22:06 +02:00
|
|
|
//_scriptHandler->listAllTexts();
|
2012-05-13 03:21:09 +02:00
|
|
|
|
2012-05-21 22:22:06 +02:00
|
|
|
debugC(1, kDebugEngineTBC, "================= Menu Script ==================");
|
|
|
|
ScriptStream script = ScriptStream(_menuScript, _menuScriptSize);
|
|
|
|
_scriptHandler->disasmScript(script);
|
|
|
|
debugC(1, kDebugEngineTBC, "============= End Menu Script ==================");
|
2012-05-12 22:21:02 +02:00
|
|
|
|
2012-05-13 03:21:09 +02:00
|
|
|
|
2012-05-21 22:22:06 +02:00
|
|
|
for (int i = 0; i < _gameScriptIndexSize; i++) {
|
|
|
|
assert(tmpVal < _gameScriptIndexSize);
|
|
|
|
debugC(1, kDebugEngineTBC, "================= Game Script %d ==================", i);
|
|
|
|
ScriptStream script = ScriptStream(&_arrayGameScripts[_arrayGameScriptIndex[i]], _arrayGameScriptIndex[i + 1] - _arrayGameScriptIndex[i]);
|
|
|
|
_scriptHandler->disasmScript(script);
|
|
|
|
debugC(1, kDebugEngineTBC, "============= End Game Script %d ==================", i);
|
|
|
|
}
|
|
|
|
|
|
|
|
while (1);
|
|
|
|
*/
|
|
|
|
|
2012-05-12 18:04:07 +02:00
|
|
|
i = index;
|
|
|
|
//debugC(1, kDebugEngineTBC, "before char %d, pos %d %d, var0 %d, var1 %d, var2 %d var16 %d, script enabled %d", i, _characterPositionX[i], _characterPositionY[i], *getCharacterVariablesPtr(i * 32 + 0), *getCharacterVariablesPtr(i * 32 + 1), *getCharacterVariablesPtr(i * 32 + 2), *getCharacterVariablesPtr(i * 32 + 22), _scriptHandler->_characterScriptEnabled[i]);
|
2012-04-29 14:57:36 +02:00
|
|
|
|
2012-04-11 15:58:41 +02:00
|
|
|
assert(tmpVal < _gameScriptIndexSize);
|
2012-05-30 08:19:53 +02:00
|
|
|
debugC(1, kDebugEngine, "================= Game Script %d for character %d ==================", tmpVal, index);
|
2012-04-27 22:08:56 +02:00
|
|
|
_scriptHandler->runScript(ScriptStream(&_arrayGameScripts[_arrayGameScriptIndex[tmpVal]], _arrayGameScriptIndex[tmpVal + 1] - _arrayGameScriptIndex[tmpVal]));
|
2012-05-30 08:19:53 +02:00
|
|
|
debugC(1, kDebugEngine, "============= End Game Script %d for character %d ==================", tmpVal, index);
|
2012-04-28 02:59:43 +02:00
|
|
|
|
2012-05-02 00:50:40 +02:00
|
|
|
//warning("dump char stat");
|
2012-05-12 18:04:07 +02:00
|
|
|
//debugC(1, kDebugEngineTBC, "after char %d, pos %d %d, var0 %d, var1 %d, var2 %d var16 %d, script enabled %d", i, _characterPositionX[i], _characterPositionY[i], *getCharacterVariablesPtr(i * 32 + 0), *getCharacterVariablesPtr(i * 32 + 1), *getCharacterVariablesPtr(i * 32 + 2), *getCharacterVariablesPtr(i * 32 + 22), _scriptHandler->_characterScriptEnabled[i]);
|
2012-04-11 10:59:42 +02:00
|
|
|
}
|
|
|
|
|
2012-03-30 18:03:59 +02:00
|
|
|
Common::Error LilliputEngine::run() {
|
2012-04-11 10:59:42 +02:00
|
|
|
debugC(1, kDebugEngine, "run()");
|
|
|
|
|
2012-03-30 18:03:59 +02:00
|
|
|
s_Engine = this;
|
2012-04-11 10:59:42 +02:00
|
|
|
initialize();
|
2012-03-30 18:03:59 +02:00
|
|
|
initGraphics(320, 200);
|
2012-04-09 17:34:30 +02:00
|
|
|
_mainSurface = new Graphics::Surface();
|
|
|
|
_mainSurface->create(320, 200, Graphics::PixelFormat::createFormatCLUT8());
|
2012-03-30 18:03:59 +02:00
|
|
|
|
|
|
|
// Setup mixer
|
|
|
|
syncSoundSettings();
|
2012-05-08 18:36:01 +02:00
|
|
|
//TODO: Init sound/music player
|
2012-03-30 18:03:59 +02:00
|
|
|
|
2012-04-09 17:34:30 +02:00
|
|
|
initPalette();
|
2012-04-04 00:03:41 +02:00
|
|
|
|
|
|
|
// Load files. In the original, the size was hardcoded
|
2012-05-08 19:47:16 +02:00
|
|
|
_bufferIdeogram = loadVGA("IDEOGRAM.VGA", 25600, false);
|
|
|
|
_bufferMen = loadVGA("MEN.VGA", 61440, false);
|
|
|
|
_bufferMen2 = loadVGA("MEN2.VGA", 61440, false);
|
|
|
|
_bufferIsoChars = loadVGA("ISOCHARS.VGA", 4096, false);
|
2012-05-24 20:12:21 +02:00
|
|
|
_bufferIsoMap = loadRaw("ISOMAP.DTA", 16384);
|
2012-04-04 00:03:41 +02:00
|
|
|
|
|
|
|
loadRules();
|
2012-05-22 22:12:09 +02:00
|
|
|
_int8installed = true;
|
2012-04-04 00:03:41 +02:00
|
|
|
|
2012-04-20 01:10:46 +02:00
|
|
|
_lastTime = _system->getMillis();
|
|
|
|
|
2012-05-09 08:07:58 +02:00
|
|
|
_scriptHandler->runScript(ScriptStream(_initScript, _initScriptSize));
|
2012-04-04 00:03:41 +02:00
|
|
|
|
2012-05-16 20:58:41 +02:00
|
|
|
while (!_shouldQuit) {
|
2012-04-11 10:59:42 +02:00
|
|
|
handleMenu();
|
2012-04-11 18:23:17 +02:00
|
|
|
handleGameScripts();
|
2012-04-11 10:59:42 +02:00
|
|
|
// To be removed when handled in the previous fonctions
|
2012-04-19 08:03:19 +02:00
|
|
|
update();
|
2012-04-11 10:59:42 +02:00
|
|
|
}
|
2012-04-09 17:34:30 +02:00
|
|
|
|
2012-03-30 18:03:59 +02:00
|
|
|
return Common::kNoError;
|
|
|
|
}
|
|
|
|
|
|
|
|
void LilliputEngine::initialize() {
|
|
|
|
debugC(1, kDebugEngine, "initialize");
|
|
|
|
|
|
|
|
_rnd = new Common::RandomSource("robin");
|
|
|
|
_rnd->setSeed(42); // Kick random number generator
|
2012-04-10 00:57:59 +02:00
|
|
|
_shouldQuit = false;
|
2012-04-06 08:15:22 +02:00
|
|
|
|
|
|
|
for (int i = 0; i < 4; i++) {
|
2012-05-11 17:01:00 +02:00
|
|
|
_smallAnims[i]._active = false;
|
|
|
|
_smallAnims[i]._pos = Common::Point(0, 0);
|
2012-04-06 08:15:22 +02:00
|
|
|
for (int j = 0; j < 8; j ++)
|
2012-05-11 17:01:00 +02:00
|
|
|
_smallAnims[i]._frameIndex[j] = 0;
|
2012-04-06 08:15:22 +02:00
|
|
|
}
|
2012-03-30 18:03:59 +02:00
|
|
|
}
|
|
|
|
|
2012-05-04 23:13:43 +02:00
|
|
|
byte *LilliputEngine::getCharacterVariablesPtr(int16 index) {
|
2012-05-17 20:35:20 +02:00
|
|
|
debugC(1, kDebugEngine, "getCharacterVariablesPtr(%d)", index);
|
2012-05-13 03:21:09 +02:00
|
|
|
|
2012-05-05 00:10:55 +02:00
|
|
|
assert((index > -3120) && (index < 1400));
|
2012-05-04 23:13:43 +02:00
|
|
|
if (index >= 0)
|
2012-05-26 02:06:12 +02:00
|
|
|
return &_characterVariables[index];
|
2012-05-04 23:13:43 +02:00
|
|
|
else
|
2012-05-26 02:06:12 +02:00
|
|
|
return &_characterVariables[1400 - index];
|
2012-05-04 23:13:43 +02:00
|
|
|
}
|
|
|
|
|
2012-03-30 18:03:59 +02:00
|
|
|
void LilliputEngine::syncSoundSettings() {
|
|
|
|
Engine::syncSoundSettings();
|
|
|
|
|
|
|
|
// _sound->syncVolume();
|
|
|
|
}
|
|
|
|
|
|
|
|
Common::String LilliputEngine::getSavegameFilename(int slot) {
|
|
|
|
return _targetName + Common::String::format("-%02d.SAV", slot);
|
|
|
|
}
|
|
|
|
|
2012-06-03 11:57:07 +02:00
|
|
|
Common::Event LilliputEngine::_keyboard_getch() {
|
2012-04-11 10:59:42 +02:00
|
|
|
warning("getch()");
|
2012-05-31 08:29:02 +02:00
|
|
|
while(_keyboard_nextIndex == _keyboard_oldIndex)
|
|
|
|
pollEvent();
|
|
|
|
|
2012-06-03 11:57:07 +02:00
|
|
|
Common::Event tmpEvent = _keyboard_buffer[_keyboard_oldIndex];
|
2012-05-31 08:29:02 +02:00
|
|
|
_keyboard_oldIndex = (_keyboard_oldIndex + 1) % 8;
|
|
|
|
|
|
|
|
return tmpEvent;
|
2012-04-06 08:15:22 +02:00
|
|
|
}
|
2012-03-30 18:03:59 +02:00
|
|
|
|
2012-06-01 08:18:33 +02:00
|
|
|
bool LilliputEngine::_keyboard_checkKeyboard() {
|
|
|
|
return (_keyboard_nextIndex != _keyboard_oldIndex);
|
|
|
|
}
|
|
|
|
|
|
|
|
void LilliputEngine::_keyboard_resetKeyboardBuffer() {
|
|
|
|
_keyboard_nextIndex = _keyboard_oldIndex = 0;
|
|
|
|
}
|
|
|
|
|
2012-03-30 18:03:59 +02:00
|
|
|
} // End of namespace Lilliput
|