2009-01-18 17:04:24 +00:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
|
|
|
*
|
|
|
|
* ScummVM is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
|
|
* file distributed with this source distribution.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2009-03-04 11:53:25 +00:00
|
|
|
#ifdef ENABLE_LOL
|
|
|
|
|
2009-01-18 17:04:24 +00:00
|
|
|
#include "kyra/lol.h"
|
|
|
|
#include "kyra/screen_lol.h"
|
|
|
|
#include "kyra/resource.h"
|
2009-02-21 23:20:14 +00:00
|
|
|
#include "kyra/timer.h"
|
2009-01-18 17:04:24 +00:00
|
|
|
|
|
|
|
#include "common/endian.h"
|
2011-04-24 08:34:27 +00:00
|
|
|
#include "common/system.h"
|
2009-01-18 17:04:24 +00:00
|
|
|
|
|
|
|
namespace Kyra {
|
|
|
|
|
|
|
|
void LoLEngine::loadLevel(int index) {
|
2009-06-07 20:43:43 +00:00
|
|
|
_flagsTable[73] |= 0x08;
|
2009-01-18 17:04:24 +00:00
|
|
|
setMouseCursorToIcon(0x85);
|
2009-02-01 19:27:01 +00:00
|
|
|
_nextScriptFunc = 0;
|
2009-01-18 17:04:24 +00:00
|
|
|
|
2009-01-19 23:35:27 +00:00
|
|
|
snd_stopMusic();
|
2009-01-18 17:04:24 +00:00
|
|
|
|
2009-12-26 19:02:16 +00:00
|
|
|
stopPortraitSpeechAnim();
|
2009-01-18 17:04:24 +00:00
|
|
|
|
|
|
|
for (int i = 0; i < 400; i++) {
|
2011-12-11 00:57:03 +00:00
|
|
|
delete[] _levelDecorationShapes[i];
|
|
|
|
_levelDecorationShapes[i] = 0;
|
2009-01-18 17:04:24 +00:00
|
|
|
}
|
|
|
|
_emc->unload(&_scriptData);
|
|
|
|
|
2009-01-19 23:35:27 +00:00
|
|
|
resetItems(1);
|
2009-03-24 07:18:16 +00:00
|
|
|
disableMonsters();
|
2009-02-14 13:55:00 +00:00
|
|
|
resetBlockProperties();
|
2009-01-18 17:04:24 +00:00
|
|
|
|
|
|
|
releaseMonsterShapes(0);
|
|
|
|
releaseMonsterShapes(1);
|
|
|
|
|
2009-02-21 23:20:14 +00:00
|
|
|
for (int i = 0x50; i < 0x53; i++)
|
|
|
|
_timer->disable(i);
|
2009-02-14 13:55:00 +00:00
|
|
|
|
2009-01-19 23:35:27 +00:00
|
|
|
_currentLevel = index;
|
2009-02-01 19:27:01 +00:00
|
|
|
_updateFlags = 0;
|
2009-01-19 23:35:27 +00:00
|
|
|
|
2009-03-24 07:18:16 +00:00
|
|
|
setDefaultButtonState();
|
2009-01-19 23:35:27 +00:00
|
|
|
|
|
|
|
loadTalkFile(index);
|
2009-01-18 17:04:24 +00:00
|
|
|
|
2009-04-03 21:32:50 +00:00
|
|
|
loadLevelWallData(index, true);
|
2009-01-18 17:04:24 +00:00
|
|
|
_loadLevelFlag = 1;
|
|
|
|
|
2011-06-09 17:09:54 +00:00
|
|
|
Common::String filename = Common::String::format("LEVEL%d.INI", index);
|
2009-02-14 13:55:00 +00:00
|
|
|
|
2009-03-28 11:58:22 +00:00
|
|
|
int f = _hasTempDataFlags & (1 << (index - 1));
|
2009-01-18 17:04:24 +00:00
|
|
|
|
2011-06-09 17:09:54 +00:00
|
|
|
runInitScript(filename.c_str(), f ? 0 : 1);
|
2009-01-18 17:04:24 +00:00
|
|
|
|
|
|
|
if (f)
|
2009-03-28 11:58:22 +00:00
|
|
|
restoreBlockTempData(index);
|
2009-01-18 17:04:24 +00:00
|
|
|
|
2011-06-09 17:09:54 +00:00
|
|
|
filename = Common::String::format("LEVEL%d.INF", index);
|
|
|
|
runInfScript(filename.c_str());
|
2009-01-18 17:04:24 +00:00
|
|
|
|
|
|
|
addLevelItems();
|
2009-04-03 21:32:50 +00:00
|
|
|
deleteMonstersFromBlock(_currentBlock);
|
2009-01-18 17:04:24 +00:00
|
|
|
|
2009-09-19 13:17:55 +00:00
|
|
|
if (!_flags.use16ColorMode)
|
|
|
|
_screen->generateGrayOverlay(_screen->getPalette(0), _screen->_grayOverlay, 32, 16, 0, 0, 128, true);
|
2009-01-18 17:04:24 +00:00
|
|
|
|
2009-02-14 00:51:07 +00:00
|
|
|
_sceneDefaultUpdate = 0;
|
2009-01-18 17:04:24 +00:00
|
|
|
if (_screen->_fadeFlag == 3)
|
|
|
|
_screen->fadeToBlack(10);
|
|
|
|
|
|
|
|
gui_drawPlayField();
|
|
|
|
|
2009-06-29 16:06:18 +00:00
|
|
|
setPaletteBrightness(_screen->getPalette(0), _brightness, _lampEffect);
|
2009-01-18 17:04:24 +00:00
|
|
|
setMouseCursorToItemInHand();
|
2009-01-19 23:35:27 +00:00
|
|
|
|
2009-09-19 13:17:55 +00:00
|
|
|
if (_flags.use16ColorMode)
|
2010-01-25 01:39:44 +00:00
|
|
|
_screen->fadeToPalette1(10);
|
2009-09-19 13:17:55 +00:00
|
|
|
|
2009-01-19 23:35:27 +00:00
|
|
|
snd_playTrack(_curMusicTheme);
|
2009-01-18 17:04:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void LoLEngine::addLevelItems() {
|
|
|
|
for (int i = 0; i < 400; i++) {
|
|
|
|
if (_itemsInPlay[i].level != _currentLevel)
|
|
|
|
continue;
|
|
|
|
|
2011-12-12 19:10:57 +00:00
|
|
|
assignBlockItem(&_levelBlockProperties[_itemsInPlay[i].block], i);
|
2009-01-18 17:04:24 +00:00
|
|
|
|
2009-04-25 13:15:05 +00:00
|
|
|
_levelBlockProperties[_itemsInPlay[i].block].direction = 5;
|
2009-03-15 16:48:20 +00:00
|
|
|
_itemsInPlay[i].nextDrawObject = 0;
|
2009-01-18 17:04:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-12-12 19:10:57 +00:00
|
|
|
void LoLEngine::assignBlockItem(LevelBlockProperty *l, uint16 item) {
|
2009-11-11 23:05:19 +00:00
|
|
|
uint16 *index = &l->assignedObjects;
|
2011-12-12 19:10:57 +00:00
|
|
|
LoLObject *tmp = 0;
|
2009-02-01 19:27:01 +00:00
|
|
|
|
2009-11-11 23:05:19 +00:00
|
|
|
while (*index & 0x8000) {
|
|
|
|
tmp = findObject(*index);
|
|
|
|
index = &tmp->nextAssignedObject;
|
2009-01-18 17:04:24 +00:00
|
|
|
}
|
|
|
|
|
2009-03-15 16:48:20 +00:00
|
|
|
tmp = findObject(item);
|
2011-12-31 04:11:33 +00:00
|
|
|
((LoLItem *)tmp)->level = -1;
|
2009-02-01 19:27:01 +00:00
|
|
|
|
2009-11-11 23:05:19 +00:00
|
|
|
uint16 ix = *index;
|
2009-01-18 17:04:24 +00:00
|
|
|
|
|
|
|
if (ix == item)
|
|
|
|
return;
|
|
|
|
|
2009-11-11 23:05:19 +00:00
|
|
|
*index = item;
|
|
|
|
index = &tmp->nextAssignedObject;
|
2009-01-18 17:04:24 +00:00
|
|
|
|
2009-11-11 23:05:19 +00:00
|
|
|
while (*index) {
|
|
|
|
tmp = findObject(*index);
|
|
|
|
index = &tmp->nextAssignedObject;
|
2009-02-01 19:27:01 +00:00
|
|
|
}
|
2009-01-18 17:04:24 +00:00
|
|
|
|
2009-11-11 23:05:19 +00:00
|
|
|
*index = ix;
|
2009-01-18 17:04:24 +00:00
|
|
|
}
|
|
|
|
|
2009-04-03 21:32:50 +00:00
|
|
|
void LoLEngine::loadLevelWallData(int index, bool mapShapes) {
|
2011-06-09 17:09:54 +00:00
|
|
|
Common::String filename = Common::String::format("LEVEL%d.WLL", index);
|
2009-01-18 17:04:24 +00:00
|
|
|
|
|
|
|
uint32 size;
|
2011-06-09 17:09:54 +00:00
|
|
|
uint8 *file = _res->fileData(filename.c_str(), &size);
|
2009-01-18 17:04:24 +00:00
|
|
|
|
|
|
|
uint16 c = READ_LE_UINT16(file);
|
|
|
|
loadLevelShpDat(_levelShpList[c], _levelDatList[c], false);
|
|
|
|
|
|
|
|
uint8 *d = file + 2;
|
|
|
|
size = (size - 2) / 12;
|
|
|
|
for (uint32 i = 0; i < size; i++) {
|
|
|
|
c = READ_LE_UINT16(d);
|
|
|
|
d += 2;
|
|
|
|
_wllVmpMap[c] = *d;
|
|
|
|
d += 2;
|
|
|
|
|
|
|
|
if (mapShapes) {
|
|
|
|
int16 sh = (int16) READ_LE_UINT16(d);
|
2009-02-14 13:55:00 +00:00
|
|
|
if (sh > 0)
|
2011-12-11 00:57:03 +00:00
|
|
|
_wllShapeMap[c] = assignLevelDecorationShapes(sh);
|
2009-01-18 17:04:24 +00:00
|
|
|
else
|
|
|
|
_wllShapeMap[c] = *d;
|
|
|
|
}
|
|
|
|
d += 2;
|
2010-02-07 16:12:31 +00:00
|
|
|
_specialWallTypes[c] = *d;
|
2009-01-18 17:04:24 +00:00
|
|
|
d += 2;
|
2009-01-19 07:31:34 +00:00
|
|
|
_wllWallFlags[c] = *d;
|
2009-01-18 17:04:24 +00:00
|
|
|
d += 2;
|
2011-12-11 00:57:03 +00:00
|
|
|
_wllAutomapData[c] = *d;
|
2009-02-14 13:55:00 +00:00
|
|
|
d += 2;
|
2009-01-18 17:04:24 +00:00
|
|
|
}
|
|
|
|
|
2009-01-18 17:38:29 +00:00
|
|
|
delete[] file;
|
2009-01-18 17:04:24 +00:00
|
|
|
|
|
|
|
delete _lvlShpFileHandle;
|
2009-02-14 13:55:00 +00:00
|
|
|
_lvlShpFileHandle = 0;
|
2009-01-18 17:04:24 +00:00
|
|
|
}
|
|
|
|
|
2011-12-11 00:57:03 +00:00
|
|
|
int LoLEngine::assignLevelDecorationShapes(int index) {
|
2009-05-29 12:52:03 +00:00
|
|
|
uint16 *p1 = (uint16 *)_tempBuffer5120;
|
|
|
|
uint16 *p2 = (uint16 *)(_tempBuffer5120 + 4000);
|
2009-01-18 17:04:24 +00:00
|
|
|
|
|
|
|
uint16 r = p2[index];
|
|
|
|
if (r)
|
|
|
|
return r;
|
|
|
|
|
2011-12-11 00:57:03 +00:00
|
|
|
uint16 o = _mappedDecorationsCount++;
|
2009-01-18 17:04:24 +00:00
|
|
|
|
2011-12-11 00:57:03 +00:00
|
|
|
memcpy(&_levelDecorationProperties[o], &_levelDecorationData[index], sizeof(LevelDecorationProperty));
|
2009-02-14 13:55:00 +00:00
|
|
|
|
2009-01-18 17:04:24 +00:00
|
|
|
for (int i = 0; i < 10; i++) {
|
2011-12-11 00:57:03 +00:00
|
|
|
uint16 t = _levelDecorationProperties[o].shapeIndex[i];
|
2009-01-18 17:04:24 +00:00
|
|
|
if (t == 0xffff)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
uint16 pv = p1[t];
|
|
|
|
if (pv) {
|
2011-12-11 00:57:03 +00:00
|
|
|
_levelDecorationProperties[o].shapeIndex[i] = pv;
|
2009-01-18 17:04:24 +00:00
|
|
|
} else {
|
2011-09-13 19:46:23 +00:00
|
|
|
releaseDecorations(_lvlShapeIndex, 1);
|
2011-12-11 00:57:03 +00:00
|
|
|
_levelDecorationShapes[_lvlShapeIndex] = getLevelDecorationShapes(t);
|
2009-01-18 17:04:24 +00:00
|
|
|
p1[t] = _lvlShapeIndex;
|
2011-12-11 00:57:03 +00:00
|
|
|
_levelDecorationProperties[o].shapeIndex[i] = _lvlShapeIndex++;
|
2009-01-18 17:04:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
p2[index] = o;
|
2011-12-11 00:57:03 +00:00
|
|
|
if (_levelDecorationProperties[o].next)
|
|
|
|
_levelDecorationProperties[o].next = assignLevelDecorationShapes(_levelDecorationProperties[o].next);
|
2009-01-18 17:04:24 +00:00
|
|
|
|
|
|
|
return o;
|
|
|
|
}
|
|
|
|
|
2011-12-11 00:57:03 +00:00
|
|
|
uint8 *LoLEngine::getLevelDecorationShapes(int shapeIndex) {
|
|
|
|
if (_decorationCount <= shapeIndex)
|
2009-01-18 17:04:24 +00:00
|
|
|
return 0;
|
|
|
|
|
2009-01-22 16:56:22 +00:00
|
|
|
_lvlShpFileHandle->seek(shapeIndex * 4 + 2, SEEK_SET);
|
|
|
|
uint32 offs = _lvlShpFileHandle->readUint32LE() + 2;
|
|
|
|
_lvlShpFileHandle->seek(offs, SEEK_SET);
|
2009-01-18 17:04:24 +00:00
|
|
|
|
|
|
|
uint8 tmp[16];
|
|
|
|
_lvlShpFileHandle->read(tmp, 16);
|
|
|
|
uint16 size = _screen->getShapeSize(tmp);
|
|
|
|
|
2009-01-22 16:56:22 +00:00
|
|
|
_lvlShpFileHandle->seek(offs, SEEK_SET);
|
2009-01-18 17:04:24 +00:00
|
|
|
uint8 *res = new uint8[size];
|
|
|
|
_lvlShpFileHandle->read(res, size);
|
2009-02-14 13:55:00 +00:00
|
|
|
|
2009-01-18 17:04:24 +00:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2011-09-13 19:46:23 +00:00
|
|
|
void LoLEngine::releaseDecorations(int first, int num) {
|
|
|
|
for (int i = first; i < (first + num); i++) {
|
|
|
|
delete[] _levelDecorationShapes[i];
|
|
|
|
_levelDecorationShapes[i] = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-11-11 23:05:19 +00:00
|
|
|
void LoLEngine::loadBlockProperties(const char *cmzFile) {
|
2009-01-19 07:31:34 +00:00
|
|
|
memset(_levelBlockProperties, 0, 1024 * sizeof(LevelBlockProperty));
|
2009-11-11 23:05:19 +00:00
|
|
|
_screen->loadBitmap(cmzFile, 2, 2, 0);
|
2009-01-18 17:04:24 +00:00
|
|
|
const uint8 *h = _screen->getCPagePtr(2);
|
|
|
|
uint16 len = READ_LE_UINT16(&h[4]);
|
|
|
|
const uint8 *p = h + 6;
|
2009-02-14 13:55:00 +00:00
|
|
|
|
2009-01-18 17:04:24 +00:00
|
|
|
for (int i = 0; i < 1024; i++) {
|
|
|
|
for (int ii = 0; ii < 4; ii++)
|
2009-01-19 07:31:34 +00:00
|
|
|
_levelBlockProperties[i].walls[ii] = p[i * len + ii];
|
2009-01-18 17:04:24 +00:00
|
|
|
|
2009-03-01 14:45:30 +00:00
|
|
|
_levelBlockProperties[i].direction = 5;
|
2009-01-18 17:04:24 +00:00
|
|
|
|
2011-12-11 00:57:03 +00:00
|
|
|
if (_wllAutomapData[_levelBlockProperties[i].walls[0]] == 17) {
|
2009-01-19 07:31:34 +00:00
|
|
|
_levelBlockProperties[i].flags &= 0xef;
|
|
|
|
_levelBlockProperties[i].flags |= 0x20;
|
2009-01-18 17:04:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-08-21 18:26:07 +00:00
|
|
|
const uint8 *LoLEngine::getBlockFileData(int levelIndex) {
|
|
|
|
_screen->loadBitmap(Common::String::format("LEVEL%d.CMZ", levelIndex).c_str(), 15, 15, 0);
|
2011-12-12 17:54:41 +00:00
|
|
|
return _screen->getCPagePtr(14);
|
2011-08-21 18:26:07 +00:00
|
|
|
}
|
|
|
|
|
2009-01-18 17:04:24 +00:00
|
|
|
void LoLEngine::loadLevelShpDat(const char *shpFile, const char *datFile, bool flag) {
|
|
|
|
memset(_tempBuffer5120, 0, 5120);
|
|
|
|
|
2009-01-23 04:57:18 +00:00
|
|
|
_lvlShpFileHandle = _res->createReadStream(shpFile);
|
2011-12-11 00:57:03 +00:00
|
|
|
_decorationCount = _lvlShpFileHandle->readUint16LE();
|
2009-01-18 17:04:24 +00:00
|
|
|
|
2009-01-23 04:57:18 +00:00
|
|
|
Common::SeekableReadStream *s = _res->createReadStream(datFile);
|
2009-01-18 17:04:24 +00:00
|
|
|
|
2011-12-11 00:57:03 +00:00
|
|
|
_levelDecorationDataSize = s->readUint16LE();
|
|
|
|
delete[] _levelDecorationData;
|
|
|
|
_levelDecorationData = new LevelDecorationProperty[_levelDecorationDataSize];
|
|
|
|
for (int i = 0; i < _levelDecorationDataSize; i++) {
|
2011-12-31 04:11:33 +00:00
|
|
|
LevelDecorationProperty *l = &_levelDecorationData[i];
|
2009-01-18 17:04:24 +00:00
|
|
|
for (int ii = 0; ii < 10; ii++)
|
|
|
|
l->shapeIndex[ii] = s->readUint16LE();
|
|
|
|
for (int ii = 0; ii < 10; ii++)
|
|
|
|
l->scaleFlag[ii] = s->readByte();
|
|
|
|
for (int ii = 0; ii < 10; ii++)
|
2009-03-24 07:18:16 +00:00
|
|
|
l->shapeX[ii] = s->readSint16LE();
|
2009-01-18 17:04:24 +00:00
|
|
|
for (int ii = 0; ii < 10; ii++)
|
2009-03-24 07:18:16 +00:00
|
|
|
l->shapeY[ii] = s->readSint16LE();
|
2009-01-18 17:04:24 +00:00
|
|
|
l->next = s->readByte();
|
|
|
|
l->flags = s->readByte();
|
|
|
|
}
|
|
|
|
|
2009-01-18 17:31:25 +00:00
|
|
|
delete s;
|
2009-01-18 17:04:24 +00:00
|
|
|
|
|
|
|
if (!flag) {
|
2011-12-11 00:57:03 +00:00
|
|
|
_mappedDecorationsCount = 1;
|
2009-01-18 17:04:24 +00:00
|
|
|
_lvlShapeIndex = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-01-18 23:50:31 +00:00
|
|
|
void LoLEngine::loadLevelGraphics(const char *file, int specialColor, int weight, int vcnLen, int vmpLen, const char *palFile) {
|
2009-01-18 17:04:24 +00:00
|
|
|
if (file) {
|
|
|
|
_lastSpecialColor = specialColor;
|
|
|
|
_lastSpecialColorWeight = weight;
|
2009-09-20 23:25:39 +00:00
|
|
|
strcpy(_lastBlockDataFile, file);
|
2009-01-18 23:50:31 +00:00
|
|
|
if (palFile) {
|
|
|
|
strcpy(_lastOverridePalFile, palFile);
|
|
|
|
_lastOverridePalFilePtr = _lastOverridePalFile;
|
2009-01-18 17:04:24 +00:00
|
|
|
} else {
|
2009-01-18 23:50:31 +00:00
|
|
|
_lastOverridePalFilePtr = 0;
|
2009-01-18 17:04:24 +00:00
|
|
|
}
|
|
|
|
}
|
2009-02-14 13:55:00 +00:00
|
|
|
|
2009-09-19 13:17:55 +00:00
|
|
|
if (_flags.use16ColorMode) {
|
2009-10-02 21:27:10 +00:00
|
|
|
if (_lastSpecialColor == 1)
|
|
|
|
_lastSpecialColor = 0x44;
|
|
|
|
else if (_lastSpecialColor == 0x66)
|
2009-09-20 23:38:35 +00:00
|
|
|
_lastSpecialColor = scumm_stricmp(file, "YVEL2") ? 0xcc : 0x44;
|
2009-09-19 13:17:55 +00:00
|
|
|
else if (_lastSpecialColor == 0x6b)
|
2009-09-20 23:25:39 +00:00
|
|
|
_lastSpecialColor = 0xcc;
|
2009-09-19 13:17:55 +00:00
|
|
|
else
|
2009-09-20 23:25:39 +00:00
|
|
|
_lastSpecialColor = 0x44;
|
2009-09-19 13:17:55 +00:00
|
|
|
}
|
|
|
|
|
2011-06-09 17:09:54 +00:00
|
|
|
Common::String fname;
|
2009-09-19 13:17:55 +00:00
|
|
|
const uint8 *v = 0;
|
|
|
|
int tlen = 0;
|
|
|
|
|
|
|
|
if (_flags.use16ColorMode) {
|
2011-06-09 17:09:54 +00:00
|
|
|
fname = Common::String::format("%s.VCF", _lastBlockDataFile);
|
|
|
|
_screen->loadBitmap(fname.c_str(), 3, 3, 0);
|
2009-09-19 13:17:55 +00:00
|
|
|
v = _screen->getCPagePtr(2);
|
|
|
|
tlen = READ_LE_UINT16(v) << 5;
|
|
|
|
v += 2;
|
2009-01-18 17:04:24 +00:00
|
|
|
|
2009-10-02 23:13:47 +00:00
|
|
|
delete[] _vcfBlocks;
|
2009-09-19 13:17:55 +00:00
|
|
|
_vcfBlocks = new uint8[tlen];
|
|
|
|
|
|
|
|
memcpy(_vcfBlocks, v, tlen);
|
|
|
|
}
|
|
|
|
|
2011-06-09 17:09:54 +00:00
|
|
|
fname = Common::String::format("%s.VCN", _lastBlockDataFile);
|
|
|
|
_screen->loadBitmap(fname.c_str(), 3, 3, 0);
|
2009-09-19 13:17:55 +00:00
|
|
|
v = _screen->getCPagePtr(2);
|
|
|
|
tlen = READ_LE_UINT16(v);
|
2009-01-18 17:04:24 +00:00
|
|
|
v += 2;
|
|
|
|
|
|
|
|
if (vcnLen == -1)
|
|
|
|
vcnLen = tlen << 5;
|
|
|
|
|
2009-10-02 23:13:47 +00:00
|
|
|
delete[] _vcnBlocks;
|
2009-01-18 17:04:24 +00:00
|
|
|
_vcnBlocks = new uint8[vcnLen];
|
|
|
|
|
2009-10-13 19:48:41 +00:00
|
|
|
if (!_flags.use16ColorMode) {
|
2009-10-02 23:13:47 +00:00
|
|
|
delete[] _vcnShift;
|
2009-09-19 23:51:19 +00:00
|
|
|
_vcnShift = new uint8[tlen];
|
|
|
|
|
|
|
|
memcpy(_vcnShift, v, tlen);
|
|
|
|
v += tlen;
|
|
|
|
|
2012-02-13 17:39:50 +00:00
|
|
|
memcpy(_vcnColTable, v, 128);
|
2009-09-19 13:17:55 +00:00
|
|
|
v += 128;
|
|
|
|
|
|
|
|
if (_lastOverridePalFilePtr) {
|
|
|
|
_res->loadFileToBuf(_lastOverridePalFilePtr, _screen->getPalette(0).getData(), 384);
|
|
|
|
} else {
|
|
|
|
_screen->getPalette(0).copy(v, 0, 128);
|
|
|
|
}
|
2009-01-18 17:04:24 +00:00
|
|
|
|
2009-09-19 23:51:19 +00:00
|
|
|
v += 384;
|
2010-01-25 01:39:44 +00:00
|
|
|
}
|
2009-02-14 13:55:00 +00:00
|
|
|
|
2009-03-24 07:18:16 +00:00
|
|
|
if (_currentLevel == 11) {
|
2009-10-08 19:42:39 +00:00
|
|
|
if (_flags.use16ColorMode) {
|
|
|
|
_screen->loadPalette("LOLICE.NOL", _screen->getPalette(2));
|
|
|
|
|
|
|
|
} else {
|
|
|
|
_screen->loadPalette("SWAMPICE.COL", _screen->getPalette(2));
|
|
|
|
_screen->getPalette(2).copy(_screen->getPalette(0), 128);
|
|
|
|
}
|
2009-03-24 07:18:16 +00:00
|
|
|
|
2009-06-07 20:43:43 +00:00
|
|
|
if (_flagsTable[52] & 0x04) {
|
2009-06-22 02:35:45 +00:00
|
|
|
uint8 *pal0 = _screen->getPalette(0).getData();
|
|
|
|
uint8 *pal2 = _screen->getPalette(2).getData();
|
2009-10-08 19:42:39 +00:00
|
|
|
for (int i = 1; i < _screen->getPalette(0).getNumColors() * 3; i++)
|
2009-03-24 07:18:16 +00:00
|
|
|
SWAP(pal0[i], pal2[i]);
|
2009-04-04 21:10:35 +00:00
|
|
|
}
|
2009-03-24 07:18:16 +00:00
|
|
|
}
|
2009-01-18 17:04:24 +00:00
|
|
|
|
|
|
|
memcpy(_vcnBlocks, v, vcnLen);
|
|
|
|
v += vcnLen;
|
|
|
|
|
2011-06-09 17:09:54 +00:00
|
|
|
fname = Common::String::format("%s.VMP", _lastBlockDataFile);
|
|
|
|
_screen->loadBitmap(fname.c_str(), 3, 3, 0);
|
2009-01-18 17:04:24 +00:00
|
|
|
v = _screen->getCPagePtr(2);
|
|
|
|
|
|
|
|
if (vmpLen == -1)
|
|
|
|
vmpLen = READ_LE_UINT16(v);
|
|
|
|
v += 2;
|
|
|
|
|
2009-10-02 23:13:47 +00:00
|
|
|
delete[] _vmpPtr;
|
2009-01-18 17:04:24 +00:00
|
|
|
_vmpPtr = new uint16[vmpLen];
|
|
|
|
|
|
|
|
for (int i = 0; i < vmpLen; i++)
|
|
|
|
_vmpPtr[i] = READ_LE_UINT16(&v[i << 1]);
|
|
|
|
|
2009-09-30 21:46:00 +00:00
|
|
|
Palette tpal(256);
|
2009-10-02 21:27:10 +00:00
|
|
|
if (_flags.use16ColorMode) {
|
|
|
|
uint8 *dst = tpal.getData();
|
2009-10-13 19:48:41 +00:00
|
|
|
_res->loadFileToBuf("LOL.NOL", dst, 48);
|
2009-10-02 21:27:10 +00:00
|
|
|
for (int i = 1; i < 16; i++) {
|
|
|
|
int s = ((i << 4) | i) * 3;
|
|
|
|
SWAP(dst[s], dst[i * 3]);
|
|
|
|
SWAP(dst[s + 1], dst[i * 3 + 1]);
|
|
|
|
SWAP(dst[s + 2], dst[i * 3 + 2]);
|
|
|
|
}
|
2009-10-13 19:48:41 +00:00
|
|
|
} else {
|
|
|
|
tpal.copy(_screen->getPalette(0));
|
2009-10-02 21:27:10 +00:00
|
|
|
}
|
|
|
|
|
2009-01-18 17:04:24 +00:00
|
|
|
for (int i = 0; i < 7; i++) {
|
|
|
|
weight = 100 - (i * _lastSpecialColorWeight);
|
|
|
|
weight = (weight > 0) ? (weight * 255) / 100 : 0;
|
2010-08-03 16:22:12 +00:00
|
|
|
_screen->generateOverlay(tpal, _screen->getLevelOverlay(i), _lastSpecialColor, weight);
|
2009-01-18 17:04:24 +00:00
|
|
|
|
2009-09-20 23:25:39 +00:00
|
|
|
int l = _flags.use16ColorMode ? 256 : 128;
|
2009-09-20 23:56:42 +00:00
|
|
|
uint8 *levelOverlay = _screen->getLevelOverlay(i);
|
2009-09-20 23:25:39 +00:00
|
|
|
for (int ii = 0; ii < l; ii++) {
|
2009-09-20 23:56:42 +00:00
|
|
|
if (levelOverlay[ii] == 255)
|
|
|
|
levelOverlay[ii] = 0;
|
2009-01-18 17:04:24 +00:00
|
|
|
}
|
|
|
|
|
2009-09-20 23:25:39 +00:00
|
|
|
for (int ii = l; ii < 256; ii++)
|
2009-09-20 23:56:42 +00:00
|
|
|
levelOverlay[ii] = ii & 0xff;
|
2009-01-18 17:04:24 +00:00
|
|
|
}
|
|
|
|
|
2009-09-20 23:56:42 +00:00
|
|
|
uint8 *levelOverlay = _screen->getLevelOverlay(7);
|
2009-01-18 17:04:24 +00:00
|
|
|
for (int i = 0; i < 256; i++)
|
2009-09-20 23:56:42 +00:00
|
|
|
levelOverlay[i] = i & 0xff;
|
2009-01-18 17:04:24 +00:00
|
|
|
|
2009-09-19 13:17:55 +00:00
|
|
|
if (_flags.use16ColorMode) {
|
2009-09-20 23:25:39 +00:00
|
|
|
_screen->getLevelOverlay(6)[0xee] = 0xee;
|
2009-09-20 23:56:42 +00:00
|
|
|
if (_lastSpecialColor == 0x44)
|
2009-09-20 23:25:39 +00:00
|
|
|
_screen->getLevelOverlay(5)[0xee] = 0xee;
|
2009-09-19 13:17:55 +00:00
|
|
|
|
|
|
|
for (int i = 0; i < 7; i++)
|
|
|
|
memcpy(_screen->getLevelOverlay(i), _screen->getLevelOverlay(i + 1), 256);
|
|
|
|
|
2009-09-20 23:25:39 +00:00
|
|
|
_screen->loadPalette("LOL.NOL", _screen->getPalette(0));
|
|
|
|
|
2009-09-19 13:17:55 +00:00
|
|
|
for (int i = 0; i < 8; i++) {
|
|
|
|
uint8 *pl = _screen->getLevelOverlay(7 - i);
|
2009-09-20 23:25:39 +00:00
|
|
|
for (int ii = 0; ii < 16; ii++)
|
2012-02-13 17:39:50 +00:00
|
|
|
_vcnColTable[(i << 4) + ii] = pl[(ii << 4) | ii];
|
2009-09-19 13:17:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-01-18 17:04:24 +00:00
|
|
|
_loadSuppFilesFlag = 0;
|
2009-06-29 16:06:31 +00:00
|
|
|
generateBrightnessPalette(_screen->getPalette(0), _screen->getPalette(1), _brightness, _lampEffect);
|
2009-01-18 17:04:24 +00:00
|
|
|
|
2009-09-03 21:03:10 +00:00
|
|
|
if (_flags.isTalkie) {
|
2011-06-09 17:09:54 +00:00
|
|
|
Common::SeekableReadStream *s = _res->createReadStream(Common::String::format("LEVEL%.02d.TLC", _currentLevel));
|
2009-11-11 23:05:19 +00:00
|
|
|
s->read(_transparencyTable1, 256);
|
|
|
|
s->read(_transparencyTable2, 5120);
|
2009-09-02 06:24:01 +00:00
|
|
|
delete s;
|
|
|
|
} else {
|
2009-11-11 23:05:19 +00:00
|
|
|
createTransparencyTables();
|
2009-09-02 06:24:01 +00:00
|
|
|
}
|
2009-01-18 17:04:24 +00:00
|
|
|
|
|
|
|
_loadSuppFilesFlag = 1;
|
|
|
|
}
|
|
|
|
|
2009-01-19 23:35:27 +00:00
|
|
|
void LoLEngine::resetItems(int flag) {
|
|
|
|
for (int i = 0; i < 1024; i++) {
|
2009-03-01 14:45:30 +00:00
|
|
|
_levelBlockProperties[i].direction = 5;
|
2009-03-15 16:48:20 +00:00
|
|
|
uint16 id = _levelBlockProperties[i].assignedObjects;
|
2011-12-12 19:10:57 +00:00
|
|
|
LoLObject *r = 0;
|
2009-01-19 23:35:27 +00:00
|
|
|
|
|
|
|
while (id & 0x8000) {
|
2011-12-12 19:10:57 +00:00
|
|
|
r = findObject(id);
|
2009-03-15 16:48:20 +00:00
|
|
|
id = r->nextAssignedObject;
|
2009-01-19 23:35:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!id)
|
|
|
|
continue;
|
|
|
|
|
2011-12-12 19:10:57 +00:00
|
|
|
LoLItem *it = &_itemsInPlay[id];
|
2009-01-19 23:35:27 +00:00
|
|
|
it->level = _currentLevel;
|
2009-04-25 13:15:05 +00:00
|
|
|
it->block = i;
|
2009-03-24 07:18:16 +00:00
|
|
|
if (r)
|
|
|
|
r->nextAssignedObject = 0;
|
2009-01-19 23:35:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (flag)
|
2009-03-24 07:18:16 +00:00
|
|
|
memset(_flyingObjects, 0, 8 * sizeof(FlyingObject));
|
2009-01-19 23:35:27 +00:00
|
|
|
}
|
|
|
|
|
2009-03-24 07:18:16 +00:00
|
|
|
void LoLEngine::disableMonsters() {
|
2011-12-12 19:10:57 +00:00
|
|
|
memset(_monsters, 0, 30 * sizeof(LoLMonster));
|
2009-01-19 23:35:27 +00:00
|
|
|
for (int i = 0; i < 30; i++)
|
2009-03-01 14:45:30 +00:00
|
|
|
_monsters[i].mode = 0x10;
|
2009-01-19 23:35:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void LoLEngine::resetBlockProperties() {
|
|
|
|
for (int i = 0; i < 1024; i++) {
|
|
|
|
LevelBlockProperty *l = &_levelBlockProperties[i];
|
|
|
|
if (l->flags & 0x10) {
|
|
|
|
l->flags &= 0xef;
|
|
|
|
if (testWallInvisibility(i, 0) && testWallInvisibility(i, 1))
|
|
|
|
l->flags |= 0x40;
|
|
|
|
} else {
|
|
|
|
if (l->flags & 0x40)
|
|
|
|
l->flags &= 0xbf;
|
|
|
|
else if (l->flags & 0x80)
|
2009-02-14 13:55:00 +00:00
|
|
|
l->flags &= 0x7f;
|
2009-01-19 23:35:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-02-14 00:51:07 +00:00
|
|
|
bool LoLEngine::testWallFlag(int block, int direction, int flag) {
|
|
|
|
if (_levelBlockProperties[block].flags & 0x10)
|
|
|
|
return true;
|
|
|
|
|
2009-02-14 13:55:00 +00:00
|
|
|
if (direction != -1)
|
2009-02-14 00:51:07 +00:00
|
|
|
return (_wllWallFlags[_levelBlockProperties[block].walls[direction ^ 2]] & flag) ? true : false;
|
|
|
|
|
|
|
|
for (int i = 0; i < 4; i++) {
|
|
|
|
if (_wllWallFlags[_levelBlockProperties[block].walls[i]] & flag)
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-02-14 13:55:00 +00:00
|
|
|
return false;
|
2009-02-14 00:51:07 +00:00
|
|
|
}
|
|
|
|
|
2009-01-19 23:35:27 +00:00
|
|
|
bool LoLEngine::testWallInvisibility(int block, int direction) {
|
|
|
|
uint8 w = _levelBlockProperties[block].walls[direction];
|
|
|
|
if (_wllVmpMap[w] || _wllShapeMap[w] || _levelBlockProperties[block].flags & 0x80)
|
|
|
|
return false;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-02-01 19:27:01 +00:00
|
|
|
void LoLEngine::resetLampStatus() {
|
2009-06-07 20:43:43 +00:00
|
|
|
_flagsTable[31] |= 0x04;
|
2009-04-03 21:32:50 +00:00
|
|
|
_lampEffect = -1;
|
2009-01-18 17:04:24 +00:00
|
|
|
updateLampStatus();
|
|
|
|
}
|
|
|
|
|
2009-02-01 19:27:01 +00:00
|
|
|
void LoLEngine::setLampMode(bool lampOn) {
|
2009-06-07 20:43:43 +00:00
|
|
|
_flagsTable[31] &= 0xFB;
|
2009-12-26 14:12:38 +00:00
|
|
|
if (!(_flagsTable[31] & 0x08) || !lampOn)
|
2009-02-01 19:27:01 +00:00
|
|
|
return;
|
|
|
|
|
2009-09-05 14:15:36 +00:00
|
|
|
_screen->drawShape(0, _gameShapes[_flags.isTalkie ? 43 : 41], 291, 56, 0, 0);
|
2009-03-28 11:58:22 +00:00
|
|
|
_lampEffect = 8;
|
2009-02-01 19:27:01 +00:00
|
|
|
}
|
|
|
|
|
2009-01-18 17:04:24 +00:00
|
|
|
void LoLEngine::updateLampStatus() {
|
2009-12-26 14:12:38 +00:00
|
|
|
int8 newLampEffect = 0;
|
2009-04-03 21:32:50 +00:00
|
|
|
uint8 tmpOilStatus = 0;
|
2009-01-18 17:04:24 +00:00
|
|
|
|
2009-06-07 20:43:43 +00:00
|
|
|
if ((_updateFlags & 4) || !(_flagsTable[31] & 0x08))
|
2009-01-18 17:04:24 +00:00
|
|
|
return;
|
|
|
|
|
2009-03-28 11:58:22 +00:00
|
|
|
if (!_brightness || !_lampOilStatus) {
|
2009-04-03 21:32:50 +00:00
|
|
|
newLampEffect = 8;
|
|
|
|
if (newLampEffect != _lampEffect && _screen->_fadeFlag == 0)
|
2009-06-29 16:06:18 +00:00
|
|
|
setPaletteBrightness(_screen->getPalette(0), _brightness, newLampEffect);
|
2009-01-18 17:04:24 +00:00
|
|
|
} else {
|
2009-04-03 21:32:50 +00:00
|
|
|
tmpOilStatus = (_lampOilStatus < 100) ? _lampOilStatus : 100;
|
|
|
|
newLampEffect = (3 - ((tmpOilStatus - 1) / 25)) << 1;
|
2009-01-18 17:04:24 +00:00
|
|
|
|
2009-04-03 21:32:50 +00:00
|
|
|
if (_lampEffect == -1) {
|
2009-01-18 17:04:24 +00:00
|
|
|
if (_screen->_fadeFlag == 0)
|
2009-06-29 16:06:18 +00:00
|
|
|
setPaletteBrightness(_screen->getPalette(0), _brightness, newLampEffect);
|
2009-07-08 20:32:34 +00:00
|
|
|
_lampStatusTimer = _system->getMillis() + (10 + rollDice(1, 30)) * _tickLength;
|
2009-01-18 17:04:24 +00:00
|
|
|
} else {
|
2009-04-03 21:32:50 +00:00
|
|
|
if ((_lampEffect & 0xfe) == (newLampEffect & 0xfe)) {
|
2009-01-18 17:04:24 +00:00
|
|
|
if (_system->getMillis() <= _lampStatusTimer) {
|
2009-04-03 21:32:50 +00:00
|
|
|
newLampEffect = _lampEffect;
|
2009-01-18 17:04:24 +00:00
|
|
|
} else {
|
2009-04-03 21:32:50 +00:00
|
|
|
newLampEffect = _lampEffect ^ 1;
|
2009-07-08 20:32:34 +00:00
|
|
|
_lampStatusTimer = _system->getMillis() + (10 + rollDice(1, 30)) * _tickLength;
|
2009-01-18 17:04:24 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (_screen->_fadeFlag == 0)
|
2009-12-24 18:41:26 +00:00
|
|
|
setPaletteBrightness(_screen->getPalette(0), _brightness, newLampEffect);
|
2009-01-18 17:04:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-04-03 21:32:50 +00:00
|
|
|
if (newLampEffect == _lampEffect)
|
2009-01-18 17:04:24 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
_screen->hideMouse();
|
|
|
|
|
2009-09-05 14:15:36 +00:00
|
|
|
_screen->drawShape(_screen->_curPage, _gameShapes[(_flags.isTalkie ? 35 : 33) + newLampEffect], 291, 56, 0, 0);
|
2009-01-18 17:04:24 +00:00
|
|
|
_screen->showMouse();
|
|
|
|
|
2009-04-03 21:32:50 +00:00
|
|
|
_lampEffect = newLampEffect;
|
2009-01-18 17:04:24 +00:00
|
|
|
}
|
|
|
|
|
2009-02-01 19:27:01 +00:00
|
|
|
void LoLEngine::updateCompass() {
|
2009-06-07 20:43:43 +00:00
|
|
|
if (!(_flagsTable[31] & 0x40) || (_updateFlags & 4))
|
2009-04-04 21:10:35 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (_compassDirection == -1) {
|
|
|
|
_compassStep = 0;
|
|
|
|
gui_drawCompass();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_compassTimer >= _system->getMillis())
|
|
|
|
return;
|
2009-02-14 13:55:00 +00:00
|
|
|
|
2009-04-04 21:10:35 +00:00
|
|
|
if ((_currentDirection << 6) == _compassDirection && (!_compassStep))
|
|
|
|
return;
|
|
|
|
|
|
|
|
_compassTimer = _system->getMillis() + 3 * _tickLength;
|
|
|
|
int dir = _compassStep >= 0 ? 1 : -1;
|
|
|
|
if (_compassStep)
|
|
|
|
_compassStep -= (((ABS(_compassStep) >> 4) + 2) * dir);
|
|
|
|
|
2009-06-18 21:47:10 +00:00
|
|
|
int16 d = _compassBroken ? (int8(_rnd.getRandomNumber(255)) - _compassDirection) : (_currentDirection << 6) - _compassDirection;
|
2009-04-04 21:10:35 +00:00
|
|
|
if (d <= -128)
|
|
|
|
d += 256;
|
|
|
|
if (d >= 128)
|
|
|
|
d -= 256;
|
|
|
|
|
|
|
|
d >>= 2;
|
|
|
|
_compassStep += d;
|
|
|
|
_compassStep = CLIP(_compassStep, -24, 24);
|
|
|
|
_compassDirection += _compassStep;
|
|
|
|
|
|
|
|
if (_compassDirection < 0)
|
|
|
|
_compassDirection += 256;
|
|
|
|
if (_compassDirection > 255)
|
|
|
|
_compassDirection -= 256;
|
|
|
|
|
|
|
|
if ((_compassDirection >> 6) == _currentDirection && _compassStep < 2) {
|
|
|
|
int16 d2 = d >> 16;
|
|
|
|
d ^= d2;
|
|
|
|
d -= d2;
|
|
|
|
if (d < 4) {
|
|
|
|
_compassDirection = _currentDirection << 6;
|
|
|
|
_compassStep = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
gui_drawCompass();
|
2009-02-01 19:27:01 +00:00
|
|
|
}
|
|
|
|
|
2009-02-14 00:51:07 +00:00
|
|
|
void LoLEngine::moveParty(uint16 direction, int unk1, int unk2, int buttonShape) {
|
|
|
|
if (buttonShape)
|
|
|
|
gui_toggleButtonDisplayMode(buttonShape, 1);
|
|
|
|
|
|
|
|
uint16 opos = _currentBlock;
|
2009-02-23 20:17:53 +00:00
|
|
|
uint16 npos = calcNewBlockPosition(_currentBlock, direction);
|
2009-02-14 13:55:00 +00:00
|
|
|
|
2009-02-14 00:51:07 +00:00
|
|
|
if (!checkBlockPassability(npos, direction)) {
|
|
|
|
notifyBlockNotPassable(unk2 ? 0 : 1);
|
|
|
|
gui_toggleButtonDisplayMode(buttonShape, 0);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
_scriptDirection = direction;
|
|
|
|
_currentBlock = npos;
|
|
|
|
_sceneDefaultUpdate = 1;
|
|
|
|
|
2009-02-14 14:33:26 +00:00
|
|
|
calcCoordinates(_partyPosX, _partyPosY, _currentBlock, 0x80, 0x80);
|
2009-06-07 20:43:43 +00:00
|
|
|
_flagsTable[73] &= 0xFD;
|
2009-02-14 13:55:00 +00:00
|
|
|
|
2009-02-21 23:20:14 +00:00
|
|
|
runLevelScript(opos, 4);
|
|
|
|
runLevelScript(npos, 1);
|
2009-02-14 00:51:07 +00:00
|
|
|
|
2009-06-07 20:43:43 +00:00
|
|
|
if (!(_flagsTable[73] & 0x02)) {
|
2009-02-14 13:55:00 +00:00
|
|
|
initTextFading(2, 0);
|
2009-02-14 00:51:07 +00:00
|
|
|
|
|
|
|
if (_sceneDefaultUpdate) {
|
|
|
|
switch (unk2) {
|
2009-05-17 23:51:42 +00:00
|
|
|
case 0:
|
|
|
|
movePartySmoothScrollUp(2);
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
movePartySmoothScrollDown(2);
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
movePartySmoothScrollLeft(1);
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
movePartySmoothScrollRight(1);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2009-02-14 00:51:07 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
gui_drawScene(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
gui_toggleButtonDisplayMode(buttonShape, 0);
|
|
|
|
|
2009-02-14 14:33:26 +00:00
|
|
|
if (npos == _currentBlock) {
|
2009-02-21 23:20:14 +00:00
|
|
|
runLevelScript(opos, 8);
|
|
|
|
runLevelScript(npos, 2);
|
2009-02-14 00:51:07 +00:00
|
|
|
|
2009-02-14 14:33:26 +00:00
|
|
|
if (_levelBlockProperties[npos].walls[0] == 0x1a)
|
|
|
|
memset(_levelBlockProperties[npos].walls, 0, 4);
|
2009-04-04 21:10:35 +00:00
|
|
|
}
|
2009-02-14 00:51:07 +00:00
|
|
|
}
|
|
|
|
|
2009-03-14 15:06:02 +00:00
|
|
|
updateAutoMap(_currentBlock);
|
2009-01-19 07:31:34 +00:00
|
|
|
}
|
|
|
|
|
2009-03-01 14:45:30 +00:00
|
|
|
uint16 LoLEngine::calcBlockIndex(uint16 x, uint16 y) {
|
2009-05-31 15:42:26 +00:00
|
|
|
return (((y & 0xff00) >> 3) | (x >> 8)) & 0x3ff;
|
2009-03-01 14:45:30 +00:00
|
|
|
}
|
|
|
|
|
2009-03-21 14:30:25 +00:00
|
|
|
void LoLEngine::calcCoordinates(uint16 &x, uint16 &y, int block, uint16 xOffs, uint16 yOffs) {
|
2009-03-01 14:45:30 +00:00
|
|
|
x = (block & 0x1f) << 8 | xOffs;
|
|
|
|
y = ((block & 0xffe0) << 3) | yOffs;
|
|
|
|
}
|
|
|
|
|
2009-04-04 00:19:34 +00:00
|
|
|
void LoLEngine::calcCoordinatesForSingleCharacter(int charNum, uint16 &x, uint16 &y) {
|
2009-03-21 14:30:25 +00:00
|
|
|
static const uint8 xOffsets[] = { 0x80, 0x00, 0x00, 0x40, 0xC0, 0x00, 0x40, 0x80, 0xC0 };
|
|
|
|
int c = countActiveCharacters();
|
|
|
|
if (!c)
|
|
|
|
return;
|
|
|
|
|
|
|
|
c = (c - 1) * 3 + charNum;
|
|
|
|
|
|
|
|
x = xOffsets[c];
|
|
|
|
y = 0x80;
|
|
|
|
|
|
|
|
calcCoordinatesAddDirectionOffset(x, y, _currentDirection);
|
|
|
|
|
|
|
|
x |= (_partyPosX & 0xff00);
|
|
|
|
y |= (_partyPosY & 0xff00);
|
|
|
|
}
|
|
|
|
|
2009-04-04 00:19:34 +00:00
|
|
|
void LoLEngine::calcCoordinatesAddDirectionOffset(uint16 &x, uint16 &y, int direction) {
|
2009-03-21 14:30:25 +00:00
|
|
|
if (!direction)
|
|
|
|
return;
|
|
|
|
|
2009-04-04 00:19:34 +00:00
|
|
|
int tx = x;
|
|
|
|
int ty = y;
|
|
|
|
|
2009-03-21 14:30:25 +00:00
|
|
|
if (direction & 1)
|
2009-04-04 00:19:34 +00:00
|
|
|
SWAP(tx, ty);
|
2009-03-21 14:30:25 +00:00
|
|
|
|
2009-04-04 00:19:34 +00:00
|
|
|
if (direction != 1)
|
|
|
|
ty = (ty - 256) * -1;
|
2009-03-21 14:30:25 +00:00
|
|
|
|
2009-04-04 00:19:34 +00:00
|
|
|
if (direction != 3) {
|
|
|
|
tx = (tx - 256) * -1;
|
2009-03-21 14:30:25 +00:00
|
|
|
}
|
2009-04-04 00:19:34 +00:00
|
|
|
|
|
|
|
x = tx;
|
|
|
|
y = ty;
|
2009-03-21 14:30:25 +00:00
|
|
|
}
|
|
|
|
|
2009-02-14 00:51:07 +00:00
|
|
|
bool LoLEngine::checkBlockPassability(uint16 block, uint16 direction) {
|
|
|
|
if (testWallFlag(block, direction, 1))
|
|
|
|
return false;
|
|
|
|
|
2009-03-15 16:48:20 +00:00
|
|
|
uint16 d = _levelBlockProperties[block].assignedObjects;
|
2009-02-14 00:51:07 +00:00
|
|
|
|
|
|
|
while (d) {
|
|
|
|
if (d & 0x8000)
|
|
|
|
return false;
|
2009-03-15 16:48:20 +00:00
|
|
|
d = findObject(d)->nextAssignedObject;
|
2009-02-14 00:51:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void LoLEngine::notifyBlockNotPassable(int scrollFlag) {
|
|
|
|
if (scrollFlag)
|
|
|
|
movePartySmoothScrollBlocked(2);
|
|
|
|
|
2009-02-16 17:17:15 +00:00
|
|
|
snd_stopSpeech(true);
|
2009-08-16 17:35:59 +00:00
|
|
|
_txt->printMessage(0x8002, "%s", getLangString(0x403f));
|
2009-02-23 20:17:53 +00:00
|
|
|
snd_playSoundEffect(19, -1);
|
|
|
|
}
|
|
|
|
|
2009-03-01 14:45:30 +00:00
|
|
|
int LoLEngine::clickedDoorSwitch(uint16 block, uint16 direction) {
|
2009-02-23 20:17:53 +00:00
|
|
|
uint8 v = _wllShapeMap[_levelBlockProperties[block].walls[direction]];
|
|
|
|
if (!clickedShape(v))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
snd_playSoundEffect(78, -1);
|
2009-05-21 22:29:49 +00:00
|
|
|
_blockDoor = 0;
|
2009-02-23 20:17:53 +00:00
|
|
|
runLevelScript(block, 0x40);
|
|
|
|
|
2009-05-21 22:29:49 +00:00
|
|
|
if (!_blockDoor) {
|
2009-02-23 20:17:53 +00:00
|
|
|
delay(15 * _tickLength);
|
2009-03-06 22:53:08 +00:00
|
|
|
processDoorSwitch(block, 0);
|
2009-02-23 20:17:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2009-04-03 21:32:50 +00:00
|
|
|
int LoLEngine::clickedNiche(uint16 block, uint16 direction) {
|
2009-04-04 00:19:34 +00:00
|
|
|
uint8 v = _wllShapeMap[_levelBlockProperties[block].walls[direction]];
|
|
|
|
if (!clickedShape(v) || !_itemInHand)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
uint16 x = 0x80;
|
|
|
|
uint16 y = 0xff;
|
|
|
|
calcCoordinatesAddDirectionOffset(x, y, _currentDirection);
|
|
|
|
calcCoordinates(x, y, block, x, y);
|
|
|
|
setItemPosition(_itemInHand, x, y, 8, 1);
|
|
|
|
setHandItem(0);
|
2009-03-01 14:45:30 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2009-02-14 00:51:07 +00:00
|
|
|
void LoLEngine::movePartySmoothScrollBlocked(int speed) {
|
2009-03-28 11:58:22 +00:00
|
|
|
if (!_smoothScrollingEnabled || (_smoothScrollingEnabled && _needSceneRestore))
|
2009-02-14 00:51:07 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
_screen->backupSceneWindow(_sceneDrawPage2 == 2 ? 2 : 6, 6);
|
|
|
|
|
|
|
|
for (int i = 0; i < 2; i++) {
|
2009-06-02 00:07:11 +00:00
|
|
|
uint32 delayTimer = _system->getMillis() + speed * _tickLength;
|
2009-02-14 00:51:07 +00:00
|
|
|
_screen->smoothScrollZoomStepTop(6, 2, _scrollXTop[i], _scrollYTop[i]);
|
|
|
|
_screen->smoothScrollZoomStepBottom(6, 2, _scrollXBottom[i], _scrollYBottom[i]);
|
|
|
|
_screen->restoreSceneWindow(2, 0);
|
|
|
|
_screen->updateScreen();
|
2009-02-14 13:55:00 +00:00
|
|
|
fadeText();
|
2009-06-02 00:07:11 +00:00
|
|
|
delayUntil(delayTimer);
|
2009-02-14 00:51:07 +00:00
|
|
|
if (!_smoothScrollModeNormal)
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int i = 2; i; i--) {
|
2009-06-02 00:07:11 +00:00
|
|
|
uint32 delayTimer = _system->getMillis() + speed * _tickLength;
|
2009-02-14 00:51:07 +00:00
|
|
|
_screen->smoothScrollZoomStepTop(6, 2, _scrollXTop[i], _scrollYTop[i]);
|
|
|
|
_screen->smoothScrollZoomStepBottom(6, 2, _scrollXBottom[i], _scrollYBottom[i]);
|
|
|
|
_screen->restoreSceneWindow(2, 0);
|
|
|
|
_screen->updateScreen();
|
2009-02-14 13:55:00 +00:00
|
|
|
fadeText();
|
2009-06-02 00:07:11 +00:00
|
|
|
delayUntil(delayTimer);
|
2009-02-14 00:51:07 +00:00
|
|
|
if (!_smoothScrollModeNormal)
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_sceneDefaultUpdate != 2) {
|
|
|
|
_screen->restoreSceneWindow(6, 0);
|
|
|
|
_screen->updateScreen();
|
|
|
|
}
|
|
|
|
|
2009-03-28 11:58:22 +00:00
|
|
|
updateDrawPage2();
|
2009-02-14 00:51:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void LoLEngine::movePartySmoothScrollUp(int speed) {
|
2009-03-28 11:58:22 +00:00
|
|
|
if (!_smoothScrollingEnabled || (_smoothScrollingEnabled && _needSceneRestore))
|
2009-02-14 00:51:07 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
int d = 0;
|
|
|
|
|
|
|
|
if (_sceneDrawPage2 == 2) {
|
2009-05-25 22:58:05 +00:00
|
|
|
d = smoothScrollDrawSpecialGuiShape(6);
|
2009-02-14 00:51:07 +00:00
|
|
|
gui_drawScene(6);
|
2009-03-28 11:58:22 +00:00
|
|
|
_screen->backupSceneWindow(6, 12);
|
2009-02-14 00:51:07 +00:00
|
|
|
_screen->backupSceneWindow(2, 6);
|
|
|
|
} else {
|
2009-05-25 22:58:05 +00:00
|
|
|
d = smoothScrollDrawSpecialGuiShape(2);
|
2009-02-14 00:51:07 +00:00
|
|
|
gui_drawScene(2);
|
2009-03-28 11:58:22 +00:00
|
|
|
_screen->backupSceneWindow(2, 12);
|
2009-02-14 00:51:07 +00:00
|
|
|
_screen->backupSceneWindow(6, 6);
|
|
|
|
}
|
2009-02-14 13:55:00 +00:00
|
|
|
|
2009-02-14 00:51:07 +00:00
|
|
|
for (int i = 0; i < 5; i++) {
|
2009-06-02 00:07:11 +00:00
|
|
|
uint32 delayTimer = _system->getMillis() + speed * _tickLength;
|
2009-02-14 00:51:07 +00:00
|
|
|
_screen->smoothScrollZoomStepTop(6, 2, _scrollXTop[i], _scrollYTop[i]);
|
|
|
|
_screen->smoothScrollZoomStepBottom(6, 2, _scrollXBottom[i], _scrollYBottom[i]);
|
|
|
|
|
2009-05-25 22:58:05 +00:00
|
|
|
if (d)
|
2009-05-30 15:52:09 +00:00
|
|
|
_screen->copyGuiShapeToSurface(14, 2);
|
2009-02-14 13:55:00 +00:00
|
|
|
|
2009-02-14 00:51:07 +00:00
|
|
|
_screen->restoreSceneWindow(2, 0);
|
|
|
|
_screen->updateScreen();
|
|
|
|
fadeText();
|
2009-06-02 00:07:11 +00:00
|
|
|
delayUntil(delayTimer);
|
2009-02-14 00:51:07 +00:00
|
|
|
if (!_smoothScrollModeNormal)
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
2009-05-25 22:58:05 +00:00
|
|
|
if (d)
|
2009-05-30 15:52:09 +00:00
|
|
|
_screen->copyGuiShapeToSurface(14, 12);
|
2009-02-14 00:51:07 +00:00
|
|
|
|
|
|
|
if (_sceneDefaultUpdate != 2) {
|
2009-03-28 11:58:22 +00:00
|
|
|
_screen->restoreSceneWindow(12, 0);
|
2009-02-14 00:51:07 +00:00
|
|
|
_screen->updateScreen();
|
|
|
|
}
|
|
|
|
|
2009-03-28 11:58:22 +00:00
|
|
|
updateDrawPage2();
|
2009-02-14 00:51:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void LoLEngine::movePartySmoothScrollDown(int speed) {
|
2009-03-21 14:30:25 +00:00
|
|
|
if (!_smoothScrollingEnabled)
|
2009-02-14 00:51:07 +00:00
|
|
|
return;
|
|
|
|
|
2009-05-25 22:58:05 +00:00
|
|
|
int d = smoothScrollDrawSpecialGuiShape(2);
|
2009-02-14 00:51:07 +00:00
|
|
|
gui_drawScene(2);
|
|
|
|
_screen->backupSceneWindow(2, 6);
|
|
|
|
|
|
|
|
for (int i = 4; i >= 0; i--) {
|
2009-06-02 00:07:11 +00:00
|
|
|
uint32 delayTimer = _system->getMillis() + speed * _tickLength;
|
2009-02-14 00:51:07 +00:00
|
|
|
_screen->smoothScrollZoomStepTop(6, 2, _scrollXTop[i], _scrollYTop[i]);
|
|
|
|
_screen->smoothScrollZoomStepBottom(6, 2, _scrollXBottom[i], _scrollYBottom[i]);
|
|
|
|
|
2009-05-25 22:58:05 +00:00
|
|
|
if (d)
|
2009-05-30 15:52:09 +00:00
|
|
|
_screen->copyGuiShapeToSurface(14, 2);
|
2009-02-14 13:55:00 +00:00
|
|
|
|
2009-02-14 00:51:07 +00:00
|
|
|
_screen->restoreSceneWindow(2, 0);
|
|
|
|
_screen->updateScreen();
|
|
|
|
fadeText();
|
2009-06-02 00:07:11 +00:00
|
|
|
delayUntil(delayTimer);
|
2009-02-14 00:51:07 +00:00
|
|
|
if (!_smoothScrollModeNormal)
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
2009-05-25 22:58:05 +00:00
|
|
|
if (d)
|
2009-05-30 15:52:09 +00:00
|
|
|
_screen->copyGuiShapeToSurface(14, 12);
|
2009-02-14 00:51:07 +00:00
|
|
|
|
|
|
|
if (_sceneDefaultUpdate != 2) {
|
|
|
|
_screen->restoreSceneWindow(6, 0);
|
|
|
|
_screen->updateScreen();
|
|
|
|
}
|
|
|
|
|
2009-03-28 11:58:22 +00:00
|
|
|
updateDrawPage2();
|
2009-02-14 00:51:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void LoLEngine::movePartySmoothScrollLeft(int speed) {
|
2009-03-21 14:30:25 +00:00
|
|
|
if (!_smoothScrollingEnabled)
|
2009-02-14 00:51:07 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
speed <<= 1;
|
|
|
|
|
|
|
|
gui_drawScene(_sceneDrawPage1);
|
|
|
|
|
|
|
|
for (int i = 88, d = 88; i > 22; i -= 22, d += 22) {
|
2009-06-02 00:07:11 +00:00
|
|
|
uint32 delayTimer = _system->getMillis() + speed * _tickLength;
|
2009-02-14 00:51:07 +00:00
|
|
|
_screen->smoothScrollHorizontalStep(_sceneDrawPage2, 66, d, i);
|
|
|
|
_screen->copyRegion(112 + i, 0, 112, 0, d, 120, _sceneDrawPage1, _sceneDrawPage2, Screen::CR_NO_P_CHECK);
|
|
|
|
_screen->copyRegion(112, 0, 112, 0, 176, 120, _sceneDrawPage2, 0, Screen::CR_NO_P_CHECK);
|
|
|
|
_screen->updateScreen();
|
|
|
|
fadeText();
|
2009-06-02 00:07:11 +00:00
|
|
|
delayUntil(delayTimer);
|
2009-02-14 00:51:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (_sceneDefaultUpdate != 2) {
|
|
|
|
_screen->copyRegion(112, 0, 112, 0, 176, 120, _sceneDrawPage1, 0, Screen::CR_NO_P_CHECK);
|
|
|
|
_screen->updateScreen();
|
|
|
|
}
|
|
|
|
|
|
|
|
SWAP(_sceneDrawPage1, _sceneDrawPage2);
|
|
|
|
}
|
|
|
|
|
|
|
|
void LoLEngine::movePartySmoothScrollRight(int speed) {
|
2009-03-21 14:30:25 +00:00
|
|
|
if (!_smoothScrollingEnabled)
|
2009-02-14 00:51:07 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
speed <<= 1;
|
|
|
|
|
|
|
|
gui_drawScene(_sceneDrawPage1);
|
|
|
|
|
2009-06-02 00:07:11 +00:00
|
|
|
uint32 delayTimer = _system->getMillis() + speed * _tickLength;
|
2009-02-14 00:51:07 +00:00
|
|
|
_screen->copyRegion(112, 0, 222, 0, 66, 120, _sceneDrawPage1, _sceneDrawPage2, Screen::CR_NO_P_CHECK);
|
|
|
|
_screen->copyRegion(112, 0, 112, 0, 176, 120, _sceneDrawPage2, 0, Screen::CR_NO_P_CHECK);
|
|
|
|
_screen->updateScreen();
|
|
|
|
fadeText();
|
2009-06-02 00:07:11 +00:00
|
|
|
delayUntil(delayTimer);
|
2009-02-14 00:51:07 +00:00
|
|
|
|
2009-06-02 00:07:11 +00:00
|
|
|
delayTimer = _system->getMillis() + speed * _tickLength;
|
2009-02-14 00:51:07 +00:00
|
|
|
_screen->smoothScrollHorizontalStep(_sceneDrawPage2, 22, 0, 66);
|
|
|
|
_screen->copyRegion(112, 0, 200, 0, 88, 120, _sceneDrawPage1, _sceneDrawPage2, Screen::CR_NO_P_CHECK);
|
|
|
|
_screen->copyRegion(112, 0, 112, 0, 176, 120, _sceneDrawPage2, 0, Screen::CR_NO_P_CHECK);
|
|
|
|
_screen->updateScreen();
|
|
|
|
fadeText();
|
2009-06-02 00:07:11 +00:00
|
|
|
delayUntil(delayTimer);
|
2009-02-14 00:51:07 +00:00
|
|
|
|
2009-06-02 00:07:11 +00:00
|
|
|
delayTimer = _system->getMillis() + speed * _tickLength;
|
2009-02-14 00:51:07 +00:00
|
|
|
_screen->smoothScrollHorizontalStep(_sceneDrawPage2, 44, 0, 22);
|
|
|
|
_screen->copyRegion(112, 0, 178, 0, 110, 120, _sceneDrawPage1, _sceneDrawPage2, Screen::CR_NO_P_CHECK);
|
|
|
|
_screen->copyRegion(112, 0, 112, 0, 176, 120, _sceneDrawPage2, 0, Screen::CR_NO_P_CHECK);
|
|
|
|
_screen->updateScreen();
|
|
|
|
fadeText();
|
2009-06-02 00:07:11 +00:00
|
|
|
delayUntil(delayTimer);
|
2009-02-14 00:51:07 +00:00
|
|
|
|
|
|
|
if (_sceneDefaultUpdate != 2) {
|
|
|
|
_screen->copyRegion(112, 0, 112, 0, 176, 120, _sceneDrawPage1, 0, Screen::CR_NO_P_CHECK);
|
|
|
|
_screen->updateScreen();
|
|
|
|
}
|
|
|
|
|
|
|
|
SWAP(_sceneDrawPage1, _sceneDrawPage2);
|
|
|
|
}
|
|
|
|
|
|
|
|
void LoLEngine::movePartySmoothScrollTurnLeft(int speed) {
|
2009-03-21 14:30:25 +00:00
|
|
|
if (!_smoothScrollingEnabled)
|
2009-02-14 00:51:07 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
speed <<= 1;
|
|
|
|
|
2009-05-25 22:58:05 +00:00
|
|
|
int d = smoothScrollDrawSpecialGuiShape(_sceneDrawPage1);
|
2009-02-14 00:51:07 +00:00
|
|
|
gui_drawScene(_sceneDrawPage1);
|
2009-05-29 12:52:03 +00:00
|
|
|
int dp = _sceneDrawPage2 == 2 ? _sceneDrawPage2 : _sceneDrawPage1;
|
2009-02-14 00:51:07 +00:00
|
|
|
|
2009-06-02 00:07:11 +00:00
|
|
|
uint32 delayTimer = _system->getMillis() + speed * _tickLength;
|
2009-02-14 00:51:07 +00:00
|
|
|
_screen->smoothScrollTurnStep1(_sceneDrawPage1, _sceneDrawPage2, dp);
|
2009-05-25 22:58:05 +00:00
|
|
|
if (d)
|
2009-05-30 15:52:09 +00:00
|
|
|
_screen->copyGuiShapeToSurface(14, dp);
|
2009-02-14 00:51:07 +00:00
|
|
|
_screen->restoreSceneWindow(dp, 0);
|
|
|
|
_screen->updateScreen();
|
|
|
|
fadeText();
|
2009-06-02 00:07:11 +00:00
|
|
|
delayUntil(delayTimer);
|
2009-02-14 00:51:07 +00:00
|
|
|
|
2009-06-02 00:07:11 +00:00
|
|
|
delayTimer = _system->getMillis() + speed * _tickLength;
|
2009-02-14 00:51:07 +00:00
|
|
|
_screen->smoothScrollTurnStep2(_sceneDrawPage1, _sceneDrawPage2, dp);
|
2009-05-25 22:58:05 +00:00
|
|
|
if (d)
|
2009-05-30 15:52:09 +00:00
|
|
|
_screen->copyGuiShapeToSurface(14, dp);
|
2009-02-14 00:51:07 +00:00
|
|
|
_screen->restoreSceneWindow(dp, 0);
|
|
|
|
_screen->updateScreen();
|
|
|
|
fadeText();
|
2009-06-02 00:07:11 +00:00
|
|
|
delayUntil(delayTimer);
|
2009-02-14 00:51:07 +00:00
|
|
|
|
2009-06-02 00:07:11 +00:00
|
|
|
delayTimer = _system->getMillis() + speed * _tickLength;
|
2009-02-14 00:51:07 +00:00
|
|
|
_screen->smoothScrollTurnStep3(_sceneDrawPage1, _sceneDrawPage2, dp);
|
2009-05-25 22:58:05 +00:00
|
|
|
if (d)
|
2009-05-30 15:52:09 +00:00
|
|
|
_screen->copyGuiShapeToSurface(14, dp);
|
2009-02-14 00:51:07 +00:00
|
|
|
_screen->restoreSceneWindow(dp, 0);
|
|
|
|
_screen->updateScreen();
|
|
|
|
fadeText();
|
2009-06-02 00:07:11 +00:00
|
|
|
delayUntil(delayTimer);
|
2009-02-14 00:51:07 +00:00
|
|
|
|
|
|
|
if (_sceneDefaultUpdate != 2) {
|
2009-05-25 22:58:05 +00:00
|
|
|
drawSpecialGuiShape(_sceneDrawPage1);
|
2009-02-14 00:51:07 +00:00
|
|
|
_screen->copyRegion(112, 0, 112, 0, 176, 120, _sceneDrawPage1, 0, Screen::CR_NO_P_CHECK);
|
|
|
|
_screen->updateScreen();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void LoLEngine::movePartySmoothScrollTurnRight(int speed) {
|
2009-03-21 14:30:25 +00:00
|
|
|
if (!_smoothScrollingEnabled)
|
2009-02-14 00:51:07 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
speed <<= 1;
|
|
|
|
|
2009-05-25 22:58:05 +00:00
|
|
|
int d = smoothScrollDrawSpecialGuiShape(_sceneDrawPage1);
|
2009-02-14 00:51:07 +00:00
|
|
|
gui_drawScene(_sceneDrawPage1);
|
|
|
|
int dp = _sceneDrawPage2 == 2 ? _sceneDrawPage2 : _sceneDrawPage1;
|
|
|
|
|
2009-06-02 00:07:11 +00:00
|
|
|
uint32 delayTimer = _system->getMillis() + speed * _tickLength;
|
2009-02-14 00:51:07 +00:00
|
|
|
_screen->smoothScrollTurnStep3(_sceneDrawPage2, _sceneDrawPage1, dp);
|
2009-05-25 22:58:05 +00:00
|
|
|
if (d)
|
2009-05-30 15:52:09 +00:00
|
|
|
_screen->copyGuiShapeToSurface(14, dp);
|
2009-02-14 00:51:07 +00:00
|
|
|
_screen->restoreSceneWindow(dp, 0);
|
|
|
|
_screen->updateScreen();
|
|
|
|
fadeText();
|
2009-06-02 00:07:11 +00:00
|
|
|
delayUntil(delayTimer);
|
2009-02-14 00:51:07 +00:00
|
|
|
|
2009-06-02 00:07:11 +00:00
|
|
|
delayTimer = _system->getMillis() + speed * _tickLength;
|
2009-02-14 00:51:07 +00:00
|
|
|
_screen->smoothScrollTurnStep2(_sceneDrawPage2, _sceneDrawPage1, dp);
|
2009-05-25 22:58:05 +00:00
|
|
|
if (d)
|
2009-05-30 15:52:09 +00:00
|
|
|
_screen->copyGuiShapeToSurface(14, dp);
|
2009-02-14 00:51:07 +00:00
|
|
|
_screen->restoreSceneWindow(dp, 0);
|
|
|
|
_screen->updateScreen();
|
|
|
|
fadeText();
|
2009-06-02 00:07:11 +00:00
|
|
|
delayUntil(delayTimer);
|
2009-02-14 00:51:07 +00:00
|
|
|
|
2009-06-02 00:07:11 +00:00
|
|
|
delayTimer = _system->getMillis() + speed * _tickLength;
|
2009-02-14 00:51:07 +00:00
|
|
|
_screen->smoothScrollTurnStep1(_sceneDrawPage2, _sceneDrawPage1, dp);
|
2009-05-25 22:58:05 +00:00
|
|
|
if (d)
|
2009-05-30 15:52:09 +00:00
|
|
|
_screen->copyGuiShapeToSurface(14, dp);
|
2009-02-14 00:51:07 +00:00
|
|
|
_screen->restoreSceneWindow(dp, 0);
|
|
|
|
_screen->updateScreen();
|
|
|
|
fadeText();
|
2009-06-02 00:07:11 +00:00
|
|
|
delayUntil(delayTimer);
|
2009-02-14 00:51:07 +00:00
|
|
|
|
|
|
|
if (_sceneDefaultUpdate != 2) {
|
2009-05-25 22:58:05 +00:00
|
|
|
drawSpecialGuiShape(_sceneDrawPage1);
|
2009-02-14 00:51:07 +00:00
|
|
|
_screen->copyRegion(112, 0, 112, 0, 176, 120, _sceneDrawPage1, 0, Screen::CR_NO_P_CHECK);
|
|
|
|
_screen->updateScreen();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-05-15 06:29:08 +00:00
|
|
|
void LoLEngine::pitDropScroll(int numSteps) {
|
|
|
|
_screen->copyRegionSpecial(0, 320, 200, 112, 0, 6, 176, 120, 0, 0, 176, 120, 0);
|
2009-06-01 23:53:30 +00:00
|
|
|
uint32 etime = 0;
|
2009-05-15 06:29:08 +00:00
|
|
|
|
|
|
|
for (int i = 0; i < numSteps; i++) {
|
2009-06-01 23:53:30 +00:00
|
|
|
etime = _system->getMillis() + _tickLength;
|
2009-05-15 06:29:08 +00:00
|
|
|
int ys = ((30720 / numSteps) * i) >> 8;
|
|
|
|
_screen->copyRegionSpecial(6, 176, 120, 0, ys, 0, 320, 200, 112, 0, 176, 120 - ys, 0);
|
|
|
|
_screen->copyRegionSpecial(2, 320, 200, 112, 0, 0, 320, 200, 112, 120 - ys, 176, ys, 0);
|
|
|
|
_screen->updateScreen();
|
|
|
|
|
2009-06-01 23:53:30 +00:00
|
|
|
delayUntil(etime);
|
2009-05-21 13:13:09 +00:00
|
|
|
}
|
2009-05-15 06:29:08 +00:00
|
|
|
|
2009-06-01 23:53:30 +00:00
|
|
|
etime = _system->getMillis() + _tickLength;
|
|
|
|
|
2009-05-15 06:29:08 +00:00
|
|
|
_screen->copyRegionSpecial(2, 320, 200, 112, 0, 0, 320, 200, 112, 0, 176, 120, 0);
|
|
|
|
_screen->updateScreen();
|
|
|
|
|
2009-06-01 23:53:30 +00:00
|
|
|
delayUntil(etime);
|
|
|
|
|
2009-05-15 06:29:08 +00:00
|
|
|
updateDrawPage2();
|
|
|
|
}
|
|
|
|
|
|
|
|
void LoLEngine::shakeScene(int duration, int width, int height, int restore) {
|
|
|
|
_screen->copyRegion(112, 0, 112, 0, 176, 120, 0, 6, Screen::CR_NO_P_CHECK);
|
|
|
|
uint32 endTime = _system->getMillis() + duration * _tickLength;
|
2009-05-21 13:13:09 +00:00
|
|
|
|
2009-05-15 06:29:08 +00:00
|
|
|
while (endTime > _system->getMillis()) {
|
2009-06-02 00:07:11 +00:00
|
|
|
uint32 delayTimer = _system->getMillis() + 2 * _tickLength;
|
2009-05-15 06:29:08 +00:00
|
|
|
|
2009-06-18 21:47:10 +00:00
|
|
|
int s1 = width ? (_rnd.getRandomNumber(255) % (width << 1)) - width : 0;
|
|
|
|
int s2 = height ? (_rnd.getRandomNumber(255) % (height << 1)) - height : 0;
|
2009-05-15 06:29:08 +00:00
|
|
|
|
|
|
|
int x1, y1, x2, y2, w, h;
|
|
|
|
if (s1 >= 0) {
|
|
|
|
x1 = 112;
|
2009-06-03 14:24:00 +00:00
|
|
|
x2 = 112 + s1;
|
2009-05-15 06:29:08 +00:00
|
|
|
w = 176 - s1;
|
|
|
|
} else {
|
|
|
|
x1 = 112 - s1;
|
2009-06-03 14:24:00 +00:00
|
|
|
x2 = 112;
|
2009-05-15 06:29:08 +00:00
|
|
|
w = 176 + s1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (s2 >= 0) {
|
|
|
|
y1 = 0;
|
2009-06-03 14:24:00 +00:00
|
|
|
y2 = s2;
|
2009-05-15 06:29:08 +00:00
|
|
|
h = 120 - s2;
|
|
|
|
} else {
|
|
|
|
y1 = -s2;
|
2009-06-03 14:24:00 +00:00
|
|
|
y2 = 0;
|
2009-05-15 06:29:08 +00:00
|
|
|
h = 120 + s2;
|
|
|
|
}
|
|
|
|
|
|
|
|
_screen->copyRegion(x1, y1, x2, y2, w, h, 6, 0, Screen::CR_NO_P_CHECK);
|
|
|
|
_screen->updateScreen();
|
2009-05-21 13:13:09 +00:00
|
|
|
|
2009-06-02 00:07:11 +00:00
|
|
|
delayUntil(delayTimer);
|
2009-05-15 06:29:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (restore) {
|
|
|
|
_screen->copyRegion(112, 0, 112, 0, 176, 120, 6, 0, Screen::CR_NO_P_CHECK);
|
|
|
|
_screen->updateScreen();
|
|
|
|
updateDrawPage2();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-05-30 15:52:09 +00:00
|
|
|
void LoLEngine::processGasExplosion(int soundId) {
|
|
|
|
int cp = _screen->setCurPage(2);
|
|
|
|
_screen->copyPage(0, 12);
|
|
|
|
|
|
|
|
static const uint8 sounds[] = { 0x62, 0xA7, 0xA7, 0xA8 };
|
|
|
|
snd_playSoundEffect(sounds[soundId], -1);
|
|
|
|
|
|
|
|
uint16 targetBlock = 0;
|
|
|
|
int dist = getSpellTargetBlock(_currentBlock, _currentDirection, 3, targetBlock);
|
|
|
|
|
2009-06-22 02:35:45 +00:00
|
|
|
uint8 *p1 = _screen->getPalette(1).getData();
|
|
|
|
uint8 *p2 = _screen->getPalette(3).getData();
|
2009-05-30 15:52:09 +00:00
|
|
|
|
|
|
|
if (dist) {
|
2009-06-09 11:26:15 +00:00
|
|
|
WSAMovie_v2 *mov = new WSAMovie_v2(this);
|
2011-06-09 17:09:54 +00:00
|
|
|
Common::String file = Common::String::format("gasexp%0d.wsa", dist);
|
|
|
|
mov->open(file.c_str(), 1, 0);
|
2009-05-30 15:52:09 +00:00
|
|
|
if (!mov->opened())
|
|
|
|
error("Gas: Unable to load gasexp.wsa");
|
|
|
|
|
|
|
|
playSpellAnimation(mov, 0, 6, 1, (176 - mov->width()) / 2 + 112, (120 - mov->height()) / 2, 0, 0, 0, 0, false);
|
|
|
|
|
|
|
|
mov->close();
|
|
|
|
delete mov;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
memcpy(p2, p1, 768);
|
|
|
|
|
|
|
|
for (int i = 1; i < 128; i++)
|
|
|
|
p2[i * 3] = 0x3f;
|
|
|
|
|
|
|
|
uint32 ctime = _system->getMillis();
|
2009-06-22 02:35:45 +00:00
|
|
|
while (_screen->fadePaletteStep(_screen->getPalette(0).getData(), p2, _system->getMillis() - ctime, 10))
|
2009-05-30 15:52:09 +00:00
|
|
|
updateInput();
|
|
|
|
|
|
|
|
ctime = _system->getMillis();
|
2009-06-22 02:35:45 +00:00
|
|
|
while (_screen->fadePaletteStep(p2, _screen->getPalette(0).getData(), _system->getMillis() - ctime, 50))
|
2009-05-30 15:52:09 +00:00
|
|
|
updateInput();
|
|
|
|
}
|
2009-06-02 00:10:13 +00:00
|
|
|
|
2009-05-30 15:52:09 +00:00
|
|
|
_screen->copyPage(12, 2);
|
|
|
|
_screen->setCurPage(cp);
|
|
|
|
|
|
|
|
updateDrawPage2();
|
|
|
|
_sceneUpdateRequired = true;
|
|
|
|
gui_drawScene(0);
|
|
|
|
}
|
|
|
|
|
2009-05-25 22:58:05 +00:00
|
|
|
int LoLEngine::smoothScrollDrawSpecialGuiShape(int pageNum) {
|
2009-09-30 16:16:53 +00:00
|
|
|
if (!_specialGuiShape)
|
2009-02-14 00:51:07 +00:00
|
|
|
return 0;
|
2009-05-25 22:58:05 +00:00
|
|
|
|
|
|
|
_screen->clearGuiShapeMemory(pageNum);
|
|
|
|
_screen->drawShape(pageNum, _specialGuiShape, _specialGuiShapeX, _specialGuiShapeY, 2, 0);
|
2009-05-30 15:52:09 +00:00
|
|
|
_screen->copyGuiShapeFromSceneBackupBuffer(pageNum, 14);
|
2009-05-25 22:58:05 +00:00
|
|
|
return 1;
|
2009-02-14 00:51:07 +00:00
|
|
|
}
|
|
|
|
|
2009-01-18 17:04:24 +00:00
|
|
|
void LoLEngine::drawScene(int pageNum) {
|
|
|
|
if (pageNum && pageNum != _sceneDrawPage1) {
|
2009-02-14 00:51:07 +00:00
|
|
|
SWAP(_sceneDrawPage1, _sceneDrawPage2);
|
2009-03-28 11:58:22 +00:00
|
|
|
updateDrawPage2();
|
2009-01-18 17:04:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (pageNum && pageNum != _sceneDrawPage1) {
|
2009-02-14 00:51:07 +00:00
|
|
|
SWAP(_sceneDrawPage1, _sceneDrawPage2);
|
2009-03-28 11:58:22 +00:00
|
|
|
updateDrawPage2();
|
2009-01-18 17:04:24 +00:00
|
|
|
}
|
|
|
|
|
2009-03-24 07:18:16 +00:00
|
|
|
generateBlockDrawingBuffer();
|
|
|
|
drawVcnBlocks();
|
2009-01-18 17:04:24 +00:00
|
|
|
drawSceneShapes();
|
|
|
|
|
2009-02-01 19:27:01 +00:00
|
|
|
if (!pageNum) {
|
2009-05-25 22:58:05 +00:00
|
|
|
drawSpecialGuiShape(_sceneDrawPage1);
|
2009-02-01 19:27:01 +00:00
|
|
|
_screen->copyRegion(112, 0, 112, 0, 176, 120, _sceneDrawPage1, _sceneDrawPage2, Screen::CR_NO_P_CHECK);
|
|
|
|
_screen->copyRegion(112, 0, 112, 0, 176, 120, _sceneDrawPage1, 0, Screen::CR_NO_P_CHECK);
|
2009-05-10 13:40:28 +00:00
|
|
|
_screen->updateScreen();
|
2009-02-14 00:51:07 +00:00
|
|
|
SWAP(_sceneDrawPage1, _sceneDrawPage2);
|
2009-01-18 17:04:24 +00:00
|
|
|
}
|
|
|
|
|
2009-03-03 22:32:39 +00:00
|
|
|
updateEnvironmentalSfx(0);
|
2009-01-18 17:04:24 +00:00
|
|
|
gui_drawCompass();
|
|
|
|
|
2009-02-01 19:27:01 +00:00
|
|
|
_sceneUpdateRequired = false;
|
2009-01-18 17:04:24 +00:00
|
|
|
}
|
|
|
|
|
2009-04-03 21:32:50 +00:00
|
|
|
|
2009-03-14 15:06:02 +00:00
|
|
|
void LoLEngine::setWallType(int block, int wall, int val) {
|
2009-03-09 01:57:42 +00:00
|
|
|
if (wall == -1) {
|
|
|
|
for (int i = 0; i < 4; i++)
|
|
|
|
_levelBlockProperties[block].walls[i] = val;
|
2011-12-11 00:57:03 +00:00
|
|
|
if (_wllAutomapData[val] == 17) {
|
2009-03-09 01:57:42 +00:00
|
|
|
_levelBlockProperties[block].flags &= 0xef;
|
|
|
|
_levelBlockProperties[block].flags |= 0x20;
|
|
|
|
} else {
|
|
|
|
_levelBlockProperties[block].flags &= 0xdf;
|
2009-04-04 21:10:35 +00:00
|
|
|
}
|
2009-03-09 01:57:42 +00:00
|
|
|
} else {
|
|
|
|
_levelBlockProperties[block].walls[wall] = val;
|
|
|
|
}
|
|
|
|
|
|
|
|
checkSceneUpdateNeed(block);
|
|
|
|
}
|
|
|
|
|
2009-03-28 11:58:22 +00:00
|
|
|
void LoLEngine::updateDrawPage2() {
|
2009-02-01 19:27:01 +00:00
|
|
|
_screen->copyRegion(112, 0, 112, 0, 176, 120, 0, _sceneDrawPage2, Screen::CR_NO_P_CHECK);
|
2009-01-18 17:04:24 +00:00
|
|
|
}
|
|
|
|
|
2009-03-24 07:18:16 +00:00
|
|
|
void LoLEngine::prepareSpecialScene(int fieldType, int hasDialogue, int suspendGui, int allowSceneUpdate, int controlMode, int fadeFlag) {
|
|
|
|
resetPortraitsAndDisableSysTimer();
|
|
|
|
if (fieldType) {
|
|
|
|
if (suspendGui)
|
|
|
|
gui_specialSceneSuspendControls(1);
|
|
|
|
|
|
|
|
if (!allowSceneUpdate)
|
|
|
|
_sceneDefaultUpdate = 0;
|
|
|
|
|
|
|
|
if (hasDialogue)
|
|
|
|
initDialogueSequence(fieldType, 0);
|
|
|
|
|
|
|
|
if (fadeFlag) {
|
2009-09-26 13:17:11 +00:00
|
|
|
if (_flags.use16ColorMode)
|
|
|
|
setPaletteBrightness(_screen->getPalette(0), _brightness, _lampEffect);
|
|
|
|
else
|
|
|
|
_screen->fadePalette(_screen->getPalette(3), 10);
|
2009-03-24 07:18:16 +00:00
|
|
|
_screen->_fadeFlag = 0;
|
|
|
|
}
|
2009-04-04 21:10:35 +00:00
|
|
|
|
2009-03-24 07:18:16 +00:00
|
|
|
setSpecialSceneButtons(0, 0, 320, 130, controlMode);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
if (suspendGui)
|
|
|
|
gui_specialSceneSuspendControls(0);
|
|
|
|
|
|
|
|
if (!allowSceneUpdate)
|
|
|
|
_sceneDefaultUpdate = 0;
|
|
|
|
|
|
|
|
gui_disableControls(controlMode);
|
|
|
|
|
|
|
|
if (fadeFlag) {
|
2009-09-20 23:25:39 +00:00
|
|
|
if (_flags.use16ColorMode) {
|
|
|
|
setPaletteBrightness(_screen->getPalette(0), _brightness, _lampEffect);
|
|
|
|
} else {
|
|
|
|
_screen->getPalette(3).copy(_screen->getPalette(0), 128);
|
|
|
|
_screen->loadSpecialColors(_screen->getPalette(3));
|
|
|
|
_screen->fadePalette(_screen->getPalette(3), 10);
|
|
|
|
}
|
2009-03-24 07:18:16 +00:00
|
|
|
_screen->_fadeFlag = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (hasDialogue)
|
|
|
|
initDialogueSequence(fieldType, 0);
|
|
|
|
|
|
|
|
setSpecialSceneButtons(112, 0, 176, 120, controlMode);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int LoLEngine::restoreAfterSpecialScene(int fadeFlag, int redrawPlayField, int releaseTimScripts, int sceneUpdateMode) {
|
2009-03-28 11:58:22 +00:00
|
|
|
if (!_needSceneRestore)
|
2009-03-24 07:18:16 +00:00
|
|
|
return 0;
|
|
|
|
|
2009-03-28 11:58:22 +00:00
|
|
|
_needSceneRestore = 0;
|
2009-03-24 07:18:16 +00:00
|
|
|
enableSysTimer(2);
|
|
|
|
|
|
|
|
if (_dialogueField)
|
|
|
|
restoreAfterDialogueSequence(_currentControlMode);
|
|
|
|
|
|
|
|
if (_specialSceneFlag)
|
|
|
|
gui_specialSceneRestoreControls(_currentControlMode);
|
|
|
|
|
|
|
|
int l = _currentControlMode;
|
|
|
|
_currentControlMode = 0;
|
|
|
|
|
|
|
|
gui_specialSceneRestoreButtons();
|
|
|
|
calcCharPortraitXpos();
|
|
|
|
|
|
|
|
_currentControlMode = l;
|
|
|
|
|
|
|
|
if (releaseTimScripts) {
|
|
|
|
for (int i = 0; i < TIM::kWSASlots; i++)
|
|
|
|
_tim->freeAnimStruct(i);
|
2009-04-04 21:10:35 +00:00
|
|
|
|
2009-03-24 07:18:16 +00:00
|
|
|
for (int i = 0; i < 10; i++)
|
|
|
|
_tim->unload(_activeTim[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
gui_enableControls();
|
|
|
|
|
|
|
|
if (fadeFlag) {
|
|
|
|
if ((_screen->_fadeFlag != 1 && _screen->_fadeFlag != 2) || (_screen->_fadeFlag == 1 && _currentControlMode)) {
|
|
|
|
if (_currentControlMode)
|
|
|
|
_screen->fadeToBlack(10);
|
|
|
|
else
|
|
|
|
_screen->fadeClearSceneWindow(10);
|
2009-04-04 21:10:35 +00:00
|
|
|
}
|
|
|
|
|
2009-03-24 07:18:16 +00:00
|
|
|
_currentControlMode = 0;
|
|
|
|
calcCharPortraitXpos();
|
|
|
|
|
|
|
|
if (redrawPlayField)
|
|
|
|
gui_drawPlayField();
|
|
|
|
|
2009-06-29 16:06:18 +00:00
|
|
|
setPaletteBrightness(_screen->getPalette(0), _brightness, _lampEffect);
|
2009-03-24 07:18:16 +00:00
|
|
|
|
|
|
|
} else {
|
|
|
|
_currentControlMode = 0;
|
|
|
|
calcCharPortraitXpos();
|
|
|
|
|
2009-04-04 21:10:35 +00:00
|
|
|
if (redrawPlayField)
|
2009-03-24 07:18:16 +00:00
|
|
|
gui_drawPlayField();
|
|
|
|
}
|
|
|
|
|
|
|
|
_sceneDefaultUpdate = sceneUpdateMode;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void LoLEngine::setSequenceButtons(int x, int y, int w, int h, int enableFlags) {
|
2009-02-14 00:51:07 +00:00
|
|
|
gui_enableSequenceButtons(x, y, w, h, enableFlags);
|
2009-03-10 00:32:20 +00:00
|
|
|
_seqWindowX1 = x;
|
|
|
|
_seqWindowY1 = y;
|
|
|
|
_seqWindowX2 = x + w;
|
|
|
|
_seqWindowY2 = y + h;
|
2009-02-14 00:51:07 +00:00
|
|
|
int offs = _itemInHand ? 10 : 0;
|
|
|
|
_screen->setMouseCursor(offs, offs, getItemIconShapePtr(_itemInHand));
|
2009-06-21 21:05:06 +00:00
|
|
|
_currentFloatingCursor = -1;
|
2009-04-03 21:32:50 +00:00
|
|
|
if (w == 320) {
|
|
|
|
setLampMode(0);
|
|
|
|
_lampStatusSuspended = true;
|
|
|
|
}
|
2009-02-14 00:51:07 +00:00
|
|
|
}
|
|
|
|
|
2009-03-24 07:18:16 +00:00
|
|
|
void LoLEngine::setSpecialSceneButtons(int x, int y, int w, int h, int enableFlags) {
|
|
|
|
gui_enableSequenceButtons(x, y, w, h, enableFlags);
|
|
|
|
_spsWindowX = x;
|
|
|
|
_spsWindowY = y;
|
|
|
|
_spsWindowW = w;
|
|
|
|
_spsWindowH = h;
|
|
|
|
}
|
|
|
|
|
|
|
|
void LoLEngine::setDefaultButtonState() {
|
2009-02-14 00:51:07 +00:00
|
|
|
gui_enableDefaultPlayfieldButtons();
|
2009-03-10 00:32:20 +00:00
|
|
|
_seqWindowX1 = _seqWindowY1 = _seqWindowX2 = _seqWindowY2 = _seqTrigger = 0;
|
2009-02-14 00:51:07 +00:00
|
|
|
if (_lampStatusSuspended)
|
|
|
|
resetLampStatus();
|
|
|
|
_lampStatusSuspended = false;
|
|
|
|
}
|
|
|
|
|
2011-11-06 16:02:52 +00:00
|
|
|
void LoLEngine::drawSceneShapes(int) {
|
2009-01-18 17:04:24 +00:00
|
|
|
for (int i = 0; i < 18; i++) {
|
|
|
|
uint8 t = _dscTileIndex[i];
|
2009-03-24 07:18:16 +00:00
|
|
|
uint8 s = _visibleBlocks[t]->walls[_sceneDrawVarDown];
|
2009-01-18 17:04:24 +00:00
|
|
|
|
2011-12-11 00:57:03 +00:00
|
|
|
_shpDmX1 = 0;
|
|
|
|
_shpDmX2 = 0;
|
2009-01-18 17:04:24 +00:00
|
|
|
|
|
|
|
int16 dimY1 = 0;
|
|
|
|
int16 dimY2 = 0;
|
|
|
|
|
2011-12-11 00:57:03 +00:00
|
|
|
setLevelShapesDim(t, _shpDmX1, _shpDmX2, _sceneShpDim);
|
2009-01-18 17:04:24 +00:00
|
|
|
|
2011-12-11 00:57:03 +00:00
|
|
|
if (_shpDmX2 <= _shpDmX1)
|
2009-01-18 17:04:24 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
drawDecorations(t);
|
|
|
|
|
2009-01-19 07:31:34 +00:00
|
|
|
uint16 w = _wllWallFlags[s];
|
2009-01-18 17:04:24 +00:00
|
|
|
|
2009-04-04 14:10:53 +00:00
|
|
|
if (t == 16)
|
2009-01-18 17:04:24 +00:00
|
|
|
w |= 0x80;
|
|
|
|
|
2009-03-21 20:24:36 +00:00
|
|
|
drawBlockEffects(t, 0);
|
2009-01-18 17:04:24 +00:00
|
|
|
|
2009-03-24 07:18:16 +00:00
|
|
|
if (_visibleBlocks[t]->assignedObjects && (w & 0x80))
|
2009-03-15 16:48:20 +00:00
|
|
|
drawBlockObjects(t);
|
2009-01-18 17:04:24 +00:00
|
|
|
|
2009-03-21 20:24:36 +00:00
|
|
|
drawBlockEffects(t, 1);
|
2009-01-18 17:04:24 +00:00
|
|
|
|
|
|
|
if (!(w & 8))
|
|
|
|
continue;
|
|
|
|
|
2010-02-09 21:09:29 +00:00
|
|
|
uint16 v = 20 * (s - (s < 23 ? _dscUnk2[s] : 0));
|
|
|
|
if (v > 80)
|
|
|
|
v = 80;
|
2009-02-14 13:55:00 +00:00
|
|
|
|
2012-02-15 17:11:18 +00:00
|
|
|
setDoorShapeDim(t, dimY1, dimY2, _sceneShpDim);
|
2010-02-09 21:09:29 +00:00
|
|
|
drawDoor(_doorShapes[(s < 23 ? _dscDoorShpIndex[s] : 0)], 0, t, 10, 0, -v, 2);
|
2011-12-11 00:57:03 +00:00
|
|
|
setLevelShapesDim(t, dimY1, dimY2, _sceneShpDim);
|
2009-01-18 17:04:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void LoLEngine::drawDecorations(int index) {
|
|
|
|
for (int i = 1; i >= 0; i--) {
|
|
|
|
int s = index * 2 + i;
|
|
|
|
uint16 scaleW = _dscShapeScaleW[s];
|
|
|
|
uint16 scaleH = _dscShapeScaleH[s];
|
|
|
|
int8 ix = _dscShapeIndex[s];
|
|
|
|
uint8 shpIx = ABS(ix);
|
2009-01-18 18:20:33 +00:00
|
|
|
uint8 ovlIndex = _dscShapeOvlIndex[4 + _dscDimMap[index] * 5] + 2;
|
2009-01-18 17:04:24 +00:00
|
|
|
if (ovlIndex > 7)
|
|
|
|
ovlIndex = 7;
|
|
|
|
|
|
|
|
if (!scaleW || !scaleH)
|
|
|
|
continue;
|
|
|
|
|
2011-12-11 00:57:03 +00:00
|
|
|
uint8 d = (_currentDirection + _dscWalls[s]) & 3;
|
2009-03-24 07:18:16 +00:00
|
|
|
int8 l = _wllShapeMap[_visibleBlocks[index]->walls[d]];
|
2009-01-18 17:04:24 +00:00
|
|
|
|
|
|
|
uint8 *shapeData = 0;
|
|
|
|
|
|
|
|
int x = 0;
|
|
|
|
int y = 0;
|
|
|
|
int flags = 0;
|
|
|
|
|
|
|
|
while (l > 0) {
|
2011-12-11 00:57:03 +00:00
|
|
|
if ((_levelDecorationProperties[l].flags & 8) && index != 3 && index != 9 && index != 13) {
|
|
|
|
l = _levelDecorationProperties[l].next;
|
2009-01-18 17:04:24 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2011-12-11 00:57:03 +00:00
|
|
|
if (_dscOvlMap[shpIx] == 1 && ((_levelDecorationProperties[l].flags & 2) || ((_levelDecorationProperties[l].flags & 4) && _wllProcessFlag)))
|
2009-01-18 17:04:24 +00:00
|
|
|
ix = -ix;
|
|
|
|
|
|
|
|
int xOffs = 0;
|
|
|
|
int yOffs = 0;
|
|
|
|
uint8 *ovl = 0;
|
|
|
|
|
2011-12-11 00:57:03 +00:00
|
|
|
if (_levelDecorationProperties[l].scaleFlag[shpIx] & 1) {
|
|
|
|
xOffs = _levelDecorationProperties[l].shapeX[shpIx];
|
|
|
|
yOffs = _levelDecorationProperties[l].shapeY[shpIx];
|
2009-01-18 17:04:24 +00:00
|
|
|
shpIx = _dscOvlMap[shpIx];
|
2009-09-20 23:25:39 +00:00
|
|
|
int ov = ovlIndex;
|
|
|
|
if (_flags.use16ColorMode) {
|
|
|
|
uint8 bb = _blockBrightness >> 4;
|
|
|
|
if (ov > bb)
|
|
|
|
ov -= bb;
|
2009-10-02 21:27:10 +00:00
|
|
|
else
|
2009-09-20 23:25:39 +00:00
|
|
|
ov = 0;
|
|
|
|
}
|
2011-12-12 17:54:41 +00:00
|
|
|
ovl = _screen->getLevelOverlay(ov);
|
2011-12-11 00:57:03 +00:00
|
|
|
} else if (_levelDecorationProperties[l].shapeIndex[shpIx] != 0xffff) {
|
2009-01-18 17:04:24 +00:00
|
|
|
scaleW = scaleH = 0x100;
|
2009-09-20 23:25:39 +00:00
|
|
|
int ov = 7;
|
|
|
|
if (_flags.use16ColorMode) {
|
|
|
|
uint8 bb = _blockBrightness >> 4;
|
|
|
|
if (ov > bb)
|
|
|
|
ov -= bb;
|
2009-10-02 21:27:10 +00:00
|
|
|
else
|
2009-09-20 23:25:39 +00:00
|
|
|
ov = 0;
|
|
|
|
}
|
2011-12-12 17:54:41 +00:00
|
|
|
ovl = _screen->getLevelOverlay(ov);
|
2009-01-18 17:04:24 +00:00
|
|
|
}
|
|
|
|
|
2011-12-11 00:57:03 +00:00
|
|
|
if (_levelDecorationProperties[l].shapeIndex[shpIx] != 0xffff) {
|
|
|
|
shapeData = _levelDecorationShapes[_levelDecorationProperties[l].shapeIndex[shpIx]];
|
2009-01-18 17:04:24 +00:00
|
|
|
if (shapeData) {
|
|
|
|
if (ix < 0) {
|
2011-12-11 00:57:03 +00:00
|
|
|
x = _dscShapeX[s] + xOffs + ((_levelDecorationProperties[l].shapeX[shpIx] * scaleW) >> 8);
|
2009-01-18 17:04:24 +00:00
|
|
|
if (ix == _dscShapeIndex[s]) {
|
2011-12-11 00:57:03 +00:00
|
|
|
x = _dscShapeX[s] - ((_levelDecorationProperties[l].shapeX[shpIx] * scaleW) >> 8) -
|
2011-12-31 04:11:33 +00:00
|
|
|
_screen->getShapeScaledWidth(shapeData, scaleW) - xOffs;
|
2009-01-18 17:04:24 +00:00
|
|
|
}
|
|
|
|
flags = 0x105;
|
|
|
|
} else {
|
2011-12-11 00:57:03 +00:00
|
|
|
x = _dscShapeX[s] + xOffs + ((_levelDecorationProperties[l].shapeX[shpIx] * scaleW) >> 8);
|
2009-01-18 17:04:24 +00:00
|
|
|
flags = 0x104;
|
|
|
|
}
|
|
|
|
|
2011-12-11 00:57:03 +00:00
|
|
|
y = _dscShapeY[s] + yOffs + ((_levelDecorationProperties[l].shapeY[shpIx] * scaleH) >> 8);
|
2011-12-12 17:54:41 +00:00
|
|
|
_screen->drawShape(_sceneDrawPage1, shapeData, x + 112, y, _sceneShpDim, flags, ovl, 1, scaleW, scaleH);
|
2009-01-18 17:04:24 +00:00
|
|
|
|
2011-12-11 00:57:03 +00:00
|
|
|
if ((_levelDecorationProperties[l].flags & 1) && shpIx < 4) {
|
2009-01-18 17:04:24 +00:00
|
|
|
//draw shadow
|
2011-12-12 17:54:41 +00:00
|
|
|
x += (_screen->getShapeScaledWidth(shapeData, scaleW));
|
2009-01-18 17:04:24 +00:00
|
|
|
flags ^= 1;
|
2011-12-12 17:54:41 +00:00
|
|
|
_screen->drawShape(_sceneDrawPage1, shapeData, x + 112, y, _sceneShpDim, flags, ovl, 1, scaleW, scaleH);
|
2009-01-18 17:04:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-12-11 00:57:03 +00:00
|
|
|
l = _levelDecorationProperties[l].next;
|
2009-01-18 17:04:24 +00:00
|
|
|
shpIx = (_dscShapeIndex[s] < 0) ? -_dscShapeIndex[s] : _dscShapeIndex[s];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-03-21 20:24:36 +00:00
|
|
|
void LoLEngine::drawBlockEffects(int index, int type) {
|
2009-04-04 00:19:34 +00:00
|
|
|
static const uint16 yOffs[] = { 0xff, 0xff, 0x80, 0x80 };
|
2009-03-24 07:18:16 +00:00
|
|
|
uint8 flg = _visibleBlocks[index]->flags;
|
2009-03-21 20:24:36 +00:00
|
|
|
// flags: 0x10 = ice wall, 0x20 = teleporter, 0x40 = blue slime spot, 0x80 = blood spot
|
|
|
|
if (!(flg & 0xf0))
|
2009-01-18 17:04:24 +00:00
|
|
|
return;
|
2009-04-04 21:10:35 +00:00
|
|
|
|
2009-03-21 20:24:36 +00:00
|
|
|
type = (type == 0) ? 2 : 0;
|
2009-04-04 21:10:35 +00:00
|
|
|
|
2009-03-21 20:24:36 +00:00
|
|
|
for (int i = 0; i < 2; i++, type++) {
|
|
|
|
if (!((0x10 << type) & flg))
|
|
|
|
continue;
|
|
|
|
|
2009-04-04 00:19:34 +00:00
|
|
|
uint16 x = 0x80;
|
|
|
|
uint16 y = yOffs[type];
|
2009-03-21 20:24:36 +00:00
|
|
|
uint16 drawFlag = (type == 3) ? 0x80 : 0x20;
|
|
|
|
uint8 *ovl = (type == 3) ? _screen->_grayOverlay : 0;
|
2009-04-04 21:10:35 +00:00
|
|
|
|
2009-10-09 21:35:48 +00:00
|
|
|
if (_flags.use16ColorMode) {
|
|
|
|
ovl = 0;
|
|
|
|
drawFlag = (type == 0 || type == 3) ? 0 : 0x20;
|
|
|
|
}
|
|
|
|
|
2009-03-21 20:24:36 +00:00
|
|
|
calcCoordinatesAddDirectionOffset(x, y, _currentDirection);
|
|
|
|
|
2009-03-24 07:18:16 +00:00
|
|
|
x |= ((_visibleBlockIndex[index] & 0x1f) << 8);
|
|
|
|
y |= ((_visibleBlockIndex[index] & 0xffe0) << 3);
|
2009-03-21 20:24:36 +00:00
|
|
|
|
|
|
|
drawItemOrMonster(_effectShapes[type], ovl, x, y, 0, (type == 1) ? -20 : 0, drawFlag, -1, false);
|
|
|
|
}
|
2009-01-18 17:04:24 +00:00
|
|
|
}
|
|
|
|
|
2009-05-25 22:58:05 +00:00
|
|
|
void LoLEngine::drawSpecialGuiShape(int pageNum) {
|
|
|
|
if (!_specialGuiShape)
|
2009-02-14 00:51:07 +00:00
|
|
|
return;
|
2009-05-25 22:58:05 +00:00
|
|
|
|
|
|
|
_screen->drawShape(pageNum, _specialGuiShape, _specialGuiShapeX, _specialGuiShapeY, 2, 0);
|
|
|
|
|
2009-05-28 23:49:41 +00:00
|
|
|
if (_specialGuiShapeMirrorFlag & 1)
|
2009-05-25 22:58:05 +00:00
|
|
|
_screen->drawShape(pageNum, _specialGuiShape, _specialGuiShapeX + _specialGuiShape[3], _specialGuiShapeY, 2, 1);
|
2009-01-18 17:04:24 +00:00
|
|
|
}
|
|
|
|
|
2009-10-04 21:26:33 +00:00
|
|
|
} // End of namespace Kyra
|
2009-01-18 17:04:24 +00:00
|
|
|
|
2009-03-04 11:53:25 +00:00
|
|
|
#endif // ENABLE_LOL
|