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.
|
|
|
|
*
|
|
|
|
* $URL$
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
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-19 23:35:27 +00:00
|
|
|
#include "kyra/sound.h"
|
2009-01-18 17:04:24 +00:00
|
|
|
|
|
|
|
#include "common/endian.h"
|
|
|
|
|
|
|
|
namespace Kyra {
|
|
|
|
|
|
|
|
void LoLEngine::loadLevel(int index) {
|
2009-05-21 16:46:40 +00:00
|
|
|
_gameFlags[36] |= 0x800;
|
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
|
|
|
|
|
|
|
updatePortraits();
|
|
|
|
|
|
|
|
for (int i = 0; i < 400; i++) {
|
2009-01-18 17:38:29 +00:00
|
|
|
delete[] _levelShapes[i];
|
2009-01-18 17:04:24 +00:00
|
|
|
_levelShapes[i] = 0;
|
|
|
|
}
|
|
|
|
_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;
|
|
|
|
|
2009-01-20 09:38:55 +00:00
|
|
|
char filename[13];
|
|
|
|
snprintf(filename, sizeof(filename), "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
|
|
|
|
|
|
|
runInitScript(filename, f ? 0 : 1);
|
|
|
|
|
|
|
|
if (f)
|
2009-03-28 11:58:22 +00:00
|
|
|
restoreBlockTempData(index);
|
2009-01-18 17:04:24 +00:00
|
|
|
|
2009-01-20 09:38:55 +00:00
|
|
|
snprintf(filename, sizeof(filename), "LEVEL%d.INF", index);
|
2009-01-18 17:04:24 +00:00
|
|
|
runInfScript(filename);
|
|
|
|
|
|
|
|
addLevelItems();
|
2009-04-03 21:32:50 +00:00
|
|
|
deleteMonstersFromBlock(_currentBlock);
|
2009-01-18 17:04:24 +00:00
|
|
|
|
2009-03-21 20:24:36 +00:00
|
|
|
_screen->generateGrayOverlay(_screen->_currentPalette, _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-03-28 11:58:22 +00:00
|
|
|
setPaletteBrightness(_screen->_currentPalette, _brightness, _lampEffect);
|
2009-01-18 17:04:24 +00:00
|
|
|
setMouseCursorToItemInHand();
|
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;
|
|
|
|
|
2009-04-25 13:15:05 +00:00
|
|
|
assignBlockObject(&_levelBlockProperties[_itemsInPlay[i].block].assignedObjects, 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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-03-16 21:20:34 +00:00
|
|
|
void LoLEngine::assignBlockObject(uint16 *cmzItemIndex, uint16 item) {
|
2009-03-01 14:45:30 +00:00
|
|
|
ItemInPlay *tmp = 0;
|
2009-02-01 19:27:01 +00:00
|
|
|
|
2009-02-14 13:55:00 +00:00
|
|
|
while (*cmzItemIndex & 0x8000) {
|
2009-03-15 16:48:20 +00:00
|
|
|
tmp = findObject(*cmzItemIndex);
|
|
|
|
cmzItemIndex = &tmp->nextAssignedObject;
|
2009-01-18 17:04:24 +00:00
|
|
|
}
|
|
|
|
|
2009-03-15 16:48:20 +00:00
|
|
|
tmp = findObject(item);
|
2009-02-01 19:27:01 +00:00
|
|
|
tmp->level = -1;
|
|
|
|
|
2009-01-18 17:04:24 +00:00
|
|
|
uint16 ix = *cmzItemIndex;
|
|
|
|
|
|
|
|
if (ix == item)
|
|
|
|
return;
|
|
|
|
|
|
|
|
*cmzItemIndex = item;
|
2009-03-15 16:48:20 +00:00
|
|
|
cmzItemIndex = &tmp->nextAssignedObject;
|
2009-01-18 17:04:24 +00:00
|
|
|
|
2009-02-01 19:27:01 +00:00
|
|
|
while (*cmzItemIndex) {
|
2009-03-15 16:48:20 +00:00
|
|
|
tmp = findObject(*cmzItemIndex);
|
|
|
|
cmzItemIndex = &tmp->nextAssignedObject;
|
2009-02-01 19:27:01 +00:00
|
|
|
}
|
2009-01-18 17:04:24 +00:00
|
|
|
|
|
|
|
*cmzItemIndex = ix;
|
|
|
|
}
|
|
|
|
|
2009-04-03 21:32:50 +00:00
|
|
|
void LoLEngine::loadLevelWallData(int index, bool mapShapes) {
|
2009-01-20 09:38:55 +00:00
|
|
|
char filename[13];
|
|
|
|
snprintf(filename, sizeof(filename), "LEVEL%d.WLL", index);
|
2009-01-18 17:04:24 +00:00
|
|
|
|
|
|
|
uint32 size;
|
|
|
|
uint8 *file = _res->fileData(filename, &size);
|
|
|
|
|
|
|
|
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)
|
2009-01-18 17:04:24 +00:00
|
|
|
_wllShapeMap[c] = assignLevelShapes(sh);
|
|
|
|
else
|
|
|
|
_wllShapeMap[c] = *d;
|
|
|
|
}
|
|
|
|
d += 2;
|
|
|
|
_wllBuffer3[c] = *d;
|
|
|
|
d += 2;
|
2009-01-19 07:31:34 +00:00
|
|
|
_wllWallFlags[c] = *d;
|
2009-01-18 17:04:24 +00:00
|
|
|
d += 2;
|
|
|
|
_wllBuffer4[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
|
|
|
}
|
|
|
|
|
|
|
|
int LoLEngine::assignLevelShapes(int index) {
|
|
|
|
uint16 *p1 = (uint16 *) _tempBuffer5120;
|
|
|
|
uint16 *p2 = (uint16 *) (_tempBuffer5120 + 4000);
|
|
|
|
|
|
|
|
uint16 r = p2[index];
|
|
|
|
if (r)
|
|
|
|
return r;
|
|
|
|
|
|
|
|
uint16 o = _lvlBlockIndex++;
|
|
|
|
|
|
|
|
memcpy(&_levelShapeProperties[o], &_levelFileData[index], sizeof(LevelShapeProperty));
|
2009-02-14 13:55:00 +00:00
|
|
|
|
2009-01-18 17:04:24 +00:00
|
|
|
for (int i = 0; i < 10; i++) {
|
|
|
|
uint16 t = _levelShapeProperties[o].shapeIndex[i];
|
|
|
|
if (t == 0xffff)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
uint16 pv = p1[t];
|
|
|
|
if (pv) {
|
|
|
|
_levelShapeProperties[o].shapeIndex[i] = pv;
|
|
|
|
} else {
|
|
|
|
_levelShapes[_lvlShapeIndex] = getLevelShapes(t);
|
|
|
|
p1[t] = _lvlShapeIndex;
|
|
|
|
_levelShapeProperties[o].shapeIndex[i] = _lvlShapeIndex++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
p2[index] = o;
|
|
|
|
if (_levelShapeProperties[o].next)
|
|
|
|
_levelShapeProperties[o].next = assignLevelShapes(_levelShapeProperties[o].next);
|
|
|
|
|
|
|
|
return o;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint8 *LoLEngine::getLevelShapes(int shapeIndex) {
|
|
|
|
if (_lvlShpNum <= shapeIndex)
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2009-03-28 11:58:22 +00:00
|
|
|
void LoLEngine::restoreBlockTempData(int index) {
|
2009-01-18 17:04:24 +00:00
|
|
|
memset(_tempBuffer5120, 0, 5120);
|
2009-03-28 11:58:22 +00:00
|
|
|
int l = index - 1;
|
2009-01-18 17:04:24 +00:00
|
|
|
|
2009-03-28 11:58:22 +00:00
|
|
|
memcpy(_monsters, _lvlTempData[l]->monsters, sizeof(MonsterInPlay) * 30);
|
|
|
|
memcpy(_flyingObjects, _lvlTempData[l]->flyingObjects, sizeof(FlyingObject) * 8);
|
2009-01-18 17:04:24 +00:00
|
|
|
|
2009-01-20 09:38:55 +00:00
|
|
|
char filename[13];
|
|
|
|
snprintf(filename, sizeof(filename), "LEVEL%d.CMZ", index);
|
2009-02-14 13:55:00 +00:00
|
|
|
|
2009-01-18 17:04:24 +00:00
|
|
|
_screen->loadBitmap(filename, 3, 3, 0);
|
|
|
|
const uint8 *p = _screen->getCPagePtr(2);
|
|
|
|
uint16 len = READ_LE_UINT16(p + 4);
|
2009-03-28 11:58:22 +00:00
|
|
|
p += 6;
|
2009-01-18 17:04:24 +00:00
|
|
|
|
2009-01-19 07:31:34 +00:00
|
|
|
memset(_levelBlockProperties, 0, 1024 * sizeof(LevelBlockProperty));
|
2009-01-18 17:04:24 +00:00
|
|
|
|
2009-03-28 11:58:22 +00:00
|
|
|
uint8 *t = _lvlTempData[l]->wallsXorData;
|
|
|
|
uint8 *t2 = _lvlTempData[l]->flags;
|
2009-01-18 17:04:24 +00:00
|
|
|
|
|
|
|
for (int i = 0; i < 1024; i++) {
|
|
|
|
for (int ii = 0; ii < 4; ii++)
|
2009-03-28 11:58:22 +00:00
|
|
|
_levelBlockProperties[i].walls[ii] = p[i * len + ii] ^ *t++;
|
|
|
|
_levelBlockProperties[i].flags = *t2++;
|
2009-01-18 17:04:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for (int i = 0; i < 30; i++) {
|
2009-04-25 13:15:05 +00:00
|
|
|
if (_monsters[i].block) {
|
|
|
|
_monsters[i].block = 0;
|
2009-02-23 20:17:53 +00:00
|
|
|
_monsters[i].properties = &_monsterProperties[_monsters[i].type];
|
2009-03-01 14:45:30 +00:00
|
|
|
placeMonster(&_monsters[i], _monsters[i].x, _monsters[i].y);
|
2009-01-18 17:04:24 +00:00
|
|
|
}
|
|
|
|
}
|
2009-02-14 13:55:00 +00:00
|
|
|
|
2009-03-28 11:58:22 +00:00
|
|
|
restoreTempDataAdjustMonsterStrength(l);
|
2009-01-18 17:04:24 +00:00
|
|
|
}
|
|
|
|
|
2009-03-28 11:58:22 +00:00
|
|
|
void LoLEngine::restoreTempDataAdjustMonsterStrength(int index) {
|
|
|
|
if (_lvlTempData[index]->monsterDifficulty == _monsterDifficulty)
|
|
|
|
return;
|
2009-01-18 17:04:24 +00:00
|
|
|
|
2009-03-28 11:58:22 +00:00
|
|
|
uint16 d = (_monsterModifiers[_lvlTempData[index]->monsterDifficulty] << 8) / _monsterModifiers[_monsterDifficulty];
|
2009-02-14 13:55:00 +00:00
|
|
|
|
2009-01-18 17:04:24 +00:00
|
|
|
for (int i = 0; i < 30; i++) {
|
2009-04-25 13:15:05 +00:00
|
|
|
if (_monsters[i].mode >= 14 || _monsters[i].block == 0 || _monsters[i].hitPoints <= 0)
|
2009-01-18 17:04:24 +00:00
|
|
|
continue;
|
|
|
|
|
2009-04-25 13:15:05 +00:00
|
|
|
_monsters[i].hitPoints = (d * _monsters[i].hitPoints) >> 8;
|
2009-03-28 11:58:22 +00:00
|
|
|
if (_monsterDifficulty < _lvlTempData[index]->monsterDifficulty)
|
2009-04-25 13:15:05 +00:00
|
|
|
_monsters[i].hitPoints++;
|
|
|
|
if (_monsters[i].hitPoints == 0)
|
|
|
|
_monsters[i].hitPoints = 1;
|
2009-01-18 17:04:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void LoLEngine::loadCmzFile(const char *file) {
|
2009-01-19 07:31:34 +00:00
|
|
|
memset(_levelBlockProperties, 0, 1024 * sizeof(LevelBlockProperty));
|
2009-01-18 17:04:24 +00:00
|
|
|
_screen->loadBitmap(file, 2, 2, 0);
|
|
|
|
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
|
|
|
|
2009-01-19 07:31:34 +00:00
|
|
|
if (_wllBuffer4[_levelBlockProperties[i].walls[0]] == 17) {
|
|
|
|
_levelBlockProperties[i].flags &= 0xef;
|
|
|
|
_levelBlockProperties[i].flags |= 0x20;
|
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);
|
2009-01-18 17:04:24 +00:00
|
|
|
_lvlShpNum = _lvlShpFileHandle->readUint16LE();
|
|
|
|
|
2009-01-23 04:57:18 +00:00
|
|
|
Common::SeekableReadStream *s = _res->createReadStream(datFile);
|
2009-01-18 17:04:24 +00:00
|
|
|
|
|
|
|
_levelFileDataSize = s->readUint16LE();
|
2009-01-18 17:38:29 +00:00
|
|
|
delete[] _levelFileData;
|
2009-01-18 17:04:24 +00:00
|
|
|
_levelFileData = new LevelShapeProperty[_levelFileDataSize];
|
|
|
|
for (int i = 0; i < _levelFileDataSize; i++) {
|
|
|
|
LevelShapeProperty * l = &_levelFileData[i];
|
|
|
|
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) {
|
|
|
|
_lvlBlockIndex = 1;
|
|
|
|
_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;
|
|
|
|
strcpy(_lastSuppFile, 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-01-20 09:38:55 +00:00
|
|
|
char fname[13];
|
|
|
|
snprintf(fname, sizeof(fname), "%s.VCN", _lastSuppFile);
|
2009-01-18 17:04:24 +00:00
|
|
|
|
|
|
|
_screen->loadBitmap(fname, 3, 3, 0);
|
|
|
|
const uint8 *v = _screen->getCPagePtr(2);
|
|
|
|
int tlen = READ_LE_UINT16(v);
|
|
|
|
v += 2;
|
|
|
|
|
|
|
|
if (vcnLen == -1)
|
|
|
|
vcnLen = tlen << 5;
|
|
|
|
|
|
|
|
if (_vcnBlocks)
|
2009-01-18 17:38:29 +00:00
|
|
|
delete[] _vcnBlocks;
|
2009-01-18 17:04:24 +00:00
|
|
|
_vcnBlocks = new uint8[vcnLen];
|
|
|
|
|
|
|
|
if (_vcnShift)
|
2009-01-18 17:38:29 +00:00
|
|
|
delete[] _vcnShift;
|
2009-01-18 17:04:24 +00:00
|
|
|
_vcnShift = new uint8[tlen];
|
|
|
|
|
|
|
|
memcpy(_vcnShift, v, tlen);
|
|
|
|
v += tlen;
|
2009-02-14 13:55:00 +00:00
|
|
|
|
2009-01-18 17:04:24 +00:00
|
|
|
memcpy(_vcnExpTable, v, 128);
|
|
|
|
v += 128;
|
2009-02-14 13:55:00 +00:00
|
|
|
|
2009-01-18 23:50:31 +00:00
|
|
|
if (_lastOverridePalFilePtr) {
|
|
|
|
uint8 *tpal = _res->fileData(_lastOverridePalFilePtr, 0);
|
|
|
|
memcpy(_screen->_currentPalette, tpal, 384);
|
2009-02-14 13:55:00 +00:00
|
|
|
delete[] tpal;
|
2009-01-18 23:50:31 +00:00
|
|
|
} else {
|
|
|
|
memcpy(_screen->_currentPalette, v, 384);
|
2009-01-18 17:04:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
v += 384;
|
|
|
|
/*uint8 tmpPal = new uint8[384];
|
|
|
|
memcpy(tmpPal, _screen->_currentPalette + 384, 384);
|
|
|
|
memset(_screen->_currentPalette + 384, 0xff, 384);
|
|
|
|
memcpy(_screen->_currentPalette + 384, tmpPal, 384);*/
|
2009-02-14 13:55:00 +00:00
|
|
|
|
2009-03-24 07:18:16 +00:00
|
|
|
if (_currentLevel == 11) {
|
|
|
|
uint8 *swampPal = _res->fileData("SWAMPICE.COL", 0);
|
|
|
|
memcpy(_screen->getPalette(2), swampPal, 384);
|
2009-05-21 16:46:40 +00:00
|
|
|
memcpy(_screen->getPalette(2) + 384, _screen->_currentPalette + 384, 384);
|
2009-03-24 07:18:16 +00:00
|
|
|
delete[] swampPal;
|
|
|
|
|
2009-05-21 16:46:40 +00:00
|
|
|
if (_gameFlags[26] & 4) {
|
2009-03-24 07:18:16 +00:00
|
|
|
uint8 *pal0 = _screen->_currentPalette;
|
|
|
|
uint8 *pal2 = _screen->getPalette(2);
|
|
|
|
for (int i = 1; i < 768; i++)
|
|
|
|
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;
|
|
|
|
|
2009-01-20 09:38:55 +00:00
|
|
|
snprintf(fname, sizeof(fname), "%s.VMP", _lastSuppFile);
|
2009-01-18 17:04:24 +00:00
|
|
|
_screen->loadBitmap(fname, 3, 3, 0);
|
|
|
|
v = _screen->getCPagePtr(2);
|
|
|
|
|
|
|
|
if (vmpLen == -1)
|
|
|
|
vmpLen = READ_LE_UINT16(v);
|
|
|
|
v += 2;
|
|
|
|
|
|
|
|
if (_vmpPtr)
|
2009-01-18 17:38:29 +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]);
|
|
|
|
|
|
|
|
for (int i = 0; i < 7; i++) {
|
|
|
|
weight = 100 - (i * _lastSpecialColorWeight);
|
|
|
|
weight = (weight > 0) ? (weight * 255) / 100 : 0;
|
|
|
|
_screen->generateLevelOverlay(_screen->_currentPalette, _screen->getLevelOverlay(i), _lastSpecialColor, weight);
|
|
|
|
|
|
|
|
for (int ii = 0; ii < 128; ii++) {
|
|
|
|
if (_screen->getLevelOverlay(i)[ii] == 255)
|
|
|
|
_screen->getLevelOverlay(i)[ii] = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int ii = 128; ii < 256; ii++)
|
|
|
|
_screen->getLevelOverlay(i)[ii] = ii & 0xff;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int i = 0; i < 256; i++)
|
|
|
|
_screen->getLevelOverlay(7)[i] = i & 0xff;
|
|
|
|
|
|
|
|
_loadSuppFilesFlag = 0;
|
2009-03-28 11:58:22 +00:00
|
|
|
generateBrightnessPalette(_screen->_currentPalette, _screen->getPalette(1), _brightness, _lampEffect);
|
2009-01-18 17:04:24 +00:00
|
|
|
|
2009-01-20 09:38:55 +00:00
|
|
|
char tname[13];
|
|
|
|
snprintf(tname, sizeof(tname), "LEVEL%.02d.TLC", _currentLevel);
|
2009-01-23 04:57:18 +00:00
|
|
|
Common::SeekableReadStream *s = _res->createReadStream(tname);
|
2009-02-01 19:27:01 +00:00
|
|
|
s->read(_trueLightTable1, 256);
|
|
|
|
s->read(_trueLightTable2, 5120);
|
2009-01-18 17:31:25 +00:00
|
|
|
delete s;
|
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;
|
2009-02-23 20:17:53 +00:00
|
|
|
MonsterInPlay *r = 0;
|
2009-01-19 23:35:27 +00:00
|
|
|
|
|
|
|
while (id & 0x8000) {
|
2009-03-15 16:48:20 +00:00
|
|
|
r = (MonsterInPlay*)findObject(id);
|
|
|
|
id = r->nextAssignedObject;
|
2009-01-19 23:35:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!id)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
ItemInPlay *it = &_itemsInPlay[id];
|
|
|
|
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() {
|
2009-02-23 20:17:53 +00:00
|
|
|
memset(_monsters, 0, 30 * sizeof(MonsterInPlay));
|
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-03-08 02:17:14 +00:00
|
|
|
_gameFlags[15] |= 0x400;
|
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-03-08 02:17:14 +00:00
|
|
|
_gameFlags[15] &= 0xFBFF;
|
|
|
|
if (!(_gameFlags[15] & 0x800) || !lampOn)
|
2009-02-01 19:27:01 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
_screen->drawShape(0, _gameShapes[43], 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-04-03 21:32:50 +00:00
|
|
|
uint8 newLampEffect = 0;
|
|
|
|
uint8 tmpOilStatus = 0;
|
2009-01-18 17:04:24 +00:00
|
|
|
|
2009-03-08 02:17:14 +00:00
|
|
|
if ((_updateFlags & 4) || !(_gameFlags[15] & 0x800))
|
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)
|
|
|
|
setPaletteBrightness(_screen->_currentPalette, _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-04-03 21:32:50 +00:00
|
|
|
setPaletteBrightness(_screen->_currentPalette, _brightness, newLampEffect);
|
2009-01-18 17:04:24 +00:00
|
|
|
_lampStatusTimer = _system->getMillis() + (10 + _rnd.getRandomNumberRng(1, 30)) * _tickLength;
|
|
|
|
} 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-01-18 17:04:24 +00:00
|
|
|
_lampStatusTimer = _system->getMillis() + (10 + _rnd.getRandomNumberRng(1, 30)) * _tickLength;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (_screen->_fadeFlag == 0)
|
2009-04-03 21:32:50 +00:00
|
|
|
setPaletteBrightness(_screen->_currentPalette, _lampEffect, 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-04-03 21:32:50 +00:00
|
|
|
_screen->drawShape(_screen->_curPage, _gameShapes[35 + 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-04-04 21:10:35 +00:00
|
|
|
if (!(_gameFlags[15] & 0x4000) || (_updateFlags & 4))
|
|
|
|
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);
|
|
|
|
|
|
|
|
int16 d = _compassBroken ? ((int8)getRandomNumberSpecial() - _compassDirection) : (_currentDirection << 6) - _compassDirection;
|
|
|
|
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-05-21 16:46:40 +00:00
|
|
|
_gameFlags[36] &= 0xfdff;
|
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-05-21 16:46:40 +00:00
|
|
|
if (!(_gameFlags[36] & 0x200)) {
|
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-02-23 20:17:53 +00:00
|
|
|
uint16 LoLEngine::calcNewBlockPosition(uint16 curBlock, uint16 direction) {
|
2009-04-03 21:32:50 +00:00
|
|
|
static const int16 blockPosTable[] = { -32, 1, 32, -1 };
|
2009-01-19 07:31:34 +00:00
|
|
|
return (curBlock + blockPosTable[direction]) & 0x3ff;
|
|
|
|
}
|
|
|
|
|
2009-03-01 14:45:30 +00:00
|
|
|
uint16 LoLEngine::calcBlockIndex(uint16 x, uint16 y) {
|
2009-03-07 19:24:31 +00:00
|
|
|
return ((y & 0xff00) >> 3) | (x >> 8);
|
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-02-14 00:51:07 +00:00
|
|
|
_txt->printMessage(0x8002, getLangString(0x403f));
|
2009-02-23 20:17:53 +00:00
|
|
|
snd_playSoundEffect(19, -1);
|
|
|
|
}
|
|
|
|
|
2009-03-01 14:45:30 +00:00
|
|
|
int LoLEngine::clickedWallShape(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_stopSpeech(true);
|
|
|
|
runLevelScript(block, 0x40);
|
2009-04-04 21:10:35 +00:00
|
|
|
|
2009-02-23 20:17:53 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2009-03-28 11:58:22 +00:00
|
|
|
int LoLEngine::clickedLeverOn(uint16 block, uint16 direction) {
|
|
|
|
uint8 v = _wllShapeMap[_levelBlockProperties[block].walls[direction]];
|
|
|
|
if (!clickedShape(v))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
_levelBlockProperties[block].walls[direction]++;
|
|
|
|
_sceneUpdateRequired = true;
|
|
|
|
|
|
|
|
snd_playSoundEffect(30, -1);
|
|
|
|
|
|
|
|
runLevelScript(block, 0x40);
|
|
|
|
|
2009-03-01 14:45:30 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2009-03-28 11:58:22 +00:00
|
|
|
int LoLEngine::clickedLeverOff(uint16 block, uint16 direction) {
|
|
|
|
uint8 v = _wllShapeMap[_levelBlockProperties[block].walls[direction]];
|
|
|
|
if (!clickedShape(v))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
_levelBlockProperties[block].walls[direction]--;
|
|
|
|
_sceneUpdateRequired = true;
|
|
|
|
|
|
|
|
snd_playSoundEffect(29, -1);
|
|
|
|
|
|
|
|
runLevelScript(block, 0x40);
|
2009-03-01 14:45:30 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int LoLEngine::clickedWallOnlyScript(uint16 block) {
|
2009-04-04 21:10:35 +00:00
|
|
|
runLevelScript(block, 0x40);
|
2009-03-01 14:45:30 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
_emcDoorState = 0;
|
|
|
|
runLevelScript(block, 0x40);
|
|
|
|
|
|
|
|
if (!_emcDoorState) {
|
|
|
|
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-23 20:17:53 +00:00
|
|
|
bool LoLEngine::clickedShape(int shapeIndex) {
|
|
|
|
while (shapeIndex) {
|
|
|
|
uint16 s = _levelShapeProperties[shapeIndex].shapeIndex[1];
|
2009-04-04 21:10:35 +00:00
|
|
|
|
2009-02-23 20:17:53 +00:00
|
|
|
if (s == 0xffff)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
int w = _levelShapes[s][3];
|
|
|
|
int h = _levelShapes[s][2];
|
|
|
|
int x = _levelShapeProperties[shapeIndex].shapeX[1] + 136;
|
|
|
|
int y = _levelShapeProperties[shapeIndex].shapeY[1] + 8;
|
|
|
|
|
|
|
|
if (_levelShapeProperties[shapeIndex].flags & 1)
|
|
|
|
w <<= 1;
|
|
|
|
|
|
|
|
if (posWithinRect(_mouseX, _mouseY, x - 4, y - 4, x + w + 8, y + h + 8))
|
|
|
|
return true;
|
|
|
|
|
|
|
|
shapeIndex = _levelShapeProperties[shapeIndex].next;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2009-05-10 13:40:28 +00:00
|
|
|
void LoLEngine::processDoorSwitch(uint16 block, int openClose) {
|
2009-03-15 16:48:20 +00:00
|
|
|
if ((block == _currentBlock) || (_levelBlockProperties[block].assignedObjects & 0x8000))
|
2009-03-06 22:53:08 +00:00
|
|
|
return;
|
|
|
|
|
2009-05-10 13:40:28 +00:00
|
|
|
if (openClose == 0) {
|
2009-03-06 22:53:08 +00:00
|
|
|
for (int i = 0; i < 3; i++) {
|
|
|
|
if (_openDoorState[i].block != block)
|
|
|
|
continue;
|
2009-05-10 13:40:28 +00:00
|
|
|
openClose = -_openDoorState[i].state;
|
2009-03-06 22:53:08 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-05-10 13:40:28 +00:00
|
|
|
if (openClose == 0)
|
|
|
|
openClose = (_wllWallFlags[_levelBlockProperties[block].walls[_wllWallFlags[_levelBlockProperties[block].walls[0]] & 8 ? 0 : 1]] & 1) ? 1 : -1;
|
2009-02-23 20:17:53 +00:00
|
|
|
|
2009-05-10 13:40:28 +00:00
|
|
|
openCloseDoor(block, openClose);
|
2009-02-23 20:17:53 +00:00
|
|
|
}
|
|
|
|
|
2009-03-06 22:53:08 +00:00
|
|
|
void LoLEngine::openCloseDoor(uint16 block, int openClose) {
|
|
|
|
int s1 = -1;
|
|
|
|
int s2 = -1;
|
|
|
|
|
|
|
|
int c = (_wllWallFlags[_levelBlockProperties[block].walls[0]] & 8) ? 0 : 1;
|
|
|
|
int v = _levelBlockProperties[block].walls[c];
|
|
|
|
int flg = (openClose == 1) ? 0x10 : (openClose == -1 ? 0x20 : 0);
|
|
|
|
|
|
|
|
if (_wllWallFlags[v] & flg)
|
|
|
|
return;
|
|
|
|
|
|
|
|
for (int i = 0; i < 3; i++) {
|
|
|
|
if (_openDoorState[i].block == block) {
|
|
|
|
s1 = i;
|
|
|
|
break;
|
|
|
|
} else if (_openDoorState[i].block == 0 && s2 == -1) {
|
|
|
|
s2 = i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (s1 != -1 || s2 != -1) {
|
|
|
|
if (s1 == -1)
|
|
|
|
s1 = s2;
|
|
|
|
|
|
|
|
_openDoorState[s1].block = block;
|
|
|
|
_openDoorState[s1].state = openClose;
|
2009-03-16 21:20:34 +00:00
|
|
|
_openDoorState[s1].wall = c;
|
2009-03-06 22:53:08 +00:00
|
|
|
|
|
|
|
flg = (-openClose == 1) ? 0x10 : (-openClose == -1 ? 0x20 : 0);
|
2009-04-04 21:10:35 +00:00
|
|
|
|
2009-03-06 22:53:08 +00:00
|
|
|
if (_wllWallFlags[v] & flg) {
|
|
|
|
_levelBlockProperties[block].walls[c] += openClose;
|
|
|
|
_levelBlockProperties[block].walls[c ^ 2] += openClose;
|
|
|
|
|
|
|
|
int snd = (openClose == -1) ? 32 : 31;
|
2009-02-23 20:17:53 +00:00
|
|
|
|
2009-03-06 22:53:08 +00:00
|
|
|
snd_processEnvironmentalSoundEffect(snd, block);
|
|
|
|
if (!checkSceneUpdateNeed(block))
|
|
|
|
updateEnvironmentalSfx(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
enableTimer(0);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
while (!(flg & _wllWallFlags[v]))
|
|
|
|
v += openClose;
|
2009-04-04 21:10:35 +00:00
|
|
|
|
2009-03-06 22:53:08 +00:00
|
|
|
_levelBlockProperties[block].walls[c] = _levelBlockProperties[block].walls[c ^ 2] = v;
|
|
|
|
checkSceneUpdateNeed(block);
|
|
|
|
}
|
2009-02-14 00:51:07 +00:00
|
|
|
}
|
|
|
|
|
2009-03-28 11:58:22 +00:00
|
|
|
void LoLEngine::completeDoorOperations() {
|
2009-03-24 07:18:16 +00:00
|
|
|
for (int i = 0; i < 3; i++) {
|
|
|
|
if (!_openDoorState[i].block)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
uint16 b = _openDoorState[i].block;
|
2009-04-04 21:10:35 +00:00
|
|
|
|
2009-03-24 07:18:16 +00:00
|
|
|
do {
|
|
|
|
_levelBlockProperties[b].walls[_openDoorState[i].wall] += _openDoorState[i].state;
|
|
|
|
_levelBlockProperties[b].walls[_openDoorState[i].wall ^ 2] += _openDoorState[i].state;
|
|
|
|
} while (!(_wllWallFlags[_levelBlockProperties[b].walls[_openDoorState[i].wall]] & 0x30));
|
|
|
|
|
|
|
|
_openDoorState[i].block = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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++) {
|
|
|
|
_smoothScrollTimer = _system->getMillis() + speed * _tickLength;
|
|
|
|
_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-02-14 00:51:07 +00:00
|
|
|
delayUntil(_smoothScrollTimer);
|
|
|
|
if (!_smoothScrollModeNormal)
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int i = 2; i; i--) {
|
|
|
|
_smoothScrollTimer = _system->getMillis() + speed * _tickLength;
|
|
|
|
_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-02-14 00:51:07 +00:00
|
|
|
delayUntil(_smoothScrollTimer);
|
|
|
|
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) {
|
|
|
|
d = smoothScrollDrawSpecialShape(6);
|
|
|
|
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 {
|
|
|
|
d = smoothScrollDrawSpecialShape(2);
|
|
|
|
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++) {
|
|
|
|
_smoothScrollTimer = _system->getMillis() + speed * _tickLength;
|
|
|
|
_screen->smoothScrollZoomStepTop(6, 2, _scrollXTop[i], _scrollYTop[i]);
|
|
|
|
_screen->smoothScrollZoomStepBottom(6, 2, _scrollXBottom[i], _scrollYBottom[i]);
|
|
|
|
|
|
|
|
//if (d)
|
|
|
|
// unk(_tempBuffer5120, page2);
|
2009-02-14 13:55:00 +00:00
|
|
|
|
2009-02-14 00:51:07 +00:00
|
|
|
_screen->restoreSceneWindow(2, 0);
|
|
|
|
_screen->updateScreen();
|
|
|
|
fadeText();
|
|
|
|
delayUntil(_smoothScrollTimer);
|
|
|
|
if (!_smoothScrollModeNormal)
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
|
|
|
//if (d)
|
|
|
|
// unk(_tempBuffer5120, _scrollSceneBuffer);
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
//int d = smoothScrollDrawSpecialShape(2);
|
|
|
|
gui_drawScene(2);
|
|
|
|
_screen->backupSceneWindow(2, 6);
|
|
|
|
|
|
|
|
for (int i = 4; i >= 0; i--) {
|
|
|
|
_smoothScrollTimer = _system->getMillis() + speed * _tickLength;
|
|
|
|
_screen->smoothScrollZoomStepTop(6, 2, _scrollXTop[i], _scrollYTop[i]);
|
|
|
|
_screen->smoothScrollZoomStepBottom(6, 2, _scrollXBottom[i], _scrollYBottom[i]);
|
|
|
|
|
|
|
|
//if (d)
|
|
|
|
// unk(_tempBuffer5120, page2);
|
2009-02-14 13:55:00 +00:00
|
|
|
|
2009-02-14 00:51:07 +00:00
|
|
|
_screen->restoreSceneWindow(2, 0);
|
|
|
|
_screen->updateScreen();
|
|
|
|
fadeText();
|
|
|
|
delayUntil(_smoothScrollTimer);
|
|
|
|
if (!_smoothScrollModeNormal)
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
|
|
|
//if (d)
|
|
|
|
// unk(_tempBuffer5120, _scrollSceneBuffer);
|
|
|
|
|
|
|
|
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) {
|
|
|
|
_smoothScrollTimer = _system->getMillis() + speed * _tickLength;
|
|
|
|
_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();
|
|
|
|
delayUntil(_smoothScrollTimer);
|
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
_smoothScrollTimer = _system->getMillis() + speed * _tickLength;
|
|
|
|
_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();
|
|
|
|
delayUntil(_smoothScrollTimer);
|
|
|
|
|
|
|
|
_smoothScrollTimer = _system->getMillis() + speed * _tickLength;
|
|
|
|
_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();
|
|
|
|
delayUntil(_smoothScrollTimer);
|
|
|
|
|
|
|
|
_smoothScrollTimer = _system->getMillis() + speed * _tickLength;
|
|
|
|
_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();
|
|
|
|
delayUntil(_smoothScrollTimer);
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
//int d = smoothScrollDrawSpecialShape(_sceneDrawPage1);
|
|
|
|
gui_drawScene(_sceneDrawPage1);
|
|
|
|
int dp = _sceneDrawPage2 == 2 ? _sceneDrawPage2 : _sceneDrawPage1;
|
|
|
|
|
|
|
|
_smoothScrollTimer = _system->getMillis() + speed * _tickLength;
|
|
|
|
_screen->smoothScrollTurnStep1(_sceneDrawPage1, _sceneDrawPage2, dp);
|
|
|
|
//if (d)
|
|
|
|
// unk(_tempBuffer5120, _scrollSceneBuffer);
|
|
|
|
_screen->restoreSceneWindow(dp, 0);
|
|
|
|
_screen->updateScreen();
|
|
|
|
fadeText();
|
|
|
|
delayUntil(_smoothScrollTimer);
|
|
|
|
|
|
|
|
_smoothScrollTimer = _system->getMillis() + speed * _tickLength;
|
|
|
|
_screen->smoothScrollTurnStep2(_sceneDrawPage1, _sceneDrawPage2, dp);
|
|
|
|
//if (d)
|
|
|
|
// unk(_tempBuffer5120, _scrollSceneBuffer);
|
|
|
|
_screen->restoreSceneWindow(dp, 0);
|
|
|
|
_screen->updateScreen();
|
|
|
|
fadeText();
|
|
|
|
delayUntil(_smoothScrollTimer);
|
|
|
|
|
|
|
|
_smoothScrollTimer = _system->getMillis() + speed * _tickLength;
|
|
|
|
_screen->smoothScrollTurnStep3(_sceneDrawPage1, _sceneDrawPage2, dp);
|
|
|
|
//if (d)
|
|
|
|
// unk(_tempBuffer5120, _scrollSceneBuffer);
|
|
|
|
_screen->restoreSceneWindow(dp, 0);
|
|
|
|
_screen->updateScreen();
|
|
|
|
fadeText();
|
|
|
|
delayUntil(_smoothScrollTimer);
|
|
|
|
|
|
|
|
if (_sceneDefaultUpdate != 2) {
|
|
|
|
drawScriptShapes(_sceneDrawPage1);
|
|
|
|
_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;
|
|
|
|
|
|
|
|
//int d = smoothScrollDrawSpecialShape(_sceneDrawPage1);
|
|
|
|
gui_drawScene(_sceneDrawPage1);
|
|
|
|
int dp = _sceneDrawPage2 == 2 ? _sceneDrawPage2 : _sceneDrawPage1;
|
|
|
|
|
|
|
|
_smoothScrollTimer = _system->getMillis() + speed * _tickLength;
|
|
|
|
_screen->smoothScrollTurnStep3(_sceneDrawPage2, _sceneDrawPage1, dp);
|
|
|
|
//if (d)
|
|
|
|
// unk(_tempBuffer5120, _scrollSceneBuffer);
|
|
|
|
_screen->restoreSceneWindow(dp, 0);
|
|
|
|
_screen->updateScreen();
|
|
|
|
fadeText();
|
|
|
|
delayUntil(_smoothScrollTimer);
|
|
|
|
|
|
|
|
_smoothScrollTimer = _system->getMillis() + speed * _tickLength;
|
|
|
|
_screen->smoothScrollTurnStep2(_sceneDrawPage2, _sceneDrawPage1, dp);
|
|
|
|
//if (d)
|
|
|
|
// unk(_tempBuffer5120, _scrollSceneBuffer);
|
|
|
|
_screen->restoreSceneWindow(dp, 0);
|
|
|
|
_screen->updateScreen();
|
|
|
|
fadeText();
|
|
|
|
delayUntil(_smoothScrollTimer);
|
|
|
|
|
|
|
|
_smoothScrollTimer = _system->getMillis() + speed * _tickLength;
|
|
|
|
_screen->smoothScrollTurnStep1(_sceneDrawPage2, _sceneDrawPage1, dp);
|
|
|
|
//if (d)
|
|
|
|
// unk(_tempBuffer5120, _scrollSceneBuffer);
|
|
|
|
_screen->restoreSceneWindow(dp, 0);
|
|
|
|
_screen->updateScreen();
|
|
|
|
fadeText();
|
|
|
|
delayUntil(_smoothScrollTimer);
|
|
|
|
|
|
|
|
if (_sceneDefaultUpdate != 2) {
|
|
|
|
drawScriptShapes(_sceneDrawPage1);
|
|
|
|
_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);
|
|
|
|
uint32 ctime = 0;
|
|
|
|
int del = 0;
|
|
|
|
|
|
|
|
for (int i = 0; i < numSteps; i++) {
|
|
|
|
ctime = _system->getMillis();
|
|
|
|
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();
|
|
|
|
|
|
|
|
del = _tickLength - (_system->getMillis() - ctime);
|
|
|
|
if (del > 0)
|
|
|
|
delay(del, false, true);
|
2009-05-21 13:13:09 +00:00
|
|
|
}
|
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();
|
|
|
|
|
|
|
|
del = _tickLength - (_system->getMillis() - ctime);
|
|
|
|
if (del > 0)
|
|
|
|
delay(del, false, true);
|
|
|
|
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()) {
|
|
|
|
_smoothScrollTimer = _system->getMillis() + 2 * _tickLength;
|
|
|
|
|
|
|
|
int s1 = width ? (getRandomNumberSpecial() % (width << 1)) - width : 0;
|
|
|
|
int s2 = height ? (getRandomNumberSpecial() % (height << 1)) - height : 0;
|
|
|
|
|
|
|
|
int x1, y1, x2, y2, w, h;
|
|
|
|
if (s1 >= 0) {
|
|
|
|
x1 = 112;
|
|
|
|
x2 = 112;
|
|
|
|
w = 176 - s1;
|
|
|
|
} else {
|
|
|
|
x1 = 112 - s1;
|
|
|
|
x2 = 112 + s1;
|
|
|
|
w = 176 + s1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (s2 >= 0) {
|
|
|
|
y1 = 0;
|
|
|
|
y2 = 0;
|
|
|
|
h = 120 - s2;
|
|
|
|
} else {
|
|
|
|
y1 = -s2;
|
|
|
|
y2 = s2;
|
|
|
|
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-05-15 06:29:08 +00:00
|
|
|
delayUntil(_smoothScrollTimer);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (restore) {
|
|
|
|
_screen->copyRegion(112, 0, 112, 0, 176, 120, 6, 0, Screen::CR_NO_P_CHECK);
|
|
|
|
_screen->updateScreen();
|
|
|
|
updateDrawPage2();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-02-14 00:51:07 +00:00
|
|
|
int LoLEngine::smoothScrollDrawSpecialShape(int pageNum) {
|
|
|
|
// TODO
|
|
|
|
if(!_scriptAssignedLevelShape)
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
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-01-18 17:04:24 +00:00
|
|
|
drawScriptShapes(_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;
|
|
|
|
if (_wllBuffer4[val] == 17) {
|
|
|
|
_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) {
|
|
|
|
_screen->fadePalette(_screen->getPalette(3), 10);
|
|
|
|
_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) {
|
|
|
|
memcpy(_screen->getPalette(3) + 384, _screen->_currentPalette + 384, 384);
|
2009-05-10 13:40:28 +00:00
|
|
|
_screen->loadSpecialColors(_screen->getPalette(3));
|
2009-03-24 07:18:16 +00:00
|
|
|
_screen->fadePalette(_screen->getPalette(3), 10);
|
|
|
|
_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-03-28 11:58:22 +00:00
|
|
|
setPaletteBrightness(_screen->_currentPalette, _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-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;
|
|
|
|
}
|
|
|
|
|
2009-03-24 07:18:16 +00:00
|
|
|
void LoLEngine::generateBlockDrawingBuffer() {
|
|
|
|
_sceneDrawVarDown = _dscBlockMap[_currentDirection];
|
|
|
|
_sceneDrawVarRight = _dscBlockMap[_currentDirection + 4];
|
|
|
|
_sceneDrawVarLeft = _dscBlockMap[_currentDirection + 8];
|
|
|
|
|
|
|
|
/*******************************************
|
|
|
|
* _visibleBlocks map *
|
|
|
|
* *
|
|
|
|
* | | | | | | *
|
|
|
|
* 00 | 01 | 02 | 03 | 04 | 05 | 06 *
|
|
|
|
* ____|_____|_____|_____|_____|_____|_____ *
|
|
|
|
* | | | | | | *
|
|
|
|
* | 07 | 08 | 09 | 10 | 11 | *
|
|
|
|
* |_____|_____|_____|_____|_____| *
|
|
|
|
* | | | | *
|
|
|
|
* | 12 | 13 | 14 | *
|
|
|
|
* |_____|_____|_____| *
|
|
|
|
* | | *
|
|
|
|
* 15 | 16 | 17 *
|
|
|
|
* | (P) | *
|
|
|
|
********************************************/
|
2009-01-18 17:04:24 +00:00
|
|
|
|
|
|
|
memset(_blockDrawingBuffer, 0, 660 * sizeof(uint16));
|
|
|
|
|
2009-03-24 07:18:16 +00:00
|
|
|
_wllProcessFlag = ((_currentBlock >> 5) + (_currentBlock & 0x1f) + _currentDirection) & 1;
|
2009-01-18 17:04:24 +00:00
|
|
|
|
2009-02-14 00:51:07 +00:00
|
|
|
if (_wllProcessFlag) // floor and ceiling
|
2009-03-24 07:18:16 +00:00
|
|
|
generateVmpTileDataFlipped(0, 15, 1, -330, 22, 15);
|
2009-01-18 17:04:24 +00:00
|
|
|
else
|
2009-03-24 07:18:16 +00:00
|
|
|
generateVmpTileData(0, 15, 1, -330, 22, 15);
|
2009-01-18 17:04:24 +00:00
|
|
|
|
2009-03-24 07:18:16 +00:00
|
|
|
assignVisibleBlocks(_currentBlock, _currentDirection);
|
2009-01-18 17:04:24 +00:00
|
|
|
|
2009-03-24 07:18:16 +00:00
|
|
|
uint8 t = _visibleBlocks[0]->walls[_sceneDrawVarRight];
|
2009-01-18 17:04:24 +00:00
|
|
|
if (t)
|
2009-03-24 07:18:16 +00:00
|
|
|
generateVmpTileData(-2, 3, t, 102, 3, 5);
|
2009-01-18 17:04:24 +00:00
|
|
|
|
2009-03-24 07:18:16 +00:00
|
|
|
t = _visibleBlocks[6]->walls[_sceneDrawVarLeft];
|
2009-01-18 17:04:24 +00:00
|
|
|
if (t)
|
2009-03-24 07:18:16 +00:00
|
|
|
generateVmpTileDataFlipped(21, 3, t, 102, 3, 5);
|
2009-01-18 17:04:24 +00:00
|
|
|
|
2009-03-24 07:18:16 +00:00
|
|
|
t = _visibleBlocks[1]->walls[_sceneDrawVarRight];
|
|
|
|
uint8 t2 = _visibleBlocks[2]->walls[_sceneDrawVarDown];
|
2009-01-18 17:04:24 +00:00
|
|
|
|
2009-01-19 07:31:34 +00:00
|
|
|
if (hasWall(t) && !(_wllWallFlags[t2] & 8))
|
2009-03-24 07:18:16 +00:00
|
|
|
generateVmpTileData(2, 3, t, 102, 3, 5);
|
2009-01-19 07:31:34 +00:00
|
|
|
else if (t && (_wllWallFlags[t2] & 8))
|
2009-03-24 07:18:16 +00:00
|
|
|
generateVmpTileData(2, 3, t2, 102, 3, 5);
|
2009-01-18 17:04:24 +00:00
|
|
|
|
2009-03-24 07:18:16 +00:00
|
|
|
t = _visibleBlocks[5]->walls[_sceneDrawVarLeft];
|
|
|
|
t2 = _visibleBlocks[4]->walls[_sceneDrawVarDown];
|
2009-01-18 17:04:24 +00:00
|
|
|
|
2009-01-19 07:31:34 +00:00
|
|
|
if (hasWall(t) && !(_wllWallFlags[t2] & 8))
|
2009-03-24 07:18:16 +00:00
|
|
|
generateVmpTileDataFlipped(17, 3, t, 102, 3, 5);
|
2009-01-20 09:32:43 +00:00
|
|
|
else if (t && (_wllWallFlags[t2] & 8))
|
2009-03-24 07:18:16 +00:00
|
|
|
generateVmpTileDataFlipped(17, 3, t2, 102, 3, 5);
|
2009-01-18 17:04:24 +00:00
|
|
|
|
2009-03-24 07:18:16 +00:00
|
|
|
t = _visibleBlocks[2]->walls[_sceneDrawVarRight];
|
2009-01-18 17:04:24 +00:00
|
|
|
if (t)
|
2009-03-24 07:18:16 +00:00
|
|
|
generateVmpTileData(8, 3, t, 97, 1, 5);
|
2009-01-18 17:04:24 +00:00
|
|
|
|
2009-03-24 07:18:16 +00:00
|
|
|
t = _visibleBlocks[4]->walls[_sceneDrawVarLeft];
|
2009-01-18 17:04:24 +00:00
|
|
|
if (t)
|
2009-03-24 07:18:16 +00:00
|
|
|
generateVmpTileDataFlipped(13, 3, t, 97, 1, 5);
|
2009-01-18 17:04:24 +00:00
|
|
|
|
2009-03-24 07:18:16 +00:00
|
|
|
t = _visibleBlocks[1]->walls[_sceneDrawVarDown];
|
2009-01-19 07:31:34 +00:00
|
|
|
if (hasWall(t))
|
2009-03-24 07:18:16 +00:00
|
|
|
generateVmpTileData(-4, 3, t, 129, 6, 5);
|
2009-01-18 17:04:24 +00:00
|
|
|
|
2009-03-24 07:18:16 +00:00
|
|
|
t = _visibleBlocks[5]->walls[_sceneDrawVarDown];
|
2009-01-19 07:31:34 +00:00
|
|
|
if (hasWall(t))
|
2009-03-24 07:18:16 +00:00
|
|
|
generateVmpTileData(20, 3, t, 129, 6, 5);
|
2009-01-18 17:04:24 +00:00
|
|
|
|
2009-03-24 07:18:16 +00:00
|
|
|
t = _visibleBlocks[2]->walls[_sceneDrawVarDown];
|
2009-01-19 07:31:34 +00:00
|
|
|
if (hasWall(t))
|
2009-03-24 07:18:16 +00:00
|
|
|
generateVmpTileData(2, 3, t, 129, 6, 5);
|
2009-01-18 17:04:24 +00:00
|
|
|
|
2009-03-24 07:18:16 +00:00
|
|
|
t = _visibleBlocks[4]->walls[_sceneDrawVarDown];
|
2009-01-19 07:31:34 +00:00
|
|
|
if (hasWall(t))
|
2009-03-24 07:18:16 +00:00
|
|
|
generateVmpTileData(14, 3, t, 129, 6, 5);
|
2009-01-18 17:04:24 +00:00
|
|
|
|
2009-03-24 07:18:16 +00:00
|
|
|
t = _visibleBlocks[3]->walls[_sceneDrawVarDown];
|
2009-01-18 17:04:24 +00:00
|
|
|
if (t)
|
2009-03-24 07:18:16 +00:00
|
|
|
generateVmpTileData(8, 3, t, 129, 6, 5);
|
2009-01-18 17:04:24 +00:00
|
|
|
|
2009-03-24 07:18:16 +00:00
|
|
|
t = _visibleBlocks[7]->walls[_sceneDrawVarRight];
|
2009-01-18 17:04:24 +00:00
|
|
|
if (t)
|
2009-03-24 07:18:16 +00:00
|
|
|
generateVmpTileData(0, 3, t, 117, 2, 6);
|
2009-01-18 17:04:24 +00:00
|
|
|
|
2009-03-24 07:18:16 +00:00
|
|
|
t = _visibleBlocks[11]->walls[_sceneDrawVarLeft];
|
2009-01-18 17:04:24 +00:00
|
|
|
if (t)
|
2009-03-24 07:18:16 +00:00
|
|
|
generateVmpTileDataFlipped(20, 3, t, 117, 2, 6);
|
2009-01-18 17:04:24 +00:00
|
|
|
|
2009-03-24 07:18:16 +00:00
|
|
|
t = _visibleBlocks[8]->walls[_sceneDrawVarRight];
|
2009-01-18 17:04:24 +00:00
|
|
|
if (t)
|
2009-03-24 07:18:16 +00:00
|
|
|
generateVmpTileData(6, 2, t, 81, 2, 8);
|
2009-01-18 17:04:24 +00:00
|
|
|
|
2009-03-24 07:18:16 +00:00
|
|
|
t = _visibleBlocks[10]->walls[_sceneDrawVarLeft];
|
2009-01-18 17:04:24 +00:00
|
|
|
if (t)
|
2009-03-24 07:18:16 +00:00
|
|
|
generateVmpTileDataFlipped(14, 2, t, 81, 2, 8);
|
2009-01-18 17:04:24 +00:00
|
|
|
|
2009-03-24 07:18:16 +00:00
|
|
|
t = _visibleBlocks[8]->walls[_sceneDrawVarDown];
|
2009-01-19 07:31:34 +00:00
|
|
|
if (hasWall(t))
|
2009-03-24 07:18:16 +00:00
|
|
|
generateVmpTileData(-4, 2, t, 159, 10, 8);
|
2009-01-18 17:04:24 +00:00
|
|
|
|
2009-03-24 07:18:16 +00:00
|
|
|
t = _visibleBlocks[10]->walls[_sceneDrawVarDown];
|
2009-01-19 07:31:34 +00:00
|
|
|
if (hasWall(t))
|
2009-03-24 07:18:16 +00:00
|
|
|
generateVmpTileData(16, 2, t, 159, 10, 8);
|
2009-01-18 17:04:24 +00:00
|
|
|
|
2009-03-24 07:18:16 +00:00
|
|
|
t = _visibleBlocks[9]->walls[_sceneDrawVarDown];
|
2009-01-18 17:04:24 +00:00
|
|
|
if (t)
|
2009-03-24 07:18:16 +00:00
|
|
|
generateVmpTileData(6, 2, t, 159, 10, 8);
|
2009-01-18 17:04:24 +00:00
|
|
|
|
2009-03-24 07:18:16 +00:00
|
|
|
t = _visibleBlocks[12]->walls[_sceneDrawVarRight];
|
2009-01-18 17:04:24 +00:00
|
|
|
if (t)
|
2009-03-24 07:18:16 +00:00
|
|
|
generateVmpTileData(3, 1, t, 45, 3, 12);
|
2009-01-18 17:04:24 +00:00
|
|
|
|
2009-03-24 07:18:16 +00:00
|
|
|
t = _visibleBlocks[14]->walls[_sceneDrawVarLeft];
|
2009-01-18 17:04:24 +00:00
|
|
|
if (t)
|
2009-03-24 07:18:16 +00:00
|
|
|
generateVmpTileDataFlipped(16, 1, t, 45, 3, 12);
|
2009-01-18 17:04:24 +00:00
|
|
|
|
2009-03-24 07:18:16 +00:00
|
|
|
t = _visibleBlocks[12]->walls[_sceneDrawVarDown];
|
2009-01-19 07:31:34 +00:00
|
|
|
if (!(_wllWallFlags[t] & 8))
|
2009-03-24 07:18:16 +00:00
|
|
|
generateVmpTileData(-13, 1, t, 239, 16, 12);
|
2009-01-18 17:04:24 +00:00
|
|
|
|
2009-03-24 07:18:16 +00:00
|
|
|
t = _visibleBlocks[14]->walls[_sceneDrawVarDown];
|
2009-01-19 07:31:34 +00:00
|
|
|
if (!(_wllWallFlags[t] & 8))
|
2009-03-24 07:18:16 +00:00
|
|
|
generateVmpTileData(19, 1, t, 239, 16, 12);
|
2009-01-18 17:04:24 +00:00
|
|
|
|
2009-03-24 07:18:16 +00:00
|
|
|
t = _visibleBlocks[13]->walls[_sceneDrawVarDown];
|
2009-01-18 17:04:24 +00:00
|
|
|
if (t)
|
2009-03-24 07:18:16 +00:00
|
|
|
generateVmpTileData(3, 1, t, 239, 16, 12);
|
2009-01-18 17:04:24 +00:00
|
|
|
|
2009-03-24 07:18:16 +00:00
|
|
|
t = _visibleBlocks[15]->walls[_sceneDrawVarRight];
|
|
|
|
t2 = _visibleBlocks[17]->walls[_sceneDrawVarLeft];
|
|
|
|
if (t)
|
|
|
|
generateVmpTileData(0, 0, t, 0, 3, 15);
|
|
|
|
if (t2)
|
|
|
|
generateVmpTileDataFlipped(19, 0, t2, 0, 3, 15);
|
2009-01-18 17:04:24 +00:00
|
|
|
}
|
|
|
|
|
2009-03-24 07:18:16 +00:00
|
|
|
void LoLEngine::generateVmpTileData(int16 startBlockX, uint8 startBlockY, uint8 vmpMapIndex, int16 vmpOffset, uint8 numBlocksX, uint8 numBlocksY) {
|
|
|
|
if (!_wllVmpMap[vmpMapIndex])
|
2009-01-18 17:04:24 +00:00
|
|
|
return;
|
|
|
|
|
2009-03-24 07:18:16 +00:00
|
|
|
uint16 *vmp = &_vmpPtr[(_wllVmpMap[vmpMapIndex] - 1) * 431 + vmpOffset + 330];
|
2009-01-18 17:04:24 +00:00
|
|
|
|
2009-03-24 07:18:16 +00:00
|
|
|
for (int i = 0; i < numBlocksY; i++) {
|
|
|
|
uint16 *bl = &_blockDrawingBuffer[(startBlockY + i) * 22 + startBlockX];
|
|
|
|
for (int ii = 0; ii < numBlocksX; ii++) {
|
|
|
|
if ((startBlockX + ii >= 0) && (startBlockX + ii < 22) && *vmp)
|
2009-01-18 17:04:24 +00:00
|
|
|
*bl = *vmp;
|
|
|
|
bl++;
|
|
|
|
vmp++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-03-24 07:18:16 +00:00
|
|
|
void LoLEngine::generateVmpTileDataFlipped(int16 startBlockX, uint8 startBlockY, uint8 vmpMapIndex, int16 vmpOffset, uint8 numBlocksX, uint8 numBlocksY) {
|
|
|
|
if (!_wllVmpMap[vmpMapIndex])
|
2009-01-18 17:04:24 +00:00
|
|
|
return;
|
|
|
|
|
2009-03-24 07:18:16 +00:00
|
|
|
uint16 *vmp = &_vmpPtr[(_wllVmpMap[vmpMapIndex] - 1) * 431 + vmpOffset + 330];
|
2009-01-18 17:04:24 +00:00
|
|
|
|
2009-03-24 07:18:16 +00:00
|
|
|
for (int i = 0; i < numBlocksY; i++) {
|
|
|
|
for (int ii = 0; ii < numBlocksX; ii++) {
|
|
|
|
if ((startBlockX + ii) < 0 || (startBlockX + ii) > 21)
|
2009-02-14 00:51:07 +00:00
|
|
|
continue;
|
|
|
|
|
2009-03-24 07:18:16 +00:00
|
|
|
uint16 v = vmp[i * numBlocksX + (numBlocksX - 1 - ii)];
|
2009-02-14 00:51:07 +00:00
|
|
|
if (!v)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (v & 0x4000)
|
|
|
|
v -= 0x4000;
|
|
|
|
else
|
|
|
|
v |= 0x4000;
|
|
|
|
|
2009-03-24 07:18:16 +00:00
|
|
|
_blockDrawingBuffer[(startBlockY + i) * 22 + startBlockX + ii] = v;
|
2009-01-18 17:04:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-01-19 07:31:34 +00:00
|
|
|
bool LoLEngine::hasWall(int index) {
|
|
|
|
if (!index || (_wllWallFlags[index] & 8))
|
2009-01-18 17:04:24 +00:00
|
|
|
return false;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-03-24 07:18:16 +00:00
|
|
|
void LoLEngine::assignVisibleBlocks(int block, int direction) {
|
2009-01-18 17:04:24 +00:00
|
|
|
for (int i = 0; i < 18; i++) {
|
2009-01-19 07:31:34 +00:00
|
|
|
uint16 t = (block + _dscBlockIndex[direction * 18 + i]) & 0x3ff;
|
2009-03-24 07:18:16 +00:00
|
|
|
_visibleBlockIndex[i] = t;
|
2009-01-18 17:04:24 +00:00
|
|
|
|
2009-03-24 07:18:16 +00:00
|
|
|
_visibleBlocks[i] = &_levelBlockProperties[t];
|
2009-01-18 17:04:24 +00:00
|
|
|
_lvlShapeLeftRight[i] = _lvlShapeLeftRight[18 + i] = -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-03-24 07:18:16 +00:00
|
|
|
void LoLEngine::drawVcnBlocks() {
|
2009-02-14 13:55:00 +00:00
|
|
|
uint8 *d = _sceneWindowBuffer;
|
2009-03-24 07:18:16 +00:00
|
|
|
uint16 *bdb = _blockDrawingBuffer;
|
2009-02-14 13:55:00 +00:00
|
|
|
|
2009-01-18 17:04:24 +00:00
|
|
|
for (int y = 0; y < 15; y++) {
|
|
|
|
for (int x = 0; x < 22; x++) {
|
2009-03-24 07:18:16 +00:00
|
|
|
bool horizontalFlip = false;
|
2009-01-18 17:04:24 +00:00
|
|
|
int remainder = 0;
|
|
|
|
|
2009-03-24 07:18:16 +00:00
|
|
|
uint16 vcnOffset = *bdb++;
|
2009-01-18 17:04:24 +00:00
|
|
|
|
|
|
|
if (vcnOffset & 0x8000) {
|
2009-04-04 21:10:35 +00:00
|
|
|
// this renders a wall block over the transparent pixels of a floor/ceiling block
|
2009-01-18 17:04:24 +00:00
|
|
|
remainder = vcnOffset - 0x8000;
|
|
|
|
vcnOffset = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (vcnOffset & 0x4000) {
|
2009-03-24 07:18:16 +00:00
|
|
|
horizontalFlip = true;
|
2009-01-18 17:04:24 +00:00
|
|
|
vcnOffset &= 0x3fff;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!vcnOffset) {
|
2009-03-24 07:18:16 +00:00
|
|
|
// floor/ceiling blocks
|
|
|
|
vcnOffset = bdb[329];
|
2009-01-18 17:04:24 +00:00
|
|
|
if (vcnOffset & 0x4000) {
|
2009-03-24 07:18:16 +00:00
|
|
|
horizontalFlip = true;
|
2009-01-18 17:04:24 +00:00
|
|
|
vcnOffset &= 0x3fff;
|
|
|
|
}
|
|
|
|
}
|
2009-02-14 13:55:00 +00:00
|
|
|
|
2009-03-24 07:18:16 +00:00
|
|
|
uint8 shift = _vcnShift[vcnOffset];
|
|
|
|
uint8 *src = &_vcnBlocks[vcnOffset << 5];
|
2009-01-18 17:04:24 +00:00
|
|
|
|
2009-03-24 07:18:16 +00:00
|
|
|
if (horizontalFlip) {
|
2009-01-18 17:04:24 +00:00
|
|
|
for (int blockY = 0; blockY < 8; blockY++) {
|
|
|
|
src += 3;
|
|
|
|
for (int blockX = 0; blockX < 4; blockX++) {
|
|
|
|
uint8 t = *src--;
|
|
|
|
*d++ = _vcnExpTable[(t & 0x0f) | shift];
|
|
|
|
*d++ = _vcnExpTable[(t >> 4) | shift];
|
|
|
|
}
|
|
|
|
src += 5;
|
|
|
|
d += 168;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
for (int blockY = 0; blockY < 8; blockY++) {
|
|
|
|
for (int blockX = 0; blockX < 4; blockX++) {
|
|
|
|
uint8 t = *src++;
|
|
|
|
*d++ = _vcnExpTable[(t >> 4) | shift];
|
|
|
|
*d++ = _vcnExpTable[(t & 0x0f) | shift];
|
|
|
|
}
|
|
|
|
d += 168;
|
2009-02-14 13:55:00 +00:00
|
|
|
}
|
2009-01-18 17:04:24 +00:00
|
|
|
}
|
|
|
|
d -= 1400;
|
|
|
|
|
|
|
|
if (remainder) {
|
|
|
|
d -= 8;
|
2009-03-24 07:18:16 +00:00
|
|
|
horizontalFlip = false;
|
2009-01-18 17:04:24 +00:00
|
|
|
|
|
|
|
if (remainder & 0x4000) {
|
|
|
|
remainder &= 0x3fff;
|
2009-03-24 07:18:16 +00:00
|
|
|
horizontalFlip = true;
|
2009-01-18 17:04:24 +00:00
|
|
|
}
|
|
|
|
|
2009-03-24 07:18:16 +00:00
|
|
|
shift = _vcnShift[remainder];
|
|
|
|
src = &_vcnBlocks[remainder << 5];
|
2009-01-18 17:04:24 +00:00
|
|
|
|
2009-03-24 07:18:16 +00:00
|
|
|
if (horizontalFlip) {
|
2009-01-18 17:04:24 +00:00
|
|
|
for (int blockY = 0; blockY < 8; blockY++) {
|
|
|
|
src += 3;
|
|
|
|
for (int blockX = 0; blockX < 4; blockX++) {
|
|
|
|
uint8 t = *src--;
|
|
|
|
uint8 h = _vcnExpTable[(t & 0x0f) | shift];
|
|
|
|
uint8 l = _vcnExpTable[(t >> 4) | shift];
|
2009-02-14 13:55:00 +00:00
|
|
|
if (h)
|
2009-01-18 17:04:24 +00:00
|
|
|
*d = h;
|
|
|
|
d++;
|
2009-02-14 13:55:00 +00:00
|
|
|
if (l)
|
2009-01-18 17:04:24 +00:00
|
|
|
*d = l;
|
|
|
|
d++;
|
|
|
|
}
|
|
|
|
src += 5;
|
|
|
|
d += 168;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
for (int blockY = 0; blockY < 8; blockY++) {
|
|
|
|
for (int blockX = 0; blockX < 4; blockX++) {
|
|
|
|
uint8 t = *src++;
|
2009-02-14 13:55:00 +00:00
|
|
|
uint8 h = _vcnExpTable[(t >> 4) | shift];
|
2009-01-18 17:04:24 +00:00
|
|
|
uint8 l = _vcnExpTable[(t & 0x0f) | shift];
|
2009-02-14 13:55:00 +00:00
|
|
|
if (h)
|
2009-01-18 17:04:24 +00:00
|
|
|
*d = h;
|
|
|
|
d++;
|
2009-02-14 13:55:00 +00:00
|
|
|
if (l)
|
2009-01-18 17:04:24 +00:00
|
|
|
*d = l;
|
|
|
|
d++;
|
|
|
|
}
|
|
|
|
d += 168;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
d -= 1400;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
d += 1232;
|
|
|
|
}
|
|
|
|
|
2009-03-24 07:18:16 +00:00
|
|
|
_screen->copyBlockToPage(_sceneDrawPage1, 112, 0, 176, 120, _sceneWindowBuffer);
|
2009-01-18 17:04:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void LoLEngine::drawSceneShapes() {
|
|
|
|
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
|
|
|
|
|
|
|
int16 x1 = 0;
|
|
|
|
int16 x2 = 0;
|
|
|
|
|
|
|
|
int16 dimY1 = 0;
|
|
|
|
int16 dimY2 = 0;
|
|
|
|
|
|
|
|
setLevelShapesDim(t, x1, x2, 13);
|
|
|
|
|
|
|
|
if (x2 <= x1)
|
|
|
|
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;
|
|
|
|
|
|
|
|
uint16 v = 20 * (s - _dscUnk2[s]);
|
2009-02-14 13:55:00 +00:00
|
|
|
|
2009-01-18 17:04:24 +00:00
|
|
|
scaleLevelShapesDim(t, dimY1, dimY2, 13);
|
|
|
|
drawDoor(_doorShapes[_dscDoorShpIndex[s]], 0, t, 10, 0, -v, 2);
|
|
|
|
setLevelShapesDim(t, dimY1, dimY2, 13);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void LoLEngine::setLevelShapesDim(int index, int16 &x1, int16 &x2, int dim) {
|
|
|
|
if (_lvlShapeLeftRight[index << 1] == -1) {
|
|
|
|
x1 = 0;
|
|
|
|
x2 = 22;
|
|
|
|
|
|
|
|
int16 y1 = 0;
|
|
|
|
int16 y2 = 120;
|
|
|
|
|
|
|
|
int m = index * 18;
|
|
|
|
|
|
|
|
for (int i = 0; i < 18; i++) {
|
2009-03-24 07:18:16 +00:00
|
|
|
uint8 d = _visibleBlocks[i]->walls[_sceneDrawVarDown];
|
2009-01-19 07:31:34 +00:00
|
|
|
uint8 a = _wllWallFlags[d];
|
2009-01-18 17:04:24 +00:00
|
|
|
|
|
|
|
if (a & 8) {
|
|
|
|
int t = _dscDim2[(m + i) << 1];
|
|
|
|
|
|
|
|
if (t > x1) {
|
|
|
|
x1 = t;
|
|
|
|
if (!(a & 0x10))
|
|
|
|
scaleLevelShapesDim(index, y1, y2, -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
t = _dscDim2[((m + i) << 1) + 1];
|
2009-02-14 13:55:00 +00:00
|
|
|
|
2009-01-18 17:04:24 +00:00
|
|
|
if (t < x2) {
|
|
|
|
x2 = t;
|
|
|
|
if (!(a & 0x10))
|
|
|
|
scaleLevelShapesDim(index, y1, y2, -1);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
int t = _dscDim1[m + i];
|
2009-02-14 13:55:00 +00:00
|
|
|
|
2009-01-18 17:04:24 +00:00
|
|
|
if (!_wllVmpMap[d] || t == -40)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (t == -41) {
|
|
|
|
x1 = 22;
|
|
|
|
x2 = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (t > 0 && x2 > t)
|
|
|
|
x2 = t;
|
|
|
|
|
|
|
|
if (t < 0 && x1 < -t)
|
|
|
|
x1 = -t;
|
|
|
|
}
|
2009-02-14 13:55:00 +00:00
|
|
|
|
2009-01-18 17:04:24 +00:00
|
|
|
if (x2 < x1)
|
|
|
|
break;
|
|
|
|
}
|
2009-02-14 13:55:00 +00:00
|
|
|
|
2009-01-18 17:04:24 +00:00
|
|
|
x1 += 14;
|
|
|
|
x2 += 14;
|
|
|
|
|
|
|
|
_lvlShapeTop[index] = y1;
|
|
|
|
_lvlShapeBottom[index] = y2;
|
|
|
|
_lvlShapeLeftRight[index << 1] = x1;
|
|
|
|
_lvlShapeLeftRight[(index << 1) + 1] = x2;
|
|
|
|
} else {
|
|
|
|
x1 = _lvlShapeLeftRight[index << 1];
|
|
|
|
x2 = _lvlShapeLeftRight[(index << 1) + 1];
|
|
|
|
}
|
|
|
|
|
|
|
|
drawLevelModifyScreenDim(dim, x1, 0, x2, 15);
|
|
|
|
}
|
|
|
|
|
|
|
|
void LoLEngine::scaleLevelShapesDim(int index, int16 &y1, int16 &y2, int dim) {
|
|
|
|
static const int8 dscY1[] = { 0x1E, 0x18, 0x10, 0x00 };
|
|
|
|
static const int8 dscY2[] = { 0x3B, 0x47, 0x56, 0x78 };
|
|
|
|
|
|
|
|
uint8 a = _dscDimMap[index];
|
|
|
|
|
|
|
|
if (dim == -1 && a != 3)
|
|
|
|
a++;
|
|
|
|
|
|
|
|
y1 = dscY1[a];
|
|
|
|
y2 = dscY2[a];
|
|
|
|
|
|
|
|
if (dim == -1)
|
|
|
|
return;
|
|
|
|
|
|
|
|
const ScreenDim *cDim = _screen->getScreenDim(dim);
|
|
|
|
|
|
|
|
_screen->modifyScreenDim(dim, cDim->sx, y1, cDim->w, y2 - y1);
|
|
|
|
}
|
|
|
|
|
|
|
|
void LoLEngine::drawLevelModifyScreenDim(int dim, int16 x1, int16 y1, int16 x2, int16 y2) {
|
|
|
|
_screen->modifyScreenDim(dim, x1, y1 << 3, x2 - x1, (y2 - y1) << 3);
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
2009-01-18 23:50:31 +00:00
|
|
|
uint8 d = (_currentDirection + _dscUnk1[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) {
|
|
|
|
if ((_levelShapeProperties[l].flags & 8) && index != 3 && index != 9 && index != 13) {
|
|
|
|
l = _levelShapeProperties[l].next;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_dscOvlMap[shpIx] == 1 && ((_levelShapeProperties[l].flags & 2) || ((_levelShapeProperties[l].flags & 4) && _wllProcessFlag)))
|
|
|
|
ix = -ix;
|
|
|
|
|
|
|
|
int xOffs = 0;
|
|
|
|
int yOffs = 0;
|
|
|
|
uint8 *ovl = 0;
|
|
|
|
|
|
|
|
if (_levelShapeProperties[l].scaleFlag[shpIx] & 1) {
|
|
|
|
xOffs = _levelShapeProperties[l].shapeX[shpIx];
|
|
|
|
yOffs = _levelShapeProperties[l].shapeY[shpIx];
|
|
|
|
shpIx = _dscOvlMap[shpIx];
|
|
|
|
ovl = _screen->getLevelOverlay(ovlIndex);
|
|
|
|
} else if (_levelShapeProperties[l].shapeIndex[shpIx] != 0xffff) {
|
|
|
|
scaleW = scaleH = 0x100;
|
|
|
|
ovl = _screen->getLevelOverlay(7);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_levelShapeProperties[l].shapeIndex[shpIx] != 0xffff) {
|
|
|
|
shapeData = _levelShapes[_levelShapeProperties[l].shapeIndex[shpIx]];
|
|
|
|
if (shapeData) {
|
|
|
|
if (ix < 0) {
|
|
|
|
x = _dscShapeX[s] + xOffs + ((_levelShapeProperties[l].shapeX[shpIx] * scaleW) >> 8);
|
|
|
|
if (ix == _dscShapeIndex[s]) {
|
|
|
|
x = _dscShapeX[s] - ((_levelShapeProperties[l].shapeX[shpIx] * scaleW) >> 8) -
|
|
|
|
_screen->getShapeScaledWidth(shapeData, scaleW) - xOffs;
|
|
|
|
}
|
|
|
|
flags = 0x105;
|
|
|
|
} else {
|
|
|
|
x = _dscShapeX[s] + xOffs + ((_levelShapeProperties[l].shapeX[shpIx] * scaleW) >> 8);
|
|
|
|
flags = 0x104;
|
|
|
|
}
|
|
|
|
|
|
|
|
y = _dscShapeY[s] + yOffs + ((_levelShapeProperties[l].shapeY[shpIx] * scaleH) >> 8);
|
|
|
|
_screen->drawShape(_sceneDrawPage1, shapeData, x + 112, y, 13, flags, ovl, 1, scaleW, scaleH);
|
|
|
|
|
2009-01-18 17:17:39 +00:00
|
|
|
if ((_levelShapeProperties[l].flags & 1) && shpIx < 4) {
|
2009-01-18 17:04:24 +00:00
|
|
|
//draw shadow
|
|
|
|
x += (_screen->getShapeScaledWidth(shapeData, scaleW));
|
|
|
|
flags ^= 1;
|
|
|
|
_screen->drawShape(_sceneDrawPage1, shapeData, x + 112, y, 13, flags, ovl, 1, scaleW, scaleH);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
l = _levelShapeProperties[l].next;
|
|
|
|
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-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
|
|
|
}
|
|
|
|
|
|
|
|
void LoLEngine::drawScriptShapes(int pageNum) {
|
2009-02-14 00:51:07 +00:00
|
|
|
if (!_scriptAssignedLevelShape)
|
|
|
|
return;
|
2009-01-18 17:04:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // end of namespace Kyra
|
|
|
|
|
2009-03-04 11:53:25 +00:00
|
|
|
#endif // ENABLE_LOL
|
|
|
|
|