diff options
Diffstat (limited to 'engines/kyra/lol.cpp')
-rw-r--r-- | engines/kyra/lol.cpp | 410 |
1 files changed, 131 insertions, 279 deletions
diff --git a/engines/kyra/lol.cpp b/engines/kyra/lol.cpp index 120900537b..6cb3b51370 100644 --- a/engines/kyra/lol.cpp +++ b/engines/kyra/lol.cpp @@ -42,10 +42,9 @@ namespace Kyra { const char *const LoLEngine::kKeymapName = "lol"; -LoLEngine::LoLEngine(OSystem *system, const GameFlags &flags) : KyraEngine_v1(system, flags) { +LoLEngine::LoLEngine(OSystem *system, const GameFlags &flags) : LolEobBaseEngine(system, flags) { _screen = 0; _gui = 0; - _txt = 0; _tim = 0; _lang = 0; @@ -97,15 +96,11 @@ LoLEngine::LoLEngine(OSystem *system, const GameFlags &flags) : KyraEngine_v1(sy memset(_inventory, 0, sizeof(_inventory)); memset(_charStatusFlags, 0, sizeof(_charStatusFlags)); _inventoryCurItem = 0; - _currentControlMode = 0; - _specialSceneFlag = 0; _lastCharInventory = -1; _emcLastItem = -1; _itemIconShapes = _itemShapes = _gameShapes = _thrownShapes = _effectShapes = _fireballShapes = _healShapes = _healiShapes = 0; _levelShpList = _levelDatList = 0; - _monsterShapes = _monsterPalettes = 0; - _monsterShapesEx = 0; _gameShapeMap = 0; memset(_monsterAnimType, 0, 3); _healOverlay = 0; @@ -116,10 +111,8 @@ LoLEngine::LoLEngine(OSystem *system, const GameFlags &flags) : KyraEngine_v1(sy _charSelection = -1; _characters = 0; _spellProperties = 0; - _updateFlags = 0; _selectedSpell = 0; - _updateCharNum = _updatePortraitSpeechAnimDuration = _portraitSpeechAnimMode = _resetPortraitAfterSpeechAnim = _textColorFlag = _needSceneRestore = 0; - _fadeText = false; + _updateCharNum = _portraitSpeechAnimMode = _textColorFlag = 0; _palUpdateTimer = _updatePortraitNext = 0; _lampStatusTimer = 0xffffffff; @@ -128,66 +121,42 @@ LoLEngine::LoLEngine(OSystem *system, const GameFlags &flags) : KyraEngine_v1(sy _lastButtonShape = 0; _buttonPressTimer = 0; _selectedCharacter = 0; - _suspendScript = _sceneUpdateRequired = false; + _suspendScript = false; _scriptDirection = 0; - _currentDirection = 0; - _currentBlock = 0; - _compassDirection = _compassDirectionIndex = -1; + _compassDirectionIndex = -1; _compassStep = 0; - memset(_visibleBlockIndex, 0, sizeof(_visibleBlockIndex)); _smoothScrollModeNormal = 1; - _wllVmpMap = _specialWallTypes = _wllBuffer4 = _wllWallFlags = 0; - _wllShapeMap = 0; - _lvlShapeTop = _lvlShapeBottom = _lvlShapeLeftRight = 0; - _levelBlockProperties = 0; + _wllAutomapData = 0; + _sceneXoffset = 112; + _sceneShpDim = 13; _monsters = 0; _monsterProperties = 0; - _lvlBlockIndex = _lvlShapeIndex = 0; + _lvlShapeIndex = 0; _partyAwake = true; - _vcnBlocks = 0; - _vcnShift = 0; - _vcnExpTable = 0; - _vmpPtr = 0; - _vcfBlocks = 0; _transparencyTable2 = 0; _transparencyTable1 = 0; - _levelShapeProperties = 0; - _levelShapes = 0; _specialGuiShape = 0; _specialGuiShapeX = _specialGuiShapeY = _specialGuiShapeMirrorFlag = 0; - _blockDrawingBuffer = 0; - _sceneWindowBuffer = 0; - memset(_doorShapes, 0, sizeof(_doorShapes)); memset(_characterFaceShapes, 0, sizeof(_characterFaceShapes)); _lampEffect = _brightness = _lampOilStatus = 0; _lampStatusSuspended = false; - _blockBrightness = 0; _tempBuffer5120 = 0; _flyingObjects = 0; _monsters = 0; _lastMouseRegion = 0; - _objectLastDirection = _monsterStepCounter = _monsterStepMode = 0; + _objectLastDirection = 0; _monsterCurBlock = 0; _seqWindowX1 = _seqWindowY1 = _seqWindowX2 = _seqWindowY2 = _seqTrigger = 0; _spsWindowX = _spsWindowY = _spsWindowW = _spsWindowH = 0; - _dscUnk1 = 0; - _dscShapeIndex = 0; + _dscWalls = 0; _dscOvlMap = 0; _dscShapeScaleW = 0; - _dscShapeScaleH = 0; - _dscShapeX = 0; + _dscShapeScaleH = 0; _dscShapeY = 0; - _dscTileIndex = 0; - _dscUnk2 = 0; - _dscDoorShpIndex = 0; - _dscDim1 = 0; - _dscDim2 = 0; - _dscBlockMap = _dscDoor1 = _dscShapeOvlIndex = 0; - _dscBlockIndex = 0; - _dscDimMap = 0; + _dscShapeOvlIndex = 0; _dscDoorMonsterX = _dscDoorMonsterY = 0; _dscDoor4 = 0; @@ -198,29 +167,24 @@ LoLEngine::LoLEngine(OSystem *system, const GameFlags &flags) : KyraEngine_v1(sy _curMusicTheme = -1; _curMusicFileExt = 0; _curMusicFileIndex = -1; - _environmentSfx = _environmentSfxVol = _envSfxDistThreshold = 0; _envSfxUseQueue = false; _envSfxNumTracksInQueue = 0; memset(_envSfxQueuedTracks, 0, sizeof(_envSfxQueuedTracks)); memset(_envSfxQueuedBlocks, 0, sizeof(_envSfxQueuedBlocks)); - _sceneDrawVarDown = _sceneDrawVarRight = _sceneDrawVarLeft = _wllProcessFlag = 0; _partyPosX = _partyPosY = 0; _shpDmX = _shpDmY = _dmScaleW = _dmScaleH = 0; _floatingCursorControl = _currentFloatingCursor = 0; memset(_activeTim, 0, sizeof(_activeTim)); - memset(_openDoorState, 0, sizeof(_openDoorState)); memset(&_activeSpell, 0, sizeof(_activeSpell)); - _activeVoiceFileTotalTime = 0; _pageBuffer1 = _pageBuffer2 = 0; memset(_charStatsTemp, 0, sizeof(_charStatsTemp)); _compassBroken = _drainMagic = 0; - _dialogueField = false; _buttonData = 0; _activeButtons = 0; @@ -228,8 +192,6 @@ LoLEngine::LoLEngine(OSystem *system, const GameFlags &flags) : KyraEngine_v1(sy _preserveEvents = false; _buttonList1 = _buttonList2 = _buttonList3 = _buttonList4 = _buttonList5 = _buttonList6 = _buttonList7 = _buttonList8 = 0; - memset(_lvlTempData, 0, sizeof(_lvlTempData)); - _mapOverlay = 0; _automapShapes = 0; _defaultLegendData = 0; @@ -250,6 +212,7 @@ LoLEngine::LoLEngine(OSystem *system, const GameFlags &flags) : KyraEngine_v1(sy LoLEngine::~LoLEngine() { setupPrologueData(false); + releaseTempData(); #ifdef ENABLE_KEYMAPPER _eventMan->getKeymapper()->cleanupGameKeymaps(); @@ -264,8 +227,6 @@ LoLEngine::~LoLEngine() { _gui = 0; delete _tim; _tim = 0; - delete _txt; - _txt = 0; delete[] _itemsInPlay; delete[] _itemProperties; @@ -322,64 +283,47 @@ LoLEngine::~LoLEngine() { delete[] _healiShapes; } - for (int i = 0; i < 3; i++) - releaseMonsterShapes(i); + if (_monsterDecorationShapes) { + for (int i = 0; i < 3; i++) + releaseMonsterShapes(i); - delete[] _monsterShapes; - delete[] _monsterPalettes; - delete[] _monsterShapesEx; + delete[] _monsterShapes; + _monsterShapes = 0; + delete[] _monsterPalettes; + _monsterPalettes = 0; + delete[] _monsterDecorationShapes; + _monsterDecorationShapes = 0; + } + + for (int i = 0; i < 6; i++) { + delete[] _doorShapes[i]; + _doorShapes[i] = 0; + } delete[] _automapShapes; - for (Common::Array<const TIMOpcode *>::iterator i = _timIntroOpcodes.begin(); i != _timIntroOpcodes.end(); ++i) + for (Common::Array<const TIMOpcode*>::iterator i = _timIntroOpcodes.begin(); i != _timIntroOpcodes.end(); ++i) delete *i; _timIntroOpcodes.clear(); - for (Common::Array<const TIMOpcode *>::iterator i = _timOutroOpcodes.begin(); i != _timOutroOpcodes.end(); ++i) + for (Common::Array<const TIMOpcode*>::iterator i = _timOutroOpcodes.begin(); i != _timOutroOpcodes.end(); ++i) delete *i; _timOutroOpcodes.clear(); - for (Common::Array<const TIMOpcode *>::iterator i = _timIngameOpcodes.begin(); i != _timIngameOpcodes.end(); ++i) + for (Common::Array<const TIMOpcode*>::iterator i = _timIngameOpcodes.begin(); i != _timIngameOpcodes.end(); ++i) delete *i; _timIngameOpcodes.clear(); - - delete[] _wllVmpMap; - delete[] _wllShapeMap; - delete[] _specialWallTypes; - delete[] _wllBuffer4; - delete[] _wllWallFlags; - delete[] _lvlShapeTop; - delete[] _lvlShapeBottom; - delete[] _lvlShapeLeftRight; + delete[] _wllAutomapData; delete[] _tempBuffer5120; delete[] _flyingObjects; delete[] _monsters; - delete[] _levelBlockProperties; delete[] _monsterProperties; - delete[] _levelFileData; - delete[] _vcnExpTable; - delete[] _vcnBlocks; - delete[] _vcnShift; - delete[] _vmpPtr; - delete[] _vcfBlocks; delete[] _transparencyTable2; delete[] _transparencyTable1; - delete[] _levelShapeProperties; - delete[] _blockDrawingBuffer; - delete[] _sceneWindowBuffer; delete[] _lightningProps; - if (_levelShapes) { - for (int i = 0; i < 400; i++) - delete[] _levelShapes[i]; - delete[] _levelShapes; - } - - for (int i = 0; i < 2; i++) - delete[] _doorShapes[i]; - delete _lvlShpFileHandle; if (_ingameSoundList) { @@ -388,16 +332,6 @@ LoLEngine::~LoLEngine() { delete[] _ingameSoundList; } - for (int i = 0; i < 29; i++) { - if (_lvlTempData[i]) { - delete[] _lvlTempData[i]->wallsXorData; - delete[] _lvlTempData[i]->flags; - delete[] _lvlTempData[i]->monsters; - delete[] _lvlTempData[i]->flyingObjects; - delete _lvlTempData[i]; - } - } - for (int i = 0; i < 3; i++) { for (int ii = 0; ii < 40; ii++) delete[] _characterFaceShapes[ii][i]; @@ -409,7 +343,7 @@ LoLEngine::~LoLEngine() { delete[] _mapCursorOverlay; delete[] _mapOverlay; - for (Common::Array<const SpellProc *>::iterator i = _spellProcs.begin(); i != _spellProcs.end(); ++i) + for (Common::Array<const SpellProc*>::iterator i = _spellProcs.begin(); i != _spellProcs.end(); ++i) delete *i; _spellProcs.clear(); @@ -440,13 +374,18 @@ Common::Error LoLEngine::init() { KyraEngine_v1::init(); initStaticResource(); - _envSfxDistThreshold = _sound->getSfxType() == Sound::kAdLib ? 15 : 3; - _gui = new GUI_LoL(this); assert(_gui); _gui->initStaticData(); _txt = new TextDisplayer_LoL(this, _screen); + _dialogueButtonLabelCol1 = 144; + _dialogueButtonLabelCol2 = 254; + _dialogueButtonW = 74; + _dialogueButtonH = 9; + _bkgColor_1 = -1; + _color1_1 = 136; + _color2_1 = 251; _screen->setAnimBlockPtr(10000); _screen->setScreenDim(0); @@ -465,41 +404,15 @@ Common::Error LoLEngine::init() { if (!_sound->init()) error("Couldn't init sound"); - _wllVmpMap = new uint8[80]; - memset(_wllVmpMap, 0, 80); - _wllShapeMap = new int8[80]; - memset(_wllShapeMap, 0, 80); - _specialWallTypes = new uint8[80]; - memset(_specialWallTypes, 0, 80); - _wllBuffer4 = new uint8[80]; - memset(_wllBuffer4, 0, 80); - _wllWallFlags = new uint8[80]; - memset(_wllWallFlags, 0, 80); - _lvlShapeTop = new int16[18]; - memset(_lvlShapeTop, 0, 18 * sizeof(int16)); - _lvlShapeBottom = new int16[18]; - memset(_lvlShapeBottom, 0, 18 * sizeof(int16)); - _lvlShapeLeftRight = new int16[36]; - memset(_lvlShapeLeftRight, 0, 36 * sizeof(int16)); - _levelShapeProperties = new LevelShapeProperty[100]; - memset(_levelShapeProperties, 0, 100 * sizeof(LevelShapeProperty)); - _levelShapes = new uint8 *[400]; - memset(_levelShapes, 0, 400 * sizeof(uint8 *)); - _blockDrawingBuffer = new uint16[1320]; - memset(_blockDrawingBuffer, 0, 1320 * sizeof(uint16)); - _sceneWindowBuffer = new uint8[21120]; - memset(_sceneWindowBuffer, 0, 21120); - - _levelBlockProperties = new LevelBlockProperty[1025]; - memset(_levelBlockProperties, 0, 1025 * sizeof(LevelBlockProperty)); - _monsters = new MonsterInPlay[30]; - memset(_monsters, 0, 30 * sizeof(MonsterInPlay)); - _monsterProperties = new MonsterProperty[5]; - memset(_monsterProperties, 0, 5 * sizeof(MonsterProperty)); - - _vcnExpTable = new uint8[128]; - for (int i = 0; i < 128; i++) - _vcnExpTable[i] = i & 0x0f; + LolEobBaseEngine::init(); + + _wllAutomapData = new uint8[80]; + memset(_wllAutomapData, 0, 80); + + _monsters = new LolMonsterInPlay[30]; + memset(_monsters, 0, 30 * sizeof(LolMonsterInPlay)); + _monsterProperties = new LolMonsterProperty[5]; + memset(_monsterProperties, 0, 5 * sizeof(LolMonsterProperty)); _tempBuffer5120 = new uint8[5120]; memset(_tempBuffer5120, 0, 5120); @@ -509,25 +422,26 @@ Common::Error LoLEngine::init() { memset(_globalScriptVars, 0, sizeof(_globalScriptVars)); - _levelFileData = 0; _lvlShpFileHandle = 0; _sceneDrawPage1 = 2; _sceneDrawPage2 = 6; - _monsterShapes = new uint8 *[48]; - memset(_monsterShapes, 0, 48 * sizeof(uint8 *)); - _monsterPalettes = new uint8 *[48]; - memset(_monsterPalettes, 0, 48 * sizeof(uint8 *)); + _clickedShapeXOffs = 136; + _clickedShapeYOffs = 8; + _clickedSpecialFlag = 0x40; - _monsterShapesEx = new uint8 *[576]; - memset(_monsterShapesEx, 0, 576 * sizeof(uint8 *)); + _monsterShapes = new uint8*[48]; + memset(_monsterShapes, 0, 48 * sizeof(uint8*)); + _monsterPalettes = new uint8*[48]; + memset(_monsterPalettes, 0, 48 * sizeof(uint8*)); + _monsterDecorationShapes = new uint8*[576]; + memset(_monsterDecorationShapes, 0, 576 * sizeof(uint8*)); memset(&_scriptData, 0, sizeof(EMCData)); - _hasTempDataFlags = 0; _activeMagicMenu = -1; - _automapShapes = new const uint8 *[109]; + _automapShapes = new const uint8*[109]; _mapOverlay = new uint8[256]; memset(_availableSpells, -1, 8); @@ -687,7 +601,7 @@ void LoLEngine::loadItemIconShapes() { _screen->loadBitmap("ITEMICN.SHP", 3, 3, 0); const uint8 *shp = _screen->getCPagePtr(3); _numItemIconShapes = READ_LE_UINT16(shp); - _itemIconShapes = new uint8 *[_numItemIconShapes]; + _itemIconShapes = new uint8*[_numItemIconShapes]; for (int i = 0; i < _numItemIconShapes; i++) _itemIconShapes[i] = _screen->makeShapeCopy(shp, i); @@ -697,7 +611,7 @@ void LoLEngine::loadItemIconShapes() { _screen->loadBitmap("GAMESHP.SHP", 3, 3, 0); shp = _screen->getCPagePtr(3); _numGameShapes = READ_LE_UINT16(shp); - _gameShapes = new uint8 *[_numGameShapes]; + _gameShapes = new uint8*[_numGameShapes]; for (int i = 0; i < _numGameShapes; i++) _gameShapes[i] = _screen->makeShapeCopy(shp, i); } @@ -717,12 +631,6 @@ void LoLEngine::setMouseCursorToItemInHand() { _screen->setMouseCursor(o, o, getItemIconShapePtr(_itemInHand)); } -bool LoLEngine::posWithinRect(int mouseX, int mouseY, int x1, int y1, int x2, int y2) { - if (mouseX < x1 || mouseX > x2 || mouseY < y1 || mouseY > y2) - return false; - return true; -} - void LoLEngine::checkFloatingPointerRegions() { if (!_floatingCursorsEnabled) return; @@ -877,42 +785,42 @@ void LoLEngine::startup() { _screen->loadBitmap("ITEMSHP.SHP", 3, 3, 0); const uint8 *shp = _screen->getCPagePtr(3); _numItemShapes = READ_LE_UINT16(shp); - _itemShapes = new uint8 *[_numItemShapes]; + _itemShapes = new uint8*[_numItemShapes]; for (int i = 0; i < _numItemShapes; i++) _itemShapes[i] = _screen->makeShapeCopy(shp, i); _screen->loadBitmap("THROWN.SHP", 3, 3, 0); shp = _screen->getCPagePtr(3); _numThrownShapes = READ_LE_UINT16(shp); - _thrownShapes = new uint8 *[_numThrownShapes]; + _thrownShapes = new uint8*[_numThrownShapes]; for (int i = 0; i < _numThrownShapes; i++) _thrownShapes[i] = _screen->makeShapeCopy(shp, i); _screen->loadBitmap("ICE.SHP", 3, 3, 0); shp = _screen->getCPagePtr(3); _numEffectShapes = READ_LE_UINT16(shp); - _effectShapes = new uint8 *[_numEffectShapes]; + _effectShapes = new uint8*[_numEffectShapes]; for (int i = 0; i < _numEffectShapes; i++) _effectShapes[i] = _screen->makeShapeCopy(shp, i); _screen->loadBitmap("FIREBALL.SHP", 3, 3, 0); shp = _screen->getCPagePtr(3); _numFireballShapes = READ_LE_UINT16(shp); - _fireballShapes = new uint8 *[_numFireballShapes]; + _fireballShapes = new uint8*[_numFireballShapes]; for (int i = 0; i < _numFireballShapes; i++) _fireballShapes[i] = _screen->makeShapeCopy(shp, i); _screen->loadBitmap("HEAL.SHP", 3, 3, 0); shp = _screen->getCPagePtr(3); _numHealShapes = READ_LE_UINT16(shp); - _healShapes = new uint8 *[_numHealShapes]; + _healShapes = new uint8*[_numHealShapes]; for (int i = 0; i < _numHealShapes; i++) _healShapes[i] = _screen->makeShapeCopy(shp, i); _screen->loadBitmap("HEALI.SHP", 3, 3, 0); shp = _screen->getCPagePtr(3); _numHealiShapes = READ_LE_UINT16(shp); - _healiShapes = new uint8 *[_numHealiShapes]; + _healiShapes = new uint8*[_numHealiShapes]; for (int i = 0; i < _numHealiShapes; i++) _healiShapes[i] = _screen->makeShapeCopy(shp, i); @@ -969,10 +877,9 @@ void LoLEngine::runLoop() { enableSysTimer(2); - bool _runFlag = true; _flagsTable[73] |= 0x08; - while (!shouldQuit() && _runFlag) { + while (!shouldQuit()) { if (_gameToLoad != -1) { // FIXME: Instead of throwing away the error returned by // loadGameState, we should use it / augment it. @@ -1784,44 +1691,6 @@ void LoLEngine::fadeText() { _fadeText = false; } -void LoLEngine::transformRegion(int x1, int y1, int x2, int y2, int w, int h, int srcPage, int dstPage) { - uint16 *p1 = (uint16 *)_tempBuffer5120; - uint16 *p2 = (uint16 *)(_tempBuffer5120 + 640); - - for (int i = 0; i < w; i++) - p1[i] = i; - - for (int i = 0; i < h; i++) - p2[i] = i; - - for (int i = 0; i < w; i++) - SWAP(p1[_rnd.getRandomNumberRng(0, w - 1)], p1[i]); - - for (int i = 0; i < h; i++) - SWAP(p2[_rnd.getRandomNumberRng(0, h - 1)], p2[i]); - - for (int i = 0; i < h; i++) { - int i2 = i; - - for (int ii = 0; ii < w; ii++) { - int dx1 = x1 + p1[ii]; - int dy1 = y1 + p2[i2]; - int dx2 = x2 + p1[ii]; - int dy2 = y2 + p2[i2]; - - if (++i2 == h) - i2 = 0; - - _screen->setPagePixel(dstPage, dx2, dy2, _screen->getPagePixel(srcPage, dx1, dy1)); - } - - if (!dstPage && (i & 5) == 5) { - updateInput(); - _screen->updateScreen(); - } - } -} - void LoLEngine::setPaletteBrightness(const Palette &srcPal, int brightness, int modifier) { generateBrightnessPalette(srcPal, _screen->getPalette(1), brightness, modifier); _screen->fadePalette(_screen->getPalette(1), 5, 0); @@ -2040,7 +1909,46 @@ int LoLEngine::playCharacterScriptChat(int charId, int mode, int restorePortrait return 1; } -void LoLEngine::giveItemToMonster(MonsterInPlay *monster, Item item) { +void LoLEngine::setupDialogueButtons(int numStr, const char *s1, const char *s2, const char *s3) { + screen()->setScreenDim(5); + + if (numStr == 1 && speechEnabled()) { + _dialogueNumButtons = 0; + _dialogueButtonString[0] = _dialogueButtonString[1] = _dialogueButtonString[2] = 0; + } else { + _dialogueNumButtons = numStr; + _dialogueButtonString[0] = s1; + _dialogueButtonString[1] = s2; + _dialogueButtonString[2] = s3; + _dialogueHighlightedButton = 0; + + const ScreenDim *d = screen()->getScreenDim(5); + + static uint16 posX[3]; + static uint8 posY[3]; + + memset(posY, d->sy + d->h - 9, 3); + + _dialogueButtonPosX = posX; + _dialogueButtonPosY = posY; + + if (numStr == 1) { + posX[0] = posX[1] = posX[2] = d->sx + d->w - (_dialogueButtonW + 3); + } else { + int xOffs = d->w / numStr; + posX[0] = d->sx + (xOffs >> 1) - 37; + posX[1] = posX[0] + xOffs; + posX[2] = posX[1] + xOffs; + } + + drawDialogueButtons(); + } + + if (!shouldQuit()) + removeInputTop(); +} + +void LoLEngine::giveItemToMonster(LolMonsterInPlay *monster, Item item) { uint16 *c = &monster->assignedItems; while (*c) c = &_itemsInPlay[*c].nextAssignedObject; @@ -2049,7 +1957,7 @@ void LoLEngine::giveItemToMonster(MonsterInPlay *monster, Item item) { } const uint16 *LoLEngine::getCharacterOrMonsterStats(int id) { - return (id & 0x8000) ? (const uint16 *)_monsters[id & 0x7fff].properties->fightingStats : _characters[id].defaultModifiers; + return (id & 0x8000) ? (const uint16*)_monsters[id & 0x7fff].properties->fightingStats : _characters[id].defaultModifiers; } uint16 *LoLEngine::getCharacterOrMonsterItemsMight(int id) { @@ -2073,21 +1981,6 @@ void LoLEngine::delay(uint32 millis, bool doUpdate, bool) { } } -int LoLEngine::rollDice(int times, int pips) { - if (times <= 0 || pips <= 0) - return 0; - - int res = 0; - while (times--) - res += _rnd.getRandomNumberRng(1, pips); - - return res; -} - -void LoLEngine::updateEnvironmentalSfx(int soundId) { - snd_processEnvironmentalSoundEffect(soundId, _currentBlock); -} - // spells int LoLEngine::castSpell(int charNum, int spellType, int spellLevel) { @@ -2502,7 +2395,7 @@ int LoLEngine::processMagicIce(int charNum, int spellLevel) { int might = rollDice(iceDamageMin[spellLevel], iceDamageMax[spellLevel]) + iceDamageAdd[spellLevel]; int dmg = calcInflictableDamagePerItem(charNum, 0, might, 3, 2); - MonsterInPlay *m = &_monsters[o & 0x7fff]; + LolMonsterInPlay *m = &_monsters[o & 0x7fff]; if (m->hitPoints <= dmg) { increaseExperience(charNum, 2, m->hitPoints); o = m->nextAssignedObject; @@ -2581,7 +2474,7 @@ int LoLEngine::processMagicFireball(int charNum, int spellLevel) { while (o & 0x8000) { static const uint8 fireballDamage[] = { 20, 40, 80, 100 }; int dmg = calcInflictableDamagePerItem(charNum, o, fireballDamage[spellLevel], 4, 1); - MonsterInPlay *m = &_monsters[o & 0x7fff]; + LolMonsterInPlay *m = &_monsters[o & 0x7fff]; o = m->nextAssignedObject; _envSfxUseQueue = true; inflictDamage(m->id | 0x8000, dmg, charNum, 2, 4); @@ -2746,7 +2639,7 @@ int LoLEngine::processMagicHandOfFate(int spellLevel) { uint16 o = _levelBlockProperties[b1].assignedObjects; while (o & 0x8000) { uint16 o2 = o; - MonsterInPlay *m = &_monsters[o & 0x7fff]; + LolMonsterInPlay *m = &_monsters[o & 0x7fff]; o = findObject(o)->nextAssignedObject; int nX = 0; int nY = 0; @@ -3015,7 +2908,7 @@ int LoLEngine::processMagicVaelansCube() { uint16 o = _levelBlockProperties[bl].assignedObjects; while (o & 0x8000) { - MonsterInPlay *m = &_monsters[o & 0x7fff]; + LolMonsterInPlay *m = &_monsters[o & 0x7fff]; if (m->properties->flags & 0x1000) { inflictDamage(o, 100, 0xffff, 0, 0x80); v = 1; @@ -3495,7 +3388,7 @@ int LoLEngine::calcInflictableDamage(int16 attacker, int16 target, int hitType) } int LoLEngine::inflictDamage(uint16 target, int damage, uint16 attacker, int skill, int flags) { - MonsterInPlay *m = 0; + LolMonsterInPlay *m = 0; LoLCharacter *c = 0; if (target & 0x8000) { @@ -3712,7 +3605,7 @@ void LoLEngine::checkForPartyDeath() { } } -void LoLEngine::applyMonsterAttackSkill(MonsterInPlay *monster, int16 target, int16 damage) { +void LoLEngine::applyMonsterAttackSkill(LolMonsterInPlay *monster, int16 target, int16 damage) { if (rollDice(1, 100) > monster->properties->attackSkillChance) return; @@ -3782,7 +3675,7 @@ void LoLEngine::applyMonsterAttackSkill(MonsterInPlay *monster, int16 target, in } } -void LoLEngine::applyMonsterDefenseSkill(MonsterInPlay *monster, int16 attacker, int flags, int skill, int damage) { +void LoLEngine::applyMonsterDefenseSkill(LolMonsterInPlay *monster, int16 attacker, int flags, int skill, int damage) { if (rollDice(1, 100) > monster->properties->defenseSkillChance) return; @@ -4041,7 +3934,7 @@ uint16 LoLEngine::getNearestMonsterFromCharacterForBlock(uint16 block, int charN int o = _levelBlockProperties[block].assignedObjects; while (o & 0x8000) { - MonsterInPlay *m = &_monsters[o & 0x7fff]; + LolMonsterInPlay *m = &_monsters[o & 0x7fff]; if (m->mode >= 13) { o = m->nextAssignedObject; continue; @@ -4107,7 +4000,7 @@ void LoLEngine::displayAutomap() { _currentMapLevel = _currentLevel; uint8 *tmpWll = new uint8[80]; - memcpy(tmpWll, _wllBuffer4, 80); + memcpy(tmpWll, _wllAutomapData, 80); _screen->loadBitmap("parch.cps", 2, 2, &_screen->getPalette(3)); _screen->loadBitmap("autobut.shp", 3, 5, 0); @@ -4188,7 +4081,7 @@ void LoLEngine::displayAutomap() { _screen->fadeToBlack(10); loadLevelWallData(_currentLevel, false); - memcpy(_wllBuffer4, tmpWll, 80); + memcpy(_wllAutomapData, tmpWll, 80); delete[] tmpWll; restoreBlockTempData(_currentLevel); addLevelItems(); @@ -4229,7 +4122,7 @@ bool LoLEngine::updateAutoMapIntern(uint16 block, uint16 x, uint16 y, int16 xOff uint16 b = block + blockPosTable[6 + xOffs]; if (fx != -1) { - if (_wllBuffer4[_levelBlockProperties[b].walls[fx]] & 0xc0) + if (_wllAutomapData[_levelBlockProperties[b].walls[fx]] & 0xc0) return false; } @@ -4237,13 +4130,13 @@ bool LoLEngine::updateAutoMapIntern(uint16 block, uint16 x, uint16 y, int16 xOff b = block + blockPosTable[9 + yOffs]; if (fy != -1) { - if (_wllBuffer4[_levelBlockProperties[b].walls[fy]] & 0xc0) + if (_wllAutomapData[_levelBlockProperties[b].walls[fy]] & 0xc0) return false; } b = block + blockPosTable[6 + xOffs] + blockPosTable[9 + yOffs]; - if ((fx != -1) && (fy != -1) && (_wllBuffer4[_levelBlockProperties[b].walls[fx]] & 0xc0) && (_wllBuffer4[_levelBlockProperties[b].walls[fy]] & 0xc0)) + if ((fx != -1) && (fy != -1) && (_wllAutomapData[_levelBlockProperties[b].walls[fx]] & 0xc0) && (_wllAutomapData[_levelBlockProperties[b].walls[fy]] & 0xc0)) return false; _levelBlockProperties[b].flags |= 7; @@ -4252,7 +4145,7 @@ bool LoLEngine::updateAutoMapIntern(uint16 block, uint16 x, uint16 y, int16 xOff } void LoLEngine::loadMapLegendData(int level) { - uint16 *legendData = (uint16 *)_tempBuffer5120; + uint16 *legendData= (uint16*)_tempBuffer5120; for (int i = 0; i < 32; i++) { legendData[i * 6] = 0xffff; legendData[i * 6 + 5] = 0xffff; @@ -4306,7 +4199,7 @@ void LoLEngine::drawMapPage(int pageNum) { for (; bl < 1024; bl++) { uint8 *w = _levelBlockProperties[bl].walls; - if ((_levelBlockProperties[bl].flags & 7) == 7 && (!(_wllBuffer4[w[0]] & 0xc0)) && (!(_wllBuffer4[w[2]] & 0xc0)) && (!(_wllBuffer4[w[1]] & 0xc0))&& (!(_wllBuffer4[w[3]] & 0xc0))) { + if ((_levelBlockProperties[bl].flags & 7) == 7 && (!(_wllAutomapData[w[0]] & 0xc0)) && (!(_wllAutomapData[w[2]] & 0xc0)) && (!(_wllAutomapData[w[1]] & 0xc0))&& (!(_wllAutomapData[w[3]] & 0xc0))) { uint16 b0 = calcNewBlockPosition(bl, 0); uint16 b2 = calcNewBlockPosition(bl, 2); uint16 b1 = calcNewBlockPosition(bl, 1); @@ -4323,25 +4216,25 @@ void LoLEngine::drawMapPage(int pageNum) { // draw north wall drawMapBlockWall(b3, w31, sx, sy, 3); drawMapShape(w31, sx, sy, 3); - if (_wllBuffer4[w31] & 0xc0) + if (_wllAutomapData[w31] & 0xc0) _screen->copyBlockAndApplyOverlay(_screen->_curPage, sx, sy, _screen->_curPage, sx, sy, 1, 6, 0, _mapOverlay); // draw west wall drawMapBlockWall(b1, w13, sx, sy, 1); drawMapShape(w13, sx, sy, 1); - if (_wllBuffer4[w13] & 0xc0) + if (_wllAutomapData[w13] & 0xc0) _screen->copyBlockAndApplyOverlay(_screen->_curPage, sx + 6, sy, _screen->_curPage, sx + 6, sy, 1, 6, 0, _mapOverlay); // draw east wall drawMapBlockWall(b0, w02, sx, sy, 0); drawMapShape(w02, sx, sy, 0); - if (_wllBuffer4[w02] & 0xc0) + if (_wllAutomapData[w02] & 0xc0) _screen->copyBlockAndApplyOverlay(_screen->_curPage, sx, sy, _screen->_curPage, sx, sy, 7, 1, 0, _mapOverlay); //draw south wall drawMapBlockWall(b2, w20, sx, sy, 2); drawMapShape(w20, sx, sy, 2); - if (_wllBuffer4[w20] & 0xc0) + if (_wllAutomapData[w20] & 0xc0) _screen->copyBlockAndApplyOverlay(_screen->_curPage, sx, sy + 5, _screen->_curPage, sx, sy + 5, 7, 1, 0, _mapOverlay); } @@ -4362,7 +4255,7 @@ void LoLEngine::drawMapPage(int pageNum) { sx = mapGetStartPosX(); sy = mapGetStartPosY(); - uint16 *legendData = (uint16 *)_tempBuffer5120; + uint16 *legendData = (uint16*)_tempBuffer5120; uint8 yOffset = _flags.use16ColorMode ? 4 : 0; for (int ii = 0; ii < 32; ii++) { @@ -4508,7 +4401,7 @@ void LoLEngine::redrawMapCursor() { } void LoLEngine::drawMapBlockWall(uint16 block, uint8 wall, int x, int y, int direction) { - if (((1 << direction) & _levelBlockProperties[block].flags) || ((_wllBuffer4[wall] & 0x1f) != 13)) + if (((1 << direction) & _levelBlockProperties[block].flags) || ((_wllAutomapData[wall] & 0x1f) != 13)) return; int cp = _screen->_curPage; @@ -4518,7 +4411,7 @@ void LoLEngine::drawMapBlockWall(uint16 block, uint8 wall, int x, int y, int dir } void LoLEngine::drawMapShape(uint8 wall, int x, int y, int direction) { - int l = _wllBuffer4[wall] & 0x1f; + int l = _wllAutomapData[wall] & 0x1f; if (l == 0x1f) return; @@ -4611,48 +4504,7 @@ void LoLEngine::printMapExitButtonText() { _screen->setCurPage(cp); } -void LoLEngine::generateTempData() { - int l = _currentLevel - 1; - if (_lvlTempData[l]) { - delete[] _lvlTempData[l]->wallsXorData; - delete[] _lvlTempData[l]->flags; - delete[] _lvlTempData[l]->monsters; - delete[] _lvlTempData[l]->flyingObjects; - delete _lvlTempData[l]; - } - - _lvlTempData[l] = new LevelTempData; - _lvlTempData[l]->wallsXorData = new uint8[4096]; - _lvlTempData[l]->flags = new uint8[1024]; - _lvlTempData[l]->monsters = new MonsterInPlay[30]; - _lvlTempData[l]->flyingObjects = new FlyingObject[8]; - - Common::String filename = Common::String::format("LEVEL%d.CMZ", _currentLevel); - - _screen->loadBitmap(filename.c_str(), 15, 15, 0); - const uint8 *p = _screen->getCPagePtr(14); - uint16 len = READ_LE_UINT16(p + 4); - p += 6; - - memset(_lvlTempData[l]->wallsXorData, 0, 4096); - memset(_lvlTempData[l]->flags, 0, 1024); - uint8 *d = _lvlTempData[l]->wallsXorData; - uint8 *df = _lvlTempData[l]->flags; - - for (int i = 0; i < 1024; i++) { - for (int ii = 0; ii < 4; ii++) - *d++ = p[i * len + ii] ^ _levelBlockProperties[i].walls[ii]; - *df++ = _levelBlockProperties[i].flags; - } - - memcpy(_lvlTempData[l]->monsters, _monsters, sizeof(MonsterInPlay) * 30); - memcpy(_lvlTempData[l]->flyingObjects, _flyingObjects, sizeof(FlyingObject) * 8); - - _lvlTempData[l]->monsterDifficulty =_monsterDifficulty; - - _hasTempDataFlags |= (1 << l); -} } // End of namespace Kyra |